@zyro-sec/session-ui 0.0.0-stage → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (261) hide show
  1. package/AGENTS.md +25 -0
  2. package/bunfig.toml +2 -0
  3. package/component-tests/basic-tool.fixture.tsx +46 -0
  4. package/component-tests/basic-tool.spec.ts +63 -0
  5. package/component-tests/file-media.fixture.tsx +39 -0
  6. package/component-tests/file-media.spec.ts +13 -0
  7. package/component-tests/file-tool.spec.ts +62 -0
  8. package/component-tests/file-viewer.fixture.tsx +109 -0
  9. package/component-tests/file-viewer.spec.ts +134 -0
  10. package/component-tests/file.spec.ts +33 -0
  11. package/component-tests/line-comment-v2.spec.ts +15 -0
  12. package/component-tests/markdown-code-wrap.spec.ts +94 -0
  13. package/component-tests/markdown-readiness.spec.ts +95 -0
  14. package/component-tests/markdown.fixture.tsx +104 -0
  15. package/component-tests/markdown.spec.ts +1564 -0
  16. package/component-tests/mermaid-preview.spec.ts +43 -0
  17. package/component-tests/patch-group.spec.ts +79 -0
  18. package/component-tests/read-group.spec.ts +72 -0
  19. package/component-tests/read-image.fixture.tsx +66 -0
  20. package/component-tests/read-image.spec.ts +154 -0
  21. package/component-tests/session-compaction.spec.ts +254 -0
  22. package/component-tests/session-lifecycle.spec.ts +190 -0
  23. package/component-tests/session-message-projection.spec.ts +639 -0
  24. package/component-tests/session-notice-projection.spec.ts +20 -0
  25. package/component-tests/session-review-comments.spec.ts +179 -0
  26. package/component-tests/session-shell.spec.ts +93 -0
  27. package/component-tests/session-timeline-mobile.spec.ts +201 -0
  28. package/component-tests/session-timeline-notices.spec.ts +38 -0
  29. package/component-tests/session-timeline-reasoning.spec.ts +107 -0
  30. package/component-tests/session-timeline.spec.ts +157 -0
  31. package/component-tests/session-tool-projection.spec.ts +323 -0
  32. package/component-tests/text-lifecycle.fixture.tsx +26 -0
  33. package/component-tests/text-lifecycle.spec.ts +42 -0
  34. package/component-tests/timeline-subagent-rows.spec.ts +33 -0
  35. package/component-tests/tool-disclosure.spec.ts +48 -0
  36. package/component-tests/tool-group-sticky.spec.ts +37 -0
  37. package/component-tests/tool-group.spec.ts +290 -0
  38. package/component-tests/tool-status-title.fixture.tsx +22 -0
  39. package/component-tests/tool-status-title.spec.ts +30 -0
  40. package/component-tests/user-message-quotes.spec.ts +111 -0
  41. package/package.json +91 -4
  42. package/playwright.components.config.ts +4 -0
  43. package/playwright.local.config.ts +2 -0
  44. package/src/actions.ts +54 -0
  45. package/src/components/apply-patch-file.ts +122 -0
  46. package/src/components/basic-tool.css +487 -0
  47. package/src/components/basic-tool.tsx +258 -0
  48. package/src/components/copy-machine.ts +78 -0
  49. package/src/components/copy.ts +85 -0
  50. package/src/components/diagram-preview.tsx +28 -0
  51. package/src/components/disclosure-machine.ts +188 -0
  52. package/src/components/disclosure.ts +129 -0
  53. package/src/components/dock-prompt.stories.tsx +73 -0
  54. package/src/components/dock-prompt.tsx +29 -0
  55. package/src/components/file-comment-selection.tsx +146 -0
  56. package/src/components/file-media-machine.ts +165 -0
  57. package/src/components/file-media.stories.tsx +112 -0
  58. package/src/components/file-media.tsx +323 -0
  59. package/src/components/file-search.tsx +73 -0
  60. package/src/components/file.css +59 -0
  61. package/src/components/file.tsx +1300 -0
  62. package/src/components/image-preview.tsx +35 -0
  63. package/src/components/line-comment-annotations.tsx +580 -0
  64. package/src/components/line-comment-machine.ts +262 -0
  65. package/src/components/line-comment-styles.ts +293 -0
  66. package/src/components/line-comment.stories.tsx +152 -0
  67. package/src/components/line-comment.tsx +448 -0
  68. package/src/components/link-segments.ts +20 -0
  69. package/src/components/linked-text.tsx +21 -0
  70. package/src/components/markdown-cache-machine.ts +257 -0
  71. package/src/components/markdown-cache.tsx +556 -0
  72. package/src/components/markdown-clipboard.ts +101 -0
  73. package/src/components/markdown-code-machine.ts +200 -0
  74. package/src/components/markdown-code-state.ts +22 -0
  75. package/src/components/markdown-fragment-links.ts +74 -0
  76. package/src/components/markdown-github.svg +3 -0
  77. package/src/components/markdown-globe.svg +5 -0
  78. package/src/components/markdown-image-machine.ts +170 -0
  79. package/src/components/markdown-image.ts +156 -0
  80. package/src/components/markdown-inline-code-kind.ts +39 -0
  81. package/src/components/markdown-mermaid.ts +18 -0
  82. package/src/components/markdown-phase-machine.ts +102 -0
  83. package/src/components/markdown-projection.ts +13 -0
  84. package/src/components/markdown-session-links.ts +183 -0
  85. package/src/components/markdown-solid.test.tsx +92 -0
  86. package/src/components/markdown-solid.tsx +113 -0
  87. package/src/components/markdown-stream.ts +95 -0
  88. package/src/components/markdown-worker-machine.ts +516 -0
  89. package/src/components/markdown-worker-protocol.ts +73 -0
  90. package/src/components/markdown-worker.ts +250 -0
  91. package/src/components/markdown.css +672 -0
  92. package/src/components/markdown.stories.tsx +199 -0
  93. package/src/components/markdown.tsx +1612 -0
  94. package/src/components/markdown.worker.ts +188 -0
  95. package/src/components/message-file.ts +102 -0
  96. package/src/components/message-nav.css +134 -0
  97. package/src/components/message-nav.tsx +159 -0
  98. package/src/components/message-part.css +2109 -0
  99. package/src/components/message-part.tsx +3 -0
  100. package/src/components/question-prompt-experimental.css +576 -0
  101. package/src/components/question-prompt.css +527 -0
  102. package/src/components/quote-highlight.css +59 -0
  103. package/src/components/review-focus-driver.ts +142 -0
  104. package/src/components/review-focus-machine.ts +95 -0
  105. package/src/components/session-compaction.css +270 -0
  106. package/src/components/session-diff.ts +358 -0
  107. package/src/components/session-error.tsx +41 -0
  108. package/src/components/session-retry.tsx +92 -0
  109. package/src/components/session-review-machine.ts +241 -0
  110. package/src/components/session-review.css +264 -0
  111. package/src/components/session-review.stories.tsx +232 -0
  112. package/src/components/session-review.tsx +733 -0
  113. package/src/components/session-turn.css +282 -0
  114. package/src/components/shell-submessage.css +24 -0
  115. package/src/components/timeline-separator.tsx +69 -0
  116. package/src/components/tool-count-label.css +57 -0
  117. package/src/components/tool-count-label.tsx +76 -0
  118. package/src/components/tool-count-summary.css +102 -0
  119. package/src/components/tool-count-summary.stories.tsx +99 -0
  120. package/src/components/tool-count-summary.tsx +44 -0
  121. package/src/components/tool-error-card.css +178 -0
  122. package/src/components/tool-error-card.stories.tsx +113 -0
  123. package/src/components/tool-error-card.tsx +202 -0
  124. package/src/components/tool-status-title-machine.ts +128 -0
  125. package/src/components/tool-status-title.css +89 -0
  126. package/src/components/tool-status-title.tsx +163 -0
  127. package/src/context/data.tsx +107 -0
  128. package/src/context/index.ts +1 -0
  129. package/src/context/markdown.tsx +129 -0
  130. package/src/context/sources.tsx +34 -0
  131. package/src/document.ts +8 -0
  132. package/src/file-presentation.ts +34 -0
  133. package/src/message/action-machine.ts +72 -0
  134. package/src/message/agent-label.ts +3 -0
  135. package/src/message/attachment-card.css +119 -0
  136. package/src/message/attachment-card.tsx +40 -0
  137. package/src/message/attachment-media-machine.ts +213 -0
  138. package/src/message/comment-card.tsx +155 -0
  139. package/src/message/compaction-entrance-machine.ts +93 -0
  140. package/src/message/current-message.tsx +157 -0
  141. package/src/message/current-tool-state.ts +161 -0
  142. package/src/message/message-content.tsx +1391 -0
  143. package/src/message/paced-text-machine.ts +73 -0
  144. package/src/message/prompt-message.stories.tsx +149 -0
  145. package/src/message/relative-time.ts +45 -0
  146. package/src/message/user-message-quote-parts.ts +16 -0
  147. package/src/message/user-message-quotes.stories.tsx +797 -0
  148. package/src/message/user-message-quotes.tsx +135 -0
  149. package/src/pierre/comment-hover-machine.ts +53 -0
  150. package/src/pierre/comment-hover.ts +131 -0
  151. package/src/pierre/comment-selection-machine.ts +257 -0
  152. package/src/pierre/commented-lines.ts +106 -0
  153. package/src/pierre/diff-selection.ts +91 -0
  154. package/src/pierre/file-find-machine.ts +323 -0
  155. package/src/pierre/file-find.ts +537 -0
  156. package/src/pierre/file-runtime.ts +42 -0
  157. package/src/pierre/file-selection.ts +140 -0
  158. package/src/pierre/index.ts +344 -0
  159. package/src/pierre/media.ts +140 -0
  160. package/src/pierre/render-machine.ts +381 -0
  161. package/src/pierre/selection-bridge.ts +82 -0
  162. package/src/pierre/selection-machine.ts +198 -0
  163. package/src/pierre/virtualizer.ts +114 -0
  164. package/src/pierre/worker.ts +46 -0
  165. package/src/sources/experiment.ts +59 -0
  166. package/src/sources/site-icon.tsx +53 -0
  167. package/src/sources/sources-chip.tsx +57 -0
  168. package/src/sources/sources-expand-machine.ts +101 -0
  169. package/src/sources/sources-panel.tsx +249 -0
  170. package/src/sources/sources-title.tsx +21 -0
  171. package/src/sources/sources.css +266 -0
  172. package/src/sources/sources.ts +141 -0
  173. package/src/storybook/current-session-fixtures.ts +1492 -0
  174. package/src/storybook/current-session-scenarios.ts +76 -0
  175. package/src/storybook/current-session-story.tsx +154 -0
  176. package/src/storybook/index.ts +43 -0
  177. package/src/styles/index.css +19 -0
  178. package/src/timeline/__snapshots__/group-labels.test.ts.snap +110 -0
  179. package/src/timeline/__snapshots__/placement.test.ts.snap +1041 -0
  180. package/src/timeline/code-blocks.stories.tsx +105 -0
  181. package/src/timeline/commentary.stories.tsx +70 -0
  182. package/src/timeline/commentary.ts +38 -0
  183. package/src/timeline/detail.ts +111 -0
  184. package/src/timeline/error-card.stories.tsx +134 -0
  185. package/src/timeline/error-spacing.stories.tsx +71 -0
  186. package/src/timeline/facts.ts +493 -0
  187. package/src/timeline/file-changes.stories.tsx +436 -0
  188. package/src/timeline/group-label-fixtures.ts +97 -0
  189. package/src/timeline/mermaid.stories.tsx +131 -0
  190. package/src/timeline/place.ts +280 -0
  191. package/src/timeline/placement-fixtures.ts +365 -0
  192. package/src/timeline/placement-reactivity.ts +133 -0
  193. package/src/timeline/projection.ts +1261 -0
  194. package/src/timeline/research-and-agents.stories.tsx +461 -0
  195. package/src/timeline/session-timeline-row.tsx +1675 -0
  196. package/src/timeline/session-timeline.tsx +68 -0
  197. package/src/timeline/steer-arrival-machine.ts +134 -0
  198. package/src/timeline/terminal-work.stories.tsx +464 -0
  199. package/src/timeline/timeline-row.stories.tsx +1069 -0
  200. package/src/timeline/timeline-row.ts +238 -0
  201. package/src/timeline/turn-phase-machine.ts +112 -0
  202. package/src/timeline/user-message-fold.stories.tsx +194 -0
  203. package/src/timeline/user-runs.ts +87 -0
  204. package/src/timeline-next/__snapshots__/placement.test.ts.snap +990 -0
  205. package/src/timeline-next/compaction.tsx +236 -0
  206. package/src/timeline-next/errors.ts +101 -0
  207. package/src/timeline-next/event-row.tsx +168 -0
  208. package/src/timeline-next/events.ts +103 -0
  209. package/src/timeline-next/index.ts +10 -0
  210. package/src/timeline-next/nested-rail.ts +125 -0
  211. package/src/timeline-next/projection.ts +1028 -0
  212. package/src/timeline-next/row.tsx +1728 -0
  213. package/src/timeline-next/rules.ts +89 -0
  214. package/src/timeline-next/separator.tsx +73 -0
  215. package/src/timeline-next/spacing.ts +127 -0
  216. package/src/timeline-next/status-line.tsx +41 -0
  217. package/src/timeline-next/status.ts +33 -0
  218. package/src/timeline-next/stories/compare-renderer.stories.tsx +190 -0
  219. package/src/timeline-next/stories/compare-sessions/.gitignore +3 -0
  220. package/src/timeline-next/stories/compare.stories.tsx +486 -0
  221. package/src/timeline-next/stories/playground.stories.tsx +297 -0
  222. package/src/timeline-next/stories/session-replay.ts +1156 -0
  223. package/src/timeline-next/stories/session-timeline.tsx +50 -0
  224. package/src/timeline-next/stories/subagent-status.stories.tsx +132 -0
  225. package/src/timeline-next/timeline-next.css +649 -0
  226. package/src/timeline-next/tools/__snapshots__/activity-label.test.ts.snap +39 -0
  227. package/src/timeline-next/tools/activity-label.ts +166 -0
  228. package/src/timeline-next/tools/assistant-content.tsx +84 -0
  229. package/src/timeline-next/tools/context-group.tsx +619 -0
  230. package/src/timeline-next/tools/error-card.tsx +147 -0
  231. package/src/timeline-next/tools/explore.tsx +119 -0
  232. package/src/timeline-next/tools/file-group.tsx +128 -0
  233. package/src/timeline-next/tools/patch.tsx +174 -0
  234. package/src/timeline-next/tools/shell.tsx +186 -0
  235. package/src/timeline-next/tools/thought.tsx +87 -0
  236. package/src/timeline-next/tools/tool-display.tsx +119 -0
  237. package/src/tools/ansi.ts +8 -0
  238. package/src/tools/context-group-label.ts +123 -0
  239. package/src/tools/file-runs.ts +35 -0
  240. package/src/tools/project-path.ts +18 -0
  241. package/src/tools/read-group.stories.tsx +159 -0
  242. package/src/tools/run-machine.ts +185 -0
  243. package/src/tools/shell-output-machine.ts +233 -0
  244. package/src/tools/shell-output.ts +91 -0
  245. package/src/tools/subagent-row-variants.stories.tsx +129 -0
  246. package/src/tools/tool-group.stories.tsx +345 -0
  247. package/src/tools/tool-renderer.tsx +2876 -0
  248. package/src/v2/components/line-comment-annotations-v2.tsx +215 -0
  249. package/src/v2/components/session-file-panel-v2.tsx +149 -0
  250. package/src/v2/components/session-progress-indicator-v2.css +5 -0
  251. package/src/v2/components/session-progress-indicator-v2.stories.tsx +86 -0
  252. package/src/v2/components/session-progress-indicator-v2.tsx +16 -0
  253. package/src/v2/components/session-review-empty-changes-v2.tsx +17 -0
  254. package/src/v2/components/session-review-empty-no-git-v2.tsx +28 -0
  255. package/src/v2/components/session-review-file-preview-v2-virtualize.ts +5 -0
  256. package/src/v2/components/session-review-file-preview-v2.tsx +266 -0
  257. package/src/v2/components/session-review-v2.css +653 -0
  258. package/src/v2/components/session-review-v2.tsx +422 -0
  259. package/src/v2/components/sidebar-presence-machine.ts +69 -0
  260. package/tsconfig.json +20 -0
  261. package/README.md +0 -3
@@ -0,0 +1,461 @@
1
+ import type { SessionMessageAssistant, SessionMessageAssistantTool } from "@zyro-sec/client/promise"
2
+ import { createMemo } from "solid-js"
3
+ import { Dynamic } from "solid-js/web"
4
+ import { createStore } from "solid-js/store"
5
+ import type { SessionDocument } from "../document"
6
+ import { CurrentSessionProviders, CurrentSessionTimelineStory } from "../storybook/current-session-story"
7
+ import {
8
+ CURRENT_SESSION_ID,
9
+ STORY_MODEL,
10
+ STORY_TIME,
11
+ inspectAndExplainDocument,
12
+ loadedResourcesDocument,
13
+ subagentDocument,
14
+ thinkingDocument,
15
+ webResearchDocument,
16
+ } from "../storybook/current-session-fixtures"
17
+ import { storyDocument, storyPatchFile, storyTool } from "../storybook/current-session-scenarios"
18
+ import { timelinePresets, type TimelinePlacement } from "./detail"
19
+ import { SessionTimeline } from "./session-timeline"
20
+
21
+ export default {
22
+ title: "OpenCode/Work/Research and agents",
23
+ id: "current-session-research-agents",
24
+ component: SessionTimeline,
25
+ parameters: {
26
+ layout: "fullscreen",
27
+ docs: {
28
+ description: {
29
+ component:
30
+ "Read-only investigation and delegated work using the production context group, web tools, skill notice, and child-Session cards.",
31
+ },
32
+ },
33
+ },
34
+ }
35
+
36
+ export const InspectTheCodebase = {
37
+ render: () => (
38
+ <CurrentSessionTimelineStory
39
+ title="Inspect the codebase"
40
+ description="Glob, grep, and read calls collapse into one context group before the explanation."
41
+ document={inspectAndExplainDocument}
42
+ width="760px"
43
+ />
44
+ ),
45
+ }
46
+
47
+ export const ResearchTheWeb = {
48
+ render: () => (
49
+ <CurrentSessionTimelineStory
50
+ title="Research the web"
51
+ description="A targeted search and source fetch precede a short answer with no code changes."
52
+ document={webResearchDocument}
53
+ width="760px"
54
+ />
55
+ ),
56
+ }
57
+
58
+ export const LoadedResources = {
59
+ render: () => (
60
+ <CurrentSessionTimelineStory
61
+ title="Loaded instruction file and skill"
62
+ description="The assistant reads project instructions, loads specialized guidance, and applies both to its response."
63
+ document={loadedResourcesDocument}
64
+ width="760px"
65
+ />
66
+ ),
67
+ }
68
+
69
+ export const DelegateFocusedTasks = {
70
+ render: () => (
71
+ <CurrentSessionTimelineStory
72
+ title="Delegate focused tasks"
73
+ description="A completed review and an active test task show the two normal child-Session states together."
74
+ document={subagentDocument}
75
+ width="760px"
76
+ />
77
+ ),
78
+ }
79
+
80
+ const delegationDocument = storyDocument([
81
+ storyTool("tool_delegation_glob", "glob", "completed", { pattern: "src/timeline/**/*.ts" }),
82
+ storyTool("tool_delegation_grep", "grep", "completed", { pattern: "timelineDetail" }),
83
+ storyTool("tool_delegation_read", "read", "completed", { path: "src/timeline/projection.ts" }),
84
+ storyTool(
85
+ "tool_delegation_explore",
86
+ "subagent",
87
+ "completed",
88
+ { agent: "explore", description: "Map the timeline grouping rules", prompt: "Find where tool rows are grouped." },
89
+ { output: "Grouping lives in the timeline projection.", metadata: { sessionID: "session_child_explore" } },
90
+ ),
91
+ storyTool(
92
+ "tool_delegation_review",
93
+ "subagent",
94
+ "completed",
95
+ { agent: "review", description: "Review the detail presets", prompt: "Check each timeline preset." },
96
+ { output: "Every preset is consistent.", metadata: { sessionID: "session_child_review" } },
97
+ ),
98
+ storyTool("tool_delegation_read_tests", "read", "completed", { path: "src/timeline/rows-current.test.ts" }),
99
+ storyTool("tool_delegation_grep_tests", "grep", "completed", { pattern: "subagent" }),
100
+ storyTool(
101
+ "tool_delegation_general",
102
+ "subagent",
103
+ "completed",
104
+ { agent: "general", description: "Run the focused timeline tests", prompt: "Run the timeline tests." },
105
+ { output: "All timeline tests pass.", metadata: { sessionID: "session_child_general" } },
106
+ ),
107
+ {
108
+ type: "text",
109
+ text: "Each delegated task keeps its own row while the reads and searches between them stay grouped.",
110
+ },
111
+ ])
112
+
113
+ export const DelegateBetweenTools = {
114
+ args: { subagents: "separate" },
115
+ argTypes: { subagents: { control: { type: "inline-radio" }, options: ["separate", "grouped", "hidden"] } },
116
+ render: (args: { subagents: TimelinePlacement }) => (
117
+ <section class="mx-auto min-h-screen w-full max-w-[720px] bg-v2-background-bg-base p-6">
118
+ <CurrentSessionProviders document={delegationDocument}>
119
+ <SessionTimeline
120
+ document={delegationDocument}
121
+ timelineDetail={{ ...timelinePresets[2].value, subagents: { placement: args.subagents } }}
122
+ />
123
+ </CurrentSessionProviders>
124
+ </section>
125
+ ),
126
+ }
127
+
128
+ function CodebaseExplorationStory() {
129
+ const [state, setState] = createStore({ read: false, glob: false })
130
+
131
+ const tool = (name: "read" | "glob", completed: boolean) => {
132
+ const input = name === "read" ? { path: "src/a.ts", offset: 0, limit: 120 } : { path: ".", pattern: "**/*.ts" }
133
+
134
+ return {
135
+ type: "tool",
136
+ id: `tool_context_${name}`,
137
+ name,
138
+ state: completed
139
+ ? { status: "completed", input, content: [{ type: "text", text: "Complete" }], metadata: {} }
140
+ : { status: "running", input, metadata: {} },
141
+ time: completed
142
+ ? { created: STORY_TIME, ran: STORY_TIME + 100, completed: STORY_TIME + 200 }
143
+ : { created: STORY_TIME, ran: STORY_TIME + 100 },
144
+ } satisfies SessionMessageAssistantTool
145
+ }
146
+
147
+ const document = createMemo(
148
+ () =>
149
+ ({
150
+ sessionID: CURRENT_SESSION_ID,
151
+ messages: [
152
+ ...thinkingDocument.messages,
153
+ {
154
+ id: "msg_codebase_exploration_assistant",
155
+ type: "assistant",
156
+ agent: "build",
157
+ model: STORY_MODEL,
158
+ content: [tool("read", state.read), tool("glob", state.glob)],
159
+ time:
160
+ state.read && state.glob ? { created: STORY_TIME, completed: STORY_TIME + 300 } : { created: STORY_TIME },
161
+ } satisfies SessionMessageAssistant,
162
+ ],
163
+ status: { type: state.read && state.glob ? "idle" : "busy" },
164
+ diffs: [],
165
+ }) satisfies SessionDocument,
166
+ )
167
+
168
+ return (
169
+ <section class="mx-auto flex w-full max-w-[720px] flex-col gap-4 p-6">
170
+ <div class="flex gap-2">
171
+ <button type="button" onClick={() => setState("read", true)}>
172
+ Complete read
173
+ </button>
174
+ <button type="button" onClick={() => setState("glob", true)}>
175
+ Complete glob
176
+ </button>
177
+ </div>
178
+ <CurrentSessionProviders document={document()}>
179
+ <SessionTimeline document={document()} />
180
+ </CurrentSessionProviders>
181
+ </section>
182
+ )
183
+ }
184
+
185
+ const ExploreTheCodebase = { render: () => <CodebaseExplorationStory /> }
186
+
187
+ const CompareSearchProviders = {
188
+ render: () => (
189
+ <CurrentSessionTimelineStory
190
+ title="Compare web search providers"
191
+ description="Search results identify Parallel, Exa, and the generic provider clearly."
192
+ document={storyDocument([
193
+ storyTool(
194
+ "tool_search_parallel",
195
+ "websearch",
196
+ "completed",
197
+ { query: "parallel" },
198
+ { metadata: { provider: "parallel" } },
199
+ ),
200
+ storyTool("tool_search_exa", "websearch", "completed", { query: "exa" }, { metadata: { provider: "exa" } }),
201
+ storyTool("tool_search_generic", "websearch", "completed", { query: "generic" }),
202
+ ])}
203
+ />
204
+ ),
205
+ }
206
+
207
+ const SearchResultsAndFiles = {
208
+ render: () => (
209
+ <CurrentSessionTimelineStory
210
+ title="Search results and opened files"
211
+ description="Grouped file searches show their match counts and the filename that was inspected."
212
+ document={storyDocument([
213
+ storyTool(
214
+ "tool_label_glob",
215
+ "glob",
216
+ "completed",
217
+ { path: ".", pattern: "**/*.ts" },
218
+ { metadata: { count: 1 } },
219
+ ),
220
+ storyTool(
221
+ "tool_label_grep",
222
+ "grep",
223
+ "completed",
224
+ { path: ".", pattern: "value" },
225
+ { metadata: { matches: 12 } },
226
+ ),
227
+ storyTool("tool_label_read", "read", "completed", { path: "src/a.ts" }),
228
+ ])}
229
+ />
230
+ ),
231
+ }
232
+
233
+ const ReadOneFile = {
234
+ render: () => (
235
+ <CurrentSessionTimelineStory
236
+ title="Read one source file"
237
+ description="A single read opens its own file label without neighboring tool calls."
238
+ document={storyDocument([storyTool("prt_read_path", "read", "completed", { path: "src/a.ts" })])}
239
+ />
240
+ ),
241
+ }
242
+
243
+ const LoadingSpecializedSkills = {
244
+ render: () => (
245
+ <CurrentSessionTimelineStory
246
+ title="Loading specialized skills"
247
+ description="Active and completed skills display their identifier or resolved name."
248
+ document={storyDocument([
249
+ storyTool("tool_skill_id", "skill", "running", { id: "frontend-design" }),
250
+ storyTool("tool_skill_name", "skill", "completed", { id: "opencode" }, { metadata: { name: "OpenCode" } }),
251
+ ])}
252
+ />
253
+ ),
254
+ }
255
+
256
+ const ResearchAcrossSteps = {
257
+ render: () => (
258
+ <CurrentSessionTimelineStory
259
+ title="Research across separate steps"
260
+ description="An explanation and command naturally separate independent file-investigation groups."
261
+ document={storyDocument([
262
+ storyTool("tool_boundary_read", "read", "completed", { path: "src/a.ts" }),
263
+ { type: "text", text: "Boundary text" },
264
+ storyTool("tool_boundary_glob", "glob", "completed", { path: ".", pattern: "**/*.ts" }),
265
+ storyTool("tool_boundary_grep", "grep", "completed", { path: ".", pattern: "stable" }),
266
+ storyTool("tool_boundary_shell", "shell", "completed", { command: "printf done" }, { output: "done" }),
267
+ storyTool("tool_boundary_list", "list", "completed", { path: "src" }),
268
+ ])}
269
+ />
270
+ ),
271
+ }
272
+
273
+ const questions = { questions: [{ header: "Stability", question: "Keep it stable?", options: [] }] }
274
+
275
+ const CompleteAgentWorkflow = {
276
+ render: () => (
277
+ <CurrentSessionTimelineStory
278
+ title="Complete agent workflow"
279
+ description="A realistic investigation combines file research, web sources, delegation, commands, edits, and specialist guidance."
280
+ document={storyDocument([
281
+ storyTool("tool_family_read", "read", "completed", { path: "src/a.ts" }),
282
+ storyTool("tool_family_glob", "glob", "completed", { path: ".", pattern: "**/*.ts" }),
283
+ storyTool("tool_family_grep", "grep", "completed", { path: ".", pattern: "value" }),
284
+ storyTool("tool_family_list", "list", "completed", { path: "src" }),
285
+ storyTool("tool_family_webfetch", "webfetch", "completed", { url: "https://example.com" }),
286
+ storyTool("tool_family_websearch", "websearch", "completed", { query: "timeline stability" }),
287
+ storyTool("tool_family_subagent", "subagent", "completed", {
288
+ description: "Inspect timeline",
289
+ agent: "explore",
290
+ prompt: "Inspect the timeline implementation.",
291
+ }),
292
+ storyTool("tool_family_shell", "shell", "completed", { command: "printf stable" }, { output: "stable" }),
293
+ storyTool(
294
+ "tool_family_edit",
295
+ "edit",
296
+ "completed",
297
+ { path: "src/a.ts", oldString: "before", newString: "after" },
298
+ {
299
+ metadata: { files: [storyPatchFile("src/a.ts")] },
300
+ },
301
+ ),
302
+ storyTool("tool_family_write", "write", "completed", {
303
+ path: "src/new.ts",
304
+ content: "export const stable = true",
305
+ }),
306
+ storyTool("tool_family_write_extra", "write", "completed", {
307
+ path: "src/extra.ts",
308
+ content: "export const extra = true",
309
+ }),
310
+ storyTool(
311
+ "tool_family_patch",
312
+ "patch",
313
+ "completed",
314
+ { patchText: "Update the projected files" },
315
+ {
316
+ metadata: { files: [storyPatchFile("src/a.ts")] },
317
+ },
318
+ ),
319
+ storyTool("tool_family_todo", "todowrite", "completed", { todos: [{ content: "Hidden", status: "pending" }] }),
320
+ storyTool("tool_family_question", "question", "completed", questions, { metadata: { answers: [["Yes"]] } }),
321
+ storyTool("tool_family_skill", "skill", "completed", { name: "stability" }),
322
+ storyTool("tool_family_custom", "custom_mcp_tool", "completed", { target: "timeline" }),
323
+ ])}
324
+ width="860px"
325
+ />
326
+ ),
327
+ }
328
+
329
+ const RecoverFromToolFailures = {
330
+ render: () => {
331
+ const names = ["shell", "edit", "write", "patch", "webfetch", "websearch", "subagent", "skill", "mcp_probe"]
332
+
333
+ const input = (name: string) => {
334
+ if (name === "shell") return { command: "exit 1" }
335
+
336
+ if (name === "edit" || name === "write") return { path: "src/error.ts", content: "" }
337
+
338
+ if (name === "patch") return { patchText: "Update src/error.ts" }
339
+
340
+ if (name === "webfetch") return { url: "https://example.com" }
341
+
342
+ if (name === "websearch") return { query: "failure" }
343
+
344
+ if (name === "subagent") return { description: "Fail subagent", agent: "explore", prompt: "Inspect." }
345
+
346
+ if (name === "skill") return { name: "failure" }
347
+
348
+ return { target: "failure" }
349
+ }
350
+
351
+ return (
352
+ <CurrentSessionTimelineStory
353
+ title="Recover from failed work"
354
+ description="Commands, edits, searches, and delegated work explain their failures while dismissed questions stay recognizable."
355
+ document={storyDocument([
356
+ ...names.map((name) => storyTool(`tool_error_${name}`, name, "error", input(name))),
357
+ storyTool("tool_error_question_dismissed", "question", "error", questions, {
358
+ error: "The user dismissed this question",
359
+ }),
360
+ storyTool("tool_error_question_transport", "question", "error", questions, {
361
+ error: "Question transport failed",
362
+ }),
363
+ storyTool("tool_error_todo", "todowrite", "error", { todos: [] }, { error: "Hidden todo failure" }),
364
+ ])}
365
+ width="860px"
366
+ />
367
+ )
368
+ },
369
+ }
370
+
371
+ function FailedCommandAndQuestionStory() {
372
+ const [state, setState] = createStore({ failed: false })
373
+
374
+ const document = createMemo(() =>
375
+ storyDocument(
376
+ [
377
+ storyTool(
378
+ "tool_transition_shell",
379
+ "shell",
380
+ state.failed ? "error" : "running",
381
+ { command: "exit 1" },
382
+ {
383
+ error: "Command exited 1",
384
+ },
385
+ ),
386
+ storyTool("tool_transition_question", "question", state.failed ? "error" : "running", questions, {
387
+ error: "The user dismissed this question",
388
+ }),
389
+ ],
390
+ !state.failed,
391
+ ),
392
+ )
393
+
394
+ return (
395
+ <section class="mx-auto flex w-full max-w-[720px] flex-col gap-4 p-6">
396
+ <button type="button" onClick={() => setState("failed", true)}>
397
+ Fail running tools
398
+ </button>
399
+ <CurrentSessionProviders document={document()}>
400
+ <SessionTimeline document={document()} shellToolDefaultOpen />
401
+ </CurrentSessionProviders>
402
+ </section>
403
+ )
404
+ }
405
+
406
+ const FailedCommandAndQuestion = { render: () => <FailedCommandAndQuestionStory /> }
407
+
408
+ const DelegatingAnAgent = {
409
+ render: () => (
410
+ <CurrentSessionTimelineStory
411
+ title="Delegating an agent"
412
+ description="The assistant shows its compact delegation status while preparing a focused task."
413
+ document={storyDocument([storyTool("tool_notice_delegation", "subagent", "streaming", {}, { raw: "" })], true)}
414
+ />
415
+ ),
416
+ }
417
+
418
+ const StartingBackgroundWork = {
419
+ render: () => (
420
+ <CurrentSessionTimelineStory
421
+ title="Starting background work"
422
+ description="A delegated task keeps its ordinary label until the background request completes."
423
+ document={storyDocument(
424
+ [
425
+ storyTool(
426
+ "tool_notice_background",
427
+ "subagent",
428
+ "running",
429
+ { description: "Inspect code" },
430
+ {
431
+ metadata: { status: "running" },
432
+ },
433
+ ),
434
+ ],
435
+ true,
436
+ )}
437
+ />
438
+ ),
439
+ }
440
+
441
+ const researchScenarios = {
442
+ workflow: CompleteAgentWorkflow,
443
+ exploration: ExploreTheCodebase,
444
+ providers: CompareSearchProviders,
445
+ results: SearchResultsAndFiles,
446
+ read: ReadOneFile,
447
+ skills: LoadingSpecializedSkills,
448
+ steps: ResearchAcrossSteps,
449
+ failures: RecoverFromToolFailures,
450
+ transition: FailedCommandAndQuestion,
451
+ delegation: DelegatingAnAgent,
452
+ background: StartingBackgroundWork,
453
+ }
454
+
455
+ export const AgentResearch = {
456
+ args: { scenario: "workflow" },
457
+ argTypes: { scenario: { control: "select", options: Object.keys(researchScenarios) } },
458
+ render: (args: { scenario: keyof typeof researchScenarios }) => (
459
+ <Dynamic component={researchScenarios[args.scenario]?.render ?? researchScenarios.workflow.render} />
460
+ ),
461
+ }