workflow-digest-gate.fixture.tsx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. import "@/styles.css";
  2. import { useState } from "react";
  3. import { createRoot } from "react-dom/client";
  4. import type { IPlatformService } from "@zcode/shared";
  5. import type { ToolCallRow } from "@zcode/shared/zcode-protocol-v4";
  6. import { PlatformProvider } from "@/hooks/usePlatform.js";
  7. import { ZCodeIntlProvider } from "@/i18n/IntlProvider.js";
  8. import { TooltipProvider } from "@/components/ui/tooltip.js";
  9. import { DEFAULT_CODE_PREVIEW_SETTINGS } from "@/lib/codePreviewSettings.js";
  10. import { ConversationTurnGroup } from "@/v4/ConversationTurnGroup.js";
  11. import type { ConversationTurnRenderUnit } from "@/v4/conversationTurnRenderUnits.js";
  12. const tool: ToolCallRow = {
  13. rowId: 5,
  14. turnId: "gate",
  15. createdAt: 1,
  16. createdAtSeq: 5,
  17. kind: "toolCall",
  18. toolCallId: "tool-5",
  19. toolName: "CreateWorkflow",
  20. status: "success",
  21. input: { name: "Gate workflow", script: "return;" },
  22. inputText: "{}",
  23. };
  24. function Fixture() {
  25. const [joined, setJoined] = useState(false);
  26. const [running, setRunning] = useState(true);
  27. const unit: ConversationTurnRenderUnit = {
  28. key: "gate",
  29. turnId: "gate",
  30. visibleUserInputs: [],
  31. assistantWorkRows: [tool],
  32. assistantHistoryRows: [],
  33. assistantFollowingRows: [],
  34. assistantTailRows: [],
  35. browserTurnEndRows: [],
  36. hookInvocations: [],
  37. assistantTextRows: [],
  38. leadingBoundaryRows: [],
  39. flowItems: [],
  40. renderRows: [tool],
  41. isLastTurn: true,
  42. isRunning: running,
  43. assistantHistoryDefaultOpen: false,
  44. timelineOnly: false,
  45. };
  46. return (
  47. <ZCodeIntlProvider initialLocale="en-US">
  48. <PlatformProvider platform={{} as IPlatformService}>
  49. <TooltipProvider>
  50. <button onClick={() => setJoined(true)}>Join run</button>
  51. <button onClick={() => setRunning(false)}>Finish reply</button>
  52. <ConversationTurnGroup
  53. unit={unit}
  54. context={{
  55. workspacePath: "/workspace",
  56. theme: "system",
  57. codePreviewSettings: DEFAULT_CODE_PREVIEW_SETTINGS,
  58. workflowRunByToolCallId: joined
  59. ? new Map([
  60. [
  61. "tool-5",
  62. { runId: "run-gate", status: "running", nodesTotal: 1, nodesSettled: 0 },
  63. ],
  64. ])
  65. : undefined,
  66. }}
  67. />
  68. </TooltipProvider>
  69. </PlatformProvider>
  70. </ZCodeIntlProvider>
  71. );
  72. }
  73. createRoot(document.getElementById("root")!).render(<Fixture />);