@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,254 @@
1
+ import { expect, story } from "../../stories/playwright/story"
2
+
3
+ const rows = "current-session-timeline-rows"
4
+
5
+ story("shows a running automatic compaction as one Compacting divider", async ({ mount }) => {
6
+ const timeline = await mount(`${rows}--compaction-in-progress`)
7
+ const message = timeline.locator('[data-component="session-compaction-message"]')
8
+ const divider = message.locator('[data-slot="session-compaction-divider"]')
9
+
10
+ await expect(message).toHaveAttribute("data-quiet", "")
11
+ // Already running when the history loads, so it shows at once rather than waiting out the grace.
12
+ await expect(message).not.toHaveAttribute("data-enter")
13
+ await expect(divider).toHaveAttribute("data-state", "running")
14
+ await expect(divider).toBeDisabled()
15
+ await expect(divider).toHaveAttribute("aria-busy", "true")
16
+ await expect(divider).toHaveAccessibleName("Compacting")
17
+ await expect(divider).not.toHaveAttribute("aria-expanded")
18
+ await expect(message.locator('[data-slot="session-compaction-running"]')).toHaveCSS("opacity", "1")
19
+ await expect(message).not.toContainText("Session compaction started")
20
+ await expect(message).not.toContainText("Restore compaction output")
21
+ await expect(message.locator('[data-component="text-part"]')).toHaveCount(0)
22
+ })
23
+
24
+ story("opens a finished automatic compaction's summary from its divider", async ({ mount, page }) => {
25
+ const timeline = await mount(`${rows}--compaction-and-continuation`)
26
+ const message = timeline.locator('[data-component="session-compaction-message"]')
27
+ const divider = message.locator('[data-slot="session-compaction-divider"]')
28
+ const summary = message.locator('[data-slot="session-compaction-summary"]')
29
+
30
+ // The stem Compacting and Compacted share, then the ending that differs.
31
+ const colors = () =>
32
+ message.locator('[data-slot="session-compaction-label"]').evaluate((label) =>
33
+ [label.firstElementChild, label.querySelector('[data-slot="session-compaction-done"]')].map((part) => {
34
+ if (!part) throw new Error("Expected the label's stem and ending")
35
+
36
+ return getComputedStyle(part).color
37
+ }),
38
+ )
39
+
40
+ // Loaded with the history, so it is already there rather than fading in.
41
+ await expect(message).not.toHaveAttribute("data-enter")
42
+ await expect(divider).toHaveAttribute("data-state", "done")
43
+ await expect(message.locator('[data-slot="session-compaction-done"]')).toHaveCSS("opacity", "1")
44
+ await expect(divider).toHaveAccessibleName("Compacted")
45
+ await expect(divider).toHaveAttribute("aria-expanded", "false")
46
+ await expect(divider).not.toHaveAttribute("aria-controls")
47
+ await expect(summary).toHaveCount(0)
48
+ const [rest] = await colors()
49
+
50
+ // Hovering lights the whole word, not only the ending.
51
+ await divider.hover()
52
+ await expect.poll(async () => (await colors())[0]).not.toBe(rest)
53
+ await expect.poll(async () => new Set(await colors()).size).toBe(1)
54
+
55
+ await divider.click()
56
+ await expect(divider).toHaveAttribute("aria-expanded", "true")
57
+ await expect(summary).toContainText("The Session timeline now consumes current nested assistant content.")
58
+ await expect(summary).toContainText("11.9K in · 508 out")
59
+ await expect(divider).toHaveAttribute("aria-controls", (await summary.getAttribute("id")) ?? "")
60
+ // An open divider keeps the whole word lit once the pointer leaves.
61
+ await page.mouse.move(0, 0)
62
+ await expect.poll(async () => (await colors())[0]).not.toBe(rest)
63
+ await expect.poll(async () => new Set(await colors()).size).toBe(1)
64
+
65
+ await divider.click()
66
+ await expect(divider).toHaveAttribute("aria-expanded", "false")
67
+ await expect(divider).not.toHaveAttribute("aria-controls")
68
+ await expect(summary).toHaveCount(0)
69
+ })
70
+
71
+ story("fades in an instant automatic compaction as Compacted", async ({ mount }) => {
72
+ const timeline = await mount(`${rows}--compaction-replay`, { args: { run: "instant" } })
73
+ const message = timeline.locator('[data-component="session-compaction-message"]')
74
+ const divider = message.locator('[data-slot="session-compaction-divider"]')
75
+
76
+ await expect(message).toHaveAttribute("data-enter", "now")
77
+ await expect(divider).toHaveAttribute("data-state", "done")
78
+ await expect(divider).toHaveCSS("animation-name", "session-compaction-enter")
79
+ await expect(divider).toHaveAccessibleName("Compacted")
80
+ await expect(message.locator('[data-slot="session-compaction-light"]').first()).toBeHidden()
81
+ })
82
+
83
+ story("fades in a compaction that ends inside the grace as Compacted only", async ({ mount, page }) => {
84
+ await mount(`${rows}--compaction-replay`, { args: { run: "quick" } })
85
+
86
+ // Sample the frame after it finishes: Compacting must already be gone rather than crossfading under Compacted.
87
+ const ended = await page.evaluate(
88
+ () =>
89
+ new Promise<{ enter: string | null; animation: string; running: string; done: string }>((resolve) => {
90
+ const sample = () => {
91
+ const message = document.querySelector('[data-component="session-compaction-message"]')
92
+ const divider = message?.querySelector('[data-slot="session-compaction-divider"]')
93
+
94
+ if (!message || !divider || divider.getAttribute("data-state") !== "done")
95
+ return requestAnimationFrame(sample)
96
+
97
+ requestAnimationFrame(() =>
98
+ resolve({
99
+ enter: message.getAttribute("data-enter"),
100
+ animation: getComputedStyle(divider).animationName,
101
+ running: getComputedStyle(message.querySelector('[data-slot="session-compaction-running"]')!).opacity,
102
+ done: getComputedStyle(message.querySelector('[data-slot="session-compaction-done"]')!).opacity,
103
+ }),
104
+ )
105
+ }
106
+
107
+ sample()
108
+ }),
109
+ )
110
+
111
+ expect(ended).toEqual({ enter: "now", animation: "session-compaction-enter", running: "0", done: "1" })
112
+ })
113
+
114
+ story("warms the label only once the gathering light reaches it", async ({ mount }) => {
115
+ const timeline = await mount(`${rows}--compaction-in-progress`)
116
+ const message = timeline.locator('[data-component="session-compaction-message"]')
117
+
118
+ // Hold the divider's animations at a point in their 3.2 s cycle and read the light and the label's glint there.
119
+ const at = (progress: number) =>
120
+ message.evaluate((root, progress) => {
121
+ root.ownerDocument
122
+ .getAnimations()
123
+ .filter(
124
+ (animation) => animation instanceof CSSAnimation && animation.animationName.startsWith("session-compaction-"),
125
+ )
126
+ .forEach((animation) => {
127
+ animation.pause()
128
+ animation.currentTime = progress * 3_200
129
+ })
130
+
131
+ const light = root.querySelector('[data-slot="session-compaction-light"]')
132
+ const glint = root.querySelector('[data-slot="session-compaction-glint"]')
133
+
134
+ if (!light || !glint) throw new Error("Expected the light and the glint")
135
+
136
+ return [getComputedStyle(light, "::after").opacity, getComputedStyle(glint).opacity].map(Number)
137
+ }, progress)
138
+
139
+ const [travelling, arriving, landed, cooled] = await Promise.all(
140
+ [0.3, 0.48, 0.57, 0.9].map((progress) => at(progress)),
141
+ )
142
+
143
+ expect(travelling).toEqual([1, 0])
144
+ expect(arriving).toEqual([1, 0])
145
+ expect(landed[0]).toBeLessThan(1)
146
+ expect(landed[1]).toBeCloseTo(0.75, 2)
147
+ expect(cooled).toEqual([0, 0])
148
+ })
149
+
150
+ story("splits a translated label between whole characters", async ({ mount }) => {
151
+ // Bengali's two words part at a vowel sign, which draws a dotted circle when it is cut from its consonant.
152
+ const timeline = await mount(`${rows}--compaction-and-continuation`, { globals: { locale: "bn" } })
153
+ const message = timeline.locator('[data-component="session-compaction-message"]')
154
+
155
+ await expect(message.locator('[data-slot="session-compaction-divider"]')).toHaveAccessibleName("সংকুচিত হয়েছে")
156
+ await expect(message.locator('[data-slot="session-compaction-done"]')).toHaveText(/^\P{M}/u)
157
+ })
158
+
159
+ story("keeps the space where a translated label splits", async ({ mount, page }) => {
160
+ // Hindi's two phrases part after a space, which a label split into boxes drops unless it keeps its white space.
161
+ const timeline = await mount(`${rows}--compaction-and-continuation`, { globals: { locale: "hi" } })
162
+ const label = timeline.locator('[data-slot="session-compaction-label"]')
163
+ await expect(timeline.locator('[data-slot="session-compaction-divider"]')).toHaveAccessibleName("संक्षिप्त किया गया")
164
+ await page.evaluate(() => document.fonts.ready.then(() => undefined))
165
+
166
+ // The label's two parts against the same phrase set as one run of text beside it.
167
+ const [split, whole] = await label.evaluate((element) => {
168
+ const stem = element.firstElementChild
169
+ const ending = element.querySelector('[data-slot="session-compaction-done"]')
170
+ const copy = element.cloneNode(false)
171
+
172
+ if (!stem || !ending || !(copy instanceof HTMLElement)) throw new Error("Expected the label's stem and ending")
173
+ copy.textContent = element.closest("button")?.getAttribute("aria-label") ?? ""
174
+ element.after(copy)
175
+
176
+ const widths = [
177
+ stem.getBoundingClientRect().width + ending.getBoundingClientRect().width,
178
+ copy.getBoundingClientRect().width,
179
+ ]
180
+
181
+ copy.remove()
182
+
183
+ return widths
184
+ })
185
+
186
+ expect(whole).toBeGreaterThan(0)
187
+ expect(Math.abs(split - whole)).toBeLessThan(1)
188
+ })
189
+
190
+ story("keeps the full record for a manual compaction", async ({ mount }) => {
191
+ const timeline = await mount(`${rows}--compaction-manual`)
192
+ const message = timeline.locator('[data-component="session-compaction-message"]')
193
+
194
+ await expect(message).not.toHaveAttribute("data-quiet")
195
+ await expect(message).toContainText("Session compaction started")
196
+ await expect(message).toContainText("The Session timeline now consumes current nested assistant content.")
197
+ await expect(message).toContainText("Session compacted · 11.9K in · 508 out")
198
+ })
199
+
200
+ story("keeps the full record for a failed automatic compaction", async ({ mount }) => {
201
+ const timeline = await mount(`${rows}--compaction-failed`)
202
+ const message = timeline.locator('[data-component="session-compaction-message"]')
203
+
204
+ await expect(message).not.toHaveAttribute("data-quiet")
205
+ await expect(message).toContainText("Session compaction started")
206
+ await expect(message).toContainText("Session compaction failed")
207
+ await expect(message.locator('[data-component="card"]')).toContainText(
208
+ "The provider rejected the compaction request.",
209
+ )
210
+ })
211
+
212
+ story("keeps the divider's box while an automatic compaction runs and finishes", async ({ mount, page }) => {
213
+ const timeline = await mount(`${rows}--conversation`, { args: { scenario: "compaction" } })
214
+ const message = timeline.locator('[data-component="session-compaction-message"]')
215
+ const label = message.locator('[data-slot="session-compaction-label"]')
216
+ const stem = label.locator("span").first()
217
+
218
+ // The story's turn above gains its footer when the Session goes idle, so measure the divider against itself.
219
+ const box = async () => {
220
+ const [outer, text, start] = await Promise.all([message.boundingBox(), label.boundingBox(), stem.boundingBox()])
221
+
222
+ if (!outer || !text || !start) throw new Error("Expected the compaction divider to be laid out")
223
+
224
+ return {
225
+ width: outer.width,
226
+ height: outer.height,
227
+ label: [text.x - outer.x, text.y - outer.y, text.width],
228
+ stem: [start.x - outer.x, start.width],
229
+ }
230
+ }
231
+
232
+ await expect(message.locator('[data-slot="session-compaction-divider"]')).toHaveAttribute("data-state", "running")
233
+ const running = await box()
234
+
235
+ await page.getByRole("button", { name: "Stream summary" }).click()
236
+ await expect(message).not.toContainText("Streamed implementation details.")
237
+ expect(await box()).toEqual(running)
238
+
239
+ await page.getByRole("button", { name: "Complete summary" }).click()
240
+ await expect(message.locator('[data-slot="session-compaction-divider"]')).toHaveAttribute("data-state", "done")
241
+ expect(await box()).toEqual(running)
242
+ })
243
+
244
+ story("holds the lines still under reduced motion", async ({ mount, page }) => {
245
+ await page.emulateMedia({ reducedMotion: "reduce" })
246
+ const timeline = await mount(`${rows}--compaction-in-progress`)
247
+ const message = timeline.locator('[data-component="session-compaction-message"]')
248
+ const line = message.locator('[data-slot="session-compaction-line"]').first()
249
+
250
+ await expect(message.locator('[data-slot="session-compaction-light"]').first()).toBeHidden()
251
+ await expect(message.locator('[data-slot="session-compaction-glint"]')).toBeHidden()
252
+ await expect.poll(() => line.evaluate((element) => getComputedStyle(element, "::before").opacity)).toBe("1")
253
+ await expect(message.locator('[data-slot="session-compaction-running"]')).toHaveCSS("opacity", "1")
254
+ })
@@ -0,0 +1,190 @@
1
+ import { expect, story } from "../../stories/playwright/story"
2
+
3
+ for (const [tool, title] of [
4
+ ["shell", "Shell"],
5
+ ["execute", "Execute"],
6
+ ["subagent", "Agent"],
7
+ ]) {
8
+ for (const open of [false, true]) {
9
+ story(`keeps ${tool} inside an existing ${open ? "open" : "closed"} group through execution`, async ({ mount }) => {
10
+ const timeline = await mount("current-session-terminal-work--terminal-commands", {
11
+ args: { existingGroup: true, tool },
12
+ })
13
+
14
+ const group = timeline.locator('[data-component="collapsed-tool-group"]')
15
+ const trigger = group.locator(':scope > [data-component="collapsible"] > [data-slot="collapsible-trigger"]')
16
+ await expect(group).toHaveAttribute("data-timeline-part-ids", "tool_context_lifecycle")
17
+
18
+ if (open) await trigger.click()
19
+ await expect(trigger).toHaveAttribute("aria-expanded", String(open))
20
+ await timeline.getByRole("button", { name: "Start tool", exact: true }).click()
21
+ await expect(group).toHaveAttribute("data-timeline-part-ids", "tool_context_lifecycle,tool_shell_lifecycle")
22
+ const original = await group.elementHandle()
23
+
24
+ for (const action of [undefined, "Complete input", "Run command", "Complete command"]) {
25
+ if (action) await timeline.getByRole("button", { name: action, exact: true }).click()
26
+ await expect(group).toHaveAttribute("data-timeline-part-ids", "tool_context_lifecycle,tool_shell_lifecycle")
27
+ await expect(group.locator('[data-component="context-tool-group-trigger"]')).toHaveAttribute(
28
+ "aria-label",
29
+ `Used 2 Read, ${title}`,
30
+ )
31
+ await expect(timeline.locator('[data-timeline-row="AssistantPart"]')).toHaveCount(1)
32
+ await expect(trigger).toHaveAttribute("aria-expanded", String(open))
33
+ expect(await original!.evaluate((node) => node.isConnected)).toBe(true)
34
+
35
+ if (open) await expect(group.locator('[data-timeline-part-id="tool_shell_lifecycle"]')).toBeVisible()
36
+ }
37
+ })
38
+ }
39
+ }
40
+
41
+ for (const expanded of [false, true]) {
42
+ // Moved from packages/app/e2e/regression/session-timeline-lifecycle-state.spec.ts
43
+ story(`preserves shell user intent from a ${expanded ? "expanded" : "collapsed"} default`, async ({ mount }) => {
44
+ const timeline = await mount("current-session-terminal-work--terminal-commands", { args: { expanded } })
45
+
46
+ const trigger = expanded
47
+ ? timeline.locator('[data-timeline-part-id="tool_shell_lifecycle"] [data-slot="collapsible-trigger"]')
48
+ : timeline.getByRole("button", { name: "Used 1 Shell", exact: true })
49
+
50
+ await expect(trigger).toHaveAttribute("aria-expanded", String(expanded))
51
+ await trigger.click()
52
+ await expect(trigger).toHaveAttribute("aria-expanded", String(!expanded))
53
+ await timeline.getByRole("button", { name: "Update output" }).click()
54
+ await expect(trigger).toHaveAttribute("aria-expanded", String(!expanded))
55
+ await timeline.getByRole("button", { name: "Append sibling" }).click()
56
+ await expect(timeline.getByText("Sibling content", { exact: true })).toBeVisible()
57
+ await expect(trigger).toHaveAttribute("aria-expanded", String(!expanded))
58
+ await timeline.getByRole("button", { name: "Mark session busy" }).click()
59
+ await timeline.getByRole("button", { name: "Mark session idle" }).click()
60
+ await expect(trigger).toHaveAttribute("aria-expanded", String(!expanded))
61
+ })
62
+ }
63
+
64
+ // Moved from packages/app/e2e/regression/session-timeline-lifecycle-state.spec.ts
65
+ story("transitions a streaming shell from writing through command execution", async ({ mount }) => {
66
+ const timeline = await mount("current-session-terminal-work--terminal-commands", { args: { streaming: true } })
67
+ const tool = timeline.locator('[data-timeline-part-id="tool_shell_lifecycle"]')
68
+ const title = tool.locator('[data-slot="basic-tool-tool-title"]')
69
+ const shimmer = title.locator('[data-component="text-shimmer"]')
70
+ const subtitle = tool.locator('[data-slot="basic-tool-tool-subtitle"]')
71
+ await expect(shimmer).toHaveAttribute("aria-label", "Shell")
72
+ await expect(shimmer).toHaveAttribute("data-active", "true")
73
+ await expect(subtitle).toHaveText("Writing command…")
74
+ await expect(subtitle.locator('[data-component="text-shimmer"]')).toHaveCount(0)
75
+ await expect(tool.locator('[data-component="shell-submessage"]')).toHaveCount(0)
76
+ await expect(tool.locator('[data-slot="collapsible-trigger"]')).toHaveCSS("height", "28px")
77
+ await expect(tool.locator('[data-component="tool-trigger"]')).toHaveCSS("gap", "6px")
78
+ await expect(title).toHaveCSS("font-size", "13px")
79
+ await expect(title).toHaveCSS("font-family", /^Inter,/)
80
+ await expect(title).toHaveCSS("font-weight", "530")
81
+ await expect(title).toHaveCSS("line-height", "16px")
82
+ await expect(subtitle).toHaveCSS("font-size", "13px")
83
+ await expect(subtitle).toHaveCSS("font-family", /^Inter,/)
84
+ await expect(subtitle).toHaveCSS("font-weight", "440")
85
+ await expect(subtitle).toHaveCSS("line-height", "16px")
86
+ await timeline.getByRole("button", { name: "Complete input" }).click()
87
+ await expect(shimmer).toHaveAttribute("data-active", "true")
88
+ await expect(subtitle).toHaveText("printf ready")
89
+ await expect(tool).not.toContainText("Writing command…")
90
+ await timeline.getByRole("button", { name: "Run command" }).click()
91
+ await expect(shimmer).toHaveAttribute("data-active", "true")
92
+ await expect(subtitle).toHaveText("printf ready")
93
+ await expect(tool).not.toContainText("Writing command…")
94
+ await timeline.getByRole("button", { name: "Complete command" }).click()
95
+ const summary = timeline.getByRole("button", { name: "Used 1 Shell", exact: true })
96
+ await expect(summary).toHaveAttribute("aria-expanded", "false")
97
+ await summary.click()
98
+ await expect(subtitle).toHaveText("printf ready")
99
+ })
100
+
101
+ // Moved from packages/app/e2e/regression/session-timeline-lifecycle-state.spec.ts
102
+ story("shimmers and expands a running shell command", async ({ mount }) => {
103
+ const timeline = await mount("current-session-terminal-work--terminal-commands", { args: { streaming: true } })
104
+ await timeline.getByRole("button", { name: "Run command" }).click()
105
+ const tool = timeline.locator('[data-timeline-part-id="tool_shell_lifecycle"]')
106
+ const trigger = tool.locator('[data-slot="collapsible-trigger"]')
107
+ await expect(tool.locator('[data-component="text-shimmer"]')).toHaveAttribute("data-active", "true")
108
+ await expect(tool).not.toContainText("Writing command…")
109
+ await expect(tool.locator('[data-component="shell-submessage"]')).toHaveText("printf ready")
110
+ await expect(tool.locator('[data-component="shell-submessage"] [data-component="text-shimmer"]')).toHaveCount(0)
111
+ await expect(trigger).toHaveCSS("height", "28px")
112
+ await expect(trigger).toHaveAttribute("aria-expanded", "false")
113
+ await trigger.click()
114
+ await expect(trigger).toHaveAttribute("aria-expanded", "true")
115
+ await expect(tool.locator('[data-slot="bash-result"]')).toContainText("still running")
116
+ })
117
+
118
+ // Moved from packages/app/e2e/regression/session-timeline-lifecycle-state.spec.ts
119
+ for (const open of [false, true]) {
120
+ story(
121
+ `keeps ${open ? "expanded" : "collapsed"} reasoning intent from Thinking through standalone shell into Used`,
122
+ async ({ mount }) => {
123
+ const timeline = await mount("current-session-timeline-rows--conversation", { args: { scenario: "hidden" } })
124
+ const reasoning = timeline.locator('[data-timeline-part-id="msg_hidden_reasoning_lifecycle:reasoning:0"]')
125
+ await expect(timeline.locator('[data-timeline-row="Thinking"]')).toBeVisible()
126
+ await expect(timeline.getByText("Inspecting stability", { exact: true })).toBeVisible()
127
+ const thought = reasoning.locator('[data-slot="collapsible-trigger"]')
128
+ await expect(thought).toHaveAttribute("aria-expanded", "false")
129
+ await thought.click()
130
+ await expect(thought).toHaveAttribute("aria-expanded", "true")
131
+
132
+ if (!open) await thought.click()
133
+ await expect(thought).toHaveAttribute("aria-expanded", String(open))
134
+ await timeline.getByRole("button", { name: "Start shell" }).click()
135
+ const group = timeline.locator('[data-component="collapsed-tool-group"]')
136
+ await expect(timeline.locator('[data-timeline-part-id="tool_hidden_reasoning_shell"]')).toBeVisible()
137
+ await expect(group).toHaveCount(0)
138
+ await expect(timeline.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
139
+ await expect(thought).toContainText("Thought")
140
+ await expect(thought).not.toContainText("Inspecting stability")
141
+ await expect(thought).toHaveAttribute("aria-expanded", String(open))
142
+ await timeline.getByRole("button", { name: "Finish session" }).click()
143
+ const used = group.getByRole("button", { name: "Used 1 Shell", exact: true })
144
+ await expect(used).toHaveAttribute("aria-expanded", "false")
145
+ await used.click()
146
+ await expect(used).toHaveAttribute("aria-expanded", "true")
147
+ await expect(group.locator('[data-timeline-part-id="tool_hidden_reasoning_shell"]')).toBeVisible()
148
+ await expect(group.getByRole("button", { name: "Thought", exact: true })).toHaveAttribute(
149
+ "aria-expanded",
150
+ String(open),
151
+ )
152
+ await expect(group.locator('[data-component="context-tool-group-trigger"]')).toHaveAttribute(
153
+ "aria-label",
154
+ "Used 1 Shell",
155
+ )
156
+ await expect(timeline.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
157
+ await expect(used).toHaveAttribute("aria-expanded", "true")
158
+
159
+ if (!open) await thought.click()
160
+ await expect(reasoning.getByRole("heading", { name: "Inspecting stability", exact: true })).toBeVisible()
161
+ await used.click()
162
+ await expect(used).toHaveAttribute("aria-expanded", "false")
163
+ await used.click()
164
+ await expect(reasoning.getByRole("button", { name: "Thought", exact: true })).toHaveAttribute(
165
+ "aria-expanded",
166
+ "true",
167
+ )
168
+ await expect(reasoning.getByRole("heading", { name: "Inspecting stability", exact: true })).toBeVisible()
169
+ },
170
+ )
171
+ }
172
+
173
+ // Moved from packages/app/e2e/regression/session-timeline-lifecycle-state.spec.ts
174
+ story("does not infer Thinking from busy, retry, or recovery without reasoning", async ({ mount }) => {
175
+ const timeline = await mount("current-session-timeline-rows--conversation", { args: { scenario: "retry" } })
176
+ await expect(timeline.locator('[data-timeline-row="UserMessage"]')).toBeVisible()
177
+ await expect(timeline.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
178
+ await expect(timeline.locator('[data-timeline-row="DiffSummary"]')).toHaveCount(0)
179
+ await timeline.getByRole("button", { name: "Retry request" }).click()
180
+ await expect(timeline.locator('[data-timeline-row="Retry"]')).toBeVisible()
181
+ await expect(timeline.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
182
+ await timeline.getByRole("button", { name: "Recover request" }).click()
183
+ await expect(timeline.locator('[data-timeline-row="Retry"]')).toHaveCount(0)
184
+ await expect(timeline.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
185
+ await timeline.getByRole("button", { name: "Finish response" }).click()
186
+ await expect(timeline.locator('[data-timeline-row="Thinking"]')).toHaveCount(0)
187
+ await expect(timeline.locator('[data-timeline-part-id="msg_retry_recovery_lifecycle:text:0"]')).toContainText(
188
+ "Recovered response",
189
+ )
190
+ })