agent-placeholder.fixture.tsx 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import { createRoot } from "react-dom/client";
  2. import { AgentToolCallBlock } from "@/ToolCallBlocks/renderers/agent.js";
  3. import type { ToolCallBlockRenderContext } from "@/ToolCallBlocks/shared.js";
  4. import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js";
  5. import { TooltipProvider } from "@/components/ui/tooltip.js";
  6. import "@/styles.css";
  7. const query = new URLSearchParams(location.search);
  8. const locale = query.get("locale") === "en-US" ? "en-US" : "zh-CN";
  9. const theme = query.get("theme") === "light" ? "light" : "dark";
  10. document.documentElement.className = `${theme} theme-zai-${theme}`;
  11. const cases = [
  12. { id: "placeholder", input: {} },
  13. {
  14. id: "named",
  15. input: { subagent_type: "researcher", description: "Inspect directory structure" },
  16. },
  17. { id: "configured", input: { color: "red" } },
  18. ];
  19. createRoot(document.getElementById("root")!).render(
  20. <ZCodeIntlProvider initialLocale={locale}>
  21. <TooltipProvider>
  22. <main className="min-h-screen bg-background p-4 text-foreground">
  23. {cases.map(({ id, input }) => {
  24. const context = {
  25. toolCallNode: {
  26. toolCall: { toolId: id, name: "Agent", title: "Agent", status: "pending", input },
  27. childToolCalls: [],
  28. },
  29. workspacePath: "/example",
  30. isRunning: false,
  31. statusLabel: locale === "en-US" ? "Pending" : "等待中",
  32. nestedToolRenderer: () => null,
  33. } as unknown as ToolCallBlockRenderContext;
  34. return (
  35. <section key={id} data-case={id}>
  36. <AgentToolCallBlock {...context} />
  37. </section>
  38. );
  39. })}
  40. </main>
  41. </TooltipProvider>
  42. </ZCodeIntlProvider>,
  43. );