@kabmo-labs/kabmo 0.17.0 → 0.18.0

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 (269) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +538 -457
  3. package/dist/client/static/js/index-hp75vsv9.css +1 -0
  4. package/dist/client/static/js/{index-rerjq5th.js → index-tc09dtca.js} +823 -814
  5. package/package.json +1 -1
  6. package/src/client/components/common/MarkdownRenderer.tsx +136 -89
  7. package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
  8. package/src/client/components/common/anchored-menu/index.tsx +143 -0
  9. package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
  10. package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
  11. package/src/client/components/common/markdown-review/index.tsx +129 -0
  12. package/src/client/components/common/server-control/Panel.tsx +33 -23
  13. package/src/client/components/common/server-control/index.test.tsx +11 -5
  14. package/src/client/components/common/server-control/index.tsx +10 -8
  15. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +42 -21
  16. package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
  17. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
  18. package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
  19. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
  20. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
  21. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
  22. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +28 -10
  23. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
  24. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
  25. package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
  26. package/src/client/components/layout/update-popup/index.tsx +5 -1
  27. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
  28. package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
  29. package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
  30. package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
  31. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
  32. package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
  33. package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
  34. package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
  35. package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
  36. package/src/client/components/settings/categories/McpSettings.tsx +4 -21
  37. package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
  38. package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
  39. package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
  40. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
  41. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
  42. package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
  43. package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
  44. package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
  45. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
  46. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
  47. package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
  48. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +91 -76
  49. package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
  50. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +26 -13
  51. package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
  52. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
  53. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
  54. package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
  55. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
  56. package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
  57. package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
  58. package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
  59. package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
  60. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +35 -7
  61. package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
  62. package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
  63. package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
  64. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
  65. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
  66. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
  67. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
  68. package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
  69. package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
  70. package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
  71. package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
  72. package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
  73. package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
  74. package/src/client/components/workspace/browser-panel/index.tsx +50 -4
  75. package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
  76. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
  77. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
  78. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
  79. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
  80. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
  81. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
  82. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
  83. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
  84. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
  85. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
  86. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
  87. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
  88. package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
  89. package/src/client/components/workspace/diff-panel/changes.ts +28 -12
  90. package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
  91. package/src/client/components/workspace/diff-panel/merge.ts +21 -1
  92. package/src/client/components/workspace/editor/Body.tsx +7 -0
  93. package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
  94. package/src/client/components/workspace/editor/FilePane.tsx +12 -0
  95. package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
  96. package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
  97. package/src/client/components/workspace/editor/index.tsx +25 -22
  98. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
  99. package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
  100. package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
  101. package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
  102. package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
  103. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
  104. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
  105. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
  106. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
  107. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
  108. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
  109. package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
  110. package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
  111. package/src/client/data/agent-data/builtin.ts +0 -10
  112. package/src/client/data/agent-data/orchestrator.ts +0 -45
  113. package/src/client/data/agent-data/specialist.ts +0 -100
  114. package/src/client/data/mock/token-usage.ts +170 -120
  115. package/src/client/data/settings/omp-schema.json +33 -1
  116. package/src/client/hooks/browser/use-annotate.test.ts +143 -0
  117. package/src/client/hooks/browser/use-annotate.ts +98 -0
  118. package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
  119. package/src/client/hooks/browser/use-close-tab.ts +67 -0
  120. package/src/client/hooks/browser/use-screencast.ts +13 -1
  121. package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
  122. package/src/client/hooks/chat/composer/browser-context.ts +40 -16
  123. package/src/client/hooks/chat/composer/items.test.ts +1 -1
  124. package/src/client/hooks/chat/composer/review-context.ts +38 -0
  125. package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
  126. package/src/client/hooks/chat/composer/use-draft.ts +31 -2
  127. package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
  128. package/src/client/hooks/editor/use-document-annotations.ts +124 -0
  129. package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
  130. package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
  131. package/src/client/hooks/editor/use-preview-review.ts +148 -0
  132. package/src/client/hooks/settings/agents.ts +149 -0
  133. package/src/client/hooks/settings/crud-list.test.ts +28 -6
  134. package/src/client/hooks/settings/crud-list.ts +96 -57
  135. package/src/client/hooks/settings/omp-config.ts +164 -0
  136. package/src/client/hooks/settings/useTokenUsage.ts +125 -0
  137. package/src/client/hooks/settings/write-feedback.test.ts +104 -0
  138. package/src/client/hooks/settings/write-feedback.ts +63 -0
  139. package/src/client/hooks/ui/markdown-hydration.ts +125 -0
  140. package/src/client/hooks/ui/updates/index.test.ts +100 -1
  141. package/src/client/hooks/ui/updates/index.ts +50 -0
  142. package/src/client/hooks/ui/updates/notes.test.ts +138 -0
  143. package/src/client/hooks/ui/updates/notes.ts +57 -0
  144. package/src/client/lib/browser/element-at.test.ts +229 -0
  145. package/src/client/lib/browser/element-at.ts +139 -0
  146. package/src/client/lib/review/client.ts +73 -0
  147. package/src/client/lib/router/search-params.ts +42 -20
  148. package/src/client/tailwind.css +65 -0
  149. package/src/server/lib/btw/lifecycle.server.ts +2 -2
  150. package/src/server/lib/db/schema.ts +7 -0
  151. package/src/server/lib/db/seed-terminal.test.ts +4 -0
  152. package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
  153. package/src/server/lib/omp/config/agents.ts +231 -61
  154. package/src/server/lib/omp/config/definitions.test.ts +9 -105
  155. package/src/server/lib/omp/config/extensions.ts +16 -7
  156. package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
  157. package/src/server/lib/omp/rpc/constants.test.ts +11 -0
  158. package/src/server/lib/omp/rpc/constants.ts +15 -0
  159. package/src/server/lib/omp/rpc/process.ts +11 -14
  160. package/src/server/lib/omp/rpc/session-commands.ts +6 -3
  161. package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
  162. package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
  163. package/src/server/lib/omp/rpc/utility.ts +12 -0
  164. package/src/server/lib/review/schema.server.ts +45 -0
  165. package/src/server/lib/review/store.server.ts +138 -0
  166. package/src/server/lib/terminal/attach-replay.test.ts +132 -0
  167. package/src/server/lib/terminal/output.test.ts +166 -0
  168. package/src/server/lib/terminal/output.ts +104 -0
  169. package/src/server/lib/terminal/runtime.server.ts +5 -0
  170. package/src/server/lib/terminal/send-result.test.ts +33 -0
  171. package/src/server/lib/terminal/send-result.ts +32 -0
  172. package/src/server/lib/terminal/session.server.ts +45 -11
  173. package/src/server/lib/terminal/store-liveness.test.ts +4 -0
  174. package/src/server/lib/updates/active-notes.test.ts +149 -0
  175. package/src/server/lib/updates/active-notes.ts +75 -0
  176. package/src/server/lib/updates/changelog-file.ts +42 -11
  177. package/src/server/lib/updates/changelog.test.ts +15 -1
  178. package/src/server/lib/updates/omp.ts +42 -15
  179. package/src/server/lib/updates/release-url.ts +27 -1
  180. package/src/server/lib/usage/index-parse.test.ts +200 -0
  181. package/src/server/lib/usage/index-parse.ts +178 -0
  182. package/src/server/lib/usage/index-query.server.ts +248 -0
  183. package/src/server/lib/usage/index-scan.server.ts +343 -0
  184. package/src/server/lib/usage/index-schema.server.ts +82 -0
  185. package/src/server/lib/usage/index.test.ts +234 -0
  186. package/src/server/lib/usage/providers.server.ts +4 -53
  187. package/src/server/routes/browser/index.ts +3 -0
  188. package/src/server/routes/browser/stream.ts +31 -2
  189. package/src/server/routes/browser/tabs.test.ts +94 -0
  190. package/src/server/routes/browser/tabs.ts +85 -0
  191. package/src/server/routes/index.ts +2 -0
  192. package/src/server/routes/review/bindings.ts +11 -0
  193. package/src/server/routes/review/index.ts +127 -0
  194. package/src/server/routes/review/routes.test.ts +191 -0
  195. package/src/server/routes/settings/agents.test.ts +180 -0
  196. package/src/server/routes/settings/agents.ts +95 -102
  197. package/src/server/routes/settings/mcp.test.ts +135 -0
  198. package/src/server/routes/settings/mcp.ts +14 -6
  199. package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
  200. package/src/server/routes/telemetry/tokens.test.ts +145 -0
  201. package/src/server/routes/telemetry/tokens.ts +70 -149
  202. package/src/server/routes/terminal/ws.ts +6 -5
  203. package/src/server/routes/updates/index.ts +2 -0
  204. package/src/server/routes/updates/notes.ts +34 -0
  205. package/src/server/routes/updates/routes.test.ts +49 -0
  206. package/src/shared/lib/browser/annotate.test.ts +283 -0
  207. package/src/shared/lib/browser/annotate.ts +231 -0
  208. package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
  209. package/src/shared/lib/browser/frame-gate.test.ts +91 -0
  210. package/src/shared/lib/browser/frame-gate.ts +69 -0
  211. package/src/shared/lib/browser/frame-params.test.ts +43 -0
  212. package/src/shared/lib/browser/frame-params.ts +60 -0
  213. package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
  214. package/src/shared/lib/browser/frame-pipeline.ts +80 -0
  215. package/src/shared/lib/browser/page-context.ts +60 -4
  216. package/src/shared/lib/browser/snapshot.test.ts +115 -0
  217. package/src/shared/lib/browser/snapshot.ts +112 -0
  218. package/src/shared/lib/browser/tab-close.test.ts +74 -0
  219. package/src/shared/lib/browser/tab-close.ts +77 -0
  220. package/src/shared/lib/browser/viewer.ts +45 -26
  221. package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
  222. package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
  223. package/src/shared/lib/chat/tool/artifact.ts +55 -20
  224. package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
  225. package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
  226. package/src/shared/lib/chat/tool/minimized.ts +64 -0
  227. package/src/shared/lib/chat/tool/summary.test.ts +28 -8
  228. package/src/shared/lib/chat/tool/summary.ts +3 -32
  229. package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
  230. package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
  231. package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
  232. package/src/shared/lib/markdown/blocks/scan.ts +100 -0
  233. package/src/shared/lib/markdown/blocks/types.ts +62 -0
  234. package/src/shared/lib/markdown/marked.ts +58 -147
  235. package/src/shared/lib/markdown/math-extensions.ts +168 -0
  236. package/src/shared/lib/markdown/review/prompt.ts +77 -0
  237. package/src/shared/lib/markdown/review/reconcile.ts +55 -0
  238. package/src/shared/lib/markdown/review/review.test.ts +96 -0
  239. package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
  240. package/src/shared/lib/markdown/xml-sections.ts +139 -0
  241. package/src/shared/lib/models/provider/label.ts +57 -0
  242. package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
  243. package/src/shared/lib/omp/config/agent-file.ts +43 -0
  244. package/src/shared/lib/omp/config/row-value.test.ts +95 -0
  245. package/src/shared/lib/omp/config/row-value.ts +97 -0
  246. package/src/shared/lib/omp/config/schema.test.ts +31 -0
  247. package/src/shared/lib/omp/config/schema.ts +6 -0
  248. package/src/shared/lib/omp/rpc/frame.test.ts +48 -47
  249. package/src/shared/lib/omp/rpc/frame.ts +49 -40
  250. package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
  251. package/src/shared/lib/ui/menu-anchor.ts +89 -0
  252. package/src/shared/lib/usage/breakdown.test.ts +197 -0
  253. package/src/shared/lib/usage/breakdown.ts +241 -0
  254. package/src/shared/lib/usage/range.test.ts +204 -0
  255. package/src/shared/lib/usage/range.ts +240 -0
  256. package/src/shared/lib/usage/view.test.ts +85 -0
  257. package/src/shared/lib/usage/view.ts +74 -0
  258. package/src/shared/types/browser.ts +78 -0
  259. package/src/shared/types/index.ts +1 -0
  260. package/src/shared/types/settings/agent.ts +28 -6
  261. package/src/shared/types/settings/state.ts +4 -3
  262. package/src/shared/types/settings/write.ts +6 -0
  263. package/src/shared/types/tokenUsage.ts +128 -21
  264. package/src/shared/types/updates.ts +20 -0
  265. package/dist/client/static/js/index-3ve31rzx.css +0 -1
  266. package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
  267. package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
  268. package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
  269. package/src/server/lib/omp/session/usage/shaping.ts +0 -130
@@ -1,5 +1,5 @@
1
1
  import { useState } from 'preact/hooks';
2
- import { Check, Copy, ExternalLink, MessageSquarePlus } from 'lucide-preact';
2
+ import { Check, Copy, ExternalLink, MessageSquarePlus, SquarePen } from 'lucide-preact';
3
3
  import { BrowserViewportSelector } from '@/client/components/common/ViewportSelector';
4
4
  import { ZoomControls } from '@/client/components/workspace/browser-toolbar/ZoomControls';
5
5
  import type { ComponentChildren } from 'preact';
@@ -8,6 +8,13 @@ import type { ViewportMode } from '@/shared/types';
8
8
  export const ICON_BUTTON =
9
9
  'p-1.5 rounded hover:bg-ink/5 disabled:opacity-25 disabled:hover:bg-transparent text-ink/70 hover:text-ink transition-colors cursor-pointer disabled:cursor-not-allowed';
10
10
 
11
+ /** The user panel's annotation toggle; the agent panel never supplies it. */
12
+ export interface BrowserToolbarAnnotate {
13
+ active: boolean;
14
+ count: number;
15
+ onToggle: () => void;
16
+ }
17
+
11
18
  export interface BrowserToolbarProps {
12
19
  url: string;
13
20
  /** Status dot class plus its label — the only per-panel difference. */
@@ -29,6 +36,13 @@ export interface BrowserToolbarProps {
29
36
  viewportMode?: ViewportMode;
30
37
  onChangeViewport?: (mode: ViewportMode) => void;
31
38
  onSetZoom?: (zoom: number) => void;
39
+ /**
40
+ * Annotation mode, rendered only when supplied. The USER panel passes it: its
41
+ * marks are normalized against a measured iframe box. The AGENT panel does
42
+ * not — its surface is the agent's own live view, so the user annotates the
43
+ * page by asking the agent instead of drawing on a JPEG.
44
+ */
45
+ annotate?: BrowserToolbarAnnotate;
32
46
  /** Shown after the include/copy buttons — the agent panel's reconnect button. */
33
47
  trailingControls?: ComponentChildren;
34
48
  /** Open-external button label/title, differing between the two panels. */
@@ -57,6 +71,7 @@ export function BrowserToolbar({
57
71
  onZoomOut,
58
72
  onResetZoom,
59
73
  onSetZoom,
74
+ annotate,
60
75
  onIncludeInChat,
61
76
  onOpenExternal,
62
77
  trailingControls,
@@ -121,6 +136,31 @@ export function BrowserToolbar({
121
136
  {included ? <Check size={14} className="text-success" /> : <MessageSquarePlus size={14} />}
122
137
  </button>
123
138
 
139
+ {annotate && (
140
+ <button
141
+ type="button"
142
+ onClick={annotate.onToggle}
143
+ disabled={!url}
144
+ aria-label="Mode anotasi halaman"
145
+ aria-pressed={annotate.active}
146
+ title={
147
+ annotate.active
148
+ ? 'Tutup mode anotasi'
149
+ : annotate.count > 0
150
+ ? `Anotasi (${annotate.count}) — buka lagi`
151
+ : 'Tandai bagian halaman lalu kirim ke chat'
152
+ }
153
+ className={`${ICON_BUTTON} relative ${annotate.active ? 'bg-ink/10 text-ink' : ''}`}
154
+ >
155
+ <SquarePen size={14} />
156
+ {annotate.count > 0 && (
157
+ <span className="absolute -top-0.5 -right-0.5 min-w-[13px] h-[13px] px-0.5 rounded-full bg-error text-paper text-[9px] leading-[13px] font-mono text-center">
158
+ {annotate.count}
159
+ </span>
160
+ )}
161
+ </button>
162
+ )}
163
+
124
164
  <button
125
165
  type="button"
126
166
  onClick={handleCopy}
@@ -56,7 +56,9 @@ export function ThinkingSection({
56
56
  }: ThinkingSectionProps) {
57
57
  const mode = useToolRenderMode();
58
58
  const chrome = blockChrome(mode);
59
- const framed = mode === 'card';
59
+ // Whether the style draws a FRAME is the chrome's own fact, not the mode's
60
+ // name: `card` boxes the block, `compact`/`trace`/`minimal`/`tui` are lines.
61
+ const framed = chrome.frame !== '';
60
62
 
61
63
  const isGenerating = typeof thinking === 'object' ? Boolean(thinking.isGenerating) : false;
62
64
  const { isOpen, toggle: toggleOpen } = useThinkingOpenState(messageId, defaultExpanded, isGenerating);
@@ -33,6 +33,7 @@ import { CardRow } from '@/client/components/workspace/chat-timeline/tool-render
33
33
  import { CompactRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Compact';
34
34
  import { TraceRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Trace';
35
35
  import { MinimalRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal';
36
+ import { TuiRow } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/Tui';
36
37
  import type { ToolRowProps } from '@/client/components/workspace/chat-timeline/tool-renderers/styles/props';
37
38
 
38
39
  interface ToolCallingSectionProps {
@@ -48,6 +49,7 @@ const ROW_BY_MODE: Record<ToolRenderMode, FunctionComponent<ToolRowProps>> = {
48
49
  compact: CompactRow,
49
50
  trace: TraceRow,
50
51
  minimal: MinimalRow,
52
+ tui: TuiRow,
51
53
  };
52
54
 
53
55
  function normalizeToolData(action: ToolCallData | AgentActionData, index: number): ToolCallData {
@@ -86,10 +86,12 @@ async function paint(style: string, node: preact.ComponentChildren): Promise<HTM
86
86
  }
87
87
 
88
88
  describe('blockChrome', () => {
89
- test('only the card style has a frame', () => {
89
+ test('only the card style has a frame; tui is a line of text like its siblings', () => {
90
90
  expect(blockChrome('card').frame).toContain('rounded-xl');
91
91
  expect(blockChrome('card').frame).toContain('border-ink/10');
92
- for (const mode of ['compact', 'trace', 'minimal'] as const) {
92
+ // `tui` is NOT a card: no border, no fill. Its shape lives in the header
93
+ // row's type and colour, not in a box.
94
+ for (const mode of ['compact', 'trace', 'minimal', 'tui'] as const) {
93
95
  expect(blockChrome(mode).frame).toBe('');
94
96
  }
95
97
  });
@@ -100,6 +102,7 @@ describe('blockChrome', () => {
100
102
  expect(blockChrome('compact').node).toBeUndefined();
101
103
  expect(blockChrome('card').node).toBeUndefined();
102
104
  expect(blockChrome('minimal').node).toBeUndefined();
105
+ expect(blockChrome('tui').node).toBeUndefined();
103
106
  });
104
107
 
105
108
  test('the minimal style is the smallest type, the frame styles the largest', () => {
@@ -108,6 +111,14 @@ describe('blockChrome', () => {
108
111
  expect(blockChrome('card').header).toContain('px-3 py-2.5');
109
112
  expect(blockChrome('compact').header).toContain('py-1');
110
113
  });
114
+
115
+ test('the tui header is terminal text: monospace, accent name, meta subject', () => {
116
+ expect(blockChrome('tui').header).toContain('font-mono');
117
+ expect(blockChrome('tui').title).toContain('text-info');
118
+ expect(blockChrome('tui').subtitle).toContain('text-meta');
119
+ expect(blockChrome('tui').body).toContain('font-mono');
120
+ expect(blockChrome('tui').header).not.toBe(blockChrome('card').header);
121
+ });
111
122
  });
112
123
 
113
124
  describe('thinking follows the render style', () => {
@@ -0,0 +1,88 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `bash` card for a result omp's shell minimizer rewrote (18.16.0).
8
+ *
9
+ * The panel used to draw the compressed body with nothing saying so: a
10
+ * `git --no-pager log` that lost 7 KB of commits looked like the command's own
11
+ * output. The record omp sends is
12
+ *
13
+ * details.meta.minimized = { filter: 'git', inputBytes: 10970,
14
+ * outputBytes: 3905, artifactId: '0' }
15
+ *
16
+ * and this pins that the card states it, and that a result the minimizer left
17
+ * alone says nothing rather than drawing an empty strip.
18
+ *
19
+ * Rendered with `h()` against happy-dom, following `panels/Edit.test.ts`.
20
+ */
21
+
22
+ import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
23
+ import { Window } from 'happy-dom';
24
+ import { h, render } from 'preact';
25
+ import { act } from 'preact/test-utils';
26
+ import { Bash } from '@/client/components/workspace/chat-timeline/tool-renderers/panels/Bash';
27
+ import type { ToolCallData } from '@/shared/types';
28
+
29
+ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'HTMLInputElement', 'Event', 'MouseEvent', 'KeyboardEvent'] as const;
30
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
31
+
32
+ let container: HTMLElement;
33
+
34
+ beforeAll(() => {
35
+ const win = new Window({ url: 'http://localhost' });
36
+ const target = globalThis as unknown as Record<string, unknown>;
37
+ for (const key of DOM_GLOBALS) {
38
+ nativeGlobals[key] = target[key];
39
+ target[key] = (win as unknown as Record<string, unknown>)[key];
40
+ }
41
+ });
42
+
43
+ afterAll(() => {
44
+ const target = globalThis as unknown as Record<string, unknown>;
45
+ for (const key of DOM_GLOBALS) {
46
+ if (nativeGlobals[key] === undefined) delete target[key];
47
+ else target[key] = nativeGlobals[key];
48
+ }
49
+ });
50
+
51
+ async function mount(details: Record<string, unknown>): Promise<HTMLElement> {
52
+ container = document.createElement('div');
53
+ document.body.appendChild(container);
54
+ const tool = {
55
+ id: 'c1',
56
+ type: 'bash',
57
+ name: 'bash',
58
+ title: 'bash',
59
+ command: 'git --no-pager log',
60
+ output: 'b7b0b41 commit number 60\n6c1bd61 commit number 59',
61
+ status: 'success',
62
+ details,
63
+ } as ToolCallData;
64
+ await act(async () => {
65
+ render(h(Bash, { tool }), container);
66
+ });
67
+ return container;
68
+ }
69
+
70
+ describe('bash panel — minimized output', () => {
71
+ test('states the filter that ran and both byte sizes', async () => {
72
+ const el = await mount({
73
+ wallTimeMs: 412,
74
+ meta: { minimized: { filter: 'git', inputBytes: 10970, outputBytes: 3905, artifactId: '0' } },
75
+ });
76
+ const text = el.textContent ?? '';
77
+ expect(text).toContain('Minimized');
78
+ expect(text).toContain('git');
79
+ expect(text).toContain('10.7 KB');
80
+ expect(text).toContain('3.8 KB');
81
+ expect(text).toContain('the output below is the filtered rewrite');
82
+ });
83
+
84
+ test('says nothing when the minimizer left the output alone', async () => {
85
+ const el = await mount({ wallTimeMs: 12, meta: { limits: {} } });
86
+ expect(el.textContent ?? '').not.toContain('Minimized');
87
+ });
88
+ });
@@ -1,7 +1,9 @@
1
1
  import { useMemo } from 'preact/hooks';
2
- import { Check, Clock, Server, Terminal } from 'lucide-preact';
2
+ import { Check, Clock, Server, Shrink, Terminal } from 'lucide-preact';
3
3
  import type { ToolCallData } from '@/shared/types';
4
4
  import { bashServiceOf, daemonTone, procUptime } from '@/shared/lib/omp/session/proc';
5
+ import { formatToolBytes } from '@/shared/lib/chat/tool/labels';
6
+ import { minimizedOutputOf } from '@/shared/lib/chat/tool/minimized';
5
7
  import { CopyButton } from '@/client/components/common/CopyButton';
6
8
  import { stripAnsiCodes } from '@/shared/lib/code/ansi';
7
9
  import { isCodeLike } from '@/shared/lib/code/language';
@@ -83,6 +85,7 @@ export function Bash({ tool }: { tool: ToolCallData }) {
83
85
  const service = bashServiceOf(tool);
84
86
  const serviceTone = daemonTone(service?.state);
85
87
  const serviceUptime = service ? procUptime(service) : undefined;
88
+ const minimized = minimizedOutputOf(tool);
86
89
 
87
90
  return (
88
91
  <div className="space-y-2">
@@ -141,6 +144,26 @@ export function Bash({ tool }: { tool: ToolCallData }) {
141
144
  </div>
142
145
  )}
143
146
 
147
+ {/* omp 18.16.0 compresses verbose shell output before returning it. The
148
+ body below is the REWRITE, so a card that said nothing about it looked
149
+ like the command had produced that text — `git log` lost 6 KB and the
150
+ reader had no way to know. Naming the filter and both sizes is what
151
+ omp's own TUI does; the full output is behind the artifact chip. */}
152
+ {minimized && (
153
+ <div className="flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg border border-ink/8 bg-paper px-3 py-2 font-mono text-[10.5px]">
154
+ <span className="flex items-center gap-1.5 text-[9.5px] font-semibold uppercase tracking-wider text-ink/40">
155
+ <Shrink size={11} className="text-ink/40" />
156
+ Minimized
157
+ </span>
158
+ <span className="font-semibold text-ink">{minimized.filter}</span>
159
+ <span className="text-ink/45">
160
+ <strong className="text-ink">{formatToolBytes(minimized.inputBytes)}</strong> {'→'}{' '}
161
+ <strong className="text-ink">{formatToolBytes(minimized.outputBytes)}</strong>
162
+ </span>
163
+ <span className="text-ink/35">the output below is the filtered rewrite</span>
164
+ </div>
165
+ )}
166
+
144
167
  {/* Terminal Command Window */}
145
168
  {command && (
146
169
  <div className="overflow-hidden rounded-lg border border-ink/10 bg-paper">
@@ -153,6 +153,40 @@ describe('Read panel — language and markdown', () => {
153
153
  expect(rendered).toContain('Static content? Use read.');
154
154
  });
155
155
 
156
+ test('an xd:// doc sectioned with XML wrappers renders headings, not tags', async () => {
157
+ // omp's `xd://eval/browser` docs mark `<instruction>`, `<examples>` and
158
+ // `<critical>` as XML wrappers rather than `##` headings. Prose escapes its
159
+ // own HTML, so the panel printed the wrapper lines literally and every
160
+ // section ran together as one block.
161
+ const text = [
162
+ 'Drive real Chromium tabs.',
163
+ '',
164
+ '<instruction>',
165
+ '- Static content? Use `read`.',
166
+ '</instruction>',
167
+ '',
168
+ '<critical>',
169
+ '- MUST open a tab before direct use.',
170
+ '</critical>',
171
+ ].join('\n');
172
+ const el = await mount(readTool({
173
+ target: 'xd://eval/browser',
174
+ input: { path: 'xd://eval/browser' },
175
+ output: text.split('\n').map((line, index) => `${index + 1}|${line}`).join('\n'),
176
+ details: {
177
+ contentType: 'text/plain',
178
+ totalLines: 9,
179
+ displayContent: { text, startLine: 1, lineNumbers: [1, 2, 3, 4, 5, 6, 7, 8, 9] },
180
+ },
181
+ }));
182
+ const rendered = el.textContent ?? '';
183
+ const headings = Array.from(el.querySelectorAll('h2')).map((node) => node.textContent);
184
+ expect(headings).toEqual(['Instruction', 'Critical']);
185
+ expect(rendered).not.toContain('<instruction>');
186
+ expect(rendered).not.toContain('</instruction>');
187
+ expect(el.querySelectorAll('ul li').length).toBe(2);
188
+ });
189
+
156
190
  test('a one-row doc read keeps its line-number gutter out of the prose', async () => {
157
191
  // omp's raw output prefixes every row with its line number, and the
158
192
  // stripper needs two numbered rows to recognise the format — so the real
@@ -7,6 +7,7 @@ import { getImageMimeType } from '@/shared/lib/fs/file-kind';
7
7
  import { buildFsRawUrl, isVirtualPath, stripReadSelector } from '@/shared/lib/fs/paths';
8
8
  import { toolImageSrc } from '@/shared/lib/omp/session/tool-images';
9
9
  import { MarkdownRenderer } from '@/client/components/common/MarkdownRenderer';
10
+ import { xmlSectionsToHeadings } from '@/shared/lib/markdown/xml-sections';
10
11
  import type { ToolCallData } from '@/shared/types/chat';
11
12
  import { MAX_OUTPUT_LINES, truncateTailLines } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/truncate';
12
13
  import { extractLineMeta } from '@/client/components/workspace/chat-timeline/tool-renderers/shared/read-line-meta';
@@ -185,6 +186,9 @@ export function Read({ tool, targetFilePath, output }: ReadPanelProps) {
185
186
  * stripper that serves every other read keeps a one-row document's `1|`
186
187
  * prefix (it needs two numbered rows to recognise the format). */
187
188
  const markdownContent = displayText || parsedCode.cleanCode || displayContent;
189
+ /** An omp doc marks some sections with XML wrappers (`<instruction>…`), and
190
+ * prose escapes its own HTML: parse them as headings. Copy keeps the file. */
191
+ const markdownSource = useMemo(() => xmlSectionsToHeadings(markdownContent), [markdownContent]);
188
192
 
189
193
  const visibleEntries = dirInfo.entries.slice(-MAX_OUTPUT_LINES);
190
194
  const skippedEntries = dirInfo.entries.length - visibleEntries.length;
@@ -299,7 +303,7 @@ export function Read({ tool, targetFilePath, output }: ReadPanelProps) {
299
303
  two numbered rows to recognise the format, so a one-row document
300
304
  (`read xd://propose`) kept its prefix through it. */
301
305
  <div className="max-h-80 overflow-auto rounded-lg border border-ink/8 bg-paper px-3.5 py-3 select-text">
302
- <MarkdownRenderer content={markdownContent} className="text-[12.5px] text-ink/85" />
306
+ <MarkdownRenderer content={markdownSource} className="text-[12.5px] text-ink/85" />
303
307
  </div>
304
308
  ) : rawContent ? (
305
309
  /* Render Code Content with synchronized, straight line numbers and clean code */
@@ -4,13 +4,14 @@
4
4
  */
5
5
 
6
6
  /**
7
- * "Full output" — the chip that opens the stream omp spilled to disk.
7
+ * "Full output" — the chip that opens the stream omp kept beside the session.
8
8
  *
9
- * When a tool result is too long omp keeps only a truncated body in the
10
- * transcript and writes the whole thing beside the session, leaving an
11
- * `artifactId` in `details.meta.limits`. Measured over 5,441 real results, 65
12
- * carry one — and they are the longest outputs in the corpus, so the reader was
13
- * stopped at 768 bytes exactly where they wanted the rest.
9
+ * Two records name one, and both are reachable here (`artifactRefOf`):
10
+ * a result too long to keep inline leaves `details.meta.limits.columnTruncated`
11
+ * — measured over 5,441 real results, 65 carry one, and they are the longest
12
+ * outputs in the corpus — and since 18.16.0 a result the shell minimizer
13
+ * REWROTE carries `details.meta.minimized`, whose file is the lossless original
14
+ * of the compressed body on screen.
14
15
  *
15
16
  * The chip lives in the card's action slot rather than inside a panel: it must
16
17
  * be reachable without expanding anything, because the reason it exists is that
@@ -0,0 +1,237 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The `tui` style — omp's terminal transcript, drawn as coloured text.
8
+ *
9
+ * The style is deliberately NOT a card: omp's terminal writes a call as a
10
+ * status line (`✔ Bash: bun test [done] · 599ms`), and the colour carries what
11
+ * a box would otherwise carry with borders. These are the properties that make
12
+ * it that line rather than a recoloured card.
13
+ *
14
+ * - No frame at all — no border, no fill, no radius on the row. A regression
15
+ * that reintroduces a card is visible here as a class.
16
+ * - Three separate claims, three separate colours: the outcome (`--theme-success`
17
+ * / `--theme-error` / `--theme-info` for a live run), the tool NAME in the
18
+ * accent, the SUBJECT in the meta hue. Merging the last two is the reported
19
+ * defect — the head then reads as one undifferentiated run of text.
20
+ * - Facts are terminal text (`599ms · exit 0`), not pills, and a diff keeps
21
+ * `+4` green and `−1` red inside one statement.
22
+ * - The head is the toggle, with the SHARED wording (`toolToggleLabel`), so
23
+ * `chat.e2e.ts`'s `[aria-label^="Expand "]` collection and `mobile.e2e.ts`'s
24
+ * `/^Expand Bash/` click still work, and the section's per-call intent
25
+ * heading is untouched (it is drawn outside the renderer).
26
+ */
27
+
28
+ import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
29
+ import { Window } from 'happy-dom';
30
+ import { h, render } from 'preact';
31
+ import { act } from 'preact/test-utils';
32
+ import { ToolCallingSection } from '@/client/components/workspace/chat-timeline/ToolCallingSection';
33
+ import { SessionStateProvider } from '@/client/components/common/session-state-provider';
34
+ import { primeKabmoSettings } from '@/shared/lib/settings/client';
35
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
36
+ import type { ToolCallData } from '@/shared/types/chat';
37
+
38
+ let container: HTMLElement;
39
+
40
+ beforeAll(() => installDomGlobals(new Window({ url: 'http://localhost' })));
41
+ afterAll(() => restoreDomGlobals());
42
+
43
+ beforeEach(() => {
44
+ primeKabmoSettings({ kabmo_settings: { toolRenderStyle: 'tui' } });
45
+ container = document.createElement('div');
46
+ document.body.appendChild(container);
47
+ });
48
+
49
+ afterEach(() => {
50
+ render(null, container);
51
+ container.remove();
52
+ });
53
+
54
+ const OK_TOOL: ToolCallData = {
55
+ id: 'tui-ok',
56
+ type: 'bash',
57
+ name: 'bash',
58
+ title: 'Bash',
59
+ status: 'success',
60
+ command: 'bun test',
61
+ detail: 'bun test',
62
+ output: 'TUI_OUTPUT_TOKEN',
63
+ intent: 'Running the suite',
64
+ details: { wallTimeMs: 599, exitCode: 0 },
65
+ } as ToolCallData;
66
+
67
+ const FAILED_TOOL: ToolCallData = {
68
+ id: 'tui-fail',
69
+ type: 'bash',
70
+ name: 'bash',
71
+ title: 'Bash',
72
+ status: 'error',
73
+ command: 'bun test',
74
+ detail: 'bun test',
75
+ output: 'boom',
76
+ details: { exitCode: 1 },
77
+ } as ToolCallData;
78
+
79
+ const RUNNING_TOOL: ToolCallData = {
80
+ id: 'tui-run',
81
+ type: 'bash',
82
+ name: 'bash',
83
+ title: 'Bash',
84
+ status: 'running',
85
+ command: 'bun run build',
86
+ detail: 'bun run dev',
87
+ output: '',
88
+ } as ToolCallData;
89
+
90
+ const EDIT_TOOL: ToolCallData = {
91
+ id: 'tui-edit',
92
+ type: 'edit_file',
93
+ name: 'edit',
94
+ title: 'Edit',
95
+ status: 'success',
96
+ target: 'src/app.ts',
97
+ detail: 'src/app.ts',
98
+ output: 'Applied 6 changes.',
99
+ details: { diff: 'a\n+b\n+c\n-d\n' },
100
+ } as ToolCallData;
101
+
102
+ async function mount(tools: ToolCallData[]): Promise<HTMLElement> {
103
+ await act(async () => {
104
+ render(
105
+ h(SessionStateProvider, {
106
+ sessionId: 'spec-tui',
107
+ children: h(ToolCallingSection, { tools }),
108
+ }),
109
+ container,
110
+ );
111
+ });
112
+ return container;
113
+ }
114
+
115
+ function row(el: HTMLElement): HTMLElement {
116
+ const found = el.querySelector('[data-tool-row="tui"]');
117
+ if (!found) throw new Error('no tui row');
118
+ return found as HTMLElement;
119
+ }
120
+
121
+ function head(el: HTMLElement): HTMLElement {
122
+ return row(el).querySelector('button') as HTMLElement;
123
+ }
124
+
125
+ /** The head's own spans, in order: glyph wrapper, title, subject, outcome… */
126
+ function headClasses(el: HTMLElement): string[] {
127
+ return Array.from(head(el).children).map((child) => (child as HTMLElement).className);
128
+ }
129
+
130
+ describe('the tui style', () => {
131
+ test('the section announces the style and draws a LINE, not a card', async () => {
132
+ const el = await mount([OK_TOOL]);
133
+ expect(el.querySelector('[data-tool-section]')?.getAttribute('data-tool-style')).toBe('tui');
134
+
135
+ const frame = row(el);
136
+ expect(frame.className).toContain('font-mono');
137
+ // No card: no border, no fill, no rounded frame on the row.
138
+ expect(frame.className).not.toContain('border');
139
+ expect(frame.className).not.toContain('rounded');
140
+ expect(frame.className).not.toContain('bg-');
141
+ });
142
+
143
+ test('the head is one status line: glyph, title, subject, bracketed outcome', async () => {
144
+ const el = await mount([OK_TOOL]);
145
+ const text = head(el).textContent ?? '';
146
+ expect(text).toContain('Bash');
147
+ expect(text).toContain(':');
148
+ expect(text).toContain('bun test');
149
+ // A one-line head carries the outcome as a word, not as the card's badge.
150
+ expect(text).toContain('[done]');
151
+ // …and the same word for a screen reader, from the shared glyph table.
152
+ expect(head(el).querySelector('.sr-only')?.textContent).toBe('Done');
153
+ });
154
+
155
+ test('title and subject are different colours', async () => {
156
+ const el = await mount([OK_TOOL]);
157
+ const classes = headClasses(el);
158
+ // The name is the accent, the subject the meta hue — the two halves of the
159
+ // head must never render as one undifferentiated string.
160
+ const title = classes.find((cls) => cls.includes('text-info'));
161
+ const subject = classes.find((cls) => cls.includes('text-meta'));
162
+ expect(title).toBeDefined();
163
+ expect(subject).toBeDefined();
164
+ expect(title).not.toBe(subject);
165
+ });
166
+
167
+ test('the outcome colour follows the call state', async () => {
168
+ const ok = await mount([OK_TOOL]);
169
+ expect(head(ok).textContent).toContain('[done]');
170
+ expect(headClasses(ok).some((cls) => cls.includes('text-success'))).toBe(true);
171
+
172
+ render(null, container);
173
+ const failed = await mount([FAILED_TOOL]);
174
+ expect(head(failed).textContent).toContain('[failed]');
175
+ expect(headClasses(failed).some((cls) => cls.includes('text-error'))).toBe(true);
176
+
177
+ render(null, container);
178
+ const running = await mount([RUNNING_TOOL]);
179
+ expect(head(running).textContent).toContain('[running]');
180
+ expect(headClasses(running).some((cls) => cls.includes('text-info'))).toBe(true);
181
+ });
182
+
183
+ test('the collapsed line states the facts as terminal text', async () => {
184
+ const el = await mount([OK_TOOL]);
185
+ const text = row(el).textContent ?? '';
186
+ expect(text).toContain('599ms');
187
+ expect(text).toContain('exit 0');
188
+ // One statement, not a row of pills.
189
+ expect(text).toContain('·');
190
+ // The facts are NOT behind the toggle: they are on the collapsed line.
191
+ expect(head(el).textContent).toContain('599ms');
192
+ });
193
+
194
+ test('expanding shows the shared body and collapsing hides it', async () => {
195
+ const el = await mount([OK_TOOL]);
196
+ expect(head(el).getAttribute('aria-label')).toBe('Expand Bash — bun test');
197
+ expect(el.querySelector('.code-surface')).toBeNull();
198
+
199
+ await act(async () => {
200
+ head(el).click();
201
+ });
202
+ expect(head(el).getAttribute('aria-expanded')).toBe('true');
203
+ expect(head(el).getAttribute('aria-label')).toBe('Collapse Bash — bun test');
204
+ expect(el.querySelector('.code-surface')).not.toBeNull();
205
+ expect(row(el).textContent).toContain('TUI_OUTPUT_TOKEN');
206
+
207
+ await act(async () => {
208
+ head(el).click();
209
+ });
210
+ expect(el.querySelector('.code-surface')).toBeNull();
211
+ });
212
+
213
+ test('a diff keeps its two halves coloured inside one fact', async () => {
214
+ const el = await mount([EDIT_TOOL]);
215
+ const text = row(el).textContent ?? '';
216
+ expect(text).toContain('+2');
217
+ expect(text).toContain('−1');
218
+ const marks = Array.from(row(el).querySelectorAll('.text-success, .text-error')) as HTMLElement[];
219
+ expect(marks.some((node) => node.textContent === '+2')).toBe(true);
220
+ expect(marks.some((node) => node.textContent === '−1')).toBe(true);
221
+ });
222
+
223
+ test('the per-card intent heading the section draws survives the style', async () => {
224
+ const el = await mount([OK_TOOL]);
225
+ expect(el.textContent).toContain('Running the suite');
226
+ });
227
+
228
+ test('the toggle affordance follows the open state', async () => {
229
+ const el = await mount([OK_TOOL]);
230
+ // `▸` closed, `▾` open — omp's own navigator glyphs.
231
+ expect(row(el).textContent).toContain('▸');
232
+ await act(async () => {
233
+ head(el).click();
234
+ });
235
+ expect(row(el).textContent).toContain('▾');
236
+ });
237
+ });