@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
@@ -4,12 +4,25 @@
4
4
  */
5
5
 
6
6
  /**
7
- * Bounded protocol-v2 framing for OMP's NDJSON RPC transport.
7
+ * NDJSON framing for OMP's RPC transport, in both directions.
8
8
  *
9
- * Faithful port of omp-web/lib/omp/rpc-frame.ts. Logical RPC frames are
10
- * carried as single JSONL lines when small; frames larger than the transport
11
- * limit are split into `rpc_chunk` sequences (base64 payloads) and
12
- * reassembled on the receiving side.
9
+ * The two directions are NOT symmetric, and treating them as if they were is
10
+ * what silently dropped every prompt carrying a real image:
11
+ *
12
+ * - **omp → Kabmo** frames are bounded at `MAX_RPC_FRAME_BYTES`; under protocol
13
+ * v2 (`negotiate_protocol`) a larger event arrives as an `rpc_chunk`
14
+ * sequence, which `RpcFrameDecoder` reassembles.
15
+ * - **Kabmo → omp** frames must go out as ONE line, however long. omp
16
+ * advertises protocol v2 and acks the negotiation, but its rpc-ui stdin loop
17
+ * has no `rpc_chunk` handler: measured against omp 18.14.0 and 18.16.0, every
18
+ * chunk came back `{success:false,error:"Unknown command: rpc_chunk"}` and the
19
+ * prompt was never dispatched — 6 records for a 1.3 MB image, no `agent_start`,
20
+ * no ack, and Kabmo reset the session after `PROMPT_ACK_TIMEOUT_MS`. A single
21
+ * 30 MB line for the same image is accepted and acked in ~26 s, so the limit
22
+ * here is a guard against unbounded writes, not a transport limit.
23
+ *
24
+ * Hence: one encoder (`encodeRpcFrameLine`) that never chunks, and a decoder
25
+ * that still understands chunks.
13
26
  */
14
27
 
15
28
  import { isRecord } from '@/shared/lib/util/guards';
@@ -35,26 +48,15 @@ function isSafeInteger(value: unknown): value is number {
35
48
  }
36
49
 
37
50
  /**
38
- * One encoder for every length check on this path.
51
+ * The byte-length probe for an outbound frame.
39
52
  *
40
- * `encode()` allocates a throwaway array just to read `.byteLength`, and this
41
- * runs once per frame written to the child's stdin — every `message_update`,
42
- * every steer, every tool result. Hoisting it measured 17.2 ms → 8.6 ms per
43
- * 200k checks. A hoisted encoder rather than `Buffer.byteLength` because this
44
- * module is in `src/shared/` and is therefore browser-safe: `Buffer` is not.
53
+ * A hoisted encoder rather than `Buffer.byteLength` because this module is in
54
+ * `src/shared/` and is therefore browser-safe: `Buffer` is not.
45
55
  */
46
56
  const utf8 = new TextEncoder();
47
57
  /** Strict decoder for reassembled chunk payloads — a truncated sequence is an error. */
48
58
  const fatalUtf8 = new TextDecoder('utf-8', { fatal: true });
49
59
 
50
- function utf8ByteLength(value: string): number {
51
- return utf8.encode(value).byteLength;
52
- }
53
-
54
- function lineByteLength(value: string): number {
55
- return utf8ByteLength(value) + 1;
56
- }
57
-
58
60
  /** Strict base64 decode (canonical padding + round-trip equality). */
59
61
  function decodeBase64(value: unknown): Uint8Array {
60
62
  if (
@@ -82,22 +84,77 @@ function concatChunks(chunks: Uint8Array[], byteLength: number): Uint8Array {
82
84
  return merged;
83
85
  }
84
86
 
87
+ export interface RpcTransportLimits {
88
+ /** Largest physical stdout line, newline included. */
89
+ maxFrameBytes: number;
90
+ /** Largest logical frame the server will reassemble from chunks. */
91
+ maxReassembledBytes: number;
92
+ }
93
+
94
+ /** The documented defaults, used until a `ready` frame says otherwise. */
95
+ const DEFAULT_LIMITS: RpcTransportLimits = {
96
+ maxFrameBytes: MAX_RPC_FRAME_BYTES,
97
+ maxReassembledBytes: MAX_RPC_REASSEMBLED_BYTES,
98
+ };
99
+
85
100
  /** Decodes complete logical frames from parsed JSONL records. */
86
101
  export class RpcFrameDecoder {
87
102
  private pending: PendingChunks | undefined;
103
+ /** Set by `resync()`: swallow chunk records until a sequence starts over. */
104
+ private discarding = false;
105
+ private limits: RpcTransportLimits = { ...DEFAULT_LIMITS };
106
+
107
+ /**
108
+ * Adopt the ceilings the server advertised in `ready`.
109
+ *
110
+ * They are the server's own transport contract and may change without a
111
+ * protocol bump, so the decoder validates chunks against the advertised
112
+ * values rather than against the constants this module was compiled with.
113
+ */
114
+ setLimits(advertised: { maxFrameBytes?: unknown; maxReassembledFrameBytes?: unknown }): void {
115
+ const frameBytes = advertised.maxFrameBytes;
116
+ const reassembledBytes = advertised.maxReassembledFrameBytes;
117
+ this.limits = {
118
+ maxFrameBytes: isSafeInteger(frameBytes) && frameBytes > 0 ? frameBytes : this.limits.maxFrameBytes,
119
+ maxReassembledBytes:
120
+ isSafeInteger(reassembledBytes) && reassembledBytes > 0 ? reassembledBytes : this.limits.maxReassembledBytes,
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Drop a damaged chunk sequence and keep reading.
126
+ *
127
+ * Chunk sequences are written without interruption, so the next ordinary
128
+ * frame — or the next sequence's `index: 0` — marks the end of the damage.
129
+ * The logical frame that was in flight is LOST: the caller reports that to
130
+ * the operator instead of killing the child, because a whole session (its
131
+ * LSP children, its prewarm slot) is not a fair price for one event.
132
+ */
133
+ resync(): void {
134
+ this.pending = undefined;
135
+ this.discarding = true;
136
+ }
88
137
 
89
138
  push(value: unknown): RpcFrameRecord | undefined {
90
139
  if (!isRecord(value) || value.type !== 'rpc_chunk') {
91
- if (this.pending) throw new Error('RPC chunk sequence interrupted');
140
+ if (this.pending && !this.discarding) throw new Error('RPC chunk sequence interrupted');
141
+ this.pending = undefined;
142
+ this.discarding = false;
92
143
  if (!isRecord(value) || typeof value.type !== 'string') throw new Error('RPC frame must be an object');
93
144
  return value as RpcFrameRecord;
94
145
  }
146
+ // Mid-resync: ignore the tail of the damaged sequence. `index: 0` proves a
147
+ // new sequence started, so normal handling resumes with it.
148
+ if (this.discarding && value.index !== 0) return undefined;
149
+ this.discarding = false;
150
+
95
151
  const { chunkId, index, count, byteLength } = value;
152
+ const { maxFrameBytes, maxReassembledBytes } = this.limits;
96
153
  if (
97
154
  typeof chunkId !== 'string' || chunkId.length === 0 || chunkId.length > 128 ||
98
155
  !isSafeInteger(index) || !isSafeInteger(count) || !isSafeInteger(byteLength) ||
99
- index < 0 || count < 2 || count > Math.ceil(MAX_RPC_REASSEMBLED_BYTES / RPC_CHUNK_PAYLOAD_BYTES) ||
100
- index >= count || byteLength < MAX_RPC_FRAME_BYTES || byteLength > MAX_RPC_REASSEMBLED_BYTES
156
+ index < 0 || count < 2 || count > Math.ceil(maxReassembledBytes / RPC_CHUNK_PAYLOAD_BYTES) ||
157
+ index >= count || byteLength < maxFrameBytes || byteLength > maxReassembledBytes
101
158
  ) throw new Error('invalid RPC chunk metadata');
102
159
 
103
160
  const bytes = decodeBase64(value.data);
@@ -125,27 +182,34 @@ export class RpcFrameDecoder {
125
182
  }
126
183
  }
127
184
 
128
- /** Physical JSONL records for a logical RPC frame at the selected protocol. */
129
- export function encodeRpcFrames(frame: RpcFrameRecord, protocolVersion: RpcProtocolVersion, chunkId: string): string[] {
185
+ /**
186
+ * Largest logical frame Kabmo will WRITE to an omp child, as one JSONL line.
187
+ *
188
+ * omp reads its command loop line by line, so this is only a guard against an
189
+ * unbounded write (a runaway attachment, a corrupted payload) — not a
190
+ * transport limit. Measured: a 30 MB prompt line is accepted and acked in
191
+ * ~26 s, while the same payload split into `rpc_chunk`s is rejected outright.
192
+ * The ceiling matches the reassembly limit omp advertises for the other
193
+ * direction (`maxReassembledFrameBytes`), so neither side can claim a payload
194
+ * the other refuses.
195
+ */
196
+ export const MAX_OUTBOUND_FRAME_BYTES = MAX_RPC_REASSEMBLED_BYTES;
197
+
198
+ /**
199
+ * One physical JSONL line for a logical RPC frame.
200
+ *
201
+ * NEVER chunked, whatever `negotiate_protocol` answered: omp's rpc-ui stdin
202
+ * loop answers `Unknown command: rpc_chunk` to every chunk record (verified on
203
+ * 18.14.0 and 18.16.0) and the command is then never dispatched — a prompt
204
+ * carrying a >1 MiB image sat unacked until the ack timeout reset the session.
205
+ * The refusal is thrown at the caller instead, so a payload omp would drop is
206
+ * reported rather than silently lost.
207
+ */
208
+ export function encodeRpcFrameLine(frame: RpcFrameRecord): string {
130
209
  const json = JSON.stringify(frame);
131
- // Encode once and keep the bytes: the length check needs them either way, and
132
- // the oversized path below needs them again. Previously this encoded the
133
- // whole frame to measure it, discarded that array, then encoded it a second
134
- // time to slice it.
135
- const bytes = utf8.encode(json);
136
- if (bytes.byteLength + 1 <= MAX_RPC_FRAME_BYTES) return [`${json}\n`];
137
- if (protocolVersion === 1) throw new Error('RPC frame exceeds the v1 transport limit');
138
- if (bytes.byteLength > MAX_RPC_REASSEMBLED_BYTES) throw new Error('RPC frame exceeds the v2 reassembly limit');
139
- const count = Math.ceil(bytes.byteLength / RPC_CHUNK_PAYLOAD_BYTES);
140
- const lines: string[] = [];
141
- for (let index = 0; index < count; index++) {
142
- const chunk = {
143
- type: 'rpc_chunk', chunkId, index, count, byteLength: bytes.byteLength,
144
- data: bytes.subarray(index * RPC_CHUNK_PAYLOAD_BYTES, (index + 1) * RPC_CHUNK_PAYLOAD_BYTES).toBase64(),
145
- };
146
- const line = JSON.stringify(chunk);
147
- if (lineByteLength(line) > MAX_RPC_FRAME_BYTES) throw new Error('RPC chunk exceeds the transport limit');
148
- lines.push(`${line}\n`);
210
+ const bytes = utf8.encode(json).byteLength + 1;
211
+ if (bytes > MAX_OUTBOUND_FRAME_BYTES) {
212
+ throw new Error(`RPC frame of ${bytes} bytes exceeds the ${MAX_OUTBOUND_FRAME_BYTES}-byte outbound limit`);
149
213
  }
150
- return lines;
214
+ return `${json}\n`;
151
215
  }
@@ -24,6 +24,8 @@ import { DEFAULT_CHAT_WIDTH_MODE } from '@/shared/lib/chat/timeline/width-mode';
24
24
  import { DEFAULT_TOOL_RENDER_MODE } from '@/shared/lib/chat/timeline/tool-render-mode';
25
25
  import { DEFAULT_SIDEBAR_STYLE } from '@/shared/lib/workspace/sidebar-style';
26
26
  import { DEFAULT_COMPOSER_STYLE } from '@/shared/lib/chat/composer/style';
27
+ import { DEFAULT_SURFACE_STYLE } from '@/shared/lib/theme/surface-style';
28
+ import { DEFAULT_ICON_STYLE } from '@/shared/lib/theme/icon-style';
27
29
  import { EDITOR_DEFAULT_FONT_FAMILY } from '@/shared/lib/code/editor/typography';
28
30
  import { EDITOR_DEFAULT_THEME_ID } from '@/shared/lib/code/editor/themes';
29
31
 
@@ -41,6 +43,8 @@ export const DEFAULT_SETTINGS = {
41
43
  toolRenderStyle: DEFAULT_TOOL_RENDER_MODE,
42
44
  sidebarStyle: DEFAULT_SIDEBAR_STYLE,
43
45
  composerStyle: DEFAULT_COMPOSER_STYLE,
46
+ surfaceStyle: DEFAULT_SURFACE_STYLE,
47
+ iconStyle: DEFAULT_ICON_STYLE,
44
48
  followUpBehavior: 'queue',
45
49
  keybindingSend: 'Enter',
46
50
  keybindingNewLine: 'Shift + Enter',
@@ -30,10 +30,11 @@ const COLOR_VALUE = /^(#[0-9a-f]{3}|#[0-9a-f]{6}|#[0-9a-f]{8})$/i;
30
30
 
31
31
  describe('theme catalog', () => {
32
32
  test('ships Kabmo palettes plus every ported variant', () => {
33
- expect(THEMES.length).toBe(45);
34
- // 21 ported light + paper/contrast; 21 ported dark + one-dark-pro-soft.
35
- expect(THEMES.filter((t) => t.variant === 'light').length).toBe(23);
36
- expect(THEMES.filter((t) => t.variant === 'dark').length).toBe(22);
33
+ expect(THEMES.length).toBe(63);
34
+ // 21 ported light (upstream snapshot) + 9 newer light + paper/contrast;
35
+ // 21 ported dark + 9 newer dark + one-dark-pro-soft.
36
+ expect(THEMES.filter((t) => t.variant === 'light').length).toBe(32);
37
+ expect(THEMES.filter((t) => t.variant === 'dark').length).toBe(31);
37
38
  });
38
39
 
39
40
  test('ids are unique and each palette carries a paintable color for every slot', () => {
@@ -17,7 +17,9 @@
17
17
  import type { ThemePalette, ThemeSwatch } from '@/shared/types/theme';
18
18
  import { KABMO_PALETTES } from '@/shared/lib/theme/palettes/kabmo';
19
19
  import { DARK_PALETTES } from '@/shared/lib/theme/palettes/dark';
20
+ import { DARK_EXTENDED_PALETTES } from '@/shared/lib/theme/palettes/dark-extended';
20
21
  import { LIGHT_PALETTES } from '@/shared/lib/theme/palettes/light';
22
+ import { LIGHT_EXTENDED_PALETTES } from '@/shared/lib/theme/palettes/light-extended';
21
23
 
22
24
  /** The shipped default, and the fallback for any id the catalog does not know. */
23
25
  export const DEFAULT_THEME_ID = 'paper';
@@ -30,9 +32,17 @@ export const DEFAULT_THEME_ID = 'paper';
30
32
  export type ThemeId =
31
33
  | (typeof KABMO_PALETTES)[number]['id']
32
34
  | (typeof LIGHT_PALETTES)[number]['id']
33
- | (typeof DARK_PALETTES)[number]['id'];
35
+ | (typeof LIGHT_EXTENDED_PALETTES)[number]['id']
36
+ | (typeof DARK_PALETTES)[number]['id']
37
+ | (typeof DARK_EXTENDED_PALETTES)[number]['id'];
34
38
 
35
- const ALL_PALETTES = [...KABMO_PALETTES, ...LIGHT_PALETTES, ...DARK_PALETTES];
39
+ const ALL_PALETTES = [
40
+ ...KABMO_PALETTES,
41
+ ...LIGHT_PALETTES,
42
+ ...LIGHT_EXTENDED_PALETTES,
43
+ ...DARK_PALETTES,
44
+ ...DARK_EXTENDED_PALETTES,
45
+ ];
36
46
 
37
47
  const BY_ID: Record<string, ThemePalette | undefined> = Object.fromEntries(
38
48
  ALL_PALETTES.map((theme) => [theme.id, theme]),
@@ -50,7 +60,12 @@ const DEFAULT_PALETTE: ThemePalette = KABMO_PALETTES[0];
50
60
  */
51
61
  export const THEMES: readonly ThemePalette[] = (() => {
52
62
  const families = new Map<string, ThemePalette[]>();
53
- for (const palette of [...LIGHT_PALETTES, ...DARK_PALETTES]) {
63
+ for (const palette of [
64
+ ...LIGHT_PALETTES,
65
+ ...DARK_PALETTES,
66
+ ...LIGHT_EXTENDED_PALETTES,
67
+ ...DARK_EXTENDED_PALETTES,
68
+ ]) {
54
69
  const group = families.get(palette.family);
55
70
  if (group) group.push(palette);
56
71
  else families.set(palette.family, [palette]);
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { describe, expect, test } from 'bun:test';
7
+ import { GLASS_LIMIT_COPY, glassLimits, type GlassLimit } from '@/shared/lib/theme/glass-support';
8
+
9
+ describe('glass support', () => {
10
+ test('a supported engine with no preference reports nothing', () => {
11
+ expect(glassLimits({ backdropFilter: true, reducedTransparency: false })).toEqual([]);
12
+ });
13
+
14
+ test('a missing backdrop-filter is named even when the system also asked for less transparency', () => {
15
+ // The ORDER is the point: with no blur, the media query has nothing to switch
16
+ // off, so naming the preference first would send the reader to an OS setting
17
+ // that changes nothing on that engine.
18
+ expect(glassLimits({ backdropFilter: false, reducedTransparency: true })).toEqual([
19
+ 'no-backdrop-filter',
20
+ 'reduced-transparency',
21
+ ]);
22
+ });
23
+
24
+ test('reduced transparency alone is a limit, because the frost really is off', () => {
25
+ expect(glassLimits({ backdropFilter: true, reducedTransparency: true })).toEqual([
26
+ 'reduced-transparency',
27
+ ]);
28
+ });
29
+
30
+ test('every limit has copy long enough to act on', () => {
31
+ const limits: GlassLimit[] = ['no-backdrop-filter', 'reduced-transparency'];
32
+ for (const limit of limits) {
33
+ // A limit with no sentence is a warning nobody can act on; the number is the
34
+ // shortest of the two shipped strings.
35
+ expect(GLASS_LIMIT_COPY[limit].length).toBeGreaterThan(80);
36
+ }
37
+ });
38
+ });
@@ -0,0 +1,73 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Whether the machine running this document can actually draw the glass
8
+ * material, and if not, WHY.
9
+ *
10
+ * The `glass` surface style is pure CSS: one `backdrop-filter` on the window
11
+ * plane plus the tiers above it. Every shell Kabmo ships renders the same page —
12
+ * Android's `WebView`, iOS/macOS `WKWebView`, Windows' WebView2 and Linux's
13
+ * WebKitGTK 4.1 — so the style is not per-platform. What IS per-platform is the
14
+ * two ways it silently stops working:
15
+ *
16
+ * - **The engine has no `backdrop-filter`.** Then `glass.css`'s `@supports not
17
+ * (…)` block hands back the opaque palette, and the window looks exactly like
18
+ * `classic` while the setting says `glass`. The prefix matters here: Chromium
19
+ * only shipped the UNPREFIXED property in 76, so an Android 7 device
20
+ * (`minSdk 24`) whose WebView was never updated still needs
21
+ * `-webkit-backdrop-filter`, which the stylesheets always write.
22
+ * - **The system asked apps to reduce transparency.** macOS/iOS "Reduce
23
+ * Transparency", GNOME's equivalent: the `prefers-reduced-transparency` media
24
+ * query fires and every translucent token resolves to opaque paper. That is
25
+ * the intended behaviour — a frosted window is exactly what the setting exists
26
+ * to remove — but a user who switched the surface style ON and sees no change
27
+ * reads it as a bug ("glass doesn't work on my mac").
28
+ *
29
+ * Both are REPORTED rather than papered over (`AGENTS.md` §6: a substitution has
30
+ * to name itself), which is the whole reason this module exists: the fallback in
31
+ * CSS cannot say anything, so the settings control says it once, in the place the
32
+ * choice is made.
33
+ *
34
+ * This module is pure — the caller passes what the platform's own APIs answered —
35
+ * so the rule is testable without a browser, and the same answers can be checked
36
+ * from a terminal (`CSS.supports`, `matchMedia`) when a shell misbehaves.
37
+ */
38
+
39
+ export type GlassLimit = 'no-backdrop-filter' | 'reduced-transparency';
40
+
41
+ /** What the platform APIs answered. Both are cheap and synchronous. */
42
+ export interface GlassProbe {
43
+ /** `CSS.supports('backdrop-filter', …) || CSS.supports('-webkit-backdrop-filter', …)`. */
44
+ backdropFilter: boolean;
45
+ /** `matchMedia('(prefers-reduced-transparency: reduce)').matches`. */
46
+ reducedTransparency: boolean;
47
+ }
48
+
49
+ /**
50
+ * Every reason the frost will not appear, in the order they matter.
51
+ *
52
+ * An engine that cannot blur is the FIRST reason even when the system also asked
53
+ * for less transparency: with no `backdrop-filter` the media query has nothing to
54
+ * switch off, and naming the preference first would send the reader to an OS
55
+ * setting that changes nothing.
56
+ */
57
+ export function glassLimits({ backdropFilter, reducedTransparency }: GlassProbe): GlassLimit[] {
58
+ const limits: GlassLimit[] = [];
59
+ if (!backdropFilter) limits.push('no-backdrop-filter');
60
+ if (reducedTransparency) limits.push('reduced-transparency');
61
+ return limits;
62
+ }
63
+
64
+ /**
65
+ * What the settings control says. `null` for a limit is not allowed — a limit
66
+ * with no sentence is a warning nobody can act on.
67
+ */
68
+ export const GLASS_LIMIT_COPY: Record<GlassLimit, string> = {
69
+ 'no-backdrop-filter':
70
+ 'This engine reports no backdrop blur, so the frost falls back to opaque panels here — the window keeps the glass colours but loses the blur.',
71
+ 'reduced-transparency':
72
+ 'Your system asks apps to reduce transparency, so the frost is switched off. Turn that system setting off to see the glass material.',
73
+ };
@@ -0,0 +1,74 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The icon style's contract.
8
+ *
9
+ * Two facts are pinned here: the default must be what shipped (monochrome ink),
10
+ * and an unreadable stored value must land on it rather than leaving every mark
11
+ * with no rule to paint it.
12
+ */
13
+
14
+ import { describe, expect, test } from 'bun:test';
15
+ import {
16
+ DEFAULT_ICON_STYLE,
17
+ ICON_STYLE_ATTRIBUTE,
18
+ ICON_STYLES,
19
+ ICON_STYLE_COPY,
20
+ isIconStyle,
21
+ resolveIconStyle,
22
+ } from '@/shared/lib/theme/icon-style';
23
+
24
+ describe('isIconStyle', () => {
25
+ test('accepts exactly the two styles', () => {
26
+ expect(ICON_STYLES.map(isIconStyle)).toEqual([true, true]);
27
+ });
28
+
29
+ test('refuses what another build or a corrupted blob could carry', () => {
30
+ for (const value of ['', 'Color', 'colour', 'full-color', 0, 1, true, null, undefined, {}, ['color']]) {
31
+ expect(isIconStyle(value)).toBe(false);
32
+ }
33
+ });
34
+ });
35
+
36
+ describe('resolveIconStyle', () => {
37
+ test('keeps a style this build draws', () => {
38
+ expect(resolveIconStyle('monochrome')).toBe('monochrome');
39
+ expect(resolveIconStyle('color')).toBe('color');
40
+ });
41
+
42
+ test('an unknown value lands on the shipped default, not on undefined', () => {
43
+ expect(resolveIconStyle('vivid')).toBe(DEFAULT_ICON_STYLE);
44
+ expect(resolveIconStyle(undefined)).toBe(DEFAULT_ICON_STYLE);
45
+ expect(resolveIconStyle(null)).toBe(DEFAULT_ICON_STYLE);
46
+ });
47
+ });
48
+
49
+ describe('the style table', () => {
50
+ test('the default is monochrome, which is what every mark shipped as', () => {
51
+ expect(DEFAULT_ICON_STYLE).toBe('monochrome');
52
+ expect(ICON_STYLES).toContain(DEFAULT_ICON_STYLE);
53
+ });
54
+
55
+ test('the attribute is a plain `data-` name', () => {
56
+ expect(ICON_STYLE_ATTRIBUTE).toBe('data-icon-style');
57
+ });
58
+
59
+ test('every style carries its own label and description', () => {
60
+ const labels = ICON_STYLES.map((style) => ICON_STYLE_COPY[style].label);
61
+ expect(new Set(labels).size).toBe(ICON_STYLES.length);
62
+ for (const style of ICON_STYLES) {
63
+ expect(ICON_STYLE_COPY[style].description.length).toBeGreaterThan(0);
64
+ }
65
+ });
66
+
67
+ test('the colour copy names what it colours, so the mode promises no literal hex', () => {
68
+ // Every icon family is covered by the setting; the copy has to say so or a
69
+ // user cannot tell what they just switched on.
70
+ const description = ICON_STYLE_COPY.color.description;
71
+ expect(description).toContain('glyphs');
72
+ expect(description).toContain('brand');
73
+ });
74
+ });
@@ -0,0 +1,90 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * How EVERY icon is painted, as ONE of two styles.
8
+ *
9
+ * Three families of icon ship in this app and this setting covers all three:
10
+ *
11
+ * 1. **Functional glyphs** — Lucide's stroke icons (247 imports, 346 files).
12
+ * There is no second artwork to swap in, so `color` can only mean a TINT.
13
+ * Each glyph gets its own hue from a generated table (`icons/tint.ts`), except
14
+ * the ones whose meaning IS a signal (a trash can, a check, a clock, an info
15
+ * dot), which take the palette's `--theme-error` / `-success` / `-warning` /
16
+ * `-info`.
17
+ * 2. **Provider and model marks** (`provider-icon/`) — brand logos, painted in
18
+ * the brand's own colour where it publishes one.
19
+ * 3. **File-type marks** (`file-icon/`) — the language and tool logos a file
20
+ * list is read by.
21
+ *
22
+ * - `monochrome` — every icon in the surrounding ink. The DEFAULT, because it
23
+ * is what Kabmo ships today: an upgrade must not repaint a window the user
24
+ * did not ask to change.
25
+ * - `color` — each icon in its own colour. A brand colour that would
26
+ * vanish on the active variant (a black logo on a dark theme) keeps the ink
27
+ * instead, and the generated hues are stated at a lightness that clears the
28
+ * 3:1 non-text floor on every palette of that variant, so this never trades a
29
+ * legible row for a literal hex.
30
+ *
31
+ * Every rule is `:where()`-wrapped, so this is a DEFAULT paint and never an
32
+ * override: a caller's own `text-error` on a missing file, or `text-ink/40` on a
33
+ * muted row, still wins. That is what makes one global switch safe over 346
34
+ * files that never agreed to it.
35
+ *
36
+ * The style reaches the document as `data-icon-style` on `<html>`, read by CSS
37
+ * only: `ProviderIconPlate` alone is drawn in 26 places across five surfaces,
38
+ * and a prop would be 26 chances to miss one.
39
+ */
40
+
41
+ export type IconStyle = 'monochrome' | 'color';
42
+
43
+ /**
44
+ * The style a document with no stored preference renders at. Every provider
45
+ * mark was ink before this setting existed, so this is the no-change default.
46
+ */
47
+ export const DEFAULT_ICON_STYLE: IconStyle = 'monochrome';
48
+
49
+ /** Document attribute carrying the style. Read by CSS only. */
50
+ export const ICON_STYLE_ATTRIBUTE = 'data-icon-style';
51
+
52
+ /** `app_settings` key holding the style — see `SURFACE_STYLE_SETTING_KEY`. */
53
+ export const ICON_STYLE_SETTING_KEY = 'iconStyle';
54
+
55
+ /** Every style, in the order the settings control lists them. */
56
+ export const ICON_STYLES = ['monochrome', 'color'] as const;
57
+
58
+ /** A stored value written by another build is not a style this one can draw. */
59
+ export function isIconStyle(value: unknown): value is IconStyle {
60
+ return value === 'monochrome' || value === 'color';
61
+ }
62
+
63
+ /**
64
+ * The style to APPLY for a stored value. Anything this build cannot draw
65
+ * resolves to the default, so a corrupted blob cannot leave every mark
66
+ * unpainted.
67
+ */
68
+ export function resolveIconStyle(value: unknown): IconStyle {
69
+ return isIconStyle(value) ? value : DEFAULT_ICON_STYLE;
70
+ }
71
+
72
+ export interface IconStyleCopy {
73
+ label: string;
74
+ /** The tradeoff, stated once — including what the mode cannot colour. */
75
+ description: string;
76
+ caption: string;
77
+ }
78
+
79
+ export const ICON_STYLE_COPY: Record<IconStyle, IconStyleCopy> = {
80
+ monochrome: {
81
+ label: 'Monochrome',
82
+ description: 'Every icon inherits the palette ink — toolbar glyphs, provider logos and file marks alike. The most uniform reading.',
83
+ caption: 'Palette ink',
84
+ },
85
+ color: {
86
+ label: 'Full colour',
87
+ description: 'Each icon gets its own colour: glyphs a per-icon hue, brand marks their own logo colour, a project its accent. Tool cards in a transcript stay ink — they are read, not scanned.',
88
+ caption: 'Per-icon colour',
89
+ },
90
+ };
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * How legible a brand colour is on the palettes this build actually ships.
8
+ *
9
+ * Brand art arrives with ONE hex, chosen by the brand for its own background.
10
+ * Kabmo paints it on 63 palettes, so "the brand's colour" is not paintable
11
+ * as-is: measured, `claude`'s `#D97757` reads 2.77:1 on `#f4f1ea` (the darkest
12
+ * light paper shipped) while it is 5.25:1 on `#201E2B` (the lightest dark one).
13
+ * This module is the one place that decides what to paint instead, so the
14
+ * provider table and the file-type table cannot disagree about the rule.
15
+ *
16
+ * Two properties are load-bearing:
17
+ *
18
+ * - **The worst surface is MEASURED, not assumed.** It is the minimum contrast
19
+ * against every palette of that variant (`THEMES`), not against one hardcoded
20
+ * hex — a new palette with a mid-tone paper would otherwise silently drop a
21
+ * mark below the floor. Cost is 63 comparisons per brand, once per process.
22
+ * - **A near-monochrome brand gets NO dark value.** `#000000` mixed toward white
23
+ * lands on `#737373`, which is indistinguishable from the ink it was meant to
24
+ * replace while claiming to be a brand colour; those brands are drawn in the
25
+ * theme's ink instead (`dark: null`), which is what the reference
26
+ * implementation does with `filter: invert()`.
27
+ */
28
+
29
+ import { THEMES } from '@/shared/lib/theme/catalog';
30
+ import { mixHex, parseHexColor, relativeLuminance } from '@/shared/lib/theme/color';
31
+
32
+ /** WCAG's non-text floor: an icon is a graphic, not body copy. */
33
+ export const BRAND_CONTRAST_FLOOR = 3;
34
+
35
+ /** Below this channel spread a hex carries no hue worth keeping. */
36
+ const MONOCHROME_CHROMA = 24;
37
+
38
+ /** The largest step the mixer takes while searching for a legible shade. */
39
+ const MIX_STEP = 5;
40
+ const MIX_MAX = 95;
41
+
42
+ export function contrastRatio(a: string, b: string): number {
43
+ const [hi, lo] = [relativeLuminance(a), relativeLuminance(b)].sort((x, y) => y - x);
44
+ return (hi + 0.05) / (lo + 0.05);
45
+ }
46
+
47
+ /** Channel spread of a hex: at most 24 apart means the art is monochrome. */
48
+ export function isNearMonochrome(hex: string): boolean {
49
+ const color = parseHexColor(hex);
50
+ if (!color) return true;
51
+ return Math.max(color.r, color.g, color.b) - Math.min(color.r, color.g, color.b) < MONOCHROME_CHROMA;
52
+ }
53
+
54
+ /**
55
+ * The lowest contrast `color` reaches on any palette surface of `variant`.
56
+ *
57
+ * `paper` is the surface a mark is drawn on (a plate, a row, a card); the
58
+ * canvas is behind panels and never touches a mark directly.
59
+ */
60
+ export function worstSurfaceContrast(color: string, variant: 'light' | 'dark'): number {
61
+ let worst = Number.POSITIVE_INFINITY;
62
+ for (const theme of THEMES) {
63
+ if (theme.variant !== variant) continue;
64
+ worst = Math.min(worst, contrastRatio(color, theme.paper));
65
+ }
66
+ return worst === Number.POSITIVE_INFINITY ? BRAND_CONTRAST_FLOOR : worst;
67
+ }
68
+
69
+ /** `hex` moved toward `toward` in 5% steps until it clears the floor. */
70
+ function legibleToward(hex: string, toward: string, variant: 'light' | 'dark'): string {
71
+ if (worstSurfaceContrast(hex, variant) >= BRAND_CONTRAST_FLOOR) return hex;
72
+ for (let percent = MIX_STEP; percent <= MIX_MAX; percent += MIX_STEP) {
73
+ const mixed = mixHex(hex, toward, percent / 100);
74
+ if (worstSurfaceContrast(mixed, variant) >= BRAND_CONTRAST_FLOOR) return mixed;
75
+ }
76
+ return hex;
77
+ }
78
+
79
+ /**
80
+ * The two values a brand colour is painted in.
81
+ *
82
+ * The light value is the brand hex, or the same hue mixed toward black until it
83
+ * clears the floor on every light palette; the dark value is the mirror image
84
+ * toward white. `dark: null` means "this brand is monochrome art — draw it in
85
+ * the theme's ink", which is the only honest answer for a black logo.
86
+ */
87
+ export function legiblePair(base: string): { light: string; dark: string | null } {
88
+ const light = legibleToward(base, '#000000', 'light');
89
+ const dark = isNearMonochrome(base) ? null : legibleToward(base, '#ffffff', 'dark');
90
+ return { light, dark };
91
+ }