@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,129 @@
1
+ import { TextShimmer } from "@zyro-sec/ui/text-shimmer"
2
+ import { For, type JSX } from "solid-js"
3
+ import { CurrentSessionProviders } from "../storybook/current-session-story"
4
+ import { storyDocument, storyTool } from "../storybook/current-session-scenarios"
5
+ import { timelinePresets } from "../timeline/detail"
6
+ import { SessionTimeline } from "../timeline/session-timeline"
7
+
8
+ export default {
9
+ title: "OpenCode/Work/Subagent row variants",
10
+ id: "current-subagent-row-variants",
11
+ parameters: {
12
+ layout: "fullscreen",
13
+ docs: {
14
+ description: {
15
+ component:
16
+ "Design alternatives for child-Session rows without the old agent square. Production is the first variant; the others are static story-only sketches.",
17
+ },
18
+ },
19
+ },
20
+ }
21
+
22
+ const productionDocument = storyDocument(
23
+ [
24
+ storyTool("variant_glob", "glob", "completed", { pattern: "src/timeline/**/*.ts" }),
25
+ storyTool("variant_grep", "grep", "completed", { pattern: "timelineDetail" }),
26
+ storyTool("variant_read", "read", "completed", { path: "src/timeline/projection.ts" }),
27
+ storyTool(
28
+ "variant_explore",
29
+ "subagent",
30
+ "completed",
31
+ { agent: "explore", description: "Map the timeline grouping rules", prompt: "Find where tool rows are grouped." },
32
+ { output: "Grouping lives in the timeline projection.", metadata: { sessionID: "session_child_explore" } },
33
+ ),
34
+ storyTool(
35
+ "variant_test",
36
+ "subagent",
37
+ "running",
38
+ { agent: "test", description: "Run the focused timeline tests", prompt: "Run the timeline tests." },
39
+ { metadata: { sessionID: "session_child_test" } },
40
+ ),
41
+ storyTool("variant_delegating", "subagent", "streaming", {}, { raw: "" }),
42
+ ],
43
+ true,
44
+ )
45
+
46
+ const sketchRows = [
47
+ { title: "Explore", subtitle: "Map the timeline grouping rules", running: false },
48
+ { title: "Test", subtitle: "Run the focused timeline tests", running: true },
49
+ ]
50
+
51
+ function Frame(props: { title: string; children: JSX.Element }) {
52
+ return (
53
+ <section class="mx-auto w-full max-w-[720px] px-6 py-4">
54
+ <h2 class="mb-3 text-[13px] leading-text-compact font-[530] text-v2-text-text-muted">{props.title}</h2>
55
+ {props.children}
56
+ </section>
57
+ )
58
+ }
59
+
60
+ function SketchContext() {
61
+ return (
62
+ <div class="h-9 flex items-center text-[13px] leading-text-compact text-v2-text-text-base">
63
+ <span class="text-v2-text-text-muted">Used 3&nbsp;</span>Glob, Grep, Read
64
+ </div>
65
+ )
66
+ }
67
+
68
+ function ShimmerWhileRunning() {
69
+ return (
70
+ <div class="flex flex-col gap-2 ps-6">
71
+ <SketchContext />
72
+ <For each={sketchRows}>
73
+ {(row) => (
74
+ <div data-component="task-tool-card" class="w-fit max-w-full">
75
+ <div data-component="task-tool-surface">
76
+ <div data-slot="basic-tool-tool-info-main" class="flex items-center">
77
+ <span data-component="task-tool-title">
78
+ <TextShimmer as="span" text={row.title} active={row.running} />
79
+ </span>
80
+ <span data-slot="basic-tool-tool-subtitle">{row.subtitle}</span>
81
+ </div>
82
+ </div>
83
+ </div>
84
+ )}
85
+ </For>
86
+ </div>
87
+ )
88
+ }
89
+
90
+ function PlainLabel() {
91
+ return (
92
+ <div class="flex flex-col ps-6">
93
+ <SketchContext />
94
+ <For each={sketchRows}>
95
+ {(row) => (
96
+ <div class="h-9 flex items-center gap-2 text-[13px] leading-text-compact tracking-[-0.04px]">
97
+ <span class="font-[530] text-v2-text-text-base">
98
+ <TextShimmer as="span" text={row.title} active={row.running} />
99
+ </span>
100
+ <span class="font-[440] text-v2-text-text-muted">{row.subtitle}</span>
101
+ </div>
102
+ )}
103
+ </For>
104
+ </div>
105
+ )
106
+ }
107
+
108
+ export const Variants = {
109
+ args: { subagents: "separate" },
110
+ argTypes: { subagents: { options: ["separate", "grouped", "hidden"] } },
111
+ render: (args: { subagents: "separate" | "grouped" | "hidden" }) => (
112
+ <div class="min-h-screen bg-v2-background-bg-base py-4">
113
+ <Frame title="A. Dot-matrix spinner while running, no icon when done (production)">
114
+ <CurrentSessionProviders document={productionDocument}>
115
+ <SessionTimeline
116
+ document={productionDocument}
117
+ timelineDetail={{ ...timelinePresets[2].value, subagents: { placement: args.subagents } }}
118
+ />
119
+ </CurrentSessionProviders>
120
+ </Frame>
121
+ <Frame title="B. No icon, shimmering title while running (sketch)">
122
+ <ShimmerWhileRunning />
123
+ </Frame>
124
+ <Frame title="C. Plain label without a pill (sketch)">
125
+ <PlainLabel />
126
+ </Frame>
127
+ </div>
128
+ ),
129
+ }
@@ -0,0 +1,345 @@
1
+ import { createEffect, createMemo, createSignal, Show } from "solid-js"
2
+ import { createStore } from "solid-js/store"
3
+ import { createTwoFilesPatch } from "diff"
4
+ import { CurrentSessionProviders } from "../storybook/current-session-story"
5
+ import { storyDocument, storyTool } from "../storybook/current-session-scenarios"
6
+ import { type ContextGroupPart, CurrentContextToolGroup } from "./tool-renderer"
7
+
8
+ export default {
9
+ title: "OpenCode/Work/Tool group",
10
+ id: "current-tool-group",
11
+ component: CurrentContextToolGroup,
12
+ }
13
+
14
+ export const MixedTools = {
15
+ args: { open: true },
16
+ render: (args: { open: boolean }) => {
17
+ const [open, setOpen] = createSignal(args.open)
18
+ createEffect(() => setOpen(args.open))
19
+
20
+ const tools = [
21
+ storyTool(
22
+ "group_shell",
23
+ "shell",
24
+ "completed",
25
+ { command: "printf 'group geometry'" },
26
+ { output: "group geometry" },
27
+ ),
28
+ storyTool("group_read", "read", "completed", { path: "src/group.ts" }),
29
+ storyTool("group_general", "subagent", "completed", { agent: "general", description: "Inspect grouped tools" }),
30
+ storyTool("group_explore", "subagent", "completed", { agent: "explore", description: "Check card geometry" }),
31
+ ]
32
+
33
+ return (
34
+ <section style={{ width: "100%", "max-width": "720px", padding: "24px" }}>
35
+ <CurrentSessionProviders document={storyDocument(tools)}>
36
+ <CurrentContextToolGroup parts={tools} busy={false} open={open()} onOpenChange={setOpen} />
37
+ </CurrentSessionProviders>
38
+ </section>
39
+ )
40
+ },
41
+ }
42
+
43
+ export const NoticesOnly = {
44
+ render: () => {
45
+ const [open, setOpen] = createStore({ tools: false, notices: false })
46
+ const tools = [storyTool("notice_read", "read", "completed", { path: "AGENTS.md" })]
47
+
48
+ return (
49
+ <section class="mx-auto flex w-full max-w-[720px] flex-col gap-4 p-6">
50
+ <CurrentSessionProviders document={storyDocument(tools)}>
51
+ <CurrentContextToolGroup
52
+ parts={tools}
53
+ busy={false}
54
+ open={open.tools}
55
+ onOpenChange={(value) => setOpen("tools", value)}
56
+ />
57
+ <CurrentContextToolGroup
58
+ parts={[
59
+ { type: "notice", id: "notice_instructions", render: () => <p>Instructions updated: AGENTS.md</p> },
60
+ ]}
61
+ busy={false}
62
+ open={open.notices}
63
+ onOpenChange={(value) => setOpen("notices", value)}
64
+ />
65
+ </CurrentSessionProviders>
66
+ </section>
67
+ )
68
+ },
69
+ }
70
+
71
+ export const MixedReasoning = {
72
+ args: { reasoningDefaultOpen: false, appended: false },
73
+ render: (args: { reasoningDefaultOpen: boolean; appended: boolean }) => {
74
+ const [open, setOpen] = createSignal(true)
75
+ const [appended, setAppended] = createSignal(args.appended)
76
+ createEffect(() => setAppended(args.appended))
77
+
78
+ const parts = createMemo<ContextGroupPart[]>(() => [
79
+ storyTool("reasoning_read", "read", "completed", { path: "src/group.ts" }),
80
+ {
81
+ type: "reasoning",
82
+ id: "reasoning_first",
83
+ text: "The renderer groups adjacent tools. Check the relevant skills before changing it.",
84
+ },
85
+ storyTool("reasoning_skill_first", "skill", "completed", { id: "opencode" }),
86
+ storyTool("reasoning_skill_second", "skill", "completed", { id: "frontend-design" }),
87
+ {
88
+ type: "reasoning",
89
+ id: "reasoning_second",
90
+ text: "Keep these skill groups separate so the reasoning stays in chronological order.",
91
+ },
92
+ storyTool("reasoning_skill_third", "skill", "completed", { id: "rtl-aware-development" }),
93
+ ...(appended() ? [storyTool("reasoning_read_next", "read", "completed", { path: "src/group.test.ts" })] : []),
94
+ ])
95
+
96
+ return (
97
+ <section class="mx-auto flex w-full max-w-[860px] flex-col gap-4 p-6">
98
+ <button type="button" onClick={() => setAppended((value) => !value)}>
99
+ {appended() ? "Remove follow-up read" : "Append follow-up read"}
100
+ </button>
101
+ <CurrentSessionProviders document={storyDocument(parts())}>
102
+ <CurrentContextToolGroup
103
+ parts={parts()}
104
+ busy={false}
105
+ open={open()}
106
+ onOpenChange={setOpen}
107
+ reasoningDefaultOpen={args.reasoningDefaultOpen}
108
+ />
109
+ </CurrentSessionProviders>
110
+ </section>
111
+ )
112
+ },
113
+ }
114
+
115
+ export const CountRollover = {
116
+ args: { count: 9, attached: true },
117
+ argTypes: { count: { control: { type: "range", min: 1, max: 101, step: 1 } } },
118
+ render: (args: { count: number; attached: boolean }) => {
119
+ const [state, setState] = createStore({ open: false, count: args.count, attached: args.attached })
120
+ createEffect(() => setState("count", args.count))
121
+ createEffect(() => setState("attached", args.attached))
122
+
123
+ const parts = createMemo(() =>
124
+ Array.from({ length: state.count }, (_, index) =>
125
+ storyTool(`rollover_read_${index}`, "read", "completed", { path: `src/file-${index}.ts` }),
126
+ ),
127
+ )
128
+
129
+ // Created once, like a cached session timeline: detaching removes it from the page but keeps it updating.
130
+ const group = (
131
+ <CurrentSessionProviders document={storyDocument(parts())}>
132
+ <CurrentContextToolGroup
133
+ parts={parts()}
134
+ busy={false}
135
+ open={state.open}
136
+ onOpenChange={(open) => setState("open", open)}
137
+ />
138
+ </CurrentSessionProviders>
139
+ )
140
+
141
+ return (
142
+ <section class="mx-auto flex w-full max-w-[860px] flex-col gap-4 p-6">
143
+ <div class="flex gap-3">
144
+ <button type="button" onClick={() => setState("count", (count) => count + 1)}>
145
+ Add read
146
+ </button>
147
+ <button type="button" onClick={() => setState("count", (count) => count - 1)}>
148
+ Remove read
149
+ </button>
150
+ <button type="button" onClick={() => setState("attached", (attached) => !attached)}>
151
+ {state.attached ? "Detach" : "Attach"}
152
+ </button>
153
+ </div>
154
+ <Show when={state.attached}>{group}</Show>
155
+ </section>
156
+ )
157
+ },
158
+ }
159
+
160
+ // Mirrors a long exploration turn in a timeline viewport with the session title header above it.
161
+ const stickyCommands = [
162
+ "git log --oneline 09c318094c..upstream/v2 -- packages/tui/src/plugin/structure.ts packages/tui/src/plugin/render.tsx",
163
+ "git log --oneline 09c318094c..upstream/v2 -- packages/tui/src/plugin/structure.ts; git diff --stat upstream/v2",
164
+ 'git log --format="%h %s" 09c318094c..upstream/v2 -- packages/app/src/runtime/persistence',
165
+ 'git log --format="%h %s" 09c318094c..upstream/v2 -- packages/app/src/session/review packages/app/src/session/files',
166
+ 'git show 09c318094c:packages/app/src/session/review/model.ts | Select-String "ChangeMode ="',
167
+ "git show 09c318094c:packages/app/src/session/review/model.ts | Select-String -Pattern 'turn' -Context 0,0",
168
+ ]
169
+
170
+ const stickySource = (lines: number, changed: boolean) =>
171
+ Array.from(
172
+ { length: lines },
173
+ (_, index) => `export const value${index} = ${changed && index % 3 === 0 ? index + 1 : index}\n`,
174
+ ).join("")
175
+
176
+ const stickyParts: ContextGroupPart[] = [
177
+ storyTool("sticky_write", "write", "completed", { path: "graph.js", content: stickySource(137, false) }),
178
+ ...Array.from({ length: 36 }, (_, index): ContextGroupPart[] => [
179
+ {
180
+ type: "reasoning",
181
+ id: `sticky_thought_${index}`,
182
+ text: "Check which commits touched the review model before rebasing the stack.",
183
+ time: { created: 0, completed: ((index * 7) % 5) * 1000 + 1000 },
184
+ },
185
+ index === 18
186
+ ? storyTool(
187
+ "sticky_edit",
188
+ "edit",
189
+ "completed",
190
+ {
191
+ path: "src/session/review/model.ts",
192
+ oldString: stickySource(24, false),
193
+ newString: stickySource(24, true),
194
+ },
195
+ {},
196
+ )
197
+ : index % 6 === 5
198
+ ? storyTool(
199
+ `sticky_grep_${index}`,
200
+ "grep",
201
+ "completed",
202
+ { path: "C:/tmp/opencode/stack/packages/plugin-review-desktop/", pattern: 'turn"|lastTurn|session\\.diff' },
203
+ { metadata: { matches: 4 } },
204
+ )
205
+ : storyTool(
206
+ `sticky_shell_${index}`,
207
+ "shell",
208
+ "completed",
209
+ { command: stickyCommands[index % stickyCommands.length]! },
210
+ { output: "ok" },
211
+ ),
212
+ ]).flat(),
213
+ ]
214
+
215
+ export const StickyHeader = {
216
+ args: { height: 720 },
217
+ argTypes: { height: { control: { type: "range", min: 320, max: 1200, step: 20 } } },
218
+ render: (args: { height: number }) => {
219
+ const [state, setState] = createStore<{ open: boolean; files: Record<string, boolean> }>({ open: true, files: {} })
220
+
221
+ return (
222
+ <section
223
+ data-story="sticky-header-scroll"
224
+ class="relative w-full max-w-[1030px] overflow-y-auto bg-v2-background-bg-base"
225
+ style={{ height: `${args.height}px`, "--sticky-accordion-top": "48px" }}
226
+ >
227
+ <div class="pointer-events-none sticky top-0 z-30 w-full pb-4">
228
+ <div class="pointer-events-auto bg-v2-background-bg-base pe-3 ps-2.5">
229
+ <div class="flex h-12 items-center px-1 text-[13px] font-[530] leading-4 tracking-[-0.04px] text-v2-text-text-base">
230
+ Trace stacked review history
231
+ </div>
232
+ </div>
233
+ </div>
234
+ <div class="pointer-events-none sticky top-12 z-[5] -mt-4 h-4 w-full bg-[linear-gradient(to_bottom,var(--v2-background-bg-base),transparent)]" />
235
+ <div class="px-6" style={{ "padding-bottom": `${args.height}px` }}>
236
+ <CurrentSessionProviders document={storyDocument(stickyParts.filter((part) => part.type === "tool"))}>
237
+ <CurrentContextToolGroup
238
+ parts={stickyParts}
239
+ busy={false}
240
+ open={state.open}
241
+ onOpenChange={(open) => setState("open", open)}
242
+ fileOpen={(path) => state.files[path] ?? path.endsWith("model.ts")}
243
+ onFileOpenChange={(path, open) => setState("files", path, open)}
244
+ />
245
+ </CurrentSessionProviders>
246
+ </div>
247
+ </section>
248
+ )
249
+ },
250
+ }
251
+
252
+ export const PatchFollowUps = {
253
+ args: { separator: "none", phase: "initial" },
254
+ argTypes: {
255
+ separator: { control: "select", options: ["none", "shell", "error", "reasoning"] },
256
+ phase: { options: ["initial", "running", "completed"] },
257
+ },
258
+ render: (args: { separator: string; phase: "initial" | "running" | "completed" }) => {
259
+ const [state, setState] = createStore({ phase: args.phase, open: true, reasoning: true })
260
+ createEffect(() => setState("phase", args.phase))
261
+
262
+ const file = (path: string, before: number, after: number) => ({
263
+ file: path,
264
+ status: "modified",
265
+ additions: 1,
266
+ deletions: 1,
267
+ patch: createTwoFilesPatch(
268
+ path,
269
+ path,
270
+ `export const value = ${before}\n`,
271
+ `export const value = ${after}\n`,
272
+ "",
273
+ "",
274
+ { context: Infinity },
275
+ ),
276
+ })
277
+
278
+ const parts = createMemo<ContextGroupPart[]>(() => [
279
+ storyTool("patch_shell", "shell", "completed", { command: "printf checked" }, { output: "checked" }),
280
+ storyTool(
281
+ "patch_first",
282
+ "patch",
283
+ "completed",
284
+ {},
285
+ {
286
+ metadata: { files: [file("src/a.ts", 0, 1), file("src/b.ts", 0, 1)] },
287
+ },
288
+ ),
289
+ ...(state.phase === "initial"
290
+ ? []
291
+ : [
292
+ ...(args.separator === "shell"
293
+ ? [storyTool("patch_separator", "shell", "completed", { command: "printf checked" })]
294
+ : []),
295
+ ...(args.separator === "error"
296
+ ? [storyTool("patch_error", "patch", "error", {}, { error: "Patch failed" })]
297
+ : []),
298
+ ...(args.separator === "reasoning" && state.reasoning
299
+ ? [
300
+ {
301
+ type: "reasoning" as const,
302
+ id: "patch_reasoning",
303
+ text: "The first patch is ready. Now update the remaining files.",
304
+ },
305
+ ]
306
+ : []),
307
+ storyTool(
308
+ "patch_next",
309
+ "patch",
310
+ state.phase === "running" ? "running" : "completed",
311
+ {},
312
+ {
313
+ metadata: state.phase === "running" ? {} : { files: [file("src/a.ts", 1, 2), file("src/c.ts", 0, 1)] },
314
+ },
315
+ ),
316
+ ]),
317
+ ])
318
+
319
+ return (
320
+ <section class="mx-auto flex w-full max-w-[860px] flex-col gap-4 p-6">
321
+ <div class="flex flex-wrap gap-3">
322
+ <button type="button" onClick={() => setState("phase", "running")}>
323
+ Start follow-up patch
324
+ </button>
325
+ <button type="button" onClick={() => setState("phase", "completed")}>
326
+ Finish follow-up patch
327
+ </button>
328
+ <Show when={args.separator === "reasoning"}>
329
+ <button type="button" onClick={() => setState("reasoning", (value) => !value)}>
330
+ {state.reasoning ? "Hide thoughts" : "Show thoughts"}
331
+ </button>
332
+ </Show>
333
+ </div>
334
+ <CurrentSessionProviders document={storyDocument(parts())}>
335
+ <CurrentContextToolGroup
336
+ parts={parts()}
337
+ busy={state.phase === "running"}
338
+ open={state.open}
339
+ onOpenChange={(open) => setState("open", open)}
340
+ />
341
+ </CurrentSessionProviders>
342
+ </section>
343
+ )
344
+ },
345
+ }