@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
@@ -0,0 +1,234 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The generated paint stylesheet.
8
+ *
9
+ * Three properties are load-bearing and each fails silently:
10
+ *
11
+ * - **The sheet is inside `@layer utilities` and every rule is
12
+ * `:where()`-wrapped.** Both halves are needed: a cascade layer beats
13
+ * specificity, so an unlayered rule shrugs off `text-ink/75` no matter how low
14
+ * its specificity is (measured: a muted folder icon kept its generated hue).
15
+ * Together they keep a caller's `text-error` on a missing file — and a muted
16
+ * `text-ink/40` on a disabled row — winning over the mode.
17
+ * - **Every rule is gated on `[data-icon-style="color"]`.** A rule that leaked
18
+ * would tint icons for a user who chose monochrome.
19
+ * - **Signal rows come after the hue rows**, so `--icon-hue` cannot shadow a
20
+ * palette signal on the same element.
21
+ */
22
+
23
+ import { describe, expect, test } from 'bun:test';
24
+ import {
25
+ ICON_PAINT_STYLE_ELEMENT_ID,
26
+ iconPaintStyleSheet,
27
+ } from '@/shared/lib/icons/icon-paint-css';
28
+ import { BRAND_COLORS } from '@/shared/lib/models/provider/brand-color';
29
+ import { FILE_BRAND_COLORS } from '@/shared/lib/icons/file-brand-color';
30
+ import { ICON_HUE_ROWS, ICON_TINT_ROWS, ICON_TINT_TOKENS } from '@/shared/lib/icons/tint';
31
+
32
+ const css = iconPaintStyleSheet();
33
+ const rules = css.split('\n').filter((line) => line.startsWith(':where('));
34
+
35
+ describe('the icon paint stylesheet', () => {
36
+ test('exports the element id the SSR shell and the client both look for', () => {
37
+ expect(ICON_PAINT_STYLE_ELEMENT_ID).toBe('omp-icon-paint');
38
+ });
39
+
40
+ test('the whole sheet sits in the utilities layer, and states the order first', () => {
41
+ // A cascade layer outranks specificity: an unlayered rule would beat the
42
+ // author's `text-*` class however low its own specificity is. And the ORDER
43
+ // has to be stated here, because this sheet is inlined into <head> and is
44
+ // parsed BEFORE the bundled stylesheet — a bare `@layer utilities { … }`
45
+ // would freeze utilities as the lowest layer and demote every utility
46
+ // (measured: the sidebar collapsed to a 0-width column).
47
+ const orderIndex = css.indexOf('@layer theme, base, components, utilities;');
48
+ const blockIndex = css.indexOf('@layer utilities {');
49
+ expect(orderIndex).toBeGreaterThanOrEqual(0);
50
+ expect(blockIndex).toBeGreaterThan(orderIndex);
51
+ expect(css.trimEnd().endsWith('}')).toBe(true);
52
+ });
53
+
54
+ test('every rule either turns colour ON or states what monochrome means', () => {
55
+ // Three families of exception, each deliberate: the monochrome rules (the
56
+ // absence of the attribute is a mode too), the project accent (which belongs
57
+ // to the colour mode), and the tool-card rules (ink in BOTH modes).
58
+ const monochrome = /^:root:not\(\[data-icon-style="color"\]\)/;
59
+ const accent = /^:root\[data-icon-style="color"\] \.project-accent-mark/;
60
+ const toolCard = /^\[data-tool-row\] /;
61
+ for (const rule of rules) {
62
+ const ok =
63
+ rule.startsWith(':where([data-icon-style="color"]') ||
64
+ monochrome.test(rule) ||
65
+ accent.test(rule) ||
66
+ toolCard.test(rule);
67
+ expect(ok, rule.slice(0, 70)).toBe(true);
68
+ }
69
+ });
70
+
71
+ test('monochrome paints ink, not the inherited colour, and skips inverted surfaces', () => {
72
+ // `currentColor` was not enough: a `Check` inside a green chip INHERITS the
73
+ // chip's green, so two icons survived a monochrome pass that way.
74
+ expect(css).toContain(
75
+ ':root:not([data-icon-style="color"]) svg.lucide:not([class*="text-ink"]):not(.bg-ink *) { color: var(--theme-ink); }',
76
+ );
77
+ expect(css).toContain(':root:not([data-icon-style="color"]) [data-plugin-mark] { --plugin-color: currentColor; }');
78
+ });
79
+
80
+ test('a tool card is ink in both modes, so the transcript never turns into confetti', () => {
81
+ expect(css).toContain('[data-tool-row] svg.lucide:not([class*="text-ink"]):not(.bg-ink *) { color: var(--theme-ink); }');
82
+ expect(css).toContain('[data-tool-row] [data-plugin-mark] { --plugin-color: var(--theme-ink); }');
83
+ });
84
+
85
+ test('a muted ink icon takes its hue, muted toward the ink rather than faded out', () => {
86
+ // `text-ink/60` is a WEIGHT. It is (0,1,0) and the hue rules are (0,0,0), so
87
+ // the mute won and every muted icon stayed ink in the colour mode — the
88
+ // reported "icon di setting modal kenapa gk full color".
89
+ expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class*="text-ink/60"] { color: color-mix(in srgb,');
90
+ expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class~="text-ink"] { color: hsl(var(--icon-hue');
91
+ // Mixed toward the INK, never toward transparency: a hue at 40% alpha is
92
+ // 1.56:1 against its surface, worse than the `text-ink/40` it replaces.
93
+ const muted = css.split('\n').find((line) => line.includes('text-ink/40"')) ?? '';
94
+ expect(muted).toContain('var(--theme-ink)');
95
+ expect(muted).not.toContain('transparent');
96
+ });
97
+
98
+ test('the project accent survives the dark ink weights', () => {
99
+ // Each folder mark carries the user's OWN colour as `--project-accent`, and
100
+ // the call sites also write `text-ink/70`. The dark weight selector is
101
+ // `[data-icon-style="color"][data-theme-variant="dark"] svg.lucide[class*="text-ink/70"]`
102
+ // = (0,4,1) — one ELEMENT above
103
+ // `:root[data-icon-style="color"] .project-accent-mark` = (0,4,0) — so on a
104
+ // dark theme every folder icon came out the same hue and light looked fine.
105
+ // "A weight does not apply to the user's own colour" is the fix; out-specifying
106
+ // it would be a tie waiting for the next attribute.
107
+ expect(css).toContain('[data-icon-style="color"] svg.lucide:not(.project-accent-mark)[class*="text-ink/70"]');
108
+ expect(css).toContain(
109
+ '[data-icon-style="color"][data-theme-variant="dark"] svg.lucide:not(.project-accent-mark)[class*="text-ink/70"]',
110
+ );
111
+ expect(css).toContain(':root[data-icon-style="color"] .project-accent-mark { color: var(--project-accent); }');
112
+ // Every weight rule, not just the one probed by hand: a single step that
113
+ // forgets the `:not()` is a folder mark that goes back to the shared hue.
114
+ const weightRules = css.split('\n').filter((line) => line.includes('svg.lucide[class*="text-ink/') || line.includes('svg.lucide:not(.project-accent-mark)[class~="text-ink"'));
115
+ expect(weightRules.length).toBeGreaterThan(0);
116
+ for (const line of weightRules) expect(line).toContain(':not(.project-accent-mark)');
117
+ });
118
+
119
+ test('the project accent belongs to the colour mode', () => {
120
+ expect(css).toContain(':root[data-icon-style="color"] .project-accent-mark { color: var(--project-accent); }');
121
+ });
122
+
123
+ test('every selector is wrapped in :where(), so a caller class still wins', () => {
124
+ for (const rule of rules) {
125
+ const selector = rule.slice(0, rule.indexOf('{'));
126
+ // Balanced `:where(` and `)`: every compound in the selector is wrapped.
127
+ const opens = selector.split(':where(').length - 1;
128
+ const closes = selector.split(')').length - 1;
129
+ expect(opens, selector).toBeGreaterThan(0);
130
+ expect(closes, selector).toBe(opens);
131
+ }
132
+ });
133
+
134
+ test('the base hue rule paints a custom-property hsl(), per variant', () => {
135
+ expect(css).toContain(':where(svg.lucide) { color: hsl(var(--icon-hue,');
136
+ expect(css).toContain(':where([data-icon-style="color"][data-theme-variant="dark"]) :where(svg.lucide) { color: hsl(var(--icon-hue,');
137
+ });
138
+
139
+ test('one hue statement per generated row', () => {
140
+ for (const { className, hue } of ICON_HUE_ROWS) {
141
+ expect(css).toContain(`:where(svg.${className}) { --icon-hue: ${hue}; }`);
142
+ }
143
+ });
144
+
145
+ test('every signal row paints its palette token, after the hue rows', () => {
146
+ const hueIndex = css.indexOf('--icon-hue');
147
+ for (const { className, role } of ICON_TINT_ROWS) {
148
+ const needle = `:where(svg.${className}) { color: ${ICON_TINT_TOKENS[role]}; }`;
149
+ expect(css).toContain(needle);
150
+ expect(css.indexOf(needle), `${className} must follow the hue rules`).toBeGreaterThan(hueIndex);
151
+ }
152
+ });
153
+
154
+ test('every provider row paints both variants', () => {
155
+ for (const [name, entry] of Object.entries(BRAND_COLORS)) {
156
+ const selector = `svg[data-provider="${name}"]`;
157
+ expect(css).toContain(`:where(${selector}) { color: ${entry.light}; }`);
158
+ expect(css).toContain(`color: ${entry.dark ?? 'var(--theme-ink)'}; }`);
159
+ }
160
+ });
161
+
162
+ test('every file-brand row paints both variants', () => {
163
+ for (const [name, entry] of Object.entries(FILE_BRAND_COLORS)) {
164
+ const selector = `svg[data-file-brand="${name}"]`;
165
+ expect(css).toContain(`:where(${selector}) { color: ${entry.light}; }`);
166
+ expect(css).toContain(`color: ${entry.dark ?? 'var(--theme-ink)'}; }`);
167
+ }
168
+ });
169
+
170
+ test('a plugin mark takes a runtime hue through --plugin-color', () => {
171
+ // The hue is `hashHue(name)`, which no build can enumerate: the component
172
+ // sets `--icon-hue` inline and these rules turn it into paint.
173
+ expect(css).toContain(':where([data-plugin-mark]) { --plugin-color: var(--plugin-declared-light, hsl(var(--icon-hue,');
174
+ expect(css).toContain(':where([data-icon-style="color"][data-theme-variant="dark"]) :where([data-plugin-mark])');
175
+ });
176
+
177
+ test('a panel mark outranks a caller state class, and dims by LUMINANCE', () => {
178
+ // Two surfaces write a WEIGHT (`text-ink/70`, `text-ink/30`) to say whether
179
+ // a panel is active: the rail's button and the Built-in list's off row. A
180
+ // zero-specificity hue rule lost to it, which is what kept the right rail
181
+ // monochrome. These rules carry enough specificity to win, `:not(.bg-ink *)`
182
+ // keeps an inverted chip on its own foreground, and `[data-idle]` replaces
183
+ // the colour as the state instead of stacking a second one on top.
184
+ expect(css).toContain(':root[data-icon-style="color"] [data-panel-mark]:not(.bg-ink *) svg.lucide { color: var(--panel-color-light, hsl(var(--panel-hue, var(--icon-hue,');
185
+ expect(css).toContain(':root[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark]:not(.bg-ink *) svg.lucide');
186
+ // A plugin's own mark states `--plugin-color` from its name; inside a panel
187
+ // mark the panel's declared colour (or its assigned hue) is the authority.
188
+ expect(css).toContain(':root[data-icon-style="color"] [data-panel-mark] [data-plugin-mark] { --plugin-color: var(--panel-color-light,');
189
+ // The idle state must NOT be alpha. `opacity: 0.45` composites the hue with
190
+ // the rail's near-neutral chrome and throws most of the chroma away — the
191
+ // measured 95 → 62 on a 64px glyph, which is the "kusem" report. A brightness
192
+ // shift moves luminance only; the two variants shift opposite ways because
193
+ // "recede" is darker on ink and lighter on paper.
194
+ expect(css).toContain('[data-icon-style="color"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(1.25) saturate(1.05); }');
195
+ expect(css).toContain(
196
+ '[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(0.62) saturate(1.4); }',
197
+ );
198
+ // And the state must not be stated twice: an opacity left behind would
199
+ // desaturate exactly what the filter restored.
200
+ expect(css).not.toContain('[data-panel-mark][data-idle] { opacity');
201
+ // A plugin that DECLARES its own colour is exempt: the settings card draws
202
+ // the same mark at full strength, and one brand in two intensities is what
203
+ // made the two views disagree.
204
+ expect(css).toContain('[data-panel-mark][data-idle]:not([data-declared])');
205
+ });
206
+
207
+ test('an inverted surface takes its own foreground, not a hue', () => {
208
+ // `bg-ink` is the palette's FOREGROUND used as a fill, so it is dark on a
209
+ // light theme and light on a dark one — a paper-tuned hue is invisible on it
210
+ // in one of the two (measured 1.6:1 and 1.9:1 on the primary New Session
211
+ // button). Swapping the variant is not enough either: several palettes have a
212
+ // mid-tone ink (`#586e75`, `#93a1a1`), where no hue at any lightness clears
213
+ // 3:1. The surface already declares `text-canvas`/`text-paper`, and the
214
+ // palette guarantees that pair, so the icon inherits it.
215
+ expect(css).toContain(':where([data-icon-style="color"]) :where(.bg-ink) :where(svg.lucide) { color: currentColor; }');
216
+ expect(css).toContain(':where([data-icon-style="color"]) :where(.bg-ink) :where([data-plugin-mark]) { --plugin-color: currentColor; }');
217
+ // Same zero specificity as the base rules, so it has to come AFTER them.
218
+ expect(css.indexOf(':where(.bg-ink) :where(svg.lucide)')).toBeGreaterThan(css.indexOf(':where(svg.lucide) { color: hsl(var(--icon-hue'));
219
+ });
220
+
221
+ test('a plugin manifest colour wins over the hashed hue', () => {
222
+ // `--panel-declared`/`--panel-color` is the plugin's OWN brand, and the
223
+ // hashed hue is only the fallback — the order inside the `var()` chain is the
224
+ // contract, so it is pinned literally.
225
+ expect(css).toContain('--plugin-color: var(--plugin-declared-light, hsl(var(--icon-hue');
226
+ expect(css).toContain('--plugin-color: var(--plugin-declared-dark, hsl(var(--icon-hue');
227
+ expect(css).toContain('color: var(--panel-color-light, hsl(var(--panel-hue, var(--icon-hue,');
228
+ expect(css).toContain('color: var(--panel-color-dark, hsl(var(--panel-hue, var(--icon-hue,');
229
+ });
230
+
231
+ test('the string is cached, not rebuilt per call', () => {
232
+ expect(iconPaintStyleSheet()).toBe(css);
233
+ });
234
+ });
@@ -0,0 +1,284 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Every `[data-icon-style="color"]` rule, as one generated string.
8
+ *
9
+ * Three families of icon live in this app and they need three different paints,
10
+ * but they share ONE contract: **a paint rule is a DEFAULT, never an override.**
11
+ * Two mechanisms together buy that, and BOTH are needed:
12
+ *
13
+ * - **`:where()` on every selector**, so the whole sheet has zero specificity.
14
+ * - **`@layer utilities` around it**, so it sits in Tailwind's own utilities
15
+ * layer. A cascade layer beats specificity: an UNLAYERED rule wins over every
16
+ * layered one, so without this wrapper a zero-specificity rule still beat
17
+ * `text-ink/75` — measured in the running console, a muted folder icon painted
18
+ * its generated purple instead of the muted ink. Inside the layer, the
19
+ * caller's class (specificity 0,1,0) outranks ours (0) and wins.
20
+ *
21
+ * The sheet therefore declares Tailwind's FULL layer order before its own block.
22
+ * That is not decoration: this `<style>` is inlined into the shell's `<head>`,
23
+ * which the browser parses BEFORE the bundled stylesheet, and a first `@layer
24
+ * utilities { … }` block would freeze `utilities` as the LOWEST layer — every
25
+ * later `theme, base, components` block would then outrank every utility, and
26
+ * the whole app would lose its spacing and borders. Measured: with the bare
27
+ * block, the sidebar and composer collapsed to a 0-width column.
28
+ *
29
+ * That is what makes a global colour mode safe over 346 files that never agreed
30
+ * to it: the app's deliberate colours are untouched, and the icons that said
31
+ * nothing get one.
32
+ *
33
+ * 1. **Functional glyphs** (`lucide-*`) get their own hue, or a palette signal
34
+ * when the glyph means something (`icons/tint.ts`). Two statements, not 210:
35
+ * the hue is a custom property on the class, and ONE paint rule reads it.
36
+ * 2. **Provider marks** (`data-provider`) take their brand's colour.
37
+ * 3. **File-type marks** (`data-file-brand`) take theirs.
38
+ *
39
+ * The two brand families also emit a dark rule, because their light value is a
40
+ * darkened brand hex and would be illegible on a dark palette; the
41
+ * near-monochrome rows pin `var(--theme-ink)` explicitly, so the mark cannot
42
+ * inherit a colour from a hover state.
43
+ *
44
+ * No DOM here — the SSR shell inlines this, and the client injects the same
45
+ * string only when a served document predates it.
46
+ */
47
+
48
+ import { BRAND_COLORS } from '@/shared/lib/models/provider/brand-color';
49
+ import { panelMarkRules } from '@/shared/lib/icons/icon-paint-panel';
50
+ import { FILE_BRAND_COLORS } from '@/shared/lib/icons/file-brand-color';
51
+ import {
52
+ DEFAULT_ICON_HUE,
53
+ ICON_HUE_ROWS,
54
+ ICON_TINT_ROWS,
55
+ ICON_TINT_TOKENS,
56
+ iconHuePaint,
57
+ } from '@/shared/lib/icons/tint';
58
+
59
+ /** The `<style>` element's id: the SSR shell writes it, the client checks it. */
60
+ export const ICON_PAINT_STYLE_ELEMENT_ID = 'omp-icon-paint';
61
+
62
+ /** Both rules for one brand, since a brand colour has two values. */
63
+ function brandRules(selector: string, light: string, dark: string | null): string[] {
64
+ return [
65
+ `:where([data-icon-style="color"]) :where(${selector}) { color: ${light}; }`,
66
+ `:where([data-icon-style="color"][data-theme-variant="dark"]) :where(${selector}) { color: ${dark ?? 'var(--theme-ink)'}; }`,
67
+ ];
68
+ }
69
+
70
+ /** The hue a functional glyph is painted with, per variant. */
71
+ function hueRules(): string[] {
72
+ const rules = [
73
+ `:where([data-icon-style="color"]) :where(svg.lucide) { color: ${iconHuePaint('light')}; }`,
74
+ `:where([data-icon-style="color"][data-theme-variant="dark"]) :where(svg.lucide) { color: ${iconHuePaint('dark')}; }`,
75
+ ];
76
+ for (const { className, hue } of ICON_HUE_ROWS) {
77
+ rules.push(`:where([data-icon-style="color"]) :where(svg.${className}) { --icon-hue: ${hue}; }`);
78
+ }
79
+ return rules;
80
+ }
81
+
82
+ /**
83
+ * MONOCHROME: an icon takes the ink of the text beside it.
84
+ *
85
+ * The colour mode is a generated sheet of hues; monochrome is the ABSENCE of the
86
+ * attribute, and until this rule that absence only meant "no hue is added" — it
87
+ * did not take away the colours an AUTHOR had written. So a `Check` with
88
+ * `text-success` in a tool card stayed green with the setting on monochrome
89
+ * ("di setting monochrome kenapa iconnya berwarna?"), and the same icon then
90
+ * turned into a hue under `color`, which read as the mode being half-applied.
91
+ *
92
+ * `var(--theme-ink)`, not `currentColor`: a `Check` inside a green status chip
93
+ * INHERITS the chip's green, so `currentColor` left it green — measured, two
94
+ * icons survived a monochrome pass that way (`lucide-info` in an info chip, a
95
+ * loader in a warning one). Icons that say `text-ink/…` are excluded (that IS
96
+ * the ink, at the weight the caller chose), and an inverted `bg-ink` surface
97
+ * keeps its own foreground.
98
+ *
99
+ * Specificity is the point: `:root:not(…)` plus the class beats a single utility
100
+ * class, so this wins over `text-success` inside the same layer.
101
+ */
102
+ function monochromeRules(): string[] {
103
+ return [
104
+ ':root:not([data-icon-style="color"]) svg.lucide:not([class*="text-ink"]):not(.bg-ink *) { color: var(--theme-ink); }',
105
+ ':root:not([data-icon-style="color"]) [data-plugin-mark] { --plugin-color: currentColor; }',
106
+ ];
107
+ }
108
+
109
+ /**
110
+ * Inside a TOOL CARD, icons are ink in BOTH modes.
111
+ *
112
+ * A transcript is a reading surface: one turn can hold twenty cards, each with a
113
+ * status chip, a file mark and a chevron, and a hue per icon turns the densest
114
+ * part of the app into confetti. The codebase already said so for file-type
115
+ * marks — `languageBrandIcon` passes `monochrome` for exactly this surface — but
116
+ * the Lucide glyphs inside a card were never covered, so they followed the mode
117
+ * and flipped colour the moment the setting changed.
118
+ *
119
+ * `var(--theme-ink)` rather than `currentColor`: the check inside a green status
120
+ * chip inherits the chip's green, which is the colour this rule exists to remove.
121
+ * Icons that declare `text-ink/…` are left alone (that is the ink, at the weight
122
+ * the caller chose), and an inverted `bg-ink` surface keeps its own foreground.
123
+ */
124
+ function toolCardRules(): string[] {
125
+ return [
126
+ '[data-tool-row] svg.lucide:not([class*="text-ink"]):not(.bg-ink *) { color: var(--theme-ink); }',
127
+ '[data-tool-row] [data-plugin-mark] { --plugin-color: var(--theme-ink); }',
128
+ ];
129
+ }
130
+
131
+ /**
132
+ * The project accent a folder's mark is drawn in — the one colour a user picked
133
+ * themselves (Project settings → accent).
134
+ *
135
+ * It is a property rather than an inline `color`, because an inline style cannot
136
+ * be answered by the mode: the accent belongs to the COLOUR mode, and under
137
+ * monochrome the mark is the palette ink like every other icon.
138
+ *
139
+ * The accent is applied at FULL strength even though the call sites also write
140
+ * `text-ink/70` — the weight is how a call site mutes the palette ink, and the
141
+ * user's chosen colour is not the ink being muted.
142
+ *
143
+ * That is why `inkWeightRules` EXCLUDES this class rather than the accent trying
144
+ * to out-specify it. It cannot: the dark weight selector is
145
+ * `[data-icon-style="color"][data-theme-variant="dark"] svg.lucide[class*="text-ink/70"]`
146
+ * = (0,4,1), one element above `:root[data-icon-style="color"] .project-accent-mark`
147
+ * = (0,4,0) — so every folder mark on a dark theme came out the SAME hue, the
148
+ * reported "icon folder di sidebar jadi sama warnanya". Light never showed it
149
+ * because there the same selector is (0,3,1) and the accent wins. Escalating
150
+ * the accent's specificity would have been a tie waiting for the next attribute;
151
+ * stating "a weight does not apply to the user's own colour" removes the
152
+ * competition instead.
153
+ */
154
+ function projectAccentRules(): string[] {
155
+ return [
156
+ ':root[data-icon-style="color"] .project-accent-mark { color: var(--project-accent); }',
157
+ ];
158
+ }
159
+
160
+ /**
161
+ * An INVERTED surface: `bg-ink`.
162
+ *
163
+ * The palette's ink is the FOREGROUND, so a surface filled with it is dark on a
164
+ * light theme and light on a dark one — the opposite of paper in both. A hue
165
+ * picked for paper is therefore wrong on it in both directions: measured on the
166
+ * primary `New Session` button, `rgb(129,179,228)` on `rgb(171,178,191)` in
167
+ * `one-dark-pro-soft` and `rgb(31,77,122)` on `rgb(20,19,16)` in `paper` — the
168
+ * reported "icon + tidak terlihat di dark mode".
169
+ *
170
+ * Swapping the variant's hue is not enough, and the measurement says why: the
171
+ * ink is not an extreme in most palettes. `solarized-light`'s ink is `#586e75`
172
+ * and `solarized-dark`'s is `#93a1a1`, both mid-tones, so no single hue at any
173
+ * lightness clears 3:1 on every palette's inverted surface (measured worst case
174
+ * 1.59 at `hsl(65% 70%)`). What DOES clear it is the surface's own foreground —
175
+ * `bg-ink` is always paired with `text-canvas`/`text-paper`, and the palette
176
+ * guarantees that pair. So the icon inherits it: `color: currentColor`, which on
177
+ * this element resolves to the inherited value (the surface's text colour), not
178
+ * to a hue.
179
+ *
180
+ * That is the rule for an inverted surface generally: it already declares its
181
+ * foreground, so the icon takes it instead of inventing a second one.
182
+ */
183
+ function invertedSurfaceRules(): string[] {
184
+ return [
185
+ ':where([data-icon-style="color"]) :where(.bg-ink) :where(svg.lucide) { color: currentColor; }',
186
+ ':where([data-icon-style="color"]) :where(.bg-ink) :where([data-plugin-mark]) { --plugin-color: currentColor; }',
187
+ ];
188
+ }
189
+
190
+ /**
191
+ * A PLUGIN's mark: the hue is computed at runtime from its name
192
+ * (`hashHue`), so it cannot be a generated row — the component sets
193
+ * `--icon-hue` inline and these two rules turn it into paint.
194
+ */
195
+ function pluginMarkRules(): string[] {
196
+ return [
197
+ // A DECLARED colour wins over the hashed hue — the plugin's own brand, when
198
+ // its manifest names one. It is still gated on the colour mode, so
199
+ // monochrome leaves every mark in the palette ink.
200
+ `:where([data-icon-style="color"]) :where([data-plugin-mark]) { --plugin-color: var(--plugin-declared-light, ${iconHuePaint('light')}); }`,
201
+ `:where([data-icon-style="color"][data-theme-variant="dark"]) :where([data-plugin-mark]) { --plugin-color: var(--plugin-declared-dark, ${iconHuePaint('dark')}); }`,
202
+ ];
203
+ }
204
+
205
+ /**
206
+ * `text-ink/60` is a WEIGHT, not a colour choice.
207
+ *
208
+ * The settings sidebar, the composer toolbar and a few hundred other call sites
209
+ * write `text-ink/40`-`/80` to mute an icon. That is "the ink, quieter" — the
210
+ * caller did not pick a colour — but a utility class is (0,1,0) and the hue
211
+ * rules are `:where()` (0,0,0), so the mute won and every muted icon stayed ink
212
+ * in the colour mode ("icon di setting modal kenapa gk full color").
213
+ *
214
+ * The mute is reproduced by mixing toward the INK, not toward transparency. Two
215
+ * reasons, both measured. Transparency is the wrong lever for a graphic: a hue at
216
+ * 40% alpha is 1.56:1 (light) / 1.77:1 (dark) against its surface, while the
217
+ * `text-ink/40` it replaces was already only 1.71 / 2.05 — so the colour mode
218
+ * would have made every muted icon less legible than before. Mixing toward the
219
+ * ink instead keeps the same "mostly ink, quieter" reading AND lands at 3.89:1
220
+ * worst case across every palette (`hue 80% + ink 20%`), 4.65:1 at the muted end.
221
+ *
222
+ * Specificity `svg.lucide[class*=…]` (0,2,1) beats the utility (0,1,0) on its
223
+ * own; the `!` is not needed and is not used anywhere in this sheet.
224
+ */
225
+ function inkWeightRules(): string[] {
226
+ const steps = [25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80, 85, 90];
227
+ const rules: string[] = [];
228
+ for (const variant of ['light', 'dark'] as const) {
229
+ const gate = variant === 'dark'
230
+ ? '[data-icon-style="color"][data-theme-variant="dark"]'
231
+ : '[data-icon-style="color"]';
232
+ const paint = iconHuePaint(variant);
233
+ // The un-suffixed `text-ink` is the full-strength ink.
234
+ rules.push(`${gate} svg.lucide:not(.project-accent-mark)[class~="text-ink"] { color: ${paint}; }`);
235
+ for (const step of steps) {
236
+ // `NN%` of hue over the ink: the caller's mute survives as "mostly ink",
237
+ // and the hue is what the mode added.
238
+ rules.push(
239
+ `${gate} svg.lucide:not(.project-accent-mark)[class*="text-ink/${step}"] { color: color-mix(in srgb, ${paint} ${step}%, var(--theme-ink)); }`,
240
+ );
241
+ }
242
+ }
243
+ return rules;
244
+ }
245
+
246
+ /** The signal colours, which beat the hue because they are stated after it. */
247
+ function signalRules(): string[] {
248
+ return ICON_TINT_ROWS.map(
249
+ ({ className, role }) =>
250
+ `:where([data-icon-style="color"]) :where(svg.${className}) { color: ${ICON_TINT_TOKENS[role]}; }`,
251
+ );
252
+ }
253
+
254
+ /** Cached: the tables are fixed for the life of the process. */
255
+ let cached: string | null = null;
256
+
257
+ export function iconPaintStyleSheet(): string {
258
+ cached ??= [
259
+ `/* Generated from src/shared/lib/icons — do not edit by hand. Default hue ${DEFAULT_ICON_HUE}. */`,
260
+ // Stated HERE because this sheet loads first: a bare `@layer utilities`
261
+ // block would otherwise become the lowest layer and demote every utility.
262
+ '@layer theme, base, components, utilities;',
263
+ '@layer utilities {',
264
+ ...hueRules(),
265
+ ...inkWeightRules(),
266
+ ...panelMarkRules(),
267
+ ...signalRules(),
268
+ ...pluginMarkRules(),
269
+ // Last: same specificity as everything above, so order is what makes an
270
+ // inverted surface win over the paper-tuned paint.
271
+ ...invertedSurfaceRules(),
272
+ ...projectAccentRules(),
273
+ ...monochromeRules(),
274
+ ...toolCardRules(),
275
+ ...Object.entries(BRAND_COLORS).flatMap(([name, entry]) =>
276
+ brandRules(`svg[data-provider="${name}"]`, entry.light, entry.dark),
277
+ ),
278
+ ...Object.entries(FILE_BRAND_COLORS).flatMap(([name, entry]) =>
279
+ brandRules(`svg[data-file-brand="${name}"]`, entry.light, entry.dark),
280
+ ),
281
+ '}',
282
+ ].join('\n');
283
+ return cached;
284
+ }
@@ -0,0 +1,100 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The paint for a PANEL's mark — the one colour a panel has, on every surface.
8
+ *
9
+ * Split out of `icon-paint-css.ts` so both files stay readable, not because the
10
+ * rules are independent: they are one of the families that sheet concatenates.
11
+ *
12
+ * These are the ONE place a paint rule may outrank an author class, and it is
13
+ * deliberate: a surface expresses a panel's STATE with a weight (`text-ink/70` →
14
+ * `text-ink/30`), which is a colour — so a zero-specificity hue rule lost and the
15
+ * right rail stayed monochrome while every glyph in the panels behind it was
16
+ * tinted ("icon panel right harus punya warna sendiri"). The state moves to
17
+ * `data-idle` here, which reads the same in the monochrome mode that has no hue
18
+ * to dim, and the colour comes from the mode.
19
+ */
20
+
21
+ import { DEFAULT_ICON_HUE, ICON_HUE_PAINT } from '@/shared/lib/icons/tint';
22
+
23
+ /**
24
+ * Three sources, in this order: the colour a PLUGIN DECLARED in its manifest
25
+ * (`--panel-color`), then the hue assigned to the PANEL (`--panel-hue`), then the
26
+ * glyph's own generated hue.
27
+ *
28
+ * A declared colour arrives as TWO values (`--panel-color-light` /
29
+ * `--panel-color-dark`), because a brand hex is legible on one variant and not
30
+ * the other: `#34d399` is 1.9:1 on white paper. The component clamps it with the
31
+ * same `legiblePair` rule the brand tables use, so the plugin's colour reaches
32
+ * the mark without dropping it below the floor.
33
+ */
34
+ function panelPaint(variant: 'light' | 'dark'): string {
35
+ const { saturation, lightness } = ICON_HUE_PAINT[variant];
36
+ return `var(--panel-color-${variant}, hsl(var(--panel-hue, var(--icon-hue, ${DEFAULT_ICON_HUE})) ${saturation}% ${lightness}%))`;
37
+ }
38
+
39
+ export function panelMarkRules(): string[] {
40
+ const light = panelPaint('light');
41
+ const dark = panelPaint('dark');
42
+ // `[data-panel-mark]`, not `.panel-rail-mark`: the rail is not the only surface
43
+ // that draws a panel, and it used to be the only one that got the PANEL's
44
+ // colour. The phone's chip strip and Settings' Built-in list drew the bare
45
+ // glyph and took the GLYPH's hue instead — measured, `Files` was `hsl(0 …)` on
46
+ // the rail and `hsl(320 …)` in Settings, and `Wiki`'s `BookOpen` fell through
47
+ // to the `info` signal because it means something as a glyph but nothing as a
48
+ // panel. Every one of them now stamps the same `--panel-hue` (see
49
+ // `client/components/common/panel-mark`), so the surface a mark appears on
50
+ // cannot change what colour it is.
51
+ //
52
+ // `:root` is stated to beat `inkWeightRules` on SPECIFICITY rather than on
53
+ // source order: a surface writes `text-ink/70`/`text-ink/30` to say whether a
54
+ // panel is active, and the weight rule is (0,3,1) light / (0,4,1) dark — a tie
55
+ // this block would only win by coming later.
56
+ //
57
+ // `:not(.bg-ink *)` because a phone chip goes inverted when active: the hue is
58
+ // tuned for paper, and the chip already declares its own foreground.
59
+ const scope = `:root[data-icon-style="color"] [data-panel-mark]:not(.bg-ink *) svg.lucide`;
60
+ const scopeDark = `:root[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark]:not(.bg-ink *) svg.lucide`;
61
+ return [
62
+ `${scope} { color: ${light}; }`,
63
+ `${scopeDark} { color: ${dark}; }`,
64
+ // A plugin's mark states its own `--plugin-color` from its name; inside a
65
+ // panel mark the panel's declared colour (or assigned hue) is the authority.
66
+ `:root[data-icon-style="color"] [data-panel-mark] [data-plugin-mark] { --plugin-color: ${light}; }`,
67
+ `:root[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark] [data-plugin-mark] { --plugin-color: ${dark}; }`,
68
+ // The idle state moves LUMINANCE, never alpha.
69
+ //
70
+ // It used to be `opacity: 0.45`, which composites the hue with the rail's
71
+ // near-neutral chrome and therefore throws most of the chroma away: measured
72
+ // on a 64px glyph, `hsl(170 65% 70%)` renders at chroma 95 when active and
73
+ // **62** when idle, and the rail read as washed-out pastels — "warna icon di
74
+ // activity panel kanan / kiri kok agak kusem". A `brightness()` shift plus
75
+ // the `saturate()` that pays back what the multiply costs keeps the colour
76
+ // and moves only the luminance: the same glyph measures **94** chroma at
77
+ // contrast 3.07 instead of 62 at 2.94, i.e. the SAME quietness with the
78
+ // colour restored.
79
+ //
80
+ // The two variants shift in opposite directions because "recede" does: on ink
81
+ // an idle icon is DARKER, on paper it is LIGHTER. `1.25` in light, not more:
82
+ // measured, brighter steps walk the icon up the chroma curve and out of the
83
+ // rail's range (1.5 read 2.22:1 against 3.82:1 active — glare), while 1.25
84
+ // reads 2.74:1 with chroma 121 against the active 95, i.e. quieter and MORE
85
+ // coloured at once, which is the whole point of dimming by luminance.
86
+ //
87
+ // A DECLARED brand colour is NOT dimmed. The settings card draws the same
88
+ // plugin at full strength, so dimming this copy made one brand two colours
89
+ // depending on where you looked ("warna icon plugins di setting modal dan di
90
+ // activity bar beda"). The hue is the plugin author's, not ours to mute; the
91
+ // rail's idle state still reads, because it is carried by the BUTTON
92
+ // (background and active border), which no filter touches.
93
+ //
94
+ // `[data-declared]` is stamped from `panel.color` — a property, not a
95
+ // class-name or inline-style guess, so this cannot drift when the mark
96
+ // changes how it carries its colour.
97
+ '[data-icon-style="color"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(1.25) saturate(1.05); }',
98
+ '[data-icon-style="color"][data-theme-variant="dark"] [data-panel-mark][data-idle]:not([data-declared]) { filter: brightness(0.62) saturate(1.4); }',
99
+ ];
100
+ }