@kabmo-labs/kabmo 0.17.0 → 0.19.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 (438) hide show
  1. package/README.md +10 -7
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +523 -441
  4. package/dist/client/static/js/{index-rerjq5th.js → index-fcee4c13.js} +828 -818
  5. package/dist/client/static/js/index-sxdw908m.css +1 -0
  6. package/marketplace/plugins/command-runner/package.json +3 -2
  7. package/marketplace/plugins/git-forge/package.json +3 -2
  8. package/marketplace/plugins/session-info/package.json +3 -2
  9. package/marketplace/plugins/stats/package.json +3 -2
  10. package/package.json +3 -1
  11. package/src/client/components/auth/login-screen/index.tsx +2 -1
  12. package/src/client/components/common/ComposerPicker.tsx +1 -1
  13. package/src/client/components/common/FolderPicker.tsx +2 -2
  14. package/src/client/components/common/MarkdownRenderer.tsx +136 -89
  15. package/src/client/components/common/Modal.tsx +2 -2
  16. package/src/client/components/common/PWAInstallButton.tsx +2 -2
  17. package/src/client/components/common/ViewportSelector.tsx +1 -1
  18. package/src/client/components/common/anchored-menu/index.test.tsx +141 -0
  19. package/src/client/components/common/anchored-menu/index.tsx +147 -0
  20. package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
  21. package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
  22. package/src/client/components/common/brand-wordmark/index.tsx +13 -2
  23. package/src/client/components/common/checkbox/style.test.ts +139 -0
  24. package/src/client/components/common/checkbox/style.ts +51 -0
  25. package/src/client/components/common/context-usage-button/index.tsx +2 -2
  26. package/src/client/components/common/file-icon/index.tsx +23 -9
  27. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  28. package/src/client/components/common/markdown-review/ReviewPopover.tsx +144 -0
  29. package/src/client/components/common/markdown-review/ReviewSummary.tsx +108 -0
  30. package/src/client/components/common/markdown-review/index.tsx +129 -0
  31. package/src/client/components/common/panel-mark/index.tsx +97 -0
  32. package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
  33. package/src/client/components/common/provider-icon/index.test.ts +14 -0
  34. package/src/client/components/common/provider-icon/index.tsx +4 -0
  35. package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
  36. package/src/client/components/common/provider-icon/resolve.ts +16 -3
  37. package/src/client/components/common/server-control/Panel.tsx +33 -23
  38. package/src/client/components/common/server-control/index.test.tsx +11 -5
  39. package/src/client/components/common/server-control/index.tsx +10 -8
  40. package/src/client/components/common/session-actions-menu/index.tsx +1 -1
  41. package/src/client/components/common/toolbar-row/index.tsx +1 -1
  42. package/src/client/components/layout/ActivityBar.tsx +22 -3
  43. package/src/client/components/layout/LeftDock.tsx +9 -2
  44. package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
  45. package/src/client/components/layout/WindowAura.tsx +27 -0
  46. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
  47. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
  48. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
  49. package/src/client/components/layout/desktop-layout/index.tsx +3 -1
  50. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +44 -23
  51. package/src/client/components/layout/session-sidebar/CategoryHeader.worktree.test.tsx +36 -17
  52. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +8 -7
  53. package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
  54. package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
  55. package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
  56. package/src/client/components/layout/session-sidebar/about-modal/NotesDialog.tsx +94 -0
  57. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.test.tsx +68 -0
  58. package/src/client/components/layout/session-sidebar/about-modal/VersionLine.tsx +36 -0
  59. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +57 -34
  60. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
  61. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +40 -14
  62. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +7 -6
  63. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +1 -1
  64. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  65. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
  66. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
  67. package/src/client/components/layout/update-popup/ReleaseNotes.tsx +8 -3
  68. package/src/client/components/layout/update-popup/index.tsx +5 -1
  69. package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
  70. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  71. package/src/client/components/mobile/mobile-right-sidebar/FullEditor.tsx +13 -15
  72. package/src/client/components/mobile/mobile-right-sidebar/Header.tsx +23 -1
  73. package/src/client/components/mobile/mobile-right-sidebar/MissingFileBanner.tsx +30 -0
  74. package/src/client/components/mobile/mobile-right-sidebar/PreviewScroller.tsx +18 -2
  75. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
  76. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +22 -67
  77. package/src/client/components/mobile/mobile-session-sidebar/ItemMenu.tsx +110 -0
  78. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  79. package/src/client/components/mobile/panel-chips.tsx +10 -2
  80. package/src/client/components/settings/Modal.tsx +4 -4
  81. package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
  82. package/src/client/components/settings/SettingsSidebarList.tsx +20 -0
  83. package/src/client/components/settings/apply-side-effects.test.ts +30 -0
  84. package/src/client/components/settings/apply-side-effects.ts +14 -0
  85. package/src/client/components/settings/categories/AgentSettings.tsx +23 -50
  86. package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
  87. package/src/client/components/settings/categories/CommandSettings.tsx +2 -2
  88. package/src/client/components/settings/categories/McpSettings.tsx +4 -21
  89. package/src/client/components/settings/categories/OmpSettings.tsx +147 -194
  90. package/src/client/components/settings/categories/SkillSettings.tsx +2 -2
  91. package/src/client/components/settings/categories/TokenUsageSettings.tsx +211 -229
  92. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +229 -237
  93. package/src/client/components/settings/categories/agent-settings/ModelPicker.tsx +71 -0
  94. package/src/client/components/settings/categories/agent-settings/SidebarList.tsx +9 -2
  95. package/src/client/components/settings/categories/agent-settings/levels.ts +38 -0
  96. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
  97. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
  98. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
  99. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
  100. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
  101. package/src/client/components/settings/categories/behavior-settings/Editor.tsx +27 -7
  102. package/src/client/components/settings/categories/chat-settings/ToolRenderSection.tsx +23 -5
  103. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +75 -33
  104. package/src/client/components/settings/categories/command-settings/SidebarList.tsx +7 -0
  105. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +93 -77
  106. package/src/client/components/settings/categories/mcp-settings/EnvVarsSection.tsx +83 -0
  107. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +28 -15
  108. package/src/client/components/settings/categories/mcp-settings/SidebarList.tsx +20 -0
  109. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +97 -36
  110. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +151 -0
  111. package/src/client/components/settings/categories/omp-settings/ExtensionsPanel.tsx +68 -32
  112. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +119 -0
  113. package/src/client/components/settings/categories/omp-settings/PresetBar.tsx +14 -7
  114. package/src/client/components/settings/categories/omp-settings/RoleEditor.tsx +15 -6
  115. package/src/client/components/settings/categories/omp-settings/RowEditor.tsx +165 -226
  116. package/src/client/components/settings/categories/omp-settings/types.ts +28 -0
  117. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
  118. package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
  119. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
  120. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
  121. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
  122. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
  123. package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
  124. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
  125. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  126. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
  127. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
  128. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  129. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
  130. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +37 -8
  131. package/src/client/components/settings/categories/skill-settings/DetailPane.tsx +34 -14
  132. package/src/client/components/settings/categories/skill-settings/SidebarList.tsx +21 -0
  133. package/src/client/components/settings/categories/skill-settings/pane.test.tsx +15 -6
  134. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +242 -102
  135. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +130 -56
  136. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +135 -0
  137. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +55 -33
  138. package/src/client/components/settings/categories/token-usage-settings/Provenance.tsx +59 -0
  139. package/src/client/components/settings/categories/token-usage-settings/panel.test.tsx +239 -0
  140. package/src/client/components/workspace/browser-panel/Screencast.test.ts +1 -0
  141. package/src/client/components/workspace/browser-panel/Screencast.tsx +17 -22
  142. package/src/client/components/workspace/browser-panel/TabStrip.test.tsx +158 -0
  143. package/src/client/components/workspace/browser-panel/TabStrip.tsx +90 -0
  144. package/src/client/components/workspace/browser-panel/index.tsx +50 -4
  145. package/src/client/components/workspace/browser-toolbar/index.tsx +41 -1
  146. package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
  147. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
  148. package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
  149. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +3 -1
  150. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +2 -0
  151. package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
  152. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +13 -2
  153. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  154. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
  155. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  156. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
  157. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
  158. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  159. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  160. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
  161. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.test.ts +88 -0
  162. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +24 -1
  163. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.test.ts +34 -0
  164. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +5 -1
  165. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +7 -6
  166. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.test.tsx +237 -0
  167. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Tui.tsx +191 -0
  168. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/styles.test.tsx +1 -1
  169. package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
  170. package/src/client/components/workspace/diff-panel/MergeDiffView.tsx +21 -7
  171. package/src/client/components/workspace/diff-panel/changes.test.ts +51 -0
  172. package/src/client/components/workspace/diff-panel/changes.ts +28 -12
  173. package/src/client/components/workspace/diff-panel/index.tsx +2 -2
  174. package/src/client/components/workspace/diff-panel/merge.test.ts +28 -0
  175. package/src/client/components/workspace/diff-panel/merge.ts +21 -1
  176. package/src/client/components/workspace/editor/Body.tsx +7 -0
  177. package/src/client/components/workspace/editor/FileDocument.tsx +15 -21
  178. package/src/client/components/workspace/editor/FilePane.tsx +12 -0
  179. package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
  180. package/src/client/components/workspace/editor/PreviewPane.tsx +70 -0
  181. package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
  182. package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
  183. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  184. package/src/client/components/workspace/editor/Toolbar.tsx +17 -1
  185. package/src/client/components/workspace/editor/index.tsx +25 -22
  186. package/src/client/components/workspace/editor/toolbar-clusters.test.ts +14 -0
  187. package/src/client/components/workspace/editor/toolbar-clusters.tsx +12 -86
  188. package/src/client/components/workspace/editor/toolbar-toggle.tsx +53 -0
  189. package/src/client/components/workspace/editor/toolbar-write-clusters.tsx +112 -0
  190. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
  191. package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
  192. package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
  193. package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
  194. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
  195. package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
  196. package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
  197. package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
  198. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
  199. package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
  200. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
  201. package/src/client/components/workspace/git-panel/commit-modal.test.ts +5 -3
  202. package/src/client/components/workspace/git-panel/index.tsx +7 -0
  203. package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
  204. package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
  205. package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
  206. package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
  207. package/src/client/components/workspace/search-panel/Body.tsx +1 -1
  208. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
  209. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -0
  210. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +201 -0
  211. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +112 -0
  212. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.test.tsx +225 -0
  213. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +217 -0
  214. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +99 -0
  215. package/src/client/components/workspace/user-browser-panel/Frame.tsx +30 -1
  216. package/src/client/components/workspace/user-browser-panel/index.tsx +81 -2
  217. package/src/client/data/agent-data/builtin.ts +0 -10
  218. package/src/client/data/agent-data/orchestrator.ts +0 -45
  219. package/src/client/data/agent-data/specialist.ts +0 -100
  220. package/src/client/data/mock/token-usage.ts +170 -120
  221. package/src/client/data/settings/omp-schema.json +33 -1
  222. package/src/client/glass.css +785 -0
  223. package/src/client/glass.test.ts +346 -0
  224. package/src/client/hooks/browser/use-annotate.test.ts +143 -0
  225. package/src/client/hooks/browser/use-annotate.ts +98 -0
  226. package/src/client/hooks/browser/use-close-tab.test.ts +148 -0
  227. package/src/client/hooks/browser/use-close-tab.ts +67 -0
  228. package/src/client/hooks/browser/use-screencast.ts +13 -1
  229. package/src/client/hooks/chat/composer/browser-context.test.ts +117 -0
  230. package/src/client/hooks/chat/composer/browser-context.ts +40 -16
  231. package/src/client/hooks/chat/composer/items.test.ts +1 -1
  232. package/src/client/hooks/chat/composer/review-context.ts +38 -0
  233. package/src/client/hooks/chat/composer/use-draft.test.ts +132 -0
  234. package/src/client/hooks/chat/composer/use-draft.ts +31 -2
  235. package/src/client/hooks/chat/timeline/row-window.test.ts +15 -2
  236. package/src/client/hooks/editor/use-document-annotations.ts +124 -0
  237. package/src/client/hooks/editor/use-editor-panel-ui.ts +52 -0
  238. package/src/client/hooks/editor/use-file-review-mode.ts +35 -0
  239. package/src/client/hooks/editor/use-preview-review.ts +148 -0
  240. package/src/client/hooks/settings/agents.ts +149 -0
  241. package/src/client/hooks/settings/crud-list.test.ts +28 -6
  242. package/src/client/hooks/settings/crud-list.ts +96 -57
  243. package/src/client/hooks/settings/omp-config.ts +164 -0
  244. package/src/client/hooks/settings/useTokenUsage.ts +125 -0
  245. package/src/client/hooks/settings/write-feedback.test.ts +104 -0
  246. package/src/client/hooks/settings/write-feedback.ts +63 -0
  247. package/src/client/hooks/ui/glass-support.ts +57 -0
  248. package/src/client/hooks/ui/icon-style.ts +59 -0
  249. package/src/client/hooks/ui/markdown-hydration.ts +125 -0
  250. package/src/client/hooks/ui/stuck-header.test.ts +188 -0
  251. package/src/client/hooks/ui/stuck-header.ts +91 -0
  252. package/src/client/hooks/ui/style-attributes.test.ts +120 -0
  253. package/src/client/hooks/ui/surface-style.ts +56 -0
  254. package/src/client/hooks/ui/updates/index.test.ts +100 -1
  255. package/src/client/hooks/ui/updates/index.ts +50 -0
  256. package/src/client/hooks/ui/updates/notes.test.ts +138 -0
  257. package/src/client/hooks/ui/updates/notes.ts +57 -0
  258. package/src/client/hooks/workspace/panel-hues.ts +23 -0
  259. package/src/client/lib/browser/element-at.test.ts +229 -0
  260. package/src/client/lib/browser/element-at.ts +139 -0
  261. package/src/client/lib/review/client.ts +73 -0
  262. package/src/client/lib/router/search-params.ts +42 -20
  263. package/src/client/main.tsx +10 -0
  264. package/src/client/tailwind.css +329 -11
  265. package/src/server/lib/assets/shell-attributes.server.ts +80 -0
  266. package/src/server/lib/assets/shell-attributes.test.ts +86 -0
  267. package/src/server/lib/btw/lifecycle.server.ts +2 -2
  268. package/src/server/lib/db/schema.ts +7 -0
  269. package/src/server/lib/db/seed-terminal.test.ts +4 -0
  270. package/src/server/lib/omp/config/agent-definitions.test.ts +273 -0
  271. package/src/server/lib/omp/config/agents.ts +231 -61
  272. package/src/server/lib/omp/config/definitions.test.ts +9 -105
  273. package/src/server/lib/omp/config/extensions.ts +16 -7
  274. package/src/server/lib/omp/config/omp-config-files.test.ts +27 -0
  275. package/src/server/lib/omp/rpc/constants.test.ts +11 -0
  276. package/src/server/lib/omp/rpc/constants.ts +15 -0
  277. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
  278. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
  279. package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
  280. package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
  281. package/src/server/lib/omp/rpc/manager.ts +2 -2
  282. package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
  283. package/src/server/lib/omp/rpc/process.test.ts +106 -0
  284. package/src/server/lib/omp/rpc/process.ts +39 -18
  285. package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
  286. package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
  287. package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
  288. package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
  289. package/src/server/lib/omp/rpc/session-commands.ts +17 -3
  290. package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
  291. package/src/server/lib/omp/rpc/utility-agent-dir.test.ts +134 -0
  292. package/src/server/lib/omp/rpc/utility-agent-dir.ts +138 -0
  293. package/src/server/lib/omp/rpc/utility.ts +12 -0
  294. package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
  295. package/src/server/lib/panels/manifest.test.ts +20 -0
  296. package/src/server/lib/panels/manifest.ts +12 -0
  297. package/src/server/lib/panels/scan.server.ts +4 -0
  298. package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
  299. package/src/server/lib/queue/delivery-harness.ts +8 -4
  300. package/src/server/lib/queue/delivery.server.test.ts +29 -0
  301. package/src/server/lib/queue/delivery.server.ts +39 -0
  302. package/src/server/lib/queue/store.server.test.ts +22 -2
  303. package/src/server/lib/queue/store.server.ts +33 -11
  304. package/src/server/lib/review/schema.server.ts +45 -0
  305. package/src/server/lib/review/store.server.ts +138 -0
  306. package/src/server/lib/terminal/attach-replay.test.ts +132 -0
  307. package/src/server/lib/terminal/output.test.ts +166 -0
  308. package/src/server/lib/terminal/output.ts +104 -0
  309. package/src/server/lib/terminal/runtime.server.ts +5 -0
  310. package/src/server/lib/terminal/send-result.test.ts +33 -0
  311. package/src/server/lib/terminal/send-result.ts +32 -0
  312. package/src/server/lib/terminal/session.server.ts +45 -11
  313. package/src/server/lib/terminal/store-liveness.test.ts +4 -0
  314. package/src/server/lib/updates/active-notes.test.ts +149 -0
  315. package/src/server/lib/updates/active-notes.ts +75 -0
  316. package/src/server/lib/updates/changelog-file.ts +42 -11
  317. package/src/server/lib/updates/changelog.test.ts +15 -1
  318. package/src/server/lib/updates/omp.ts +42 -15
  319. package/src/server/lib/updates/release-url.ts +27 -1
  320. package/src/server/lib/usage/index-parse.test.ts +200 -0
  321. package/src/server/lib/usage/index-parse.ts +178 -0
  322. package/src/server/lib/usage/index-query.server.ts +248 -0
  323. package/src/server/lib/usage/index-scan.server.ts +343 -0
  324. package/src/server/lib/usage/index-schema.server.ts +82 -0
  325. package/src/server/lib/usage/index.test.ts +234 -0
  326. package/src/server/lib/usage/providers.server.ts +4 -53
  327. package/src/server/plugins/ssr.ts +22 -5
  328. package/src/server/routes/browser/index.ts +3 -0
  329. package/src/server/routes/browser/stream.ts +31 -2
  330. package/src/server/routes/browser/tabs.test.ts +94 -0
  331. package/src/server/routes/browser/tabs.ts +85 -0
  332. package/src/server/routes/index.ts +2 -0
  333. package/src/server/routes/review/bindings.ts +11 -0
  334. package/src/server/routes/review/index.ts +127 -0
  335. package/src/server/routes/review/routes.test.ts +191 -0
  336. package/src/server/routes/settings/agents.test.ts +180 -0
  337. package/src/server/routes/settings/agents.ts +95 -102
  338. package/src/server/routes/settings/mcp.test.ts +135 -0
  339. package/src/server/routes/settings/mcp.ts +14 -6
  340. package/src/server/routes/settings/settings-store-routes.test.ts +6 -113
  341. package/src/server/routes/telemetry/tokens.test.ts +145 -0
  342. package/src/server/routes/telemetry/tokens.ts +70 -149
  343. package/src/server/routes/terminal/ws.ts +6 -5
  344. package/src/server/routes/updates/index.ts +2 -0
  345. package/src/server/routes/updates/notes.ts +34 -0
  346. package/src/server/routes/updates/routes.test.ts +49 -0
  347. package/src/shared/lib/browser/annotate.test.ts +283 -0
  348. package/src/shared/lib/browser/annotate.ts +231 -0
  349. package/src/shared/lib/browser/browser-viewer.test.ts +26 -4
  350. package/src/shared/lib/browser/frame-gate.test.ts +91 -0
  351. package/src/shared/lib/browser/frame-gate.ts +69 -0
  352. package/src/shared/lib/browser/frame-params.test.ts +43 -0
  353. package/src/shared/lib/browser/frame-params.ts +60 -0
  354. package/src/shared/lib/browser/frame-pipeline.test.ts +132 -0
  355. package/src/shared/lib/browser/frame-pipeline.ts +80 -0
  356. package/src/shared/lib/browser/page-context.ts +60 -4
  357. package/src/shared/lib/browser/snapshot.test.ts +115 -0
  358. package/src/shared/lib/browser/snapshot.ts +112 -0
  359. package/src/shared/lib/browser/tab-close.test.ts +74 -0
  360. package/src/shared/lib/browser/tab-close.ts +77 -0
  361. package/src/shared/lib/browser/viewer.ts +45 -26
  362. package/src/shared/lib/chat/timeline/block-chrome.ts +19 -0
  363. package/src/shared/lib/chat/timeline/tool-render-mode.ts +17 -4
  364. package/src/shared/lib/chat/tool/artifact.ts +55 -20
  365. package/src/shared/lib/chat/tool/bash-facts.ts +96 -0
  366. package/src/shared/lib/chat/tool/minimized.test.ts +98 -0
  367. package/src/shared/lib/chat/tool/minimized.ts +64 -0
  368. package/src/shared/lib/chat/tool/summary.test.ts +28 -8
  369. package/src/shared/lib/chat/tool/summary.ts +3 -32
  370. package/src/shared/lib/icons/file-brand-color.ts +38 -0
  371. package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
  372. package/src/shared/lib/icons/icon-paint-css.ts +284 -0
  373. package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
  374. package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
  375. package/src/shared/lib/icons/tint.test.ts +273 -0
  376. package/src/shared/lib/icons/tint.ts +219 -0
  377. package/src/shared/lib/markdown/blocks/anchor.ts +63 -0
  378. package/src/shared/lib/markdown/blocks/blocks.test.ts +141 -0
  379. package/src/shared/lib/markdown/blocks/renderer.ts +120 -0
  380. package/src/shared/lib/markdown/blocks/scan.ts +100 -0
  381. package/src/shared/lib/markdown/blocks/types.ts +62 -0
  382. package/src/shared/lib/markdown/marked.ts +58 -147
  383. package/src/shared/lib/markdown/math-extensions.ts +168 -0
  384. package/src/shared/lib/markdown/review/prompt.ts +77 -0
  385. package/src/shared/lib/markdown/review/reconcile.ts +55 -0
  386. package/src/shared/lib/markdown/review/review.test.ts +96 -0
  387. package/src/shared/lib/markdown/xml-sections.test.ts +140 -0
  388. package/src/shared/lib/markdown/xml-sections.ts +139 -0
  389. package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
  390. package/src/shared/lib/models/provider/brand-color.ts +103 -0
  391. package/src/shared/lib/models/provider/label.ts +57 -0
  392. package/src/shared/lib/omp/config/agent-file.test.ts +54 -0
  393. package/src/shared/lib/omp/config/agent-file.ts +43 -0
  394. package/src/shared/lib/omp/config/row-value.test.ts +95 -0
  395. package/src/shared/lib/omp/config/row-value.ts +97 -0
  396. package/src/shared/lib/omp/config/schema.test.ts +31 -0
  397. package/src/shared/lib/omp/config/schema.ts +6 -0
  398. package/src/shared/lib/omp/rpc/frame.test.ts +113 -47
  399. package/src/shared/lib/omp/rpc/frame.ts +107 -43
  400. package/src/shared/lib/settings/defaults.ts +4 -0
  401. package/src/shared/lib/theme/catalog.test.ts +5 -4
  402. package/src/shared/lib/theme/catalog.ts +18 -3
  403. package/src/shared/lib/theme/glass-support.test.ts +38 -0
  404. package/src/shared/lib/theme/glass-support.ts +73 -0
  405. package/src/shared/lib/theme/icon-style.test.ts +74 -0
  406. package/src/shared/lib/theme/icon-style.ts +90 -0
  407. package/src/shared/lib/theme/legibility.ts +91 -0
  408. package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
  409. package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
  410. package/src/shared/lib/theme/surface-style.test.ts +68 -0
  411. package/src/shared/lib/theme/surface-style.ts +91 -0
  412. package/src/shared/lib/theme/theme.test.ts +11 -7
  413. package/src/shared/lib/ui/menu-anchor.test.ts +69 -0
  414. package/src/shared/lib/ui/menu-anchor.ts +89 -0
  415. package/src/shared/lib/usage/breakdown.test.ts +197 -0
  416. package/src/shared/lib/usage/breakdown.ts +241 -0
  417. package/src/shared/lib/usage/range.test.ts +204 -0
  418. package/src/shared/lib/usage/range.ts +240 -0
  419. package/src/shared/lib/usage/view.test.ts +85 -0
  420. package/src/shared/lib/usage/view.ts +74 -0
  421. package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
  422. package/src/shared/lib/workspace/panel-hues.ts +57 -0
  423. package/src/shared/types/browser.ts +78 -0
  424. package/src/shared/types/index.ts +1 -0
  425. package/src/shared/types/panels-registry.ts +6 -0
  426. package/src/shared/types/panels.ts +14 -0
  427. package/src/shared/types/settings/agent.ts +28 -6
  428. package/src/shared/types/settings/state.ts +30 -3
  429. package/src/shared/types/settings/write.ts +6 -0
  430. package/src/shared/types/tokenUsage.ts +128 -21
  431. package/src/shared/types/updates.ts +20 -0
  432. package/src/test-support/fake-omp-frames.ts +163 -0
  433. package/dist/client/static/js/index-3ve31rzx.css +0 -1
  434. package/src/server/lib/omp/session/usage/aggregate-shaping.test.ts +0 -149
  435. package/src/server/lib/omp/session/usage/aggregate.test.ts +0 -243
  436. package/src/server/lib/omp/session/usage/aggregate.ts +0 -330
  437. package/src/server/lib/omp/session/usage/shaping.ts +0 -130
  438. /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
@@ -12,6 +12,12 @@
12
12
  * delegated click handler manages the per-block "Copy" buttons. Mermaid
13
13
  * fences hydrate async into sanitized SVGs after mount.
14
14
  *
15
+ * ONE more mode: a `review` bridge switches the parse to the MAPPED render, so
16
+ * every top-level block carries `data-md-block` and a click names the block it
17
+ * landed on instead of following its link. The handler consults that bridge
18
+ * FIRST — a second click listener on the same container would have to agree with
19
+ * this one about precedence, and the two would eventually disagree.
20
+ *
15
21
  * Three source kinds, one pipeline: agent output (default), a workspace file's
16
22
  * preview (`document`), and a wiki page (`wikiScope`). The last two differ only
17
23
  * in what they let through — a document's own HTML is markup, and a wiki page
@@ -21,15 +27,16 @@
21
27
 
22
28
  import type { TargetedMouseEvent } from 'preact';
23
29
  import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from 'preact/hooks';
24
- import { renderMarkdown } from '@/shared/lib/markdown/marked';
30
+ import { renderMarkdown, renderMappedMarkdown } from '@/shared/lib/markdown/marked';
31
+ import type { BlockVerdict, MdBlock } from '@/shared/lib/markdown/blocks/types';
25
32
  import { rewriteDocumentReferences, type DocumentScope } from '@/shared/lib/markdown/document-urls';
26
33
  import { rewriteWikiReferences, type WikiRenderScope } from '@/shared/lib/wiki/document-urls';
27
34
  import { expandGollumLinks } from '@/shared/lib/wiki/pages';
28
- import { hydrateMathBlocks, MATH_PENDING_CLASS, preloadKatex } from '@/shared/lib/markdown/katex';
35
+ import { MATH_PENDING_CLASS, preloadKatex } from '@/shared/lib/markdown/katex';
29
36
  import { sanitizeHtml } from '@/shared/lib/markdown/sanitize';
30
- import { hydrateMermaidBlocks } from '@/shared/lib/markdown/mermaid';
31
37
  import { DIRECTIVE_BLOCK_CLASS } from '@/shared/lib/markdown/directives';
32
38
  import { hydrateDirectiveBlocks, unmountDirectiveBlocks } from '@/client/lib/plugins/directives';
39
+ import { useMathHydration, useMermaidHydration } from '@/client/hooks/ui/markdown-hydration';
33
40
  import { useDirectiveContext, useDirectiveRenderer } from '@/client/hooks/workspace/directives';
34
41
  import { copyToClipboard } from '@/client/hooks/ui/clipboard';
35
42
  import { openFileInEditor } from '@/client/hooks/ui/open-file';
@@ -38,6 +45,7 @@ import { DiagramViewer } from '@/client/components/common/diagram-viewer';
38
45
  import { readDiagramBlock, type DiagramSnapshot } from '@/client/components/common/diagram-viewer/read-block';
39
46
 
40
47
 
48
+ /** `useLayoutEffect` warns under SSR; the document renderer runs in both. */
41
49
  const useIsomorphicLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;
42
50
 
43
51
  interface MarkdownRendererProps {
@@ -59,9 +67,42 @@ interface MarkdownRendererProps {
59
67
  wikiScope?: WikiRenderScope;
60
68
  /** Follow a wiki link to another page of the same wiki. */
61
69
  onWikiNavigate?: (path: string) => void;
70
+ /**
71
+ * The review layer, when it is ON.
72
+ *
73
+ * Absent is the ordinary renderer: no `data-md-*` attributes are emitted and
74
+ * every click keeps its usual meaning. Present switches the pipeline to the
75
+ * MAPPED render (each block carries its identity) and routes block clicks to
76
+ * `onPick` BEFORE the copy/link/diagram branches — one handler, one
77
+ * precedence rule, because two handlers on one container would have to agree
78
+ * about which wins.
79
+ */
80
+ review?: MarkdownReviewBridge;
81
+ /** The blocks the render produced, for a caller that stores judgements. */
82
+ onBlocks?: (blocks: MdBlock[]) => void;
83
+ }
84
+
85
+ /** What the renderer needs of the review surface — nothing about storage. */
86
+ export interface MarkdownReviewBridge {
87
+ active: boolean;
88
+ /** Verdicts by block key, painted as `data-md-verdict`. */
89
+ marks: ReadonlyMap<string, BlockVerdict>;
90
+ /** The block the popover is open on, painted as `data-md-selected`. */
91
+ selected: string | null;
92
+ /** A block was clicked while review was active; `rect` is where it was. */
93
+ onPick: (block: MdBlock, rect: DOMRect) => void;
62
94
  }
63
95
 
64
- export function MarkdownRenderer({ content, className = '', document: isDocument = false, scope, wikiScope, onWikiNavigate }: MarkdownRendererProps) {
96
+ export function MarkdownRenderer({
97
+ content,
98
+ className = '',
99
+ document: isDocument = false,
100
+ scope,
101
+ wikiScope,
102
+ onWikiNavigate,
103
+ review,
104
+ onBlocks,
105
+ }: MarkdownRendererProps) {
65
106
  const containerRef = useRef<HTMLDivElement>(null);
66
107
  /** Block the open viewer was read from, so a theme re-render can refresh it. */
67
108
  const diagramBlockRef = useRef<HTMLElement | null>(null);
@@ -81,25 +122,70 @@ export function MarkdownRenderer({ content, className = '', document: isDocument
81
122
  /** Presence, not identity: this drives the click handler, never the parse. */
82
123
  const isWiki = wikiScope !== undefined;
83
124
 
84
- const html = useMemo(() => {
85
- if (!content) return '';
125
+ /**
126
+ * Review mode is a MODE, not a flag on the parse: it changes which pipeline
127
+ * entry point runs, because only the mapped one emits `data-md-block`. Kept
128
+ * to a boolean so a caller passing a fresh bridge object per render does not
129
+ * re-parse the whole document.
130
+ */
131
+ const reviewActive = review?.active === true;
132
+
133
+ const rendered = useMemo(() => {
134
+ if (!content) return { html: '', blocks: [] as MdBlock[] };
86
135
  // Gollum's `[[Page]]` is invisible to a markdown parser, so it is expanded
87
136
  // before parsing rather than patched afterwards.
88
137
  const source = wikiPath ? expandGollumLinks(content) : content;
89
- const rendered = renderMarkdown(source, { allowHtml: isDocument || isWiki });
138
+ const allowHtml = isDocument || isWiki;
139
+ const mapped = reviewActive ? renderMappedMarkdown(source, { allowHtml }) : null;
140
+ const markdown = mapped ? mapped.html : renderMarkdown(source, { allowHtml });
90
141
  const scoped = wikiPath && wikiEntries
91
- ? rewriteWikiReferences(rendered, { path: wikiPath, entries: wikiEntries, root: wikiRoot, repo: wikiRepo })
142
+ ? rewriteWikiReferences(markdown, { path: wikiPath, entries: wikiEntries, root: wikiRoot, repo: wikiRepo })
92
143
  : isDocument && scopePath
93
- ? rewriteDocumentReferences(rendered, { path: scopePath, root: scopeRoot, repo: scopeRepo })
94
- : rendered;
144
+ ? rewriteDocumentReferences(markdown, { path: scopePath, root: scopeRoot, repo: scopeRepo })
145
+ : markdown;
95
146
  // If the message contains math, start fetching KaTeX during parse rather
96
147
  // than waiting for the post-mount hydration effect — the request overlaps
97
148
  // sanitization and the rest of the render instead of following it.
98
149
  if (scoped.includes(MATH_PENDING_CLASS)) preloadKatex();
99
- return sanitizeHtml(scoped);
150
+ return { html: sanitizeHtml(scoped), blocks: mapped?.blocks ?? [] };
100
151
  // Primitives, never the `wikiScope` object: the panel memoizes it, but a
101
152
  // call site that builds one inline must not re-parse the page per render.
102
- }, [content, syntaxReady, isDocument, scopePath, scopeRoot, scopeRepo, isWiki, wikiPath, wikiEntries, wikiRoot, wikiRepo]);
153
+ }, [content, syntaxReady, isDocument, scopePath, scopeRoot, scopeRepo, isWiki, wikiPath, wikiEntries, wikiRoot, wikiRepo, reviewActive]);
154
+
155
+ const { html, blocks } = rendered;
156
+
157
+ // The caller stores judgements against these, so it has to know what the
158
+ // render actually produced — never what the file contains (a healed or
159
+ // truncated document renders fewer blocks than it has lines).
160
+ useEffect(() => {
161
+ if (onBlocks) onBlocks(blocks);
162
+ }, [blocks, onBlocks]);
163
+
164
+ const byKey = useMemo(() => new Map(blocks.map((block) => [block.key, block])), [blocks]);
165
+
166
+ /**
167
+ * Paint the verdicts onto the rendered DOM.
168
+ *
169
+ * An imperative pass rather than markup: the annotations arrive from the
170
+ * server AFTER the HTML string was built (and the string is memoized on
171
+ * content), so there is nothing to interpolate. The attributes are what the
172
+ * CSS hangs off, and what the click handler reads.
173
+ */
174
+ const marks = review?.marks;
175
+ const selected = review?.selected ?? null;
176
+ useIsomorphicLayoutEffect(() => {
177
+ const container = containerRef.current;
178
+ if (!container || !reviewActive) return;
179
+ for (const element of container.querySelectorAll<HTMLElement>('[data-md-block]')) {
180
+ const key = element.dataset.mdBlock;
181
+ if (!key) continue;
182
+ const verdict = marks?.get(key);
183
+ if (verdict) element.dataset.mdVerdict = verdict;
184
+ else delete element.dataset.mdVerdict;
185
+ if (key === selected) element.dataset.mdSelected = 'true';
186
+ else delete element.dataset.mdSelected;
187
+ }
188
+ }, [html, marks, selected, reviewActive]);
103
189
 
104
190
  const hasMermaid = html.includes('mermaid-block');
105
191
  const hasMath = html.includes(MATH_PENDING_CLASS);
@@ -125,87 +211,48 @@ export function MarkdownRenderer({ content, className = '', document: isDocument
125
211
  }, [hasDirective, html, directive, slotContext]);
126
212
 
127
213
  // KaTeX is ~522 kB of JS fetched only when a message contains math; the
128
- // placeholders emitted by `marked.ts` are swapped for real markup here.
129
- useEffect(() => {
130
- if (!hasMath || typeof window === 'undefined') return;
131
- const container = containerRef.current;
132
- if (!container) return;
133
-
134
- let cancelled = false;
135
- const hydrate = async () => {
136
- if (!container.isConnected) return;
137
- await hydrateMathBlocks(container);
138
- if (cancelled) return;
139
- };
140
- void hydrate();
141
- // Same reason as the mermaid observer: a timeline re-render can replace the
142
- // container's innerHTML with an identical string without this effect
143
- // re-running, stranding new placeholders. hydrate() only writes inside the
144
- // placeholder elements, so it never re-triggers this observer.
145
- const observer = new MutationObserver(() => {
146
- const current = containerRef.current;
147
- if (current?.isConnected) void hydrateMathBlocks(current);
148
- });
149
- observer.observe(container, { childList: true });
150
-
151
- return () => {
152
- cancelled = true;
153
- observer.disconnect();
154
- };
155
- }, [hasMath, html]);
156
-
157
- useIsomorphicLayoutEffect(() => {
158
- if (!hasMermaid || typeof window === 'undefined') return;
159
- const container = containerRef.current;
160
- if (!container) return;
214
+ // placeholders emitted by `marked.ts` are swapped for real markup by the hook.
215
+ useMathHydration(containerRef, html, hasMath);
161
216
 
162
- let timer: number | undefined;
163
- const hydrate = async () => {
164
- const current = containerRef.current;
165
- if (!current || !current.isConnected) return;
166
- await hydrateMermaidBlocks(current);
167
- };
168
-
169
- void hydrate();
170
- // React can rewrite the container's innerHTML with an identical html
171
- // string (timeline re-renders) without this effect re-running, which
172
- // would strand freshly-inserted pending blocks. Re-hydrate on any
173
- // direct-child replacement; hydrate writes only to grandchildren, so it
174
- // never re-triggers this observer.
175
- const observer = new MutationObserver(() => {
176
- const current = containerRef.current;
177
- if (current?.isConnected) void hydrateMermaidBlocks(current, { cachedOnly: true });
178
- window.clearTimeout(timer);
179
- timer = window.setTimeout(() => void hydrate(), 120);
180
- });
181
- observer.observe(container, { childList: true });
182
-
183
- // Diagrams bake the palette into their SVG, so every theme write must
184
- // re-render them. The trigger is the `data-theme` attribute itself rather
185
- // than the `omp:theme-changed` event: the navbar toggle and the settings
186
- // modal are both writers, and observing the attribute catches all of them
187
- // the moment the document changes. Vacuously cheap for a same-palette write
188
- // (blocks already matching the new theme key are skipped).
189
- const rehydrateForTheme = async () => {
190
- await hydrate();
191
- const block = diagramBlockRef.current;
192
- // A timeline re-render can replace the block under an open viewer; keep
193
- // the last snapshot then rather than closing the viewer on the user.
194
- if (!block?.isConnected) return;
195
- const snapshot = readDiagramBlock(block);
196
- if (snapshot) setDiagram(snapshot);
197
- };
198
- const themeObserver = new MutationObserver(() => void rehydrateForTheme());
199
- themeObserver.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
217
+ // Diagrams bake the palette into their SVG, so a theme write re-renders them —
218
+ // through the block the open viewer was read from, which the hook hands back
219
+ // when that block survived the re-render.
220
+ const onDiagramBlock = useCallback((block: HTMLElement) => {
221
+ const snapshot = readDiagramBlock(block);
222
+ if (snapshot) setDiagram(snapshot);
223
+ }, []);
224
+ useMermaidHydration({
225
+ container: containerRef,
226
+ html,
227
+ active: hasMermaid,
228
+ diagramBlock: diagramBlockRef,
229
+ onDiagramBlock,
230
+ });
200
231
 
201
- return () => {
202
- window.clearTimeout(timer);
203
- observer.disconnect();
204
- themeObserver.disconnect();
205
- };
206
- }, [hasMermaid, html]);
232
+ // Read through a ref so the single delegated handler never has to be rebuilt
233
+ // for a new bridge object — and so it always sees the CURRENT mode.
234
+ const reviewRef = useRef(review);
235
+ reviewRef.current = review;
236
+ const byKeyRef = useRef(byKey);
237
+ byKeyRef.current = byKey;
207
238
 
208
239
  const handleContainerClick = useCallback((e: TargetedMouseEvent<HTMLDivElement>) => {
240
+ const bridge = reviewRef.current;
241
+ if (bridge?.active) {
242
+ // In review mode a click names a BLOCK. Consumed before the copy button,
243
+ // the diagram and the document links, because otherwise the reader could
244
+ // not select a block that happens to contain one of them.
245
+ const block = (e.target as HTMLElement).closest<HTMLElement>('[data-md-block]');
246
+ const key = block?.dataset.mdBlock;
247
+ const picked = key ? byKeyRef.current.get(key) : undefined;
248
+ if (picked) {
249
+ e.preventDefault();
250
+ e.stopPropagation();
251
+ bridge.onPick(picked, block!.getBoundingClientRect());
252
+ }
253
+ return;
254
+ }
255
+
209
256
  const target = (e.target as HTMLElement).closest<HTMLButtonElement>('button.code-copy-float');
210
257
  if (target) {
211
258
  const text = target.dataset.copy ?? '';
@@ -50,7 +50,7 @@ export function Modal({
50
50
 
51
51
  return (
52
52
  <div
53
- className={`fixed inset-0 bg-ink/40 backdrop-blur-[2px] ${zClass} flex items-center justify-center p-4`}
53
+ className={`fixed inset-0 modal-scrim backdrop-blur-[2px] ${zClass} flex items-center justify-center p-4`}
54
54
  style={{
55
55
  paddingTop: 'max(1rem, env(safe-area-inset-top, 0px))',
56
56
  paddingBottom: 'max(1rem, env(safe-area-inset-bottom, 0px))',
@@ -69,7 +69,7 @@ export function Modal({
69
69
  role="dialog"
70
70
  aria-modal="true"
71
71
  aria-label={ariaLabel}
72
- className={`bg-paper border border-ink/15 rounded-xl shadow-2xl w-full ${maxWidthClass} max-h-full flex flex-col overflow-hidden text-ink`}
72
+ className={`glass-overlay bg-paper border border-ink/15 rounded-xl shadow-2xl w-full ${maxWidthClass} max-h-full flex flex-col overflow-hidden text-ink`}
73
73
  onClick={(e) => e.stopPropagation()}
74
74
  >
75
75
  <div className="px-5 py-4 border-b border-ink/10 flex items-center justify-between flex-shrink-0">
@@ -89,8 +89,8 @@ export const PWAInstallButton: FunctionComponent = () => {
89
89
  <Download size={16} />
90
90
  </button>
91
91
  {showIOSGuide && (
92
- <div className="fixed inset-0 z-50 flex items-center justify-center bg-ink/20 p-4">
93
- <div className="w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink">
92
+ <div className="fixed inset-0 z-50 flex items-center justify-center modal-scrim p-4">
93
+ <div className="glass-overlay w-full max-w-sm rounded bg-paper border border-ink/10 p-6 shadow-xl text-ink">
94
94
  <h3 className="text-sm font-semibold">Install on iPhone / iPad</h3>
95
95
  <p className="mt-2 text-xs opacity-80">
96
96
  1. Tap the <strong>Share</strong> button in Safari toolbar.<br />
@@ -114,7 +114,7 @@ export function BrowserViewportSelector({
114
114
  </button>
115
115
 
116
116
  {dropdownOpen && (
117
- <div className="absolute right-0 top-full mt-1 w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 z-50 text-xs font-mono">
117
+ <div className="glass-popover absolute right-0 top-full mt-1 w-56 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 z-50 text-xs font-mono">
118
118
  {/* Responsive Section */}
119
119
  <div className="px-2.5 py-1 text-[10px] text-ink/40 uppercase tracking-wider font-semibold">
120
120
  Responsive Testing
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The portalled menu panel.
8
+ *
9
+ * The regression this pins is the reported one: a `z-50` panel rendered INSIDE
10
+ * its trigger's subtree is still confined to that ancestor's stacking context,
11
+ * so a `sticky z-10` workspace header covered its own `⋯` menu with the NEXT
12
+ * header's surface, and a `z-50` panel inside the navbar's `z-20` header lost to
13
+ * anything at `z-20`+ in the chat column. The fix is structural — the panel is a
14
+ * child of `document.body` — so the test asserts the STRUCTURE, because a test
15
+ * that only asserted the menu's rows would stay green with the bug restored.
16
+ */
17
+
18
+ import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
19
+ import { Window } from 'happy-dom';
20
+ import { h, render } from 'preact';
21
+ import { act } from 'preact/test-utils';
22
+ import { AnchoredMenu } from '@/client/components/common/anchored-menu';
23
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
24
+
25
+ let win: Window;
26
+ let host: HTMLElement;
27
+ let closed: number;
28
+
29
+ const ANCHOR = { top: 100, right: 300, bottom: 122, left: 278 };
30
+
31
+ function mount(anchor = ANCHOR) {
32
+ closed = 0;
33
+ win.document.body.innerHTML = '';
34
+ host = win.document.createElement('div') as unknown as HTMLElement;
35
+ // The host stands in for the sidebar's `sticky z-10` header: it is a stacking
36
+ // context, so a panel rendered inside it can never paint over a sibling.
37
+ host.style.position = 'relative';
38
+ host.style.zIndex = '10';
39
+ win.document.body.appendChild(host as never);
40
+ act(() => {
41
+ render(
42
+ h(AnchoredMenu, {
43
+ anchor,
44
+ ariaLabel: 'Options for kabmo',
45
+ className: 'w-44 rounded-md bg-paper',
46
+ onClose: () => {
47
+ closed += 1;
48
+ },
49
+ children: h('button', { type: 'button' }, 'Pin Workspace'),
50
+ }),
51
+ host as never,
52
+ );
53
+ });
54
+ }
55
+
56
+ /** The panel is labelled, not roled: see `AnchoredMenuProps.role`. */
57
+ const panel = () => win.document.querySelector('[aria-label="Options for kabmo"]') as HTMLElement | null;
58
+
59
+ beforeEach(() => {
60
+ win = new Window({ url: 'http://127.0.0.1:3001/' });
61
+ installDomGlobals(win);
62
+ });
63
+
64
+ afterEach(() => {
65
+ if (host) act(() => render(null, host as never));
66
+ restoreDomGlobals();
67
+ });
68
+
69
+ describe('AnchoredMenu', () => {
70
+ test('the panel is a child of the document, never of its stacking ancestor', () => {
71
+ mount();
72
+ const menu = panel();
73
+ expect(menu).not.toBeNull();
74
+ // The bug, stated as an assertion: inside `host` it would be clipped by the
75
+ // NEXT sticky header and by the sidebar's own scroller.
76
+ expect(host.contains(menu as never)).toBe(false);
77
+ expect(win.document.body.contains(menu as never)).toBe(true);
78
+ });
79
+
80
+ test('it is placed from the anchor, right edges aligned', () => {
81
+ mount();
82
+ const menu = panel();
83
+ // The panel is `fixed` by class (happy-dom computes no layout, so the box is
84
+ // 0×0 and the arithmetic is covered by `menu-anchor.test.ts`); what this
85
+ // asserts is that the placement is applied HERE rather than by the caller's
86
+ // CSS, which is what lets it escape the ancestor's clipping.
87
+ expect(menu?.className).toContain('fixed');
88
+ expect(menu?.style.top).not.toBe('');
89
+ expect(menu?.style.left).not.toBe('');
90
+ expect(menu?.style.maxHeight).not.toBe('');
91
+ // Not the pre-measure placeholder, which is hidden until the layout effect
92
+ // has run.
93
+ expect(menu?.style.visibility).toBe('');
94
+ });
95
+
96
+ test('Escape closes it', () => {
97
+ mount();
98
+ act(() => {
99
+ win.document.dispatchEvent(new win.KeyboardEvent('keydown', { key: 'Escape', bubbles: true }));
100
+ });
101
+ expect(closed).toBe(1);
102
+ });
103
+
104
+ test('a click on the backdrop closes it, a click on a row does not', () => {
105
+ mount();
106
+ const menu = panel() as HTMLElement;
107
+ const row = menu.querySelector('button') as HTMLButtonElement;
108
+
109
+ act(() => {
110
+ row.dispatchEvent(new win.MouseEvent('click', { bubbles: true }) as unknown as Event);
111
+ });
112
+ expect(closed).toBe(0);
113
+
114
+ act(() => {
115
+ (menu.parentElement as HTMLElement).dispatchEvent(new win.MouseEvent('click', { bubbles: true }) as unknown as Event);
116
+ });
117
+ expect(closed).toBe(1);
118
+ });
119
+
120
+ test('no anchor and no viewport style renders nothing', () => {
121
+ closed = 0;
122
+ win.document.body.innerHTML = '';
123
+ const bare = win.document.createElement('div');
124
+ win.document.body.appendChild(bare as never);
125
+ act(() => {
126
+ render(
127
+ h(AnchoredMenu, {
128
+ anchor: null,
129
+ ariaLabel: 'closed',
130
+ className: 'w-44',
131
+ onClose: () => {
132
+ closed += 1;
133
+ },
134
+ children: null,
135
+ }),
136
+ bare as never,
137
+ );
138
+ });
139
+ expect(panel()).toBeNull();
140
+ });
141
+ });
@@ -0,0 +1,147 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * A menu that hangs off a trigger, portalled to `document.body`.
8
+ *
9
+ * Two defects make this its own module rather than a class on each call site:
10
+ *
11
+ * - **A dropdown inside a `z-index`ed ancestor cannot paint over its siblings.**
12
+ * A positioned or flex item with a `z-index` establishes a stacking context,
13
+ * so a `z-50` menu inside the sidebar's `sticky z-10` workspace header was
14
+ * still BELOW the next workspace's `sticky z-10` header — the reported "menu
15
+ * appears, then disappears under the folder below it". Measured before this
16
+ * module: `elementFromPoint` at the menu's own centre answered the next
17
+ * header's button. The desktop navbar had the same shape one level up: the
18
+ * `header` is a flex item at `z-20`, so the server panel's `z-50` lost to
19
+ * anything at `z-20`+ in the chat column.
20
+ * - **`overflow` clips a menu, `fixed` or not.** A menu drawn inside the
21
+ * sidebar's scroller is cut at the scroller's edge and drifts with the rows
22
+ * when it scrolls (`toolbar-row/OverflowMenu` documents the same bug from the
23
+ * other direction).
24
+ *
25
+ * So the panel is a `fixed` node in `document.body` at `z-[70]` — above the
26
+ * navbar (`z-20`), the panels (`z-50`) and the modals (`z-[60]`), below toasts
27
+ * (`z-[200]`) — placed from the trigger's measured rectangle (`placeMenu`) and
28
+ * measured again whenever its own content changes height.
29
+ *
30
+ * The dismissal surface is a full-viewport layer at the same layer, which is
31
+ * also what makes the grid behind it inert: a click outside closes the menu,
32
+ * and the wheel cannot scroll the list out from under it.
33
+ *
34
+ * The phone's server sheet passes `viewportStyle` instead of `anchor`: it is
35
+ * pinned below the title bar rather than to a trigger sitting near the edge
36
+ * (`shared/lib/ui/mobile-overlay` owns those insets).
37
+ */
38
+
39
+ import { useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
40
+ import type { ComponentChildren } from 'preact';
41
+ import type { CSSProperties } from 'preact/compat';
42
+ import { createPortal } from 'preact/compat';
43
+ import { placeMenu, type AnchorRect, type MenuAlign, type MenuPlacement } from '@/shared/lib/ui/menu-anchor';
44
+ import type { MobileOverlayStyle } from '@/shared/lib/ui/mobile-overlay';
45
+
46
+ export interface AnchoredMenuProps {
47
+ /** The trigger's viewport rectangle, or null while the menu is closed. */
48
+ anchor: AnchorRect | null;
49
+ align?: MenuAlign;
50
+ /** Pin to the viewport (a phone sheet) instead of hanging off the anchor. */
51
+ viewportStyle?: MobileOverlayStyle;
52
+ /**
53
+ * `dialog` for the server sheet — a panel with headings and an Add form.
54
+ * Omitted for the folder menus: their rows are plain buttons (as they were
55
+ * before the portal), and claiming `menu` would promise arrow-key roving that
56
+ * no one implements.
57
+ */
58
+ role?: 'dialog';
59
+ /** Names the panel; every caller labels it by the trigger it opened from. */
60
+ ariaLabel?: string;
61
+ /** The panel's own chrome: width, padding, border, typography. */
62
+ className: string;
63
+ /** Close on Escape, on a click outside, and on a context menu. */
64
+ onClose: () => void;
65
+ children: ComponentChildren;
66
+ }
67
+
68
+ export function AnchoredMenu({
69
+ anchor,
70
+ align = 'end',
71
+ viewportStyle,
72
+ role,
73
+ ariaLabel,
74
+ className,
75
+ onClose,
76
+ children,
77
+ }: AnchoredMenuProps) {
78
+ const panelRef = useRef<HTMLDivElement>(null);
79
+ const [placement, setPlacement] = useState<MenuPlacement | null>(null);
80
+
81
+ // Measured before paint, and re-measured on every render: the folder menu
82
+ // swaps its rows for the delete confirmation, which changes its height, and a
83
+ // placement computed for the shorter menu put the longer one past the window
84
+ // edge. The state is only written when a number actually moved, so this
85
+ // settles in one extra render instead of looping.
86
+ useLayoutEffect(() => {
87
+ if (viewportStyle) return;
88
+ if (!anchor || !panelRef.current) return;
89
+ const box = panelRef.current.getBoundingClientRect();
90
+ const next = placeMenu(
91
+ anchor,
92
+ { width: box.width, height: box.height },
93
+ { width: window.innerWidth, height: window.innerHeight },
94
+ align,
95
+ );
96
+ setPlacement((prev) =>
97
+ prev && prev.top === next.top && prev.left === next.left && prev.maxHeight === next.maxHeight ? prev : next,
98
+ );
99
+ });
100
+
101
+ useEffect(() => {
102
+ const onKeyDown = (event: globalThis.KeyboardEvent) => {
103
+ if (event.key !== 'Escape') return;
104
+ event.preventDefault();
105
+ onClose();
106
+ };
107
+ document.addEventListener('keydown', onKeyDown);
108
+ return () => document.removeEventListener('keydown', onKeyDown);
109
+ }, [onClose]);
110
+
111
+ if (!anchor && !viewportStyle) return null;
112
+
113
+ const style: CSSProperties = viewportStyle
114
+ ? { ...viewportStyle }
115
+ : placement
116
+ ? { top: `${placement.top}px`, left: `${placement.left}px`, maxHeight: `${placement.maxHeight}px` }
117
+ : // The single pre-measure render. Hidden rather than drawn at 0,0, so a
118
+ // menu never flashes in the corner before the layout effect settles it.
119
+ { top: '0px', left: '0px', visibility: 'hidden' };
120
+
121
+ return createPortal(
122
+ <div
123
+ className="fixed inset-0 z-[70]"
124
+ onClick={onClose}
125
+ onContextMenu={(event) => {
126
+ event.preventDefault();
127
+ onClose();
128
+ }}
129
+ >
130
+ <div
131
+ ref={panelRef}
132
+ role={role}
133
+ aria-label={ariaLabel}
134
+ // `glass-popover` belongs to the PRIMITIVE, not to each caller: every
135
+ // menu this renders is an anchored floating panel, and the tier is inert
136
+ // in the classic look (all of its rules are `[data-surface="glass"]`), so
137
+ // a caller that forgets it is the only way a dropdown stays opaque.
138
+ className={`glass-popover fixed z-[70] overflow-y-auto overscroll-contain ${className}`}
139
+ style={style}
140
+ onClick={(event) => event.stopPropagation()}
141
+ >
142
+ {children}
143
+ </div>
144
+ </div>,
145
+ document.body,
146
+ );
147
+ }
@@ -17,6 +17,7 @@
17
17
  */
18
18
 
19
19
  import { useEffect, useRef } from 'preact/hooks';
20
+ import { CHECKBOX_CLASS } from '@/client/components/common/checkbox/style';
20
21
 
21
22
  export interface SelectionCheckboxProps {
22
23
  checked: boolean;
@@ -50,7 +51,7 @@ export function SelectionCheckbox({
50
51
  aria-label={label}
51
52
  onChange={onChange}
52
53
  onClick={(event) => event.stopPropagation()}
53
- className={`shrink-0 accent-ink cursor-pointer rounded border-ink/30 ${
54
+ className={`${CHECKBOX_CLASS} shrink-0 accent-ink cursor-pointer ${
54
55
  size === 'md' ? 'w-3.5 h-3.5' : 'w-3 h-3'
55
56
  }`}
56
57
  />
@@ -47,10 +47,10 @@ afterEach(() => {
47
47
  container?.remove();
48
48
  });
49
49
 
50
- function mount(className?: string): HTMLElement {
50
+ function mount(className?: string, glow = false): HTMLElement {
51
51
  container = document.createElement('div');
52
52
  document.body.appendChild(container);
53
- render(h(BrandWordmark, className ? { className } : {}), container);
53
+ render(h(BrandWordmark, { ...(className ? { className } : {}), ...(glow ? { glow } : {}) }), container);
54
54
  return container;
55
55
  }
56
56
 
@@ -112,4 +112,15 @@ describe('BrandWordmark', () => {
112
112
  expect(root.className).toContain('tracking-tight');
113
113
  expect(root.className).toContain('font-extrabold');
114
114
  });
115
+
116
+ test('the halo is opt-in and rides with the size, never instead of it', () => {
117
+ // The default (login screen, About dialog) is unchanged: the halo belongs
118
+ // to the four header surfaces that pass it.
119
+ const plain = mount().firstElementChild as HTMLElement;
120
+ expect(plain.className).not.toContain('brand-wordmark-glow');
121
+ const halo = mount('text-sm', true).firstElementChild as HTMLElement;
122
+ expect(halo.className).toContain('brand-wordmark-glow');
123
+ expect(halo.className).toContain('text-sm');
124
+ expect(halo.className).toContain('tracking-tight');
125
+ });
115
126
  });