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

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,157 @@
1
+ import { expect, story } from "../../stories/playwright/story"
2
+
3
+ story("spaces an error between a shell result and expanded updates", async ({ mount }) => {
4
+ const timeline = await mount("current-session-error-spacing--error-and-updates")
5
+ const shell = timeline.locator('[data-component="bash-output"]')
6
+ const error = timeline.locator('[data-kind="session-error-card"]')
7
+ const updates = timeline.locator('[data-component="collapsed-tool-group"] [data-slot="collapsible-trigger"]')
8
+ const shellBox = (await shell.boundingBox())!
9
+ const errorBox = (await error.boundingBox())!
10
+ const updatesBox = (await updates.boundingBox())!
11
+ expect(errorBox.y - (shellBox.y + shellBox.height)).toBe(24)
12
+ expect(updatesBox.y - (errorBox.y + errorBox.height)).toBe(8)
13
+ expect(updatesBox.x).toBe(errorBox.x)
14
+ await updates.click()
15
+ const notice = timeline.locator('[data-slot="session-timeline-notice"]')
16
+ await expect(notice).toContainText("Instructions updated")
17
+ const expandedBox = (await updates.boundingBox())!
18
+ expect((await notice.boundingBox())!.y - (expandedBox.y + expandedBox.height)).toBe(0)
19
+ expect((await notice.boundingBox())!.x - expandedBox.x).toBe(24)
20
+ expect(expandedBox.height).toBe(28)
21
+ })
22
+
23
+ for (const streaming of [false, true]) {
24
+ story(`renders Mermaid in the ${streaming ? "streaming" : "completed"} timeline`, async ({ mount, page }) => {
25
+ await page.setViewportSize({ width: 390, height: 900 })
26
+ const root = await mount("current-session-mermaid--diagrams", { args: { streaming } })
27
+ const timeline = root.locator('[data-component="session-timeline"]')
28
+ const diagrams = timeline.locator('[data-component="markdown-mermaid"] > svg')
29
+ await expect(diagrams).toHaveCount(2)
30
+ await expect(diagrams.nth(0)).toBeVisible()
31
+ await expect(diagrams.nth(0)).toContainText("Client")
32
+ await expect(diagrams.nth(1)).toBeVisible()
33
+ await expect(diagrams.nth(1)).toContainText("Send prompt")
34
+ await expect(timeline.locator('[data-mermaid-ready="true"]')).toHaveCount(2)
35
+ await expect(timeline.locator('[data-mermaid-ready="true"] > pre:visible')).toHaveCount(0)
36
+
37
+ if (streaming) {
38
+ await root.getByRole("button", { name: "Complete response" }).click()
39
+ await expect(timeline.locator('[data-markdown-complete="true"]')).toHaveCount(2)
40
+ await expect(diagrams).toHaveCount(2)
41
+ await expect(diagrams.nth(0)).toBeVisible()
42
+ await expect(diagrams.nth(1)).toBeVisible()
43
+ }
44
+ })
45
+ }
46
+
47
+ story("aligns the retry icon with the error label", async ({ mount }) => {
48
+ const timeline = await mount("current-session-timeline-rows--provider-retry")
49
+ const card = timeline.locator('[data-kind="session-retry-card"]')
50
+ const icon = card.locator('[data-slot="icon-svg"]')
51
+ const label = card.locator('[data-slot="session-turn-retry-message"]')
52
+ await expect(icon).toBeVisible()
53
+ await expect(label).toBeVisible()
54
+
55
+ const [iconY, labelY] = await Promise.all([
56
+ icon.evaluate((element) => element.getBoundingClientRect().y),
57
+ label.evaluate((element) => element.getBoundingClientRect().y),
58
+ ])
59
+
60
+ expect(iconY).toBe(labelY)
61
+ })
62
+
63
+ story("centers the error icon on the first line of short and wrapped errors", async ({ mount }) => {
64
+ const timeline = await mount("current-session-error-card--provider-errors")
65
+ const cards = timeline.locator('[data-kind="session-error-card"]')
66
+
67
+ await expect(cards).toHaveCount(2)
68
+
69
+ const geometry = await cards.evaluateAll((elements) =>
70
+ elements.map((card) => {
71
+ const icon = card.querySelector('[data-slot="icon-svg"]')!.getBoundingClientRect()
72
+ const message = card.querySelector('[data-slot="icon-svg"] + div')!
73
+ const line = parseFloat(getComputedStyle(message).lineHeight)
74
+ const box = message.getBoundingClientRect()
75
+
76
+ return {
77
+ lines: Math.round(box.height / line),
78
+ offset: icon.top + icon.height / 2 - (box.top + line / 2),
79
+ }
80
+ }),
81
+ )
82
+
83
+ expect(geometry.map((card) => card.lines > 1)).toEqual([false, true])
84
+ geometry.forEach((card) => expect(card.offset).toBeCloseTo(0, 0))
85
+ })
86
+
87
+ story("links URLs in an error without splitting them at a colon", async ({ mount }) => {
88
+ const timeline = await mount("current-session-error-card--linked-error")
89
+ const card = timeline.locator('[data-kind="session-error-card"]')
90
+ const url = "http://localhost:11434/api"
91
+
92
+ await expect(card.getByRole("link", { name: url, exact: true })).toHaveAttribute("href", url)
93
+ await expect(card.locator("strong")).toHaveCount(0)
94
+ })
95
+
96
+ // Moved from packages/app/e2e/regression/session-timeline-context-state.spec.ts
97
+ story("preserves a collapsed context group through count and status updates", async ({ mount }) => {
98
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "exploration" } })
99
+ const group = timeline.locator('[data-timeline-part-ids="tool_context_read,tool_context_glob"]')
100
+ const trigger = group.locator('[data-slot="collapsible-trigger"]')
101
+ await expect(trigger).toHaveAttribute("aria-expanded", "false")
102
+ await timeline.getByRole("button", { name: "Complete read" }).click()
103
+ await expect(trigger).toHaveAttribute("aria-expanded", "false")
104
+ await timeline.getByRole("button", { name: "Complete glob" }).click()
105
+ await expect(trigger).toHaveAttribute("aria-expanded", "false")
106
+ })
107
+
108
+ // A failed turn diff load used to look like one still loading, with no way to retry until the row remounted.
109
+ story("offers a retry for a turn diff that failed to load", async ({ mount }) => {
110
+ const timeline = await mount("current-session-file-changes--turn-change-summary-failed")
111
+ const summary = timeline.locator('[data-slot="session-turn-diffs"]')
112
+ const counts = summary.locator('[data-component="diff-changes"]')
113
+
114
+ await expect(summary).toContainText("2 Changed files")
115
+ await expect(summary).toContainText("Diff unavailable")
116
+ await expect(counts).toHaveCount(0)
117
+
118
+ const retry = summary.getByRole("button", { name: "Retry", exact: true })
119
+ await retry.click()
120
+ // The header totals the turn; each file row then shows its own counts.
121
+ await expect(counts.first()).toHaveText("+2-1")
122
+ await expect(summary).not.toContainText("Diff unavailable")
123
+ await expect(retry).toHaveCount(0)
124
+ })
125
+
126
+ // Moved from packages/app/e2e/regression/session-timeline-file-projection.spec.ts
127
+ story("renders a completed write through the production file component", async ({ mount }) => {
128
+ const timeline = await mount("current-session-file-changes--changing-files", { args: { scenario: "write" } })
129
+ const write = timeline.locator('[data-timeline-part-id="prt_file_projection_write"]')
130
+ const file = write.getByRole("button", { name: /write\.ts/ })
131
+ await expect(file).toHaveAttribute("aria-expanded", "false")
132
+ await file.click()
133
+ await expect(write.locator('[data-component="file"]')).toContainText("export const written = true")
134
+ })
135
+
136
+ // Moved from packages/app/e2e/regression/session-timeline-file-state.spec.ts
137
+ story("keeps patch file disclosures independent", async ({ mount }) => {
138
+ const timeline = await mount("current-session-file-changes--changing-files", { args: { scenario: "patch" } })
139
+ const wrapper = timeline.locator('[data-timeline-part-id="prt_nested_patch"]')
140
+ const modified = wrapper.locator('[data-scope="apply-patch"] [data-type="update"] [data-slot="accordion-trigger"]')
141
+ const added = wrapper.locator('[data-scope="apply-patch"] [data-type="add"] [data-slot="accordion-trigger"]')
142
+ const deleted = wrapper.locator('[data-scope="apply-patch"] [data-type="delete"] [data-slot="accordion-trigger"]')
143
+ await expect(wrapper.locator('[data-scope="apply-patch"] [aria-expanded="false"]')).toHaveCount(3)
144
+ await deleted.click()
145
+ await expect(deleted).toHaveAttribute("aria-expanded", "true")
146
+ await expect(modified).toHaveAttribute("aria-expanded", "false")
147
+ await modified.click()
148
+ await expect(modified).toHaveAttribute("aria-expanded", "true")
149
+ await deleted.click()
150
+ await expect(deleted).toHaveAttribute("aria-expanded", "false")
151
+ await expect(modified).toHaveAttribute("aria-expanded", "true")
152
+ await expect(added).toHaveAttribute("aria-expanded", "false")
153
+ await added.click()
154
+ await expect(added).toHaveAttribute("aria-expanded", "true")
155
+ await expect(modified).toHaveAttribute("aria-expanded", "true")
156
+ await expect(deleted).toHaveAttribute("aria-expanded", "false")
157
+ })
@@ -0,0 +1,323 @@
1
+ import { expect, story } from "../../stories/playwright/story"
2
+
3
+ // Moved from packages/app/e2e/regression/session-timeline-projection.spec.ts
4
+ story("renders every admitted tool family and hides timeline-only exclusions", async ({ mount }) => {
5
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "workflow" } })
6
+
7
+ const first = timeline.locator(
8
+ '[data-timeline-part-ids="tool_family_read,tool_family_glob,tool_family_grep,tool_family_list,tool_family_webfetch,tool_family_websearch,tool_family_subagent,tool_family_shell,tool_family_edit,tool_family_write,tool_family_write_extra,tool_family_patch"]',
9
+ )
10
+
11
+ const second = timeline.locator('[data-timeline-part-ids="tool_family_skill,tool_family_custom"]')
12
+ await expect(first).toBeVisible()
13
+ await expect(second).toBeVisible()
14
+ await first.getByRole("button").click()
15
+ await second.getByRole("button").click()
16
+
17
+ for (const id of ["webfetch", "websearch", "subagent", "shell", "question", "skill", "custom"]) {
18
+ await expect(timeline.locator(`[data-timeline-part-id="tool_family_${id}"]`), id).toBeVisible()
19
+ }
20
+
21
+ const files = timeline.locator(
22
+ '[data-timeline-part-ids="tool_family_edit,tool_family_write,tool_family_write_extra,tool_family_patch"]',
23
+ )
24
+
25
+ await expect(files).toBeVisible()
26
+ await expect(files.locator('[data-scope="apply-patch"]')).toHaveCount(1)
27
+ await expect(files.locator('[data-slot="apply-patch-filename"]')).toHaveText(["a.ts", "new.ts", "extra.ts"])
28
+ await expect(files.locator('[data-slot="basic-tool-tool-title"]')).toHaveCount(0)
29
+ await expect(files.locator('[data-scope="apply-patch"] button')).toHaveCount(3)
30
+ await expect(files.locator('[data-scope="apply-patch"] button[aria-expanded="false"]')).toHaveCount(3)
31
+ await expect(timeline.locator('[data-timeline-part-id="tool_family_todo"]')).toHaveCount(0)
32
+ })
33
+
34
+ // Moved from packages/app/e2e/regression/session-timeline-tool-projection.spec.ts
35
+ story("renders every tool error outcome without leaking hidden tools", async ({ mount }) => {
36
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "failures" } })
37
+ const names = ["shell", "edit", "write", "patch", "webfetch", "websearch", "subagent", "skill", "mcp_probe"]
38
+ const group = timeline.locator(`[data-timeline-part-ids="${names.map((name) => `tool_error_${name}`).join(",")}"]`)
39
+ await expect(group.getByRole("button")).toHaveAccessibleName(/^Used 9 /)
40
+ await group.getByRole("button").click()
41
+ await expect(timeline.locator('[data-kind="tool-error-card"]')).toHaveCount(names.length + 1)
42
+ const dismissed = timeline.locator('[data-timeline-part-id="tool_error_question_dismissed"]')
43
+ await expect(dismissed.getByText(/dismissed/i)).toBeVisible()
44
+ await expect(dismissed).toContainText(/dismissed/i)
45
+ await expect(timeline.locator('[data-timeline-part-id="tool_error_todo"]')).toHaveCount(0)
46
+
47
+ for (const name of names) await expect(timeline.locator(`[data-timeline-part-id="tool_error_${name}"]`)).toBeVisible()
48
+ })
49
+
50
+ story("lists a failed execute's calls and keeps its error under the failed call", async ({ mount }) => {
51
+ const timeline = await mount("current-session-terminal-work--execute-failed")
52
+ await timeline.getByRole("button", { name: /^Used 5 / }).click()
53
+ const failed = timeline.locator('[data-timeline-part-id="tool_execute_failed_url"]')
54
+ const call = failed.locator('[data-slot="execute-tool-call"]')
55
+ // Executions open by default, so the calls show without expanding the row.
56
+ await expect(call).toHaveText([/browser\.tabs\.open/])
57
+ await expect(call).toHaveAttribute("data-status", "error")
58
+ await expect(timeline.locator('[data-kind="tool-error-card"]')).toHaveCount(0)
59
+
60
+ // The runtime error stays collapsed under the failed call until it is expanded.
61
+ const error = failed.locator('[data-slot="execute-tool-error"]')
62
+ await expect(error).toHaveCount(0)
63
+ await call.click()
64
+ await expect(call).toHaveAttribute("aria-expanded", "true")
65
+ await expect(failed.locator('[data-slot="execute-tool-call-input"]')).toContainText(
66
+ "url:file:///C:/tmp/opencode/throne-of-glass-luke.html",
67
+ )
68
+ await expect(error).toContainText(
69
+ "The connected server must be able to reach the address; localhost refers to that server.",
70
+ )
71
+ })
72
+
73
+ // Moved from packages/app/e2e/regression/session-timeline-tool-projection.spec.ts
74
+ story("transitions shell and question through running error outcomes", async ({ mount }) => {
75
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "transition" } })
76
+ const shell = timeline.locator('[data-timeline-part-id="tool_transition_shell"]')
77
+ const question = timeline.locator('[data-timeline-part-id="tool_transition_question"]')
78
+ await expect(shell).toBeVisible()
79
+ await expect(question).toHaveCount(0)
80
+ await timeline.getByRole("button", { name: "Fail running tools" }).click()
81
+ await expect(shell.locator('[data-kind="tool-error-card"]')).toBeVisible()
82
+ await expect(shell).toContainText("Command exited 1")
83
+ await expect(question).toContainText(/dismissed/i)
84
+ })
85
+
86
+ // Moved from packages/app/e2e/regression/session-timeline-tool-projection.spec.ts
87
+ story("labels all web search provider variants", async ({ mount }) => {
88
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "providers" } })
89
+ await timeline.getByRole("button", { name: "Used 3 Parallel Web Search, Exa Web Search, Web Search" }).click()
90
+ const tools = timeline.locator('[data-component="context-tool-group-list"]')
91
+ await expect(tools.getByRole("button", { name: /Parallel Web Search/ })).toBeVisible()
92
+ await expect(tools.getByRole("button", { name: /Exa Web Search/ })).toBeVisible()
93
+ await expect(tools.getByRole("button", { name: /^Web Search/ })).toBeVisible()
94
+ })
95
+
96
+ // Moved from packages/app/e2e/regression/session-timeline-tool-projection.spec.ts
97
+ story("labels completed searches with result counts", async ({ mount }) => {
98
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "results" } })
99
+ const group = timeline.locator('[data-timeline-part-ids="tool_label_glob,tool_label_grep,tool_label_read"]')
100
+ await group.locator('[data-slot="collapsible-trigger"]').click()
101
+ const rows = group.locator('[data-component="context-tool-group-list"] [data-component="tool-trigger"]')
102
+ await expect(rows.filter({ hasText: "Glob" })).toContainText("(1 match)")
103
+ await expect(rows.filter({ hasText: "Grep" })).toContainText("(12 matches)")
104
+ })
105
+
106
+ // Moved from packages/app/e2e/regression/session-timeline-tool-projection.spec.ts
107
+ story("labels read tools from their path input", async ({ mount }) => {
108
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "read" } })
109
+ const group = timeline.locator('[data-timeline-part-ids="prt_read_path"]')
110
+ await group.locator('[data-slot="collapsible-trigger"]').click()
111
+ await expect(
112
+ group
113
+ .locator('[data-component="context-tool-group-list"] [data-component="tool-trigger"]')
114
+ .filter({ hasText: "Read" }),
115
+ ).toContainText("a.ts")
116
+ })
117
+
118
+ // Moved from packages/app/e2e/regression/session-timeline-tool-projection.spec.ts
119
+ story("labels skill tools from IDs and result metadata", async ({ mount }) => {
120
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "skills" } })
121
+ const group = timeline.locator('[data-timeline-part-ids="tool_skill_id,tool_skill_name"]')
122
+ await expect(group.getByRole("button")).toHaveAccessibleName("Used 2 Skill")
123
+ await expect(group.locator('[data-component="context-tool-group-trigger"]')).toHaveAttribute(
124
+ "aria-label",
125
+ "Used 2 Skill",
126
+ )
127
+ await group.getByRole("button").click()
128
+ const loaded = group.locator('[data-component="tool-loaded-item"]')
129
+ await expect(loaded).toHaveCount(1)
130
+ await expect(loaded).toHaveAttribute("aria-label", "Loaded frontend-design, OpenCode skills")
131
+ await expect(loaded).toHaveCSS("line-height", "16px")
132
+ await expect(loaded.locator('[data-slot="tool-loaded-label"]')).toHaveText("Loaded")
133
+ await expect(loaded.locator('[data-slot="tool-loaded-kind"]')).toHaveText("skills")
134
+ const names = loaded.locator('[data-component="text-shimmer"]')
135
+ await expect(names).toHaveCount(2)
136
+ await expect(names.nth(0)).toHaveAttribute("aria-label", "frontend-design")
137
+ await expect(names.nth(1)).toHaveAttribute("aria-label", "OpenCode")
138
+ })
139
+
140
+ // Moved from packages/app/e2e/regression/session-timeline-reducer-projection.spec.ts
141
+ story("groups every collapsed tool until visible text separates the stack", async ({ mount }) => {
142
+ const timeline = await mount("current-session-research-agents--agent-research", { args: { scenario: "steps" } })
143
+ await expect(timeline.locator('[data-timeline-part-ids="tool_boundary_read"]')).toBeVisible()
144
+
145
+ const group = timeline.locator(
146
+ '[data-timeline-part-ids="tool_boundary_glob,tool_boundary_grep,tool_boundary_shell,tool_boundary_list"]',
147
+ )
148
+
149
+ await expect(group).toBeVisible()
150
+ await expect(group.getByRole("button")).toHaveAccessibleName("Used 4 Glob, Grep, Shell, List")
151
+ await expect(group.locator('[data-component="context-tool-group-trigger"]')).toHaveAttribute(
152
+ "aria-label",
153
+ "Used 4 Glob, Grep, Shell, List",
154
+ )
155
+ await expect(timeline.locator('[data-timeline-row="AssistantPart"]')).toHaveCount(3)
156
+ await expect(timeline.locator('[data-timeline-spacing="content"]')).toHaveCount(2)
157
+ await expect(timeline.locator('[data-timeline-spacing="content"]').nth(0)).toHaveCSS("padding-top", "16px")
158
+ })
159
+
160
+ // Moved from packages/app/e2e/regression/session-timeline-projection.spec.ts
161
+ story("combines adjacent edit calls and repeated files into one group", async ({ mount }) => {
162
+ const timeline = await mount("current-session-file-changes--changing-files", { args: { scenario: "repeated" } })
163
+ const group = timeline.locator('[data-timeline-part-ids="tool_grouped_edit_first,tool_grouped_edit_second"]')
164
+ await expect(group.locator('[data-slot="apply-patch-filename"]')).toHaveText(["first.ts"])
165
+ await expect(group.locator('[data-scope="apply-patch"] button')).toContainText("+2")
166
+ await expect(group.locator('[data-scope="apply-patch"] button')).toHaveAttribute("aria-expanded", "true")
167
+ })
168
+
169
+ story("opens an execution's code and output from its View code action", async ({ mount }) => {
170
+ const timeline = await mount("current-session-terminal-work--execute-code")
171
+ await timeline.getByRole("button", { name: "View code" }).first().click()
172
+ const dialog = timeline.page().getByRole("dialog")
173
+ await expect(dialog.getByRole("heading", { name: "Execute" })).toBeVisible()
174
+ await expect(dialog).toContainText("Completed")
175
+ await expect(dialog).toContainText('const tab = await tools.browser.tabs.open({ url: "http://localhost:4399" })')
176
+ await expect(dialog).toContainText('"tab": "tab_4f1c"')
177
+ await expect(dialog.getByRole("button", { name: "Copy code" })).toBeVisible()
178
+ await expect(dialog.getByRole("button", { name: "Copy output" })).toBeVisible()
179
+ })
180
+
181
+ story("wraps execute details code, pads it evenly, and starts line numbers near the block edge", async ({ mount }) => {
182
+ const timeline = await mount("current-session-terminal-work--execute-code")
183
+ const tool = timeline.locator('[data-timeline-part-id="tool_execute_long_call"]')
184
+ await tool.hover()
185
+ await tool.getByRole("button", { name: "View code" }).click()
186
+ const source = timeline.page().getByRole("dialog").locator('[data-slot="execute-details-source"]').first()
187
+ await expect(source.locator("[data-column-number]").first()).toBeVisible()
188
+
189
+ const layout = await source.evaluate((element) => {
190
+ const root = element.querySelector("diffs-container")!.shadowRoot!
191
+ const code = root.querySelector<HTMLElement>("[data-code]")!
192
+ const number = root.querySelector("[data-line-number-content]")!
193
+ const lines = [...root.querySelectorAll("[data-line]")].map((line) => line.getBoundingClientRect())
194
+ const box = element.getBoundingClientRect()
195
+
196
+ return {
197
+ paddingTop: lines[0].top - box.top,
198
+ paddingBottom: box.bottom - lines.at(-1)!.bottom,
199
+ // A horizontally scrolling block reserves a scrollbar track under a single line.
200
+ overflow: code.scrollWidth - code.clientWidth,
201
+ numberStart: number.getBoundingClientRect().left - box.left,
202
+ }
203
+ })
204
+
205
+ expect(layout.overflow).toBe(0)
206
+ expect(layout.numberStart).toBe(12)
207
+ expect(layout.paddingTop).toBe(4)
208
+ expect(layout.paddingBottom).toBe(4)
209
+ })
210
+
211
+ story("reveals the View code action while hovering anywhere over the execution", async ({ mount }) => {
212
+ const timeline = await mount("current-session-terminal-work--execute-code")
213
+ const tool = timeline.locator('[data-timeline-part-id="tool_execute_long_call"]')
214
+ const action = tool.locator('[data-slot="basic-tool-action"]')
215
+ await timeline.page().mouse.move(0, 0)
216
+ await expect(action).toHaveCSS("opacity", "0")
217
+
218
+ // The calls sit below the header, so hovering them proves the whole tool reveals the action.
219
+ await tool.locator('[data-slot="execute-tool-call"]').first().hover()
220
+ await expect(action).toHaveCSS("opacity", "1")
221
+
222
+ await timeline.page().mouse.move(0, 0)
223
+ await expect(action).toHaveCSS("opacity", "0")
224
+ })
225
+
226
+ story("keeps long execute calls inside the tool and shows the script output", async ({ mount }) => {
227
+ const timeline = await mount("current-session-terminal-work--execute-code")
228
+ const tool = timeline.locator('[data-timeline-part-id="tool_execute_long_call"]')
229
+ const calls = tool.locator('[data-component="execute-tool-calls"]')
230
+ const rows = calls.locator('[data-slot="execute-tool-call"]')
231
+ await expect(rows).toHaveText([/mesh\.exec/, /Output\s*3 lines/])
232
+
233
+ // The script output stays collapsed until its row is expanded.
234
+ const result = calls.locator('[data-slot="bash-result"]')
235
+ await expect(result).toHaveCount(0)
236
+ const top = await rows.first().evaluate((element) => element.getBoundingClientRect().top)
237
+ await rows.nth(1).click()
238
+ await expect(rows.nth(1)).toHaveAttribute("aria-expanded", "true")
239
+ await expect(result).toContainText("Cleanup finished on blade")
240
+ // Opening the output must not move the rows above it.
241
+ expect(await rows.first().evaluate((element) => element.getBoundingClientRect().top)).toBe(top)
242
+
243
+ const overflow = await tool.evaluate((element) => {
244
+ const calls = element.querySelector('[data-component="execute-tool-calls"]')
245
+
246
+ if (!calls) return Number.NaN
247
+
248
+ return calls.getBoundingClientRect().right - element.getBoundingClientRect().right
249
+ })
250
+
251
+ expect(overflow).toBeLessThanOrEqual(0)
252
+ })
253
+
254
+ story("lists a long script's latest calls and reveals earlier ones on request", async ({ mount }) => {
255
+ const timeline = await mount("current-session-terminal-work--execute-many-calls")
256
+ const tool = timeline.locator('[data-timeline-part-id="tool_execute_many_calls"]')
257
+ const rows = tool.locator('[data-slot="execute-tool-call"]:not([data-kind="output"])')
258
+ await expect(rows).toHaveCount(10)
259
+ await expect(rows.first()).toContainText("module-65.ts")
260
+
261
+ await tool.getByRole("button", { name: "+65 more" }).click()
262
+ await expect(rows).toHaveCount(60)
263
+
264
+ // The last reveal removes the button, so focus moves on to the first call instead of the page.
265
+ await tool.getByRole("button", { name: "+15 more" }).press("Enter")
266
+ await expect(rows).toHaveCount(75)
267
+ await expect(rows.first()).toContainText("module-0.ts")
268
+ await expect(rows.first()).toBeFocused()
269
+ })
270
+
271
+ story("opens execute rows while a text field elsewhere keeps its selection", async ({ mount }) => {
272
+ const timeline = await mount("current-session-terminal-work--execute-code")
273
+ const rows = timeline.locator('[data-timeline-part-id="tool_execute_long_call"] [data-slot="execute-tool-call"]')
274
+
275
+ // As in the app: its shell makes the rows non-selectable, so a press on one clears no selection, and a field such
276
+ // as the browser's address keeps the text it selected after focus leaves it.
277
+ await timeline.evaluate((root) => {
278
+ const field = document.createElement("input")
279
+ field.setAttribute("aria-label", "Address")
280
+ field.value = "https://alpha.example/"
281
+ field.style.userSelect = "text"
282
+ root.style.userSelect = "none"
283
+ root.prepend(field)
284
+ })
285
+ await timeline.getByRole("textbox", { name: "Address" }).selectText()
286
+
287
+ await rows.nth(1).click()
288
+ await expect(rows.nth(1)).toHaveAttribute("aria-expanded", "true")
289
+ await rows.first().click()
290
+ await expect(rows.first()).toHaveAttribute("aria-expanded", "true")
291
+ // The rows opened under the field's selection, not because a press cleared it.
292
+ expect(await timeline.evaluate(() => window.getSelection()?.toString())).toBe("https://alpha.example/")
293
+ })
294
+
295
+ story("keeps an execute row closed when the press selects its text", async ({ mount }) => {
296
+ const timeline = await mount("current-session-terminal-work--execute-code")
297
+ const row = timeline.locator('[data-timeline-part-id="tool_execute_long_call"] [data-slot="execute-tool-call"]').first()
298
+ const name = await row.locator('[data-slot="execute-tool-call-name"]').boundingBox()
299
+
300
+ if (!name) throw new Error("The execute call has no name to select")
301
+ const page = timeline.page()
302
+ await page.mouse.move(name.x + 1, name.y + name.height / 2)
303
+ await page.mouse.down()
304
+ await page.mouse.move(name.x + name.width - 1, name.y + name.height / 2, { steps: 4 })
305
+ await page.mouse.up()
306
+
307
+ expect(await timeline.evaluate(() => window.getSelection()?.toString())).not.toBe("")
308
+ await expect(row).toHaveAttribute("aria-expanded", "false")
309
+ })
310
+
311
+ story("shows a failed execution's error in place of its output", async ({ mount }) => {
312
+ const timeline = await mount("current-session-terminal-work--execute-failed")
313
+ await timeline.getByRole("button", { name: /^Used 5 / }).click()
314
+ await timeline
315
+ .locator('[data-timeline-part-id="tool_execute_failed_url"]')
316
+ .getByRole("button", { name: "View code" })
317
+ .click()
318
+ const dialog = timeline.page().getByRole("dialog")
319
+ await expect(dialog).toContainText("Failed")
320
+ await expect(dialog).toContainText("Invalid browser URL.")
321
+ await expect(dialog.getByRole("button", { name: "Copy error" })).toBeVisible()
322
+ await expect(dialog.getByRole("button", { name: "Copy output" })).toHaveCount(0)
323
+ })
@@ -0,0 +1,26 @@
1
+ import { createSignal } from "solid-js"
2
+ import { render } from "solid-js/web"
3
+ import { TextShimmer } from "@zyro-sec/ui/text-shimmer"
4
+ import { Typewriter } from "@zyro-sec/ui/typewriter"
5
+
6
+ export function mountTextLifecycle() {
7
+ const host = document.createElement("div")
8
+ host.dataset.testid = "text-lifecycle-fixture"
9
+ document.body.appendChild(host)
10
+ const [text, setText] = createSignal<string | undefined>(undefined)
11
+ const [active, setActive] = createSignal(true)
12
+
13
+ render(
14
+ () => (
15
+ <>
16
+ <Typewriter text={text()} as="p" />
17
+ <TextShimmer text="Exploring" active={active()} />
18
+ </>
19
+ ),
20
+ host,
21
+ )
22
+
23
+ const run = () => host.querySelector('[data-slot="text-shimmer-char-shimmer"]')!.getAttribute("data-run")
24
+
25
+ return { setText, setActive, run }
26
+ }
@@ -0,0 +1,42 @@
1
+ import { expect, sourceURL, story } from "../../stories/playwright/story"
2
+
3
+ const fixture = sourceURL(new URL("./text-lifecycle.fixture.tsx", import.meta.url))
4
+
5
+ story("the typewriter shows no cursor without text and clears when its text is cleared", async ({ mount, page }) => {
6
+ await mount("ui-text-shimmer--inactive")
7
+
8
+ const controls = await page.evaluateHandle(async (fixture) => {
9
+ const { mountTextLifecycle } = await import(fixture)
10
+
11
+ return mountTextLifecycle()
12
+ }, fixture)
13
+
14
+ const typewriter = page.getByTestId("text-lifecycle-fixture").locator("p")
15
+
16
+ // Before the machine, an empty typewriter showed a blinking cursor forever.
17
+ await expect(typewriter).toHaveText("")
18
+
19
+ await controls.evaluate((text) => text.setText("Hello world"))
20
+ await expect(typewriter).toHaveText(/^Hel.*│$/)
21
+ await controls.evaluate((text) => text.setText(""))
22
+
23
+ // Before the machine, the partial text and a solid cursor stayed on screen forever.
24
+ await expect(typewriter).toHaveText("")
25
+ })
26
+
27
+ story("a shimmer stops its sweep at once under reduced motion", async ({ mount, page }) => {
28
+ await mount("ui-text-shimmer--inactive")
29
+
30
+ const runs = await page.evaluate(async (fixture) => {
31
+ const { mountTextLifecycle } = await import(fixture)
32
+ const shimmer = mountTextLifecycle()
33
+ const active = shimmer.run()
34
+ document.documentElement.setAttribute("data-motion", "reduce")
35
+ shimmer.setActive(false)
36
+
37
+ return [active, shimmer.run()]
38
+ }, fixture)
39
+
40
+ // Before the machine, the sweep kept running for the 220 ms crossfade that reduced motion turns off.
41
+ expect(runs).toEqual(["true", "false"])
42
+ })
@@ -0,0 +1,33 @@
1
+ import { expect, story } from "../../stories/playwright/story"
2
+
3
+ const playground = "timeline-playground--playground"
4
+
5
+ story("a subagent row leads with its status", async ({ mount }) => {
6
+ const timeline = await mount(playground, { args: { scenario: "Background work", activity: true } })
7
+ const rows = timeline.locator('[data-component="timeline-subagent"] > [data-slot="timeline-event-item"]')
8
+
9
+ await expect(rows.locator('[data-slot="timeline-event-item-status"]')).toHaveText([
10
+ "Started",
11
+ "Started",
12
+ "Updated",
13
+ "Completed",
14
+ "Failed",
15
+ "Started",
16
+ "Started",
17
+ "Completed",
18
+ "Stopped",
19
+ ])
20
+ // Agent names are capitalized by CSS, so their text is as configured.
21
+ await expect(rows.nth(3).locator("> *")).toHaveText(["Completed", "review Agent", "Review the theme store"])
22
+ })
23
+
24
+ // The timeline is a list of events: a start stays a plain status even while its subagent has not reported back.
25
+ story("a started subagent never spins", async ({ mount }) => {
26
+ const timeline = await mount(playground, { args: { scenario: "Subagent between tools", activity: true } })
27
+ const status = timeline.locator('[data-component="timeline-subagent"] [data-slot="timeline-event-item-status"]')
28
+
29
+ await expect(status).toHaveText("Started")
30
+ await expect(status).toHaveAttribute("data-state", "started")
31
+ await expect(status.locator("svg")).toHaveCount(0)
32
+ await expect(status.locator('[data-component="session-progress-indicator-v2"]')).toHaveCount(0)
33
+ })
@@ -0,0 +1,48 @@
1
+ import { expect, story } from "../../stories/playwright/story"
2
+
3
+ for (const open of [true, false]) {
4
+ story(`preserves ${open ? "expanded" : "collapsed"} tool choices when calls join the group`, async ({ mount }) => {
5
+ const root = await mount("current-session-file-changes--appending-tool-calls")
6
+ const group = root.locator('[data-component="collapsed-tool-group"]')
7
+ const trigger = group.getByRole("button", { name: /^Used \d+ Shell, Patch$/ })
8
+ await expect(trigger).toHaveAccessibleName("Used 2 Shell, Patch")
9
+ await trigger.click()
10
+ const shell = group.locator('[data-timeline-part-id="tool_shell_existing"] [data-slot="collapsible-trigger"]')
11
+ await group.locator('[data-timeline-part-id="tool_patch_existing"]').evaluate((element) => {
12
+ element.setAttribute("data-disclosure-probe", "existing")
13
+ })
14
+ const patch = group.locator('[data-disclosure-probe="existing"]')
15
+ const first = patch.locator('[data-scope="apply-patch"] button').filter({ hasText: "a.ts" })
16
+ const second = patch.locator('[data-scope="apply-patch"] button').filter({ hasText: "b.ts" })
17
+ const diff = patch.locator('[data-type="update"]').filter({ hasText: "b.ts" }).locator('[data-component="file"]')
18
+ await shell.click()
19
+ await first.click()
20
+ await second.click()
21
+
22
+ if (!open) {
23
+ await shell.click()
24
+ await first.click()
25
+ }
26
+
27
+ await expect(shell).toHaveAttribute("aria-expanded", String(open))
28
+ await expect(first).toHaveAttribute("aria-expanded", String(open))
29
+ await expect(second).toHaveAttribute("aria-expanded", "true")
30
+ await expect(diff).toBeVisible()
31
+ const original = await patch.elementHandle()
32
+
33
+ for (const count of [3, 4]) {
34
+ await root.getByRole("button", { name: "Append tool call", exact: true }).click()
35
+ await expect(group.locator('[data-component="context-tool-group-trigger"]')).toHaveAttribute(
36
+ "aria-label",
37
+ `Used ${count} Shell, Patch`,
38
+ )
39
+ await expect(trigger).toHaveAccessibleName(`Used ${count} Shell, Patch`)
40
+ await expect(diff).toBeVisible()
41
+ await expect(shell).toHaveAttribute("aria-expanded", String(open))
42
+ await expect(first).toHaveAttribute("aria-expanded", String(open))
43
+ await expect(second).toHaveAttribute("aria-expanded", "true")
44
+ expect(await original!.evaluate((node) => node.isConnected)).toBe(true)
45
+ await expect(trigger).toHaveAttribute("aria-expanded", "true")
46
+ }
47
+ })
48
+ }