zidane-ui 9.2.2 → 9.3.1

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 (320) hide show
  1. package/dist/adapters/browser-keybindings-host.js +3 -1
  2. package/dist/adapters/live.d.ts +6 -0
  3. package/dist/adapters/live.js +16 -8
  4. package/dist/adapters/server-composer-host.js +22 -9
  5. package/dist/adapters/server-host.js +143 -18
  6. package/dist/adapters/server-media.d.ts +9 -1
  7. package/dist/adapters/server-media.js +14 -1
  8. package/dist/adapters/server-settings-host.js +30 -3
  9. package/dist/adapters/server-settings-sections.js +23 -1
  10. package/dist/adapters/server-sidebar-host.d.ts +3 -1
  11. package/dist/adapters/server-sidebar-host.js +10 -1
  12. package/dist/app/ModalProvider.js +1 -1
  13. package/dist/approvals/ApprovalShell.js +1 -1
  14. package/dist/chat/DaemonOrb.d.ts +29 -1
  15. package/dist/chat/DaemonOrb.js +25 -12
  16. package/dist/chat/HostTranscript.d.ts +0 -12
  17. package/dist/chat/HostTranscript.js +6 -1
  18. package/dist/chat/SessionStreamsProvider.d.ts +8 -0
  19. package/dist/chat/SessionStreamsProvider.js +11 -2
  20. package/dist/chat/StatusDot.js +8 -2
  21. package/dist/chat/Transcript.d.ts +20 -11
  22. package/dist/chat/Transcript.js +335 -162
  23. package/dist/chat/composer/ComposerEditor.js +1 -1
  24. package/dist/chat/headless/host.d.ts +43 -7
  25. package/dist/chat/headless/index.d.ts +8 -6
  26. package/dist/chat/headless/index.js +11 -9
  27. package/dist/chat/headless/labels.d.ts +30 -0
  28. package/dist/chat/headless/labels.js +29 -0
  29. package/dist/chat/headless/markdown-chunks.d.ts +2 -1
  30. package/dist/chat/headless/markdown-chunks.js +12 -20
  31. package/dist/chat/headless/markdown-scan.d.ts +66 -0
  32. package/dist/chat/headless/markdown-scan.js +124 -0
  33. package/dist/chat/headless/markdown-stream.d.ts +64 -0
  34. package/dist/chat/headless/markdown-stream.js +143 -0
  35. package/dist/chat/headless/output-pager.d.ts +68 -0
  36. package/dist/chat/headless/output-pager.js +113 -0
  37. package/dist/chat/headless/session-list.d.ts +20 -0
  38. package/dist/chat/headless/sidebar/activity.d.ts +14 -0
  39. package/dist/chat/headless/sidebar/activity.js +32 -0
  40. package/dist/chat/headless/sidebar/directory.d.ts +17 -2
  41. package/dist/chat/headless/sidebar/directory.js +50 -54
  42. package/dist/chat/headless/sidebar/environment.d.ts +5 -2
  43. package/dist/chat/headless/sidebar/environment.js +11 -2
  44. package/dist/chat/headless/sidebar/host.d.ts +15 -0
  45. package/dist/chat/headless/sidebar/inbox.d.ts +12 -3
  46. package/dist/chat/headless/sidebar/inbox.js +18 -9
  47. package/dist/chat/headless/sidebar/index.d.ts +2 -2
  48. package/dist/chat/headless/sidebar/index.js +2 -2
  49. package/dist/chat/headless/sidebar/labels.d.ts +38 -2
  50. package/dist/chat/headless/sidebar/labels.js +16 -0
  51. package/dist/chat/headless/sidebar/prewarm.d.ts +68 -0
  52. package/dist/chat/headless/sidebar/prewarm.js +114 -0
  53. package/dist/chat/headless/streams/actions.d.ts +2 -0
  54. package/dist/chat/headless/streams/actions.js +1 -0
  55. package/dist/chat/headless/streams/event-bytes.d.ts +6 -0
  56. package/dist/chat/headless/streams/event-bytes.js +34 -0
  57. package/dist/chat/headless/streams/live-events.d.ts +25 -1
  58. package/dist/chat/headless/streams/live-events.js +53 -2
  59. package/dist/chat/headless/streams/selectors.d.ts +3 -0
  60. package/dist/chat/headless/streams/selectors.js +8 -1
  61. package/dist/chat/headless/streams/session-streams.d.ts +15 -3
  62. package/dist/chat/headless/streams/session-streams.js +31 -3
  63. package/dist/chat/headless/streams/store.d.ts +24 -1
  64. package/dist/chat/headless/streams/store.js +51 -26
  65. package/dist/chat/headless/streams/transcript-map.d.ts +57 -0
  66. package/dist/chat/headless/streams/transcript-map.js +88 -0
  67. package/dist/chat/headless/streams/transcript.d.ts +4 -2
  68. package/dist/chat/headless/streams/transcript.js +19 -7
  69. package/dist/chat/headless/transcript/batch.js +5 -1
  70. package/dist/chat/headless/transcript/blob-media.d.ts +15 -0
  71. package/dist/chat/headless/transcript/blob-media.js +23 -0
  72. package/dist/chat/headless/transcript/collapse.d.ts +10 -0
  73. package/dist/chat/headless/transcript/collapse.js +32 -6
  74. package/dist/chat/headless/transcript/derive.d.ts +98 -0
  75. package/dist/chat/headless/transcript/derive.js +89 -0
  76. package/dist/chat/headless/transcript/exchange-media.d.ts +3 -1
  77. package/dist/chat/headless/transcript/exchange-media.js +8 -5
  78. package/dist/chat/headless/transcript/fold-actions.d.ts +8 -3
  79. package/dist/chat/headless/transcript/fold-actions.js +16 -0
  80. package/dist/chat/headless/transcript/fold-attachments.d.ts +2 -0
  81. package/dist/chat/headless/transcript/fold-attachments.js +3 -2
  82. package/dist/chat/headless/transcript/fold.d.ts +4 -2
  83. package/dist/chat/headless/transcript/fold.js +37 -7
  84. package/dist/chat/headless/transcript/incremental.d.ts +53 -0
  85. package/dist/chat/headless/transcript/incremental.js +181 -0
  86. package/dist/chat/headless/transcript/index.d.ts +2 -1
  87. package/dist/chat/headless/transcript/index.js +2 -1
  88. package/dist/chat/headless/transcript/nesting.js +2 -1
  89. package/dist/chat/headless/transcript/rail.d.ts +142 -0
  90. package/dist/chat/headless/transcript/rail.js +290 -0
  91. package/dist/chat/headless/transcript/rows.d.ts +11 -1
  92. package/dist/chat/headless/transcript/run-failures.d.ts +4 -0
  93. package/dist/chat/headless/transcript/run-failures.js +31 -2
  94. package/dist/chat/headless/transcript/seams.d.ts +78 -0
  95. package/dist/chat/headless/transcript/seams.js +116 -0
  96. package/dist/chat/headless/transcript/tool-media.d.ts +6 -7
  97. package/dist/chat/headless/transcript/tool-media.js +27 -9
  98. package/dist/chat/headless/transcript-labels.d.ts +1 -0
  99. package/dist/chat/headless/turn-labels.d.ts +1 -0
  100. package/dist/chat/headless/turn-labels.js +2 -1
  101. package/dist/chat/index.d.ts +10 -8
  102. package/dist/chat/index.js +9 -7
  103. package/dist/chat/interactions/ElicitationCard.js +1 -1
  104. package/dist/chat/interactions/InteractionCard.js +1 -1
  105. package/dist/chat/interactions/PlanCard.js +3 -3
  106. package/dist/chat/interactions/QuestionField.js +4 -4
  107. package/dist/chat/interactions/QuestionForm.js +3 -3
  108. package/dist/chat/interactions/SecretInput.js +1 -1
  109. package/dist/chat/sidebar/ProjectIcon.d.ts +1 -1
  110. package/dist/chat/sidebar/ProjectIcon.js +1 -1
  111. package/dist/chat/sidebar/RowChips.d.ts +3 -2
  112. package/dist/chat/sidebar/RowChips.js +6 -3
  113. package/dist/chat/sidebar/SessionSidebar.js +13 -14
  114. package/dist/chat/sidebar/SidebarFooter.d.ts +8 -5
  115. package/dist/chat/sidebar/SidebarFooter.js +6 -6
  116. package/dist/chat/sidebar/SidebarFrame.d.ts +2 -0
  117. package/dist/chat/sidebar/SidebarFrame.js +5 -2
  118. package/dist/chat/sidebar/SidebarSessionRow.d.ts +3 -1
  119. package/dist/chat/sidebar/SidebarSessionRow.js +3 -1
  120. package/dist/chat/sidebar/SpacesSection.d.ts +20 -1
  121. package/dist/chat/sidebar/SpacesSection.js +34 -13
  122. package/dist/chat/sidebar/index.d.ts +2 -2
  123. package/dist/chat/sidebar/session-menu.d.ts +11 -2
  124. package/dist/chat/sidebar/session-menu.js +50 -5
  125. package/dist/chat/sidebar/sidebar-live.js +1 -1
  126. package/dist/chat/sidebar/useInboxRows.js +43 -2
  127. package/dist/chat/sidebar/useInboxTriage.js +19 -14
  128. package/dist/chat/testing/contract.d.ts +5 -3
  129. package/dist/chat/testing/contract.js +66 -1
  130. package/dist/chat/testing/fixture-sidebar-host.d.ts +7 -1
  131. package/dist/chat/testing/fixture-sidebar-host.js +12 -0
  132. package/dist/chat/testing/sidebar.contract.d.ts +6 -0
  133. package/dist/chat/testing/sidebar.contract.js +24 -0
  134. package/dist/chat/transcript/DiffLines.d.ts +6 -1
  135. package/dist/chat/transcript/DiffLines.js +35 -20
  136. package/dist/chat/transcript/EditDiffBlock.d.ts +5 -1
  137. package/dist/chat/transcript/EditDiffBlock.js +89 -30
  138. package/dist/chat/transcript/InteractionToolBody.js +1 -1
  139. package/dist/chat/transcript/LazyRow.d.ts +40 -40
  140. package/dist/chat/transcript/LazyRow.js +101 -149
  141. package/dist/chat/transcript/MermaidDiagram.js +2 -1
  142. package/dist/chat/transcript/SelectCursor.d.ts +11 -1
  143. package/dist/chat/transcript/SelectCursor.js +10 -5
  144. package/dist/chat/transcript/SubagentBlock.js +3 -2
  145. package/dist/chat/transcript/TranscriptRail.d.ts +109 -0
  146. package/dist/chat/transcript/TranscriptRail.js +579 -0
  147. package/dist/chat/transcript/TranscriptRow.d.ts +4 -7
  148. package/dist/chat/transcript/TranscriptRow.js +9 -5
  149. package/dist/chat/transcript/actions.d.ts +43 -3
  150. package/dist/chat/transcript/actions.js +27 -1
  151. package/dist/chat/transcript/clipped-output.d.ts +58 -0
  152. package/dist/chat/transcript/clipped-output.js +131 -0
  153. package/dist/chat/transcript/fold-attachments.js +10 -5
  154. package/dist/chat/transcript/fold-worker.js +3 -2
  155. package/dist/chat/transcript/fold.js +21 -2
  156. package/dist/chat/transcript/index.d.ts +11 -9
  157. package/dist/chat/transcript/index.js +10 -8
  158. package/dist/chat/transcript/markdown-cache.d.ts +7 -1
  159. package/dist/chat/transcript/markdown-cache.js +12 -1
  160. package/dist/chat/transcript/markdown.js +116 -54
  161. package/dist/chat/transcript/media-gallery.d.ts +3 -2
  162. package/dist/chat/transcript/media-gallery.js +10 -7
  163. package/dist/chat/transcript/notices.d.ts +23 -1
  164. package/dist/chat/transcript/notices.js +110 -28
  165. package/dist/chat/transcript/prompt.js +6 -4
  166. package/dist/chat/transcript/prose.js +3 -1
  167. package/dist/chat/transcript/receipt-parts.d.ts +22 -0
  168. package/dist/chat/transcript/receipt-parts.js +87 -0
  169. package/dist/chat/transcript/root-items.d.ts +96 -0
  170. package/dist/chat/transcript/root-items.js +180 -0
  171. package/dist/chat/transcript/row-mount.d.ts +165 -0
  172. package/dist/chat/transcript/row-mount.js +498 -0
  173. package/dist/chat/transcript/row-parking.d.ts +125 -0
  174. package/dist/chat/transcript/row-parking.js +135 -0
  175. package/dist/chat/transcript/row-ui-state.d.ts +37 -0
  176. package/dist/chat/transcript/row-ui-state.js +53 -0
  177. package/dist/chat/transcript/run-rows.js +6 -78
  178. package/dist/chat/transcript/script-input.d.ts +1 -1
  179. package/dist/chat/transcript/scroll-clamp.js +1 -1
  180. package/dist/chat/transcript/tasks.js +3 -2
  181. package/dist/chat/transcript/tool-media.d.ts +4 -2
  182. package/dist/chat/transcript/tool-media.js +15 -7
  183. package/dist/chat/transcript/tool-parts.d.ts +27 -4
  184. package/dist/chat/transcript/tool-parts.js +31 -5
  185. package/dist/chat/transcript/tool-payload.js +26 -11
  186. package/dist/chat/transcript/tool-row.d.ts +2 -1
  187. package/dist/chat/transcript/tool-row.js +38 -19
  188. package/dist/chat/transcript/use-transcript-rows.d.ts +24 -7
  189. package/dist/chat/transcript/use-transcript-rows.js +28 -46
  190. package/dist/chat/transcript/useSettledReveal.js +15 -3
  191. package/dist/chat/transcript/useStickToBottom.js +4 -4
  192. package/dist/chat/transcript/useTranscriptSearch.js +30 -14
  193. package/dist/chat/transcript/view-scope.d.ts +26 -6
  194. package/dist/chat/transcript/view-scope.js +106 -20
  195. package/dist/components/ChoiceCards.js +1 -1
  196. package/dist/components/ConfirmDialog.js +1 -1
  197. package/dist/components/CopyValue.d.ts +33 -0
  198. package/dist/components/CopyValue.js +54 -0
  199. package/dist/components/Form.js +1 -1
  200. package/dist/components/HowItWorks.js +1 -1
  201. package/dist/components/Menu.js +1 -1
  202. package/dist/components/StepFrame.js +2 -2
  203. package/dist/components/SwatchPicker.js +1 -1
  204. package/dist/components/ToggleCard.js +1 -1
  205. package/dist/components/floating/HoverCard.js +2 -3
  206. package/dist/components/floating/hover-delay.d.ts +4 -0
  207. package/dist/components/floating/hover-delay.js +6 -0
  208. package/dist/core.css +14 -12
  209. package/dist/dist/{index-Betz0OWq.d.ts → index-C6-t1SS9.d.ts} +21 -2
  210. package/dist/dist/index-De9AbmxS.d.ts +1 -0
  211. package/dist/dist/index.d.ts +5 -5
  212. package/dist/dist/sandbox-CSUihARm.d.ts +2 -0
  213. package/dist/dist/{timeout-CyU7HLyz.d.ts → timeout-CmTx6V9y.d.ts} +1 -0
  214. package/dist/extensions/ExtensionDialogHost.js +1 -1
  215. package/dist/files/TreeColumn.js +3 -1
  216. package/dist/files/headless/host.d.ts +2 -2
  217. package/dist/git/ImportRepoDialog.js +1 -1
  218. package/dist/git/MoveSessionDialog.js +2 -2
  219. package/dist/git/SandboxManager.d.ts +42 -0
  220. package/dist/git/SandboxManager.js +297 -0
  221. package/dist/git/SyncChip.js +1 -1
  222. package/dist/git/headless/index.d.ts +2 -1
  223. package/dist/git/headless/index.js +2 -1
  224. package/dist/git/headless/labels.d.ts +29 -0
  225. package/dist/git/headless/labels.js +34 -1
  226. package/dist/git/headless/sandboxes.d.ts +43 -0
  227. package/dist/git/headless/sandboxes.js +52 -0
  228. package/dist/git/index.d.ts +2 -1
  229. package/dist/git/index.js +2 -1
  230. package/dist/index.d.ts +2 -1
  231. package/dist/index.js +2 -1
  232. package/dist/keybindings/headless/catalog.d.ts +1 -1
  233. package/dist/keybindings/headless/catalog.js +12 -0
  234. package/dist/machines/HostsSection.d.ts +1 -1
  235. package/dist/machines/headless/labels.js +2 -2
  236. package/dist/motion/flip-list.js +3 -10
  237. package/dist/motion/presence.d.ts +10 -0
  238. package/dist/motion/presence.js +20 -1
  239. package/dist/motion/swap.d.ts +8 -2
  240. package/dist/motion/swap.js +5 -2
  241. package/dist/onboarding/conversation.js +27 -15
  242. package/dist/onboarding/demos/how-it-works.js +1 -1
  243. package/dist/onboarding/skills/parts.js +4 -4
  244. package/dist/onboarding/sources/SourceBrowser.js +1 -1
  245. package/dist/onboarding/steps/ReadyStep.js +1 -1
  246. package/dist/onboarding/steps/connect/KeyForm.js +1 -1
  247. package/dist/palette/headless/app-sources.js +20 -0
  248. package/dist/palette/headless/labels.js +2 -0
  249. package/dist/session/PlanTracker.js +3 -3
  250. package/dist/session/SecretsPanel.js +1 -1
  251. package/dist/session/SessionHeader.d.ts +18 -6
  252. package/dist/session/SessionHeader.js +68 -12
  253. package/dist/session/SessionPlaceMenu.d.ts +35 -0
  254. package/dist/session/SessionPlaceMenu.js +299 -0
  255. package/dist/session/SessionShell.js +1 -1
  256. package/dist/session/TurnDetailsDialog.js +1 -1
  257. package/dist/session/headless/index.d.ts +2 -1
  258. package/dist/session/headless/index.js +2 -1
  259. package/dist/session/headless/labels.d.ts +73 -0
  260. package/dist/session/headless/labels.js +73 -0
  261. package/dist/session/headless/place.d.ts +49 -0
  262. package/dist/session/headless/place.js +57 -0
  263. package/dist/session/index.d.ts +2 -1
  264. package/dist/session/index.js +2 -1
  265. package/dist/settings/ConversationPresetsCard.js +1 -1
  266. package/dist/settings/SettingCard.js +2 -2
  267. package/dist/settings/SettingsRowsPage.js +1 -1
  268. package/dist/settings/headless/fixture-performance.js +4 -2
  269. package/dist/settings/headless/fixture-sections.js +7 -0
  270. package/dist/settings/headless/labels.d.ts +1 -1
  271. package/dist/settings/headless/labels.js +1 -1
  272. package/dist/settings/headless/layout.d.ts +4 -4
  273. package/dist/settings/headless/layout.js +1 -1
  274. package/dist/settings/headless/performance.d.ts +4 -0
  275. package/dist/settings/headless/search.d.ts +2 -2
  276. package/dist/settings/headless/sections-host.d.ts +20 -2
  277. package/dist/settings/sections/claude-import/ClaudeImportDialog.js +1 -1
  278. package/dist/settings/sections/enabled-list/EnabledListSection.js +2 -2
  279. package/dist/settings/sections/environments/EnvironmentsSection.d.ts +9 -3
  280. package/dist/settings/sections/environments/EnvironmentsSection.js +292 -52
  281. package/dist/settings/sections/environments/labels.d.ts +15 -0
  282. package/dist/settings/sections/environments/labels.js +18 -3
  283. package/dist/settings/sections/extensions/ChangeOriginDialog.js +1 -1
  284. package/dist/settings/sections/extensions/ExtensionSourceBrowser.js +1 -1
  285. package/dist/settings/sections/extensions/ExtensionsSection.d.ts +3 -2
  286. package/dist/settings/sections/extensions/ExtensionsSection.js +9 -3
  287. package/dist/settings/sections/host-catalog/HostCatalogSection.js +15 -5
  288. package/dist/settings/sections/keybindings/labels.d.ts +2 -0
  289. package/dist/settings/sections/keybindings/labels.js +2 -0
  290. package/dist/settings/sections/keybindings/rows.js +8 -0
  291. package/dist/settings/sections/models/SpacesDefaultsSection.d.ts +7 -3
  292. package/dist/settings/sections/models/SpacesDefaultsSection.js +11 -5
  293. package/dist/settings/sections/performance/PerformanceSection.js +8 -1
  294. package/dist/settings/sections/performance/labels.d.ts +2 -0
  295. package/dist/settings/sections/performance/labels.js +2 -0
  296. package/dist/settings/sections/skills/SkillGroups.js +1 -1
  297. package/dist/settings/server-app.d.ts +4 -2
  298. package/dist/settings/server-app.js +7 -3
  299. package/dist/settings/testing/sections.contract.d.ts +7 -1
  300. package/dist/settings/testing/sections.contract.js +37 -0
  301. package/dist/styles.css +243 -19
  302. package/dist/terminal/TerminalDrawer.js +3 -1
  303. package/dist/views/headless/answers.d.ts +8 -2
  304. package/dist/views/headless/answers.js +58 -1
  305. package/dist/views/headless/placement.d.ts +78 -0
  306. package/dist/views/headless/placement.js +154 -44
  307. package/dist/workspace/SidePanel.js +3 -1
  308. package/package.json +2 -2
  309. package/src/styles/base.css +13 -0
  310. package/src/styles/chat.css +30 -0
  311. package/src/styles/components.css +0 -10
  312. package/src/styles/files.css +5 -0
  313. package/src/styles/sidebar.css +29 -7
  314. package/src/styles/terminal.css +6 -0
  315. package/src/styles/tokens.css +5 -0
  316. package/src/styles/transcript.css +138 -0
  317. package/src/styles/workspace.css +6 -0
  318. package/dist/dist/index-QcFzZlao.d.ts +0 -1
  319. package/dist/dist/sandbox-D0zsW8I1.d.ts +0 -2
  320. /package/dist/dist/{types-_Dtoq_No.d.ts → execution-failure-SREfl-EZ.d.ts} +0 -0
@@ -1,10 +1,48 @@
1
1
  import { usePersistedState } from "../../hooks/usePersistedState.js";
2
2
  import { basename } from "../../path.js";
3
- import { INBOX_SHELVES, INBOX_SHELVES_FOLDED, INBOX_SHELVES_KEY, buildInboxRows, inboxDockStart, inboxFolderOf, nextInboxChangeAt } from "../headless/sidebar/inbox.js";
3
+ import { INBOX_RUN_HOLD_MS, INBOX_SHELVES, INBOX_SHELVES_FOLDED, INBOX_SHELVES_KEY, buildInboxRows, inboxDockStart, inboxFolderOf, nextInboxChangeAt } from "../headless/sidebar/inbox.js";
4
4
  import { useCallback, useEffect, useMemo, useState } from "react";
5
5
  // src/chat/sidebar/useInboxRows.ts
6
6
  const DEFAULT_FOLDED = new Set(INBOX_SHELVES_FOLDED);
7
7
  const NO_FOLDERS = /* @__PURE__ */ new Set();
8
+ const NO_HOLD = /* @__PURE__ */ new Set();
9
+ /**
10
+ * The sessions whose run ended less than {@link INBOX_RUN_HOLD_MS} ago: they stay on the Working shelf meanwhile,
11
+ * so a run that ends and another that starts right after (a queued message, a resume) move nothing. A session
12
+ * running again leaves the hold at once; each hold ends on its own timer.
13
+ */
14
+ function useRunHold(sessions, on) {
15
+ const [seen, setSeen] = useState(() => ({
16
+ sessions,
17
+ running: new Set(sessions.filter((s) => s.status === "running").map((s) => s.id))
18
+ }));
19
+ const [held, setHeld] = useState(/* @__PURE__ */ new Map());
20
+ if (on && seen.sessions !== sessions) {
21
+ const now = new Set(sessions.filter((s) => s.status === "running").map((s) => s.id));
22
+ const ended = [...seen.running].filter((id) => !now.has(id));
23
+ const resumed = [...held.keys()].some((id) => now.has(id));
24
+ setSeen({
25
+ sessions,
26
+ running: now
27
+ });
28
+ if (ended.length > 0 || resumed) {
29
+ const next = new Map([...held].filter(([id]) => !now.has(id)));
30
+ const until = Date.now() + INBOX_RUN_HOLD_MS;
31
+ for (const id of ended) next.set(id, until);
32
+ setHeld(next);
33
+ }
34
+ }
35
+ useEffect(() => {
36
+ if (held.size === 0) return;
37
+ const first = Math.min(...held.values());
38
+ const timer = setTimeout(() => {
39
+ const at = Date.now();
40
+ setHeld((current) => new Map([...current].filter(([, until]) => until > at)));
41
+ }, Math.max(0, first - Date.now()));
42
+ return () => clearTimeout(timer);
43
+ }, [held]);
44
+ return useMemo(() => held.size === 0 ? NO_HOLD : new Set(held.keys()), [held]);
45
+ }
8
46
  function toggled(set, item) {
9
47
  const next = new Set(set);
10
48
  if (next.has(item)) next.delete(item);
@@ -34,6 +72,7 @@ function useInboxRows({ on, sessions, groupBy, earlierAfterMs, needsYou, activeI
34
72
  [shelf]: (shown[shelf] ?? 10) + 25
35
73
  }));
36
74
  }, []);
75
+ const holdRunning = useRunHold(sessions, on);
37
76
  const [tick, setTick] = useState(0);
38
77
  useEffect(() => {
39
78
  if (!on) return;
@@ -55,6 +94,7 @@ function useInboxRows({ on, sessions, groupBy, earlierAfterMs, needsYou, activeI
55
94
  shown: shelfShown,
56
95
  activeId,
57
96
  earlierAfterMs,
97
+ holdRunning,
58
98
  ...needsYou ? { needsYou } : {}
59
99
  }) : [], [
60
100
  on,
@@ -66,7 +106,8 @@ function useInboxRows({ on, sessions, groupBy, earlierAfterMs, needsYou, activeI
66
106
  activeId,
67
107
  tick,
68
108
  earlierAfterMs,
69
- needsYou
109
+ needsYou,
110
+ holdRunning
70
111
  ]);
71
112
  const dockStart = inboxDockStart(rows);
72
113
  return {
@@ -82,22 +82,27 @@ function useInboxTriage(options) {
82
82
  const row = sessionRow(id);
83
83
  return row ? [row.session] : [];
84
84
  });
85
- Promise.allSettled(before.map((s) => save(s.id, patchFor(s)))).then((results) => {
86
- const saved = before.filter((_, i) => results[i].status === "fulfilled");
85
+ /** The sessions whose save went through. */
86
+ const saved = Promise.allSettled(before.map((s) => save(s.id, patchFor(s)))).then((results) => {
87
87
  const rejected = results.find((r) => r.status === "rejected");
88
88
  if (rejected) failed(rejected.reason);
89
- if (saved.length === 0) return;
90
- let done = false;
91
- const revert = () => {
92
- if (done) return;
93
- done = true;
94
- if (undo.current === revert) undo.current = null;
95
- for (const s of saved) save(s.id, inverseInboxPatch(s, now)).catch(failed);
96
- };
97
- undo.current = revert;
98
- setTimeout(() => {
99
- if (undo.current === revert) undo.current = null;
100
- }, UNDO_MS);
89
+ return before.filter((_, i) => results[i].status === "fulfilled");
90
+ });
91
+ let done = false;
92
+ const revert = () => {
93
+ if (done) return;
94
+ done = true;
95
+ if (undo.current === revert) undo.current = null;
96
+ saved.then((ok) => {
97
+ for (const s of ok) save(s.id, inverseInboxPatch(s, now)).catch(failed);
98
+ });
99
+ };
100
+ undo.current = revert;
101
+ setTimeout(() => {
102
+ if (undo.current === revert) undo.current = null;
103
+ }, UNDO_MS);
104
+ saved.then((ok) => {
105
+ if (ok.length === 0 && undo.current === revert) undo.current = null;
101
106
  });
102
107
  setSelected(EMPTY);
103
108
  }, [failed]);
@@ -19,9 +19,9 @@ import { ChatCommandFacts, ChatCommit, ChatContextFacts, ChatResolvedPath, ChatS
19
19
  import { ComposerContractSession, ComposerHostCapability, ComposerHostContractBackend, ComposerHostContractControl, ComposerHostHarness, ComposerHostHarnessFactory, describeComposerHostContract } from "./composer.contract.js";
20
20
  import { SidebarHostCapability, SidebarHostContractBackend, SidebarHostContractControl, SidebarHostHarness, SidebarHostHarnessFactory, describeSidebarHostContract } from "./sidebar.contract.js";
21
21
  import { BadgeActionEffect, BadgeMenuItem, ExtensionReferenceView, ReferenceProviderWire } from "zidane/chat/pure";
22
- import { InteractionRequest } from "zidane/chat";
22
+ import { InteractionRequest, ToolCallDetail as ToolCallDetail$1 } from "zidane/chat";
23
23
  /** An optional `ChatHost` member, by its path. */
24
- export type ChatHostCapability = 'sessions' | 'sessions.create' | 'sessions.rename' | 'sessions.setArchived' | 'sessions.setFavorite' | 'sessions.setInboxState' | 'sessions.remove' | 'sessions.query' | 'sessions.setSpace' | 'sessions.search' | 'sessions.onChanged' | 'sessions.views' | 'sessions.main' | 'send' | 'interrupt' | 'shell' | 'providerReady' | 'interactions' | 'interactions.cancel' | 'interactions.all' | 'models' | 'toolOutput' | 'cancelTool' | 'searchSync' | 'references' | 'paths' | 'chips' | 'chips.commit' | 'chips.sessions' | 'chips.context' | 'chips.skills' | 'chips.commands' | 'badges' | 'siteIcons' | 'blockRuns';
24
+ export type ChatHostCapability = 'sessions' | 'sessions.create' | 'sessions.rename' | 'sessions.setArchived' | 'sessions.setFavorite' | 'sessions.setInboxState' | 'sessions.remove' | 'sessions.query' | 'sessions.setSpace' | 'sessions.search' | 'sessions.onChanged' | 'sessions.views' | 'sessions.main' | 'send' | 'interrupt' | 'shell' | 'providerReady' | 'interactions' | 'interactions.cancel' | 'interactions.all' | 'models' | 'toolOutput' | 'toolOutputRange' | 'toolCall' | 'cancelTool' | 'searchSync' | 'references' | 'paths' | 'chips' | 'chips.commit' | 'chips.sessions' | 'chips.context' | 'chips.skills' | 'chips.commands' | 'badges' | 'siteIcons' | 'blockRuns';
25
25
  /** One thing the backend does while it runs a prompt, in order. */
26
26
  export type ChatHostScriptStep = {
27
27
  kind: 'reply';
@@ -42,8 +42,10 @@ export interface ChatHostContractBackend {
42
42
  sessions: readonly ChatSession[];
43
43
  /** Stored events per session id (a session missing here has none). */
44
44
  transcripts: Readonly<Record<string, readonly ChatEvent[]>>;
45
- /** A tool call's full output, by call id (any session). */
45
+ /** A tool call's full output, by call id (any session). A range of it (`toolOutputRange`) is `{ text, offset, total }` in UTF-16 code units. */
46
46
  toolOutputs: Readonly<Record<string, string>>;
47
+ /** The whole of a tool call (its input, its edit), by call id (any session). */
48
+ toolCalls?: Readonly<Record<string, ToolCallDetail$1>>;
47
49
  /**
48
50
  * What a run does with a sent prompt. The backend echoes the prompt into the transcript, starts the
49
51
  * run, plays these steps, and ends the run when they are done (unless a step holds it).
@@ -1,3 +1,4 @@
1
+ import { createToolOutputPager } from "../headless/output-pager.js";
1
2
  import { describeComposerHostContract } from "./composer.contract.js";
2
3
  import { describeSidebarHostContract } from "./sidebar.contract.js";
3
4
  import { afterEach, describe, expect, it, vi } from "vitest";
@@ -25,6 +26,8 @@ const CAPABILITIES = [
25
26
  "interactions.all",
26
27
  "models",
27
28
  "toolOutput",
29
+ "toolOutputRange",
30
+ "toolCall",
28
31
  "cancelTool",
29
32
  "searchSync",
30
33
  "references",
@@ -78,6 +81,8 @@ const SESSIONS = [{
78
81
  createdAt: 3,
79
82
  updatedAt: 4
80
83
  }];
84
+ /** A result longer than a few pages, with characters of two code units (a page edge can split one). */
85
+ const LONG_OUTPUT = Array.from({ length: 300 }, (_, i) => `line ${i} é 🙂\n`).join("");
81
86
  const CONTRACT_SHA = "abc1234def5678abc1234def5678abc1234def56";
82
87
  function contractBackend() {
83
88
  return {
@@ -89,7 +94,24 @@ function contractBackend() {
89
94
  kind: "markdown",
90
95
  text: "earlier reply"
91
96
  }] },
92
- toolOutputs: { "call-1": "the full output" },
97
+ toolOutputs: {
98
+ "call-1": "the full output",
99
+ "call-long": LONG_OUTPUT
100
+ },
101
+ toolCalls: { "call-1": {
102
+ input: {
103
+ path: "a.ts",
104
+ content: "the whole file"
105
+ },
106
+ edit: {
107
+ tool: "write_file",
108
+ path: "a.ts",
109
+ hunks: [{
110
+ oldString: "",
111
+ newString: "the whole file"
112
+ }]
113
+ }
114
+ } },
93
115
  script(prompt) {
94
116
  if (prompt === "hold") return [{ kind: "hold" }];
95
117
  if (prompt === "ask") return [{
@@ -443,6 +465,49 @@ function describeChatHostContract(name, makeHarness, capabilities) {
443
465
  expect(await host.toolOutput("c-1", "call-1")).toBe("the full output");
444
466
  expect(await host.toolOutput("c-1", "call-unknown")).toBeNull();
445
467
  });
468
+ it.skipIf(!has("toolOutputRange"))("reads a tool call's output a range at a time", async () => {
469
+ const { host } = await setup();
470
+ const total = LONG_OUTPUT.length;
471
+ expect(await host.toolOutputRange("c-1", "call-long", {
472
+ offset: 0,
473
+ length: 10
474
+ })).toEqual({
475
+ text: LONG_OUTPUT.slice(0, 10),
476
+ offset: 0,
477
+ total
478
+ });
479
+ expect(await host.toolOutputRange("c-1", "call-long", {
480
+ offset: total - 5,
481
+ length: 100
482
+ })).toEqual({
483
+ text: LONG_OUTPUT.slice(total - 5),
484
+ offset: total - 5,
485
+ total
486
+ });
487
+ expect(await host.toolOutputRange("c-1", "call-unknown", {
488
+ offset: 0,
489
+ length: 10
490
+ })).toBeNull();
491
+ const pager = createToolOutputPager((range) => host.toolOutputRange("c-1", "call-long", range), { pageSize: 1e3 });
492
+ await pager.loadMore();
493
+ expect(pager.get()).toMatchObject({
494
+ text: LONG_OUTPUT.slice(0, 1e3),
495
+ total,
496
+ error: null
497
+ });
498
+ await pager.loadAll();
499
+ expect(pager.get()).toMatchObject({
500
+ text: LONG_OUTPUT,
501
+ total,
502
+ loading: false,
503
+ error: null
504
+ });
505
+ });
506
+ it.skipIf(!has("toolCall"))("reads the whole of a tool call", async () => {
507
+ const { host } = await setup();
508
+ expect(await host.toolCall("c-1", "call-1")).toEqual(contractBackend().toolCalls["call-1"]);
509
+ expect(await host.toolCall("c-1", "call-unknown")).toBeNull();
510
+ });
446
511
  it.skipIf(!has("searchSync"))("shares a session's search with its other windows", async () => {
447
512
  const harness = await makeHarness(contractBackend());
448
513
  cleanup.push(() => harness.dispose?.());
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * An in-memory `SidebarHost` for docs, demos and tests: each session's
3
3
  * environment commands and what running one answers, with every reveal,
4
- * window, retry, run and opened host settings recorded for the caller to read.
4
+ * window, retry, wake, run and opened host settings recorded for the caller to read.
5
5
  */
6
6
  import { SessionWindowMode, SidebarHost } from "../headless/sidebar/host.js";
7
7
  import { EnvironmentActionResult, EnvironmentActionSummary } from "zidane/chat";
@@ -34,6 +34,12 @@ export interface FixtureSidebarCalls {
34
34
  }[];
35
35
  /** Every environment retried, in order. */
36
36
  retried: string[];
37
+ /** Every paused environment woken, in order. */
38
+ woken: string[];
39
+ /** Every environment paused, in order. */
40
+ paused: string[];
41
+ /** Every sandbox deleted, in order. */
42
+ removed: string[];
37
43
  /** Every environment command run, in order. */
38
44
  ran: {
39
45
  sessionId: string;
@@ -10,6 +10,9 @@ function createFixtureSidebarHost(options = {}) {
10
10
  revealed: [],
11
11
  windows: [],
12
12
  retried: [],
13
+ woken: [],
14
+ paused: [],
15
+ removed: [],
13
16
  ran: [],
14
17
  hostSettings: []
15
18
  };
@@ -41,6 +44,15 @@ function createFixtureSidebarHost(options = {}) {
41
44
  },
42
45
  retry: async (sessionId) => {
43
46
  calls.retried.push(sessionId);
47
+ },
48
+ wake: async (sessionId) => {
49
+ calls.woken.push(sessionId);
50
+ },
51
+ pause: async (sessionId) => {
52
+ calls.paused.push(sessionId);
53
+ },
54
+ remove: async (sessionId) => {
55
+ calls.removed.push(sessionId);
44
56
  }
45
57
  } } : {}
46
58
  };
@@ -37,6 +37,12 @@ export interface SidebarHostContractControl {
37
37
  }[];
38
38
  /** The environments set up again, in order. Only read with `environment`. */
39
39
  retried?: () => readonly string[];
40
+ /** The paused environments woken, in order. Given exactly when the host's `environment` offers `wake`. */
41
+ woken?: () => readonly string[];
42
+ /** The environments paused, in order. Given exactly when the host's `environment` offers `pause`. */
43
+ paused?: () => readonly string[];
44
+ /** The sandboxes deleted, in order. Given exactly when the host's `environment` offers `remove`. */
45
+ removed?: () => readonly string[];
40
46
  /** The hosts whose settings were opened, in order. Only read with `openHostSettings`. */
41
47
  hostSettingsOpened?: () => readonly string[];
42
48
  /** The backend records or changes an artifact of `sessionId`. Only called with `badges`. */
@@ -105,6 +105,30 @@ function describeSidebarHostContract(name, makeHarness, capabilities) {
105
105
  await expect(host.environment.retry("s1")).resolves.toBeUndefined();
106
106
  expect(control.retried?.()).toEqual(["s1"]);
107
107
  });
108
+ it.skipIf(!has("environment"))("wakes a paused environment when it offers that", async () => {
109
+ const { host, control } = await setup();
110
+ const wake = host.environment.wake;
111
+ expect(wake === void 0).toBe(control.woken === void 0);
112
+ if (!wake) return;
113
+ await expect(wake("s1")).resolves.toBeUndefined();
114
+ expect(control.woken?.()).toEqual(["s1"]);
115
+ });
116
+ it.skipIf(!has("environment"))("pauses an environment when it offers that", async () => {
117
+ const { host, control } = await setup();
118
+ const pause = host.environment.pause;
119
+ expect(pause === void 0).toBe(control.paused === void 0);
120
+ if (!pause) return;
121
+ await expect(pause("s1")).resolves.toBeUndefined();
122
+ expect(control.paused?.()).toEqual(["s1"]);
123
+ });
124
+ it.skipIf(!has("environment"))("deletes a session's sandbox when it offers that", async () => {
125
+ const { host, control } = await setup();
126
+ const remove = host.environment.remove;
127
+ expect(remove === void 0).toBe(control.removed === void 0);
128
+ if (!remove) return;
129
+ await expect(remove("s1")).resolves.toBeUndefined();
130
+ expect(control.removed?.()).toEqual(["s1"]);
131
+ });
108
132
  it.skipIf(!has("badges"))("reads several sessions' badges at once, none for a session without artifacts", async () => {
109
133
  const { host } = await setup();
110
134
  expect(await host.badges.read(["s1", "s2"])).toEqual({
@@ -35,6 +35,11 @@ export interface DiffLinesProps {
35
35
  * ones) highlights as one text, so a token that spans lines colors right. Absent: plain text.
36
36
  */
37
37
  language?: string;
38
+ /**
39
+ * A line number per line, 1:1 with `lines` (`null`: none for that line).
40
+ * Set, a gutter shows them before the `+` / `−` markers.
41
+ */
42
+ lineNumbers?: readonly (number | null)[];
38
43
  /** Extra classes on the root element. */
39
44
  className?: string;
40
45
  /** Inline styles on the root element, merged after the component's own. */
@@ -47,4 +52,4 @@ export interface DiffLinesProps {
47
52
  * a 500-line hunk would otherwise be 1,500 elements to build, style and lay
48
53
  * out every time its row scrolled into a long transcript.
49
54
  */
50
- export declare const DiffLines: import("react").MemoExoticComponent<({ lines, maxHeight, language, className, style: styleProp }: DiffLinesProps) => import("react").JSX.Element>;
55
+ export declare const DiffLines: import("react").MemoExoticComponent<({ lines, maxHeight, language, lineNumbers, className, style: styleProp }: DiffLinesProps) => import("react").JSX.Element>;
@@ -12,28 +12,38 @@ const MARKER = {
12
12
  };
13
13
  /** Past this many lines a diff stays plain: two highlights of a huge hunk cost more than its colors give. */
14
14
  const HIGHLIGHT_MAX_LINES = 2e3;
15
- const DiffRun = memo(({ op, text, count, tokens }) => {
15
+ const DiffRun = memo(({ op, text, count, tokens, numbers, gutter }) => {
16
+ const bg = op === "add" ? "var(--zg-diff-add-bg)" : op === "remove" ? "var(--zg-diff-remove-bg)" : "transparent";
17
+ const markerColor = op === "add" ? "var(--zg-success)" : op === "remove" ? "var(--zg-danger)" : "var(--zg-text-muted)";
16
18
  return /* @__PURE__ */ jsxs("div", {
17
19
  className: "flex items-start gap-2 px-2",
18
- style: { background: op === "add" ? "var(--zg-diff-add-bg)" : op === "remove" ? "var(--zg-diff-remove-bg)" : "transparent" },
19
- children: [/* @__PURE__ */ jsx("span", {
20
- style: {
21
- color: op === "add" ? "var(--zg-success)" : op === "remove" ? "var(--zg-danger)" : "var(--zg-text-muted)",
22
- width: "1ch"
23
- },
24
- className: "select-none shrink-0 whitespace-pre",
25
- children: Array.from({ length: count }).fill(MARKER[op]).join("\n")
26
- }), /* @__PURE__ */ jsx("span", {
27
- className: "flex-1 whitespace-pre",
28
- children: tokens ? tokens.map((line, i) => /* @__PURE__ */ jsxs("span", { children: [line.map((t, j) => /* @__PURE__ */ jsx("span", {
20
+ style: { background: bg },
21
+ children: [
22
+ numbers !== void 0 && /* @__PURE__ */ jsx("span", {
23
+ style: { width: `${gutter}ch` },
24
+ className: "select-none shrink-0 whitespace-pre text-right text-[var(--zg-text-muted)]",
25
+ children: numbers
26
+ }),
27
+ /* @__PURE__ */ jsx("span", {
29
28
  style: {
30
- color: t.color,
31
- fontStyle: t.fontStyle,
32
- fontWeight: t.fontWeight
29
+ color: markerColor,
30
+ width: "1ch"
33
31
  },
34
- children: t.text
35
- }, j)), i < tokens.length - 1 ? "\n" : line.length === 0 ? " " : ""] }, i)) : text.endsWith("\n") || text === "" ? `${text} ` : text
36
- })]
32
+ className: "select-none shrink-0 whitespace-pre",
33
+ children: Array.from({ length: count }).fill(MARKER[op]).join("\n")
34
+ }),
35
+ /* @__PURE__ */ jsx("span", {
36
+ className: "flex-1 whitespace-pre",
37
+ children: tokens ? tokens.map((line, i) => /* @__PURE__ */ jsxs("span", { children: [line.map((t, j) => /* @__PURE__ */ jsx("span", {
38
+ style: {
39
+ color: t.color,
40
+ fontStyle: t.fontStyle,
41
+ fontWeight: t.fontWeight
42
+ },
43
+ children: t.text
44
+ }, j)), i < tokens.length - 1 ? "\n" : line.length === 0 ? " " : ""] }, i)) : text.endsWith("\n") || text === "" ? `${text} ` : text
45
+ })
46
+ ]
37
47
  });
38
48
  });
39
49
  /**
@@ -43,9 +53,10 @@ const DiffRun = memo(({ op, text, count, tokens }) => {
43
53
  * a 500-line hunk would otherwise be 1,500 elements to build, style and lay
44
54
  * out every time its row scrolled into a long transcript.
45
55
  */
46
- const DiffLines = memo(({ lines, maxHeight, language, className, style: styleProp }) => {
56
+ const DiffLines = memo(({ lines, maxHeight, language, lineNumbers, className, style: styleProp }) => {
47
57
  const style = maxHeight ? { maxHeight: `${maxHeight}px` } : BASE_NO_CLAMP;
48
58
  const runs = useMemo(() => toRuns(lines), [lines]);
59
+ const gutter = useMemo(() => lineNumbers?.reduce((width, n) => Math.max(width, n === null ? 0 : String(n).length), 0) ?? 0, [lineNumbers]);
49
60
  const frameRef = useRef(null);
50
61
  const tokens = useDiffTokens(lines, language, frameRef);
51
62
  return /* @__PURE__ */ jsx("div", {
@@ -61,7 +72,11 @@ const DiffLines = memo(({ lines, maxHeight, language, className, style: stylePro
61
72
  op: run.op,
62
73
  text: run.text,
63
74
  count: run.count,
64
- ...tokens ? { tokens: tokens.slice(run.start, run.start + run.count) } : {}
75
+ ...tokens ? { tokens: tokens.slice(run.start, run.start + run.count) } : {},
76
+ ...lineNumbers && gutter > 0 ? {
77
+ numbers: lineNumbers.slice(run.start, run.start + run.count).map((n) => n ?? "").join("\n"),
78
+ gutter
79
+ } : {}
65
80
  }, run.start))
66
81
  })
67
82
  });
@@ -4,6 +4,10 @@ import { StreamEvent } from "zidane/chat";
4
4
  export interface EditDiffBlockProps {
5
5
  /** The edit to draw: its path, hunks and per-hunk approval outcomes. */
6
6
  edit: NonNullable<StreamEvent['edit']>;
7
+ /** The call's id: with it, a diff the host cut (`edit.clipped`) offers to load the rest (`TranscriptActions.toolCall`). */
8
+ callId?: string;
9
+ /** The call's turn, a hint where the host looks first. */
10
+ turnId?: string;
7
11
  /** Extra classes on the root element. */
8
12
  className?: string;
9
13
  /** Inline styles on the root element, merged after the component's own. */
@@ -17,4 +21,4 @@ export interface EditDiffBlockProps {
17
21
  * edits with all-applied outcomes collapse back to the flat layout so
18
22
  * the common case doesn't grow extra chrome.
19
23
  */
20
- export declare const EditDiffBlock: import("react").MemoExoticComponent<({ edit, className, style }: EditDiffBlockProps) => import("react").JSX.Element>;
24
+ export declare const EditDiffBlock: import("react").MemoExoticComponent<({ edit: lean, callId, turnId, className, style }: EditDiffBlockProps) => import("react").JSX.Element>;
@@ -1,13 +1,15 @@
1
1
  import { CopyButton } from "../../components/CopyButton.js";
2
2
  import { useDisplayPath } from "../../hooks/useDisplayPath.js";
3
+ import { useChatLabels } from "../useChatLabels.js";
3
4
  import { DiffLines } from "./DiffLines.js";
5
+ import { LoadFullOutputButton, useFullToolCall } from "./tool-parts.js";
4
6
  import { memo, useMemo } from "react";
5
7
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { computeLineDiff, summarizeOutcomes } from "zidane/chat/pure";
8
+ import { computeLineDiff, formatBytes, summarizeOutcomes } from "zidane/chat/pure";
7
9
  // src/chat/transcript/EditDiffBlock.tsx
8
10
  const HUNK_DIM_STYLE = { opacity: .55 };
9
11
  const HUNK_FULL_STYLE = { opacity: 1 };
10
- const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
12
+ const HunkDiffCard = memo(({ language, index, total, lines, lineNumbers, outcome }) => {
11
13
  const kind = outcome?.kind ?? "applied";
12
14
  return /* @__PURE__ */ jsxs("div", {
13
15
  className: "bg-[var(--zg-code-bg)]",
@@ -33,11 +35,43 @@ const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
33
35
  }), /* @__PURE__ */ jsx(DiffLines, {
34
36
  lines,
35
37
  maxHeight: 360,
36
- language
38
+ language,
39
+ ...lineNumbers ? { lineNumbers } : {}
37
40
  })]
38
41
  });
39
42
  });
40
43
  /**
44
+ * Each hunk's diff lines and, for a hunk the host placed in the file
45
+ * (`oldLine`), a line number per line: a removed line's in the old file,
46
+ * the others' in the new one. A `write_file`'s hunks are regions of one
47
+ * file, so each shifts the next one's new numbers by the lines it added or
48
+ * removed; an edit step's `oldLine` is in the file the earlier steps left.
49
+ */
50
+ function hunkLines(edit) {
51
+ const lines = [];
52
+ const numbers = [];
53
+ let shift = 0;
54
+ for (const hunk of edit.hunks) {
55
+ const diff = computeLineDiff(hunk.oldString, hunk.newString);
56
+ lines.push(diff);
57
+ let delta = 0;
58
+ for (const line of diff) delta += line.op === "add" ? 1 : line.op === "remove" ? -1 : 0;
59
+ if (hunk.oldLine === void 0) {
60
+ numbers.push(void 0);
61
+ shift += delta;
62
+ continue;
63
+ }
64
+ let oldNo = hunk.oldLine;
65
+ let newNo = hunk.oldLine + (edit.tool === "write_file" ? shift : 0);
66
+ numbers.push(diff.map((line) => line.op === "remove" ? oldNo++ : line.op === "add" ? newNo++ : (oldNo++, newNo++)));
67
+ shift += delta;
68
+ }
69
+ return {
70
+ lines,
71
+ numbers
72
+ };
73
+ }
74
+ /**
41
75
  * Per-hunk diff renderer with approval-outcome badges. When `edit.outcomes`
42
76
  * is set (per-edit approval landed live, or replay re-parsed it off the
43
77
  * tool result body), each hunk gets its own card with a ✓/✕/⊘/⚠/⋯ badge;
@@ -45,45 +79,70 @@ const HunkDiffCard = memo(({ language, index, total, lines, outcome }) => {
45
79
  * edits with all-applied outcomes collapse back to the flat layout so
46
80
  * the common case doesn't grow extra chrome.
47
81
  */
48
- const EditDiffBlock = memo(({ edit, className, style }) => {
82
+ const EditDiffBlock = memo(({ edit: lean, callId, turnId, className, style }) => {
83
+ const labels = useChatLabels();
84
+ const { full, load, available, ready } = useFullToolCall({
85
+ ...callId ? { callId } : {},
86
+ ...turnId ? { turnId } : {}
87
+ });
88
+ const edit = full !== "loading" && full?.edit ? full.edit : lean;
49
89
  const outcomes = edit.outcomes;
50
90
  const counts = useMemo(() => summarizeOutcomes(outcomes), [outcomes]);
51
91
  const hunks = edit.hunks;
52
92
  const shownPath = useDisplayPath().path(edit.path);
53
93
  const base = edit.path.split("/").pop() ?? "";
54
94
  const language = base.includes(".") ? base.split(".").pop().toLowerCase() : "";
55
- const perHunkLines = useMemo(() => hunks.map((h) => computeLineDiff(h.oldString, h.newString)), [hunks]);
95
+ const { lines: perHunkLines, numbers: perHunkNumbers } = useMemo(() => hunkLines(edit), [edit]);
96
+ const flatLines = useMemo(() => perHunkLines.flat(), [perHunkLines]);
97
+ const flatNumbers = useMemo(() => perHunkNumbers.some(Boolean) ? perHunkNumbers.flatMap((numbers, i) => numbers ?? perHunkLines[i].map(() => null)) : void 0, [perHunkLines, perHunkNumbers]);
98
+ const clipped = edit.clipped;
56
99
  const hasMixedOutcomes = outcomes != null && (counts.denied > 0 || counts.skipped > 0 || counts.failed > 0 || counts.pending > 0);
57
100
  const usePerHunkLayout = outcomes != null && (hunks.length > 1 || hasMixedOutcomes);
58
101
  return /* @__PURE__ */ jsxs("div", {
59
102
  className: ["group zg-tray mt-2 rounded-zg-md overflow-hidden", className].filter(Boolean).join(" "),
60
103
  style,
61
- children: [/* @__PURE__ */ jsxs("div", {
62
- className: `pl-2.5 border-b border-[var(--zg-hairline)] flex items-center gap-3 text-zg-meta ${hasMixedOutcomes ? "py-1.5 pr-2.5" : "h-8 pr-1"}`,
63
- children: [/* @__PURE__ */ jsx("span", {
64
- className: "zg-meta text-[var(--zg-text)] truncate",
65
- title: edit.path,
66
- children: shownPath
67
- }), hasMixedOutcomes ? /* @__PURE__ */ jsx(OutcomeSummary, { counts }) : /* @__PURE__ */ jsx(CopyButton, {
68
- text: edit.path,
69
- label: "Copy file path",
70
- reveal: true,
71
- className: "ml-auto"
72
- })]
73
- }), usePerHunkLayout ? /* @__PURE__ */ jsx("div", {
74
- className: "flex flex-col gap-px bg-[var(--zg-hairline)]",
75
- children: hunks.map((_hunk, idx) => /* @__PURE__ */ jsx(HunkDiffCard, {
104
+ children: [
105
+ /* @__PURE__ */ jsxs("div", {
106
+ className: `pl-2.5 border-b border-[var(--zg-hairline)] flex items-center gap-3 text-zg-meta ${hasMixedOutcomes ? "py-1.5 pr-2.5" : "h-8 pr-1"}`,
107
+ children: [/* @__PURE__ */ jsx("span", {
108
+ className: "zg-meta text-[var(--zg-text)] truncate",
109
+ title: edit.path,
110
+ children: shownPath
111
+ }), hasMixedOutcomes ? /* @__PURE__ */ jsx(OutcomeSummary, { counts }) : /* @__PURE__ */ jsx(CopyButton, {
112
+ text: edit.path,
113
+ label: "Copy file path",
114
+ reveal: true,
115
+ className: "ml-auto"
116
+ })]
117
+ }),
118
+ usePerHunkLayout ? /* @__PURE__ */ jsx("div", {
119
+ className: "flex flex-col gap-px bg-[var(--zg-hairline)]",
120
+ children: hunks.map((_hunk, idx) => /* @__PURE__ */ jsx(HunkDiffCard, {
121
+ language,
122
+ index: idx,
123
+ total: hunks.length,
124
+ lines: perHunkLines[idx] ?? [],
125
+ lineNumbers: perHunkNumbers[idx],
126
+ outcome: outcomes?.[idx]
127
+ }, idx))
128
+ }) : /* @__PURE__ */ jsx(DiffLines, {
129
+ lines: flatLines,
130
+ maxHeight: 420,
76
131
  language,
77
- index: idx,
78
- total: hunks.length,
79
- lines: perHunkLines[idx] ?? [],
80
- outcome: outcomes?.[idx]
81
- }, idx))
82
- }) : /* @__PURE__ */ jsx(DiffLines, {
83
- lines: perHunkLines.flat(),
84
- maxHeight: 420,
85
- language
86
- })]
132
+ ...flatNumbers ? { lineNumbers: flatNumbers } : {}
133
+ }),
134
+ clipped && /* @__PURE__ */ jsxs("div", {
135
+ className: "px-2.5 py-1.5 border-t border-[var(--zg-hairline)] flex items-center gap-3 text-zg-meta text-[var(--zg-text-muted)]",
136
+ children: [/* @__PURE__ */ jsx("span", { children: labels.diffNotShown(clipped.hunks - hunks.length, formatBytes(clipped.bytes)) }), available && /* @__PURE__ */ jsx(LoadFullOutputButton, {
137
+ loading: full === "loading",
138
+ disabled: !ready,
139
+ onClick: load,
140
+ className: "ml-auto",
141
+ label: labels.loadFullDiff,
142
+ loadingLabel: labels.loadingFullDiff
143
+ })]
144
+ })
145
+ ]
87
146
  });
88
147
  });
89
148
  const OUTCOME_GLYPH = {
@@ -99,7 +99,7 @@ function Outcome({ icon, tone, label, note }) {
99
99
  className: `${icon} text-zg-body shrink-0`
100
100
  }), label]
101
101
  }), note && /* @__PURE__ */ jsx("div", {
102
- className: "pl-[22px] text-zg-ui leading-5 text-[var(--zg-text)] whitespace-pre-wrap zg-pretty",
102
+ className: "pl-[22px] text-zg-ui leading-5 text-[var(--zg-text)] whitespace-pre-wrap",
103
103
  children: note
104
104
  })]
105
105
  });