@kabmo-labs/kabmo 0.21.0 → 0.22.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 (295) hide show
  1. package/README.md +7 -2
  2. package/dist/client/index.html +9 -8
  3. package/dist/client/index.js +334 -334
  4. package/dist/client/static/js/{index-zg32n2sk.js → index-297dck9a.js} +784 -791
  5. package/dist/client/static/js/index-7ppta1pb.css +1 -0
  6. package/extensions/kabmo-modes/commands.ts +17 -3
  7. package/extensions/kabmo-modes/goal-start.ts +101 -0
  8. package/extensions/kabmo-modes/goal.test.ts +80 -5
  9. package/extensions/kabmo-modes/goal.ts +13 -38
  10. package/extensions/kabmo-modes/prompts.test.ts +12 -0
  11. package/extensions/kabmo-modes/prompts.ts +9 -2
  12. package/index.html +8 -7
  13. package/package.json +2 -2
  14. package/src/cli/lib/args.js +9 -0
  15. package/src/cli/lib/args.test.js +26 -0
  16. package/src/cli/lib/commands/doctor.js +153 -0
  17. package/src/cli/lib/commands/doctor.test.js +139 -0
  18. package/src/cli/lib/commands/serve.js +23 -10
  19. package/src/cli/lib/commands/status.js +22 -3
  20. package/src/cli/lib/omp-setup.js +131 -0
  21. package/src/cli/lib/omp-setup.test.js +115 -0
  22. package/src/cli/main.js +1 -1
  23. package/src/client/components/common/DemoDataBadge.tsx +52 -0
  24. package/src/client/components/common/FolderPicker.tsx +2 -2
  25. package/src/client/components/common/Modal.tsx +15 -1
  26. package/src/client/components/common/code-surface/blame-panel.ts +1 -1
  27. package/src/client/components/common/context-usage-button/index.test.tsx +1 -1
  28. package/src/client/components/common/context-usage-button/index.tsx +4 -4
  29. package/src/client/components/common/demo-data-badge.test.tsx +58 -0
  30. package/src/client/components/common/diagram-viewer/index.tsx +2 -2
  31. package/src/client/components/common/editor-view-buttons/index.tsx +2 -2
  32. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  33. package/src/client/components/common/header-controls/index.tsx +4 -1
  34. package/src/client/components/common/markdown-review/ReviewPopover.tsx +2 -2
  35. package/src/client/components/common/markdown-review/ReviewSummary.tsx +1 -1
  36. package/src/client/components/common/panel-mark/index.tsx +2 -1
  37. package/src/client/components/common/server-control/Panel.tsx +3 -3
  38. package/src/client/components/common/server-control/index.tsx +1 -1
  39. package/src/client/components/common/shell-update-button/Modal.tsx +1 -1
  40. package/src/client/components/common/todo-row/index.tsx +1 -1
  41. package/src/client/components/layout/ActivityBar.tsx +4 -0
  42. package/src/client/components/layout/ShellNotice.tsx +33 -0
  43. package/src/client/components/layout/desktop-layout/index.tsx +14 -16
  44. package/src/client/components/layout/desktop-layout/resizer/index.tsx +14 -1
  45. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +2 -1
  46. package/src/client/components/layout/session-sidebar/ClassicView.tsx +5 -1
  47. package/src/client/components/layout/session-sidebar/SessionList.tsx +1 -1
  48. package/src/client/components/layout/session-sidebar/SessionListNotice.tsx +56 -0
  49. package/src/client/components/layout/session-sidebar/SessionsView.tsx +2 -0
  50. package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +1 -1
  51. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +12 -1
  52. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +2 -1
  53. package/src/client/components/layout/session-sidebar/modern/index.tsx +6 -2
  54. package/src/client/components/layout/session-sidebar/new-workspace-modal/CloneField.tsx +1 -1
  55. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  56. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +1 -1
  57. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskList.tsx +3 -3
  58. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +1 -1
  59. package/src/client/components/layout/session-sidebar/session-list-states.test.tsx +150 -0
  60. package/src/client/components/layout/session-sidebar/variant-props.ts +6 -0
  61. package/src/client/components/mobile/LayoutWrapper.tsx +20 -30
  62. package/src/client/components/mobile/MainView.tsx +5 -2
  63. package/src/client/components/mobile/RightSidebar.tsx +1 -1
  64. package/src/client/components/mobile/SessionSidebar.tsx +3 -0
  65. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  66. package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +7 -1
  67. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  68. package/src/client/components/settings/Modal.tsx +15 -1
  69. package/src/client/components/settings/ProjectSelectorDropdown.tsx +1 -1
  70. package/src/client/components/settings/Sidebar.tsx +2 -2
  71. package/src/client/components/settings/categories/OmpSettings.tsx +1 -1
  72. package/src/client/components/settings/categories/TokenUsageSettings.tsx +1 -1
  73. package/src/client/components/settings/categories/agent-settings/DetailPane.tsx +3 -3
  74. package/src/client/components/settings/categories/appearance-settings/EditorFontSection.tsx +1 -1
  75. package/src/client/components/settings/categories/appearance-settings/EditorThemeSection.tsx +2 -2
  76. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +5 -5
  77. package/src/client/components/settings/categories/appearance-settings/SidebarStyleSection.tsx +1 -1
  78. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +1 -1
  79. package/src/client/components/settings/categories/appearance-settings/ThemeCard.tsx +1 -1
  80. package/src/client/components/settings/categories/chat-settings/ComposerStyleSection.tsx +1 -1
  81. package/src/client/components/settings/categories/chat-settings/GoalSection.tsx +1 -1
  82. package/src/client/components/settings/categories/command-settings/DetailPane.tsx +2 -2
  83. package/src/client/components/settings/categories/omp-settings/ConfigTabs.tsx +5 -5
  84. package/src/client/components/settings/categories/omp-settings/EngineHeader.tsx +3 -3
  85. package/src/client/components/settings/categories/omp-settings/RoleRow.tsx +2 -2
  86. package/src/client/components/settings/categories/panel-plugins/LeftDockSettings.tsx +1 -1
  87. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
  88. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +4 -3
  89. package/src/client/components/settings/categories/plugin-settings/SidebarList.tsx +2 -2
  90. package/src/client/components/settings/categories/project-settings/AddProjectModal.tsx +1 -1
  91. package/src/client/components/settings/categories/project-settings/NameInput.tsx +1 -1
  92. package/src/client/components/settings/categories/project-settings/PathField.tsx +1 -1
  93. package/src/client/components/settings/categories/provider-settings/AddModelModal.tsx +3 -3
  94. package/src/client/components/settings/categories/provider-settings/AddProviderModal.tsx +1 -1
  95. package/src/client/components/settings/categories/provider-settings/AuthSection.tsx +2 -2
  96. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +1 -1
  97. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +4 -4
  98. package/src/client/components/settings/categories/provider-settings/EntryModal.tsx +2 -2
  99. package/src/client/components/settings/categories/provider-settings/LoginModal.tsx +1 -1
  100. package/src/client/components/settings/categories/provider-settings/ModelCapabilitiesModal.tsx +1 -1
  101. package/src/client/components/settings/categories/provider-settings/ModelsList.tsx +2 -2
  102. package/src/client/components/settings/categories/provider-settings/PriceFields.tsx +1 -1
  103. package/src/client/components/settings/categories/token-usage-settings/Breakdown.tsx +4 -4
  104. package/src/client/components/settings/categories/token-usage-settings/Chart.tsx +2 -2
  105. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
  106. package/src/client/components/settings/categories/token-usage-settings/MetricsGrid.tsx +1 -1
  107. package/src/client/components/settings/categories/usage-settings/KenariCard.tsx +5 -5
  108. package/src/client/components/workspace/browser-panel/AddressBar.tsx +1 -1
  109. package/src/client/components/workspace/browser-panel/Screencast.tsx +6 -6
  110. package/src/client/components/workspace/browser-panel/TabStrip.tsx +1 -1
  111. package/src/client/components/workspace/browser-panel/index.tsx +1 -1
  112. package/src/client/components/workspace/browser-toolbar/index.tsx +5 -5
  113. package/src/client/components/workspace/chat-timeline/AttachmentChips.tsx +1 -1
  114. package/src/client/components/workspace/chat-timeline/GeneratingIndicator.tsx +13 -26
  115. package/src/client/components/workspace/chat-timeline/GoalNotice.tsx +2 -2
  116. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +1 -1
  117. package/src/client/components/workspace/chat-timeline/MinimapShortcuts.tsx +1 -1
  118. package/src/client/components/workspace/chat-timeline/QueueList.tsx +1 -1
  119. package/src/client/components/workspace/chat-timeline/SubagentView.tsx +1 -1
  120. package/src/client/components/workspace/chat-timeline/SystemNotice.tsx +5 -5
  121. package/src/client/components/workspace/chat-timeline/TaskResultContent.tsx +2 -2
  122. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +4 -4
  123. package/src/client/components/workspace/chat-timeline/ToolCallingSection.tsx +1 -1
  124. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  125. package/src/client/components/workspace/chat-timeline/chat-input/ArmedGoalStrip.tsx +71 -0
  126. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +4 -3
  127. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.test.ts +1 -1
  128. package/src/client/components/workspace/chat-timeline/chat-input/GoalBanner.tsx +3 -3
  129. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.test.ts +176 -0
  130. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +70 -81
  131. package/src/client/components/workspace/chat-timeline/chat-input/GoalSurfaces.tsx +10 -1
  132. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.test.ts +20 -0
  133. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +13 -7
  134. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  135. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.test.ts +65 -3
  136. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +69 -19
  137. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +2 -2
  138. package/src/client/components/workspace/chat-timeline/chat-input/composer-portal.test.tsx +174 -0
  139. package/src/client/components/workspace/chat-timeline/chat-input/goal-modal-parts.tsx +80 -0
  140. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +15 -3
  141. package/src/client/components/workspace/chat-timeline/chat-input/styles.test.tsx +3 -1
  142. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +1 -1
  143. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  144. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  145. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/FrameControl.tsx +1 -1
  146. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OptionRow.tsx +1 -1
  147. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/OrphanAsks.tsx +1 -1
  148. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionBlock.tsx +2 -2
  149. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/QuestionCard.tsx +4 -4
  150. package/src/client/components/workspace/chat-timeline/tool-renderers/ask-panel/index.tsx +2 -2
  151. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/Header.tsx +1 -1
  152. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/SelectBody.tsx +1 -1
  153. package/src/client/components/workspace/chat-timeline/tool-renderers/hashline-patch/index.tsx +4 -4
  154. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/AstEdit.tsx +6 -6
  155. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Bash.tsx +13 -13
  156. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Checkpoint.tsx +1 -1
  157. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ContextNotes.tsx +2 -2
  158. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Debug.tsx +3 -3
  159. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Edit.tsx +9 -9
  160. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Eval.tsx +10 -10
  161. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/FileMatches.tsx +1 -1
  162. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Goal.tsx +5 -5
  163. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/GoalRecord.tsx +5 -5
  164. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Lsp.tsx +6 -6
  165. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/ManageSkill.tsx +5 -5
  166. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Mcp.tsx +2 -2
  167. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Memory.tsx +3 -3
  168. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Proc.tsx +15 -15
  169. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Read.tsx +2 -2
  170. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Resolve.tsx +4 -4
  171. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchFs.tsx +2 -2
  172. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SearchTool.tsx +1 -1
  173. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/SecurityScan.tsx +4 -4
  174. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/TaskResult.tsx +7 -7
  175. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Think.tsx +2 -2
  176. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Todo.tsx +2 -2
  177. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.missing.test.ts +4 -2
  178. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/Wait.tsx +17 -17
  179. package/src/client/components/workspace/chat-timeline/tool-renderers/panels/WebSearch.tsx +3 -3
  180. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ArtifactChip.tsx +1 -1
  181. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/EnvelopeHeader.tsx +2 -2
  182. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ExcerptCode.tsx +3 -3
  183. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/FallbackOutput.tsx +3 -3
  184. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/JsonCodeBlock.tsx +3 -3
  185. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/OutputWindow.tsx +2 -2
  186. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolBody.tsx +2 -2
  187. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolFactChips.tsx +2 -2
  188. package/src/client/components/workspace/chat-timeline/tool-renderers/shared/ToolPanelHeader.tsx +1 -1
  189. package/src/client/components/workspace/chat-timeline/tool-renderers/styles/Minimal.tsx +1 -1
  190. package/src/client/components/workspace/context-panel/RawJsonViewer.tsx +2 -2
  191. package/src/client/components/workspace/context-panel/StatsGrid.tsx +1 -1
  192. package/src/client/components/workspace/context-panel/index.tsx +1 -1
  193. package/src/client/components/workspace/diff-panel/ConflictBanner.tsx +1 -1
  194. package/src/client/components/workspace/editor/EmptyEditor.tsx +1 -1
  195. package/src/client/components/workspace/editor/FindWidget.tsx +1 -1
  196. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  197. package/src/client/components/workspace/editor/Toolbar.tsx +1 -1
  198. package/src/client/components/workspace/file-explorer/OutlineSection.tsx +2 -2
  199. package/src/client/components/workspace/file-explorer/RowLabel.tsx +1 -1
  200. package/src/client/components/workspace/file-explorer/index.tsx +1 -1
  201. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +2 -2
  202. package/src/client/components/workspace/git-panel/ChangesList.tsx +3 -3
  203. package/src/client/components/workspace/git-panel/ConflictItem.tsx +3 -3
  204. package/src/client/components/workspace/git-panel/FileItem.tsx +2 -2
  205. package/src/client/components/workspace/git-panel/StashSection.tsx +5 -5
  206. package/src/client/components/workspace/git-panel/TreeItem.tsx +2 -2
  207. package/src/client/components/workspace/git-panel/branch-modal/BranchRow.tsx +4 -4
  208. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -2
  209. package/src/client/components/workspace/git-panel/index.tsx +1 -1
  210. package/src/client/components/workspace/model-dropdown/Item.tsx +3 -3
  211. package/src/client/components/workspace/model-dropdown/Section.tsx +1 -1
  212. package/src/client/components/workspace/model-dropdown/index.tsx +3 -3
  213. package/src/client/components/workspace/plan-panel/index.tsx +2 -2
  214. package/src/client/components/workspace/repo-picker/Modal.tsx +1 -1
  215. package/src/client/components/workspace/repo-picker/Row.tsx +6 -6
  216. package/src/client/components/workspace/search-panel/Body.tsx +2 -2
  217. package/src/client/components/workspace/search-panel/Results.tsx +1 -1
  218. package/src/client/components/workspace/search-panel/index.tsx +1 -1
  219. package/src/client/components/workspace/terminal-panel/index.tsx +1 -1
  220. package/src/client/components/workspace/todo-panel/PhaseGroup.tsx +1 -1
  221. package/src/client/components/workspace/todo-panel/index.tsx +2 -2
  222. package/src/client/components/workspace/user-browser-panel/AddressBar.tsx +5 -5
  223. package/src/client/components/workspace/user-browser-panel/AnnotateBar.test.tsx +13 -13
  224. package/src/client/components/workspace/user-browser-panel/AnnotateBar.tsx +4 -4
  225. package/src/client/components/workspace/user-browser-panel/AnnotateLayer.tsx +1 -1
  226. package/src/client/components/workspace/user-browser-panel/AnnotateTarget.tsx +7 -7
  227. package/src/client/components/workspace/user-browser-panel/Frame.tsx +1 -1
  228. package/src/client/components/workspace/wiki-panel/Nav.tsx +1 -1
  229. package/src/client/components/workspace/wiki-panel/index.tsx +2 -2
  230. package/src/client/glass.css +50 -0
  231. package/src/client/glass.test.ts +68 -24
  232. package/src/client/hooks/chat/composer/browser-context.test.ts +6 -6
  233. package/src/client/hooks/chat/composer/use-draft.test.ts +2 -2
  234. package/src/client/hooks/chat/omp/prompt-send.test.ts +36 -0
  235. package/src/client/hooks/chat/omp/prompt-send.ts +24 -18
  236. package/src/client/hooks/chat/omp/session-list.tsx +24 -70
  237. package/src/client/hooks/chat/omp/session-merges.ts +89 -0
  238. package/src/client/hooks/chat/omp/session-sidebar-controller.ts +4 -1
  239. package/src/client/hooks/chat/timeline/armed-goal-send.test.ts +168 -0
  240. package/src/client/hooks/chat/timeline/armed-goal.test.ts +178 -0
  241. package/src/client/hooks/chat/timeline/goal-command.ts +57 -27
  242. package/src/client/hooks/chat/timeline/index.ts +7 -4
  243. package/src/client/hooks/chat/timeline/mode-post.ts +46 -0
  244. package/src/client/hooks/chat/timeline/modes-contract.ts +94 -0
  245. package/src/client/hooks/chat/timeline/modes.ts +60 -95
  246. package/src/client/hooks/chat/timeline/send-props.ts +97 -0
  247. package/src/client/hooks/chat/timeline/send-steer.test.ts +6 -0
  248. package/src/client/hooks/chat/timeline/send.test-util.ts +55 -8
  249. package/src/client/hooks/chat/timeline/send.test.ts +17 -1
  250. package/src/client/hooks/chat/timeline/send.ts +64 -72
  251. package/src/client/hooks/ui/dialog-behaviour.ts +143 -0
  252. package/src/client/hooks/ui/theme.ts +17 -0
  253. package/src/client/hooks/workspace/copy-tab-path.ts +23 -0
  254. package/src/client/hooks/workspace/mobile-back.ts +71 -0
  255. package/src/client/palette-class.test.ts +93 -0
  256. package/src/client/tailwind-contrast.test.ts +194 -0
  257. package/src/client/tailwind.css +327 -8
  258. package/src/server/lib/assets/theme-shell.server.ts +4 -10
  259. package/src/server/lib/omp/config/provider-seeds.test.ts +39 -1
  260. package/src/server/lib/omp/config/provider-seeds.ts +32 -3
  261. package/src/server/lib/omp/config/provider-vision-compat.test.ts +140 -0
  262. package/src/server/lib/omp/core/host-resolution.test.ts +1 -55
  263. package/src/server/lib/omp/core/install-hint.test.ts +48 -0
  264. package/src/server/lib/omp/core/install-hint.ts +64 -0
  265. package/src/server/lib/omp/core/startup.test.ts +125 -0
  266. package/src/server/lib/omp/core/startup.ts +5 -1
  267. package/src/server/lib/omp/mode/request.ts +14 -6
  268. package/src/server/plugins/ssr.ts +2 -1
  269. package/src/shared/lib/browser/annotate.test.ts +22 -22
  270. package/src/shared/lib/browser/annotate.ts +14 -14
  271. package/src/shared/lib/browser/page-context.ts +6 -6
  272. package/src/shared/lib/icons/icon-paint-authority.test.ts +86 -0
  273. package/src/shared/lib/icons/icon-paint-authority.ts +94 -0
  274. package/src/shared/lib/icons/icon-paint-css.test.ts +139 -25
  275. package/src/shared/lib/icons/icon-paint-css.ts +76 -50
  276. package/src/shared/lib/icons/icon-paint-panel.ts +15 -18
  277. package/src/shared/lib/icons/icon-paint-weight.ts +142 -0
  278. package/src/shared/lib/icons/icon-tone.ts +58 -13
  279. package/src/shared/lib/icons/tint-hues.generated.ts +51 -6
  280. package/src/shared/lib/icons/tint-tones.test.ts +257 -0
  281. package/src/shared/lib/icons/tint.test.ts +3 -211
  282. package/src/shared/lib/icons/tint.ts +23 -25
  283. package/src/shared/lib/omp/mode/actions.ts +40 -0
  284. package/src/shared/lib/omp/mode/types.ts +12 -0
  285. package/src/shared/lib/theme/css.ts +21 -0
  286. package/src/shared/lib/theme/first-frame.ts +38 -0
  287. package/src/shared/lib/theme/ink-scale.test.ts +151 -0
  288. package/src/shared/lib/theme/ink-scale.ts +103 -0
  289. package/src/shared/lib/theme/shell-palette.test.ts +22 -5
  290. package/src/shared/lib/theme/shell-palette.ts +9 -4
  291. package/src/shared/lib/theme/theme.test.ts +28 -3
  292. package/src/shared/lib/workspace/project-accent.test.ts +33 -1
  293. package/src/shared/lib/workspace/project-accent.ts +23 -0
  294. package/src/shared/types/omp/agent.ts +24 -9
  295. package/dist/client/static/js/index-0721wrkf.css +0 -1
@@ -17,8 +17,9 @@
17
17
  * copy would leave a newly added icon on the default hue, which looks like the
18
18
  * mode half-applied. `scripts/icon-tints.mjs --check` is the same comparison.
19
19
  * - **Every generated hue clears the non-text contrast floor** on every palette
20
- * of its variant, at the lightness `ICON_HUE_PAINT` states. That is the whole
21
- * reason the lightness is 30% / 70% and not something prettier.
20
+ * of its OWN variant, in BOTH solved tables, and the two variants land in a
21
+ * narrow lightness band. That is the whole reason dark is no longer one
22
+ * `hsl(H 65% 70%)` for every hue.
22
23
  * - **A signal icon is never also a hue row**, so the signal colour cannot be
23
24
  * shadowed by a `--icon-hue` on the same element.
24
25
  */
@@ -28,26 +29,13 @@ import { Window } from 'happy-dom';
28
29
  import { h, render } from 'preact';
29
30
  import * as lucide from 'lucide-preact';
30
31
  import {
31
- assignPanelHues,
32
- DEFAULT_ICON_HUE,
33
- ICON_HUE_PAINT,
34
- ICON_HUE_ROWS,
35
32
  ICON_TINTS,
36
33
  ICON_TINT_ROWS,
37
34
  ICON_TINT_TOKENS,
38
- iconHue,
39
- hashHue,
40
- iconHueColor,
41
- iconHuePaint,
42
35
  iconTintRole,
43
- iconTone,
44
36
  kebabIconName,
45
37
  lucideClassName,
46
38
  } from '@/shared/lib/icons/tint';
47
- import { ICON_HUES, ICON_TONES } from '@/shared/lib/icons/tint-hues.generated';
48
- import { oklchOf } from '@/shared/lib/icons/icon-tone';
49
- import { THEMES } from '@/shared/lib/theme/catalog';
50
- import { BRAND_CONTRAST_FLOOR, contrastRatio } from '@/shared/lib/theme/legibility';
51
39
 
52
40
  const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
53
41
  const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
@@ -77,22 +65,6 @@ afterAll(() => {
77
65
  }
78
66
  });
79
67
 
80
- /** `hsl(<hue> <sat>% <light>%)` as a hex, so contrast can be measured. */
81
- function hslHex(hue: number, saturation: number, lightness: number): string {
82
- const s = saturation / 100;
83
- const l = lightness / 100;
84
- const k = (n: number) => (n + hue / 30) % 12;
85
- const a = s * Math.min(l, 1 - l);
86
- const channel = (n: number) => l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
87
- const toHex = (value: number) =>
88
- Math.round(Math.min(1, Math.max(0, value)) * 255)
89
- .toString(16)
90
- .padStart(2, '0');
91
- return `#${toHex(channel(0))}${toHex(channel(8))}${toHex(channel(4))}`;
92
- }
93
-
94
-
95
-
96
68
  describe('kebabIconName', () => {
97
69
  test('lowercase, camel and digit boundaries', () => {
98
70
  expect(kebabIconName('Trash2')).toBe('trash-2');
@@ -151,183 +123,3 @@ describe('the signal table', () => {
151
123
  expect(new Set(classes).size).toBe(classes.length);
152
124
  });
153
125
  });
154
-
155
- describe('the generated hues', () => {
156
- test('the table has one entry per imported, non-signal icon', () => {
157
- expect(Object.keys(ICON_HUES).length).toBeGreaterThan(100);
158
- for (const name of Object.keys(ICON_TINTS)) {
159
- expect(ICON_HUES[name], `${name} is a signal and must not carry a hue`).toBeUndefined();
160
- }
161
- });
162
-
163
- test('every hue is a step on the 36-hue wheel', () => {
164
- for (const [name, hue] of Object.entries(ICON_HUES)) {
165
- expect(hue % 10, name).toBe(0);
166
- expect(hue, name).toBeGreaterThanOrEqual(0);
167
- expect(hue, name).toBeLessThan(360);
168
- }
169
- });
170
-
171
- test('neighbouring icons are not all the same colour', () => {
172
- const hues = new Set(Object.values(ICON_HUES));
173
- // The whole point of a per-icon hue: a dense list must not be one colour.
174
- expect(hues.size).toBeGreaterThan(20);
175
- });
176
-
177
- test('the hue table matches the icons this repo imports', async () => {
178
- // The generator is the source of truth; running its `--check` here is what
179
- // makes a stale table a test failure instead of a review miss.
180
- //
181
- // `Bun.fileURLToPath`, not `URL.pathname`: on a Windows host the pathname
182
- // is `/D:/a/kabmo/kabmo/`, which no process can open, so the spawn failed
183
- // for a reason that had nothing to do with the table — measured on the
184
- // Windows gate, where this case failed while every other row passed.
185
- //
186
- // The script is resolved THROUGH the URL rather than by string-joining onto
187
- // the directory: `fileURLToPath` keeps a trailing separator (`…/kabmo/`),
188
- // and a hand-written join would then carry one separator style into a path
189
- // the other half spelled the other way.
190
- const repoUrl = new URL('../../../..', import.meta.url);
191
- const repoRoot = Bun.fileURLToPath(repoUrl);
192
- const script = Bun.fileURLToPath(new URL('scripts/icon-tints.mjs', repoUrl));
193
- const check = Bun.spawnSync(['bun', 'run', script, '--check'], {
194
- cwd: repoRoot,
195
- stdout: 'pipe',
196
- stderr: 'pipe',
197
- });
198
- expect(check.exitCode, check.stderr.toString()).toBe(0);
199
- });
200
-
201
- test('every light tone clears the non-text floor on every light palette', () => {
202
- // The tone is SOLVED per hue (see `icon-tone.ts`); this is the property that
203
- // let the mode carry 39% more chroma without losing a single row, so it is
204
- // pinned per palette rather than against one hex.
205
- const papers = THEMES.filter((theme) => theme.variant === 'light').map((theme) => theme.paper);
206
- for (const [hue, tone] of Object.entries(ICON_TONES)) {
207
- expect(tone, hue).toMatch(/^#[0-9a-f]{6}$/);
208
- const worst = Math.min(...papers.map((paper) => contrastRatio(tone, paper)));
209
- expect(worst, `hue ${hue} (${tone})`).toBeGreaterThanOrEqual(BRAND_CONTRAST_FLOOR);
210
- }
211
- });
212
-
213
- test('the dark hue still clears the floor at its one stated pair', () => {
214
- // Dark is deliberately untouched: it reads bright already, and raising its
215
- // chroma would only invert the complaint.
216
- const { saturation, lightness } = ICON_HUE_PAINT.dark;
217
- const papers = THEMES.filter((theme) => theme.variant === 'dark').map((theme) => theme.paper);
218
- for (const hue of new Set(Object.values(ICON_HUES))) {
219
- const color = hslHex(hue, saturation, lightness);
220
- const worst = Math.min(...papers.map((paper) => contrastRatio(color, paper)));
221
- expect(worst, `hue ${hue} (${color})`).toBeGreaterThanOrEqual(BRAND_CONTRAST_FLOOR);
222
- }
223
- });
224
-
225
- test('a light tone carries MORE chroma than the pair it replaced', () => {
226
- // The report — "warna icon di mode full color ketika light mode kelihatan
227
- // kusem" — is this measurement, and nothing else: the old pair maxed out at
228
- // OKLCH chroma 0.075 on the muddiest hue because one saturation had to suit
229
- // every hue on the wheel. Solving per hue is what buys the colour back, and
230
- // this is the assertion that would fail if a future edit quietly put a
231
- // uniform pair back.
232
- const hues = Object.keys(ICON_TONES).map(Number);
233
- const mean = (values: number[]) => values.reduce((a, b) => a + b, 0) / values.length;
234
- const before = hues.map((hue) => oklchOf(hslHex(hue, ICON_HUE_PAINT.light.saturation, ICON_HUE_PAINT.light.lightness)).chroma);
235
- const after = hues.map((hue) => oklchOf(ICON_TONES[hue]!).chroma);
236
- expect(mean(after)).toBeGreaterThan(mean(before) * 1.3);
237
- // Every single hue must improve — a table that traded one muddy row for
238
- // another would still pass the mean.
239
- for (const hue of hues) {
240
- expect(oklchOf(ICON_TONES[hue]!).chroma, `hue ${hue}`).toBeGreaterThan(
241
- oklchOf(hslHex(hue, ICON_HUE_PAINT.light.saturation, ICON_HUE_PAINT.light.lightness)).chroma,
242
- );
243
- }
244
- });
245
-
246
- test('a light tone keeps its hue, so a row does not change colour', () => {
247
- // Solved in OKLCH, but the hue is the OKLCH angle of the OLD paint: a tone
248
- // that drifted would recolour every icon in the app, which is not what
249
- // "more colour" means.
250
- for (const [hue, tone] of Object.entries(ICON_TONES)) {
251
- const before = oklchOf(hslHex(Number(hue), ICON_HUE_PAINT.light.saturation, ICON_HUE_PAINT.light.lightness)).hue;
252
- const after = oklchOf(tone).hue;
253
- const circular = Math.min(Math.abs(before - after), 360 - Math.abs(before - after));
254
- expect(circular, `hue ${hue} (${tone})`).toBeLessThan(12);
255
- }
256
- });
257
-
258
- test('the light tone is a table lookup, not a solve, and it snaps to the wheel', () => {
259
- expect(iconTone(120)).toBe(ICON_TONES[120]!);
260
- // `hashHue` only produces wheel steps, but a stored or plugin name could
261
- // still reach here with something else; the nearest step keeps it a colour.
262
- expect(iconTone(124)).toBe(ICON_TONES[120]!);
263
- expect(iconTone(356)).toBe(ICON_TONES[0]!);
264
- expect(iconTone(-10)).toBe(ICON_TONES[350]!);
265
- });
266
-
267
- test('the paint rule and the concrete colour share one formula', () => {
268
- // The stylesheet leaves the hue to `--icon-hue`; the settings preview needs a
269
- // real colour. Both must come from the same numbers, or the preview lies.
270
- // LIGHT reads the solved `--icon-tone` (falling back to the old pair), which
271
- // is why it is not a bare `hsl()` any more.
272
- const { saturation, lightness } = ICON_HUE_PAINT.dark;
273
- expect(iconHuePaint('light')).toBe(
274
- `var(--icon-tone, hsl(var(--icon-hue, ${DEFAULT_ICON_HUE}) ${ICON_HUE_PAINT.light.saturation}% ${ICON_HUE_PAINT.light.lightness}%))`,
275
- );
276
- expect(iconHuePaint('dark')).toBe(`hsl(var(--icon-hue, ${DEFAULT_ICON_HUE}) ${saturation}% ${lightness}%)`);
277
- expect(iconHueColor(120, 'light')).toBe(ICON_TONES[120]!);
278
- expect(iconHueColor(120, 'dark')).toBe(`hsl(120 ${saturation}% ${lightness}%)`);
279
- });
280
-
281
- test('the table is exactly what the runtime hash produces', () => {
282
- // One formula for both: a plugin's mark is coloured by `hashHue` at runtime,
283
- // so if the generated rows drifted from it, an installed plugin would sit on
284
- // a different wheel than the glyphs beside it.
285
- for (const [name, hue] of Object.entries(ICON_HUES)) {
286
- expect(hashHue(name), name).toBe(hue);
287
- }
288
- });
289
-
290
- test('a plugin name gets a stable hue on the same wheel', () => {
291
- expect(hashHue('Demo Plugin')).toBe(hashHue('Demo Plugin'));
292
- expect(hashHue('Demo Plugin')).not.toBe(hashHue('Other Plugin'));
293
- for (const name of ['Demo', 'Session Info', 'git-forge', 'Stats — CPU & RAM']) {
294
- expect(hashHue(name) % 10, name).toBe(0);
295
- expect(hashHue(name), name).toBeLessThan(360);
296
- }
297
- });
298
-
299
- test('the rail gives every panel its OWN hue, even when two hashes collide', () => {
300
- // Fourteen buttons on a 36-slot wheel collide about nine times in ten
301
- // (birthday bound) — measured, three right-rail icons shared one blue.
302
- const ids = [
303
- 'context', 'files', 'search', 'git', 'wiki', 'terminal', 'user-browser',
304
- 'browser', 'usage', 'todo', 'plan', 'plugin:command-runner',
305
- 'plugin:git-forge', 'plugin:stats',
306
- ];
307
- const hues = assignPanelHues(ids);
308
-
309
- expect(hues.size).toBe(ids.length);
310
- expect(new Set(hues.values()).size).toBe(ids.length);
311
- });
312
-
313
- test('the assignment does not depend on the catalog order', () => {
314
- // Reordering a rail must not recolour it: the ids are sorted before probing.
315
- const ids = ['b', 'a', 'c', 'plugin:x'];
316
- expect([...assignPanelHues(ids)]).toEqual([...assignPanelHues([...ids].reverse())]);
317
- });
318
-
319
- test('an unassigned panel falls back to the plain hash', () => {
320
- expect(assignPanelHues(['only']).get('only')).toBe(hashHue('only'));
321
- });
322
-
323
- test('an icon outside the table keeps a neutral default', () => {
324
- expect(iconHue('NotAnIcon')).toBe(DEFAULT_ICON_HUE);
325
- expect(iconHue('Trash2')).toBe(DEFAULT_ICON_HUE);
326
- });
327
-
328
- test('the rows name classes, one per hue', () => {
329
- const classes = ICON_HUE_ROWS.map((row) => row.className);
330
- expect(new Set(classes).size).toBe(classes.length);
331
- expect(classes.every((className) => className.startsWith('lucide-'))).toBe(true);
332
- });
333
- });
@@ -31,7 +31,7 @@
31
31
  * is the single translation to `lucide-trash-2`.
32
32
  */
33
33
 
34
- import { ICON_HUES, ICON_TONES } from '@/shared/lib/icons/tint-hues.generated';
34
+ import { ICON_HUES, ICON_TONES, ICON_TONES_DARK } from '@/shared/lib/icons/tint-hues.generated';
35
35
 
36
36
  export type IconTintRole = 'error' | 'success' | 'warning' | 'info';
37
37
 
@@ -44,12 +44,13 @@ export const ICON_TINT_TOKENS: Readonly<Record<IconTintRole, string>> = {
44
44
  };
45
45
 
46
46
  /**
47
- * How the DARK hue is painted. Light has no pair any more — see below.
47
+ * How the LIGHT hue is painted when nothing stamps `--icon-tone`.
48
48
  *
49
- * `65% 70%` is the whole legibility budget on that side: measured against every
50
- * dark palette, its worst hue is 4.07:1 on `jetbrains-dark`'s `#2B2D30` (the
51
- * floor is 3:1 for a graphic). It is also the side nobody complained about, so
52
- * it is left exactly as it was.
49
+ * Both variants now have a solved table, so this is no longer the paint itself —
50
+ * it is the FALLBACK for a hue no row covers, and it is kept because a rule that
51
+ * resolves to nothing is an icon that inherits whatever colour its parent has.
52
+ * `saturation`/`lightness` are the pairs the mode shipped before it was solved
53
+ * per hue, and their OKLCH hue angle is what every solved row keeps.
53
54
  */
54
55
  export const ICON_HUE_PAINT = {
55
56
  light: { saturation: 60, lightness: 30 },
@@ -65,40 +66,37 @@ function wheelStep(hue: number): number {
65
66
  }
66
67
 
67
68
  /**
68
- * The LIGHT tone for a hue: a hex solved per hue, not one pair for all of them.
69
+ * The tone for a hue in a variant: a hex solved per hue, not one pair for all.
69
70
  *
70
- * Measured, this is the difference the report named — the muddiest row (hue 190)
71
- * goes from OKLCH chroma 0.075 to 0.102, hue 200 from 0.078 to 0.121, and the
72
- * mean from 0.121 to 0.162 (×1.34), with every tone still at 3.15:1 or better on
73
- * all 32 light palettes. `icon-tone.ts` states the rule and the numbers.
71
+ * Measured, this is the difference the report named — on the light side the
72
+ * muddiest row (hue 190) goes from OKLCH chroma 0.075 to 0.102, hue 200 from
73
+ * 0.078 to 0.121, and the mean from 0.121 to 0.162 (×1.34), with every tone
74
+ * still at 3.15:1 or better on all 32 light palettes. On the dark side the same
75
+ * solve collapses a lightness spread of 0.25 into 0.08 while RAISING mean
76
+ * chroma 0.126 → 0.170. `icon-tone.ts` states both measurements.
74
77
  *
75
78
  * A hue off the wheel snaps to the nearest step: every producer here is a
76
79
  * `hashHue` result (36 steps of 10°) or a table row, so the nearest step IS that
77
80
  * hue; snapping is what keeps this a table lookup rather than a solve on load.
78
81
  */
79
- export function iconTone(hue: number): string {
80
- return ICON_TONES[wheelStep(hue)] ?? ICON_TONES[0]!;
81
- }
82
-
83
- /** One hue as a paintable colour. Light is a solved hex; dark is still an `hsl()`. */
84
- export function iconHueColor(hue: number, variant: 'light' | 'dark'): string {
85
- if (variant === 'light') return iconTone(hue);
86
- const { saturation, lightness } = ICON_HUE_PAINT.dark;
87
- return `hsl(${hue} ${saturation}% ${lightness}%)`;
82
+ export function iconTone(hue: number, variant: 'light' | 'dark' = 'light'): string {
83
+ const table = variant === 'light' ? ICON_TONES : ICON_TONES_DARK;
84
+ return table[wheelStep(hue)] ?? table[0]!;
88
85
  }
89
86
 
90
87
  /**
91
88
  * The paint rule's value: the hue left to the custom property the class sets.
92
89
  *
93
- * `--icon-tone` wins where it is stamped (every generated row, every plugin and
94
- * panel mark). The `hsl()` behind it is the old light paint, kept as the last
95
- * resort for an icon that declares a hue no table row covers — a shade that is
96
- * merely dated, never absent.
90
+ * `--icon-tone` (light) and `--icon-tone-dark` win where they are stamped —
91
+ * every generated row, every plugin and panel mark. The `hsl()` behind each is
92
+ * the pair the mode shipped before it was solved, kept as the last resort for an
93
+ * icon that declares a hue no table row covers: a shade that is merely dated,
94
+ * never absent.
97
95
  */
98
96
  export function iconHuePaint(variant: 'light' | 'dark'): string {
99
97
  const { saturation, lightness } = ICON_HUE_PAINT[variant];
100
98
  const fallback = `hsl(var(--icon-hue, ${DEFAULT_ICON_HUE}) ${saturation}% ${lightness}%)`;
101
- return variant === 'light' ? `var(--icon-tone, ${fallback})` : fallback;
99
+ return variant === 'light' ? `var(--icon-tone, ${fallback})` : `var(--icon-tone-dark, ${fallback})`;
102
100
  }
103
101
 
104
102
  /** Glyph name → the signal it stands for. Everything else gets a generated hue. */
@@ -0,0 +1,40 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The vocabulary the composer and the goal surfaces share: the actions the
8
+ * Goal modal can submit, and the ARMED form one of them becomes.
9
+ *
10
+ * Its own module because three layers need the same names — the mode hook
11
+ * (`modes.ts`) produces them, `goal-command.ts` executes them, and the
12
+ * components name them in props (`ArmedGoalStrip`, `ModeToggles`,
13
+ * `GoalModal`). Re-declaring the union in a component would let a new action
14
+ * compile in one place and fail silently in another.
15
+ */
16
+
17
+ /** A goal recorded but not started: what the next prompt turns into.
18
+ *
19
+ * Setting a goal does not run anything — the record is created at the fence of
20
+ * the next prompt (`startTurn: false`), so that prompt is the goal's first
21
+ * turn. See `modes.ts` for why.
22
+ *
23
+ * Two shapes, and they differ in what the operator's first message MEANS:
24
+ *
25
+ * - `create` — the message is the goal's work; `objective` is already written.
26
+ * - `guided` — the message is the ANSWER that starts the interview. There is no
27
+ * objective yet (the model writes it at the end of the interview), so the
28
+ * message is folded into the kickoff prompt as the rough idea. */
29
+ export type ArmedGoal =
30
+ | { kind: 'create'; objective: string; tokenBudget?: number; maxTurns?: number }
31
+ | { kind: 'guided'; rough: string };
32
+
33
+ /** One command from the Goal modal or the goal strip. */
34
+ export type GoalAction =
35
+ | { kind: 'create'; objective: string; tokenBudget?: number; maxTurns?: number }
36
+ | { kind: 'guided'; rough: string }
37
+ | { kind: 'pause' }
38
+ | { kind: 'resume' }
39
+ | { kind: 'drop' }
40
+ | { kind: 'budget'; value: number | 'off' };
@@ -141,6 +141,18 @@ export const KABMO_MODES_ENV = 'KABMO_MODES';
141
141
  /** Kabmo-owned slash command the extension registers. */
142
142
  export const KABMO_MODE_COMMAND = 'kabmo-mode';
143
143
 
144
+ /** The body `type` a mode request travels as, from the console to
145
+ * `POST /api/agent/:id`. Distinct from the slash command above: the type
146
+ * selects the route's branch, the command names what the child runs. */
147
+ export const MODE_COMMAND_TYPE = 'kabmo_mode';
148
+
149
+ /** The pre-rename wire type. Still ACCEPTED, never sent: a browser tab this
150
+ * server does not control keeps posting it until the page reloads, and a
151
+ * rejected request there reads as a dead Plan/Goal button. External
152
+ * compatibility requirement, so it is a permanent part of the read contract
153
+ * rather than a pending deletion. */
154
+ export const LEGACY_MODE_COMMAND_TYPE = 'chamber_mode';
155
+
144
156
  /**
145
157
  * The pre-rename names, still READ and never written.
146
158
  *
@@ -28,6 +28,13 @@
28
28
 
29
29
  import type { ThemePalette } from '@/shared/types/theme';
30
30
  import { THEMES } from '@/shared/lib/theme/catalog';
31
+ import {
32
+ MUTED_STEPS,
33
+ SIGNAL_SLOTS,
34
+ inkScale,
35
+ onInkTextColor,
36
+ signalTextColor,
37
+ } from '@/shared/lib/theme/ink-scale';
31
38
 
32
39
  /** The `<style>` element's id: the SSR shell writes it, the client checks it. */
33
40
  export const THEME_STYLE_ELEMENT_ID = 'omp-theme-palettes';
@@ -44,16 +51,30 @@ const HOVER_MIXES: ReadonlyArray<readonly [string, string]> = [
44
51
  ];
45
52
 
46
53
  function paletteBlock(theme: ThemePalette): string {
54
+ const scale = inkScale(theme);
47
55
  const lines = [
48
56
  ` --theme-paper: ${theme.paper};`,
49
57
  ` --theme-canvas: ${theme.canvas};`,
50
58
  ` --theme-ink: ${theme.ink};`,
59
+ // Fifteen distinct values: the ink at N% over this palette's paper.
60
+ ...scale.ladder.map((value, index) => ` --theme-ink-${MUTED_STEPS[index]}: ${value};`),
61
+ // Muted text on an inverted surface: an alpha reads 2.91:1 on `solarized-light`.
62
+ ` --theme-on-ink-muted: ${onInkTextColor(theme)};`,
63
+ // The one level that clears AA on THIS palette. No single rung can be legal
64
+ // everywhere: the measured floor ranges from `/50` to `/90` across the 63.
65
+ ` --theme-muted: ${scale.muted};`,
51
66
  ` --theme-error: ${theme.error};`,
52
67
  ` --theme-success: ${theme.success};`,
53
68
  ` --theme-info: ${theme.info};`,
54
69
  ` --theme-warning: ${theme.warning};`,
55
70
  ` --theme-meta: ${theme.meta};`,
56
71
  ];
72
+ // The same five signals as READABLE TEXT. A status word is text, and the
73
+ // palette's own signal hex is chosen for a fill: measured as text it reaches
74
+ // 1.53:1 (`warning` on `carbonfox-light`) and fails AA on 14-22 palettes.
75
+ for (const slot of SIGNAL_SLOTS) {
76
+ lines.push(` --theme-${slot}-text: ${signalTextColor(theme, slot)};`);
77
+ }
57
78
  for (const [name, source] of HOVER_MIXES) {
58
79
  lines.push(` ${name}: color-mix(in srgb, var(${source}) 85%, var(--theme-ink));`);
59
80
  }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The colour the browser paints before the bundle's stylesheet lands.
8
+ *
9
+ * Two problems, one value:
10
+ *
11
+ * - **The first frame.** The UA's canvas is white, and on a dark install that is
12
+ * a measured white flash for the length of the CSS request. The palette's
13
+ * ground is the only correct answer, and it has to be inline because nothing
14
+ * else has loaded.
15
+ * - **The frame must follow the theme AT RUNTIME.** This rule is unlayered, so
16
+ * it outranks the `body` rule in `tailwind.css` at any specificity — which is
17
+ * exactly what makes it work before the bundle and exactly what made it wrong
18
+ * after a theme switch: measured, choosing a light theme at runtime left
19
+ * `body` painted `rgb(30,34,42)` from the previous dark palette while
20
+ * `--theme-canvas` had already moved. The element carries a stable id so
21
+ * `applyDocumentTheme` can rewrite it in the same write that flips the
22
+ * palette; a second copy of the colour is a second thing to forget.
23
+ *
24
+ * Shared rather than server-only for that second reason: the shell writes the
25
+ * first value and the client rewrites every later one, from this one function.
26
+ */
27
+
28
+ import type { ThemePalette } from '@/shared/types/theme';
29
+ import { parseHexColor, rgbaToHex } from '@/shared/lib/theme/color';
30
+
31
+ /** The `<style>` element's id: the SSR shell writes it, the theme writer updates it. */
32
+ export const FIRST_FRAME_STYLE_ELEMENT_ID = 'omp-first-frame';
33
+
34
+ /** The inline rule that paints `html` and `body` before the bundle loads. */
35
+ export function firstFrameStyle(palette: ThemePalette): string {
36
+ const canvas = rgbaToHex(parseHexColor(palette.canvas) ?? { r: 0, g: 0, b: 0, a: 1 });
37
+ return `html,body{background-color:${canvas};}`;
38
+ }
@@ -0,0 +1,151 @@
1
+ /**
2
+ * The muted ink ladder: a lightness ramp plus one solved AA floor. The shape is
3
+ * what broke twice, so it is pinned; see `TEXT_CONTRAST_FLOOR`.
4
+ */
5
+
6
+ import { describe, expect, test } from 'bun:test';
7
+
8
+ import {
9
+ MUTED_CONTRAST_FLOOR,
10
+ MUTED_STEPS,
11
+ TEXT_CONTRAST_FLOOR,
12
+ contrastBetween,
13
+ inkScale,
14
+ onInkTextColor,
15
+ signalTextColor,
16
+ worstTextContrast,
17
+ } from '@/shared/lib/theme/ink-scale';
18
+ import { SIGNAL_SLOTS } from '@/shared/lib/theme/ink-scale';
19
+ import { mixHex } from '@/shared/lib/theme/color';
20
+ import { themeStyleSheet } from '@/shared/lib/theme/css';
21
+ import { THEMES } from '@/shared/lib/theme/catalog';
22
+
23
+ const paper = THEMES.find((theme) => theme.id === 'paper')!;
24
+ const solarized = THEMES.find((theme) => theme.id === 'solarized-light')!;
25
+
26
+ describe('the muted ladder', () => {
27
+ test('the ramp is the ink at that percentage over the paper', () => {
28
+ // The class name IS the value. `text-ink/40` means 40% ink, and a ramp that
29
+ // quietly stops meaning that is a ramp nobody can reason about.
30
+ for (const theme of THEMES) {
31
+ const ladder = inkScale(theme).ladder;
32
+ MUTED_STEPS.forEach((step, index) => {
33
+ expect(ladder[index], `${theme.id}/$${step}`).toBe(
34
+ mixHex(theme.paper, theme.ink, step / 100),
35
+ );
36
+ });
37
+ }
38
+ });
39
+
40
+ test('fifteen steps are fifteen DISTINCT values on a palette with headroom', () => {
41
+ // The failure this catches: bucketing made `/30` and `/45` the same colour.
42
+ for (const theme of THEMES) {
43
+ const ladder = inkScale(theme).ladder;
44
+ expect(ladder.length).toBe(MUTED_STEPS.length);
45
+ if (theme.id === 'solarized-light') continue; // too little range to spread
46
+ expect(new Set(ladder).size, theme.id).toBe(MUTED_STEPS.length);
47
+ }
48
+ });
49
+
50
+ test('the floor is a step that clears AA, and the one below it does not', () => {
51
+ // Placed where it is NEEDED, not somewhere comfortably safe: asserting it is
52
+ // both sufficient and minimal is what stops the number drifting.
53
+ const ladder = inkScale(paper).ladder;
54
+ const floorIndex = MUTED_STEPS.indexOf(TEXT_CONTRAST_FLOOR);
55
+ expect(worstTextContrast(ladder[floorIndex], paper)).toBeGreaterThanOrEqual(
56
+ MUTED_CONTRAST_FLOOR,
57
+ );
58
+ expect(worstTextContrast(ladder[floorIndex - 1], paper)).toBeLessThan(MUTED_CONTRAST_FLOOR);
59
+ });
60
+
61
+ test('`muted` is the lightest LEGAL step of that palette, not a fixed rung', () => {
62
+ // The floor is `/65` on `paper`, but each palette's headroom differs — the
63
+ // measured floor ranges from `/50` to `/90` across the 63 — so `muted` is
64
+ // "first step that clears AA", which is the same rule applied, not a second
65
+ // convention. On `paper` the two agree, which is why the default palette
66
+ // anchors the design.
67
+ for (const theme of THEMES) {
68
+ const ladder = inkScale(theme).ladder;
69
+ const firstLegal = ladder.find(
70
+ (color) => worstTextContrast(color, theme) >= MUTED_CONTRAST_FLOOR,
71
+ );
72
+ expect(inkScale(theme).muted, theme.id).toBe(firstLegal ?? theme.ink);
73
+ expect(worstTextContrast(inkScale(theme).muted, theme), theme.id).toBeGreaterThanOrEqual(
74
+ MUTED_CONTRAST_FLOOR,
75
+ );
76
+ }
77
+ expect(inkScale(paper).muted).toBe(inkScale(paper).ladder[MUTED_STEPS.indexOf(TEXT_CONTRAST_FLOOR)]);
78
+ });
79
+
80
+ test('a palette with no headroom puts its muted level on its own ink', () => {
81
+ // `solarized-light`'s ink is 4.85:1, so nothing below it is legal. Returning
82
+ // a lighter colour there would be reporting a contrast the palette lacks.
83
+ expect(inkScale(solarized).muted).toBe(solarized.ink);
84
+ });
85
+
86
+ test('nothing in the ramp is lighter than the paper it sits on', () => {
87
+ // A step lighter than its surface is text painted in the background colour.
88
+ for (const theme of THEMES) {
89
+ for (const color of inkScale(theme).ladder) {
90
+ expect(worstTextContrast(color, theme), theme.id).toBeGreaterThan(1.2);
91
+ }
92
+ }
93
+ });
94
+ });
95
+
96
+ describe('the generated stylesheet', () => {
97
+ test('states all fifteen steps for every palette', () => {
98
+ const css = themeStyleSheet();
99
+ for (const step of MUTED_STEPS) {
100
+ expect(css.match(new RegExp(`--theme-ink-${step}:`, 'g'))?.length).toBe(THEMES.length);
101
+ }
102
+ });
103
+
104
+ test('the emitted values are the solved ones, not a second hand-tuned copy', () => {
105
+ const ladder = inkScale(paper).ladder;
106
+ MUTED_STEPS.forEach((step, index) => {
107
+ expect(themeStyleSheet()).toContain(`--theme-ink-${step}: ${ladder[index]};`);
108
+ });
109
+ });
110
+
111
+ test('the retired bucketed tokens are gone, so no stale value can be read', () => {
112
+ const css = themeStyleSheet();
113
+ expect(css).not.toContain('--theme-ink-muted:');
114
+ expect(css).not.toContain('--theme-ink-muted-2:');
115
+ });
116
+ });
117
+
118
+ describe('text on an inverted surface', () => {
119
+ test('every palette clears AA on bg-ink once solved', () => {
120
+ // Measured before: `text-canvas/60` over `bg-ink` read 2.91:1 on
121
+ // `solarized-light`, and even the full canvas only reached 4.99 there.
122
+ const failing = THEMES.filter(
123
+ (theme) => contrastBetween(onInkTextColor(theme), theme.ink) < 4.5 - 0.001,
124
+ );
125
+ expect(failing.map((theme) => theme.id)).toEqual([]);
126
+ });
127
+
128
+ test('a palette whose canvas already reads keeps its own canvas', () => {
129
+ expect(onInkTextColor(paper)).toBe(paper.canvas);
130
+ });
131
+ });
132
+
133
+ describe('signal colours as text', () => {
134
+ test('every slot clears AA on every palette once solved', () => {
135
+ // Measured before: `text-success` 1.75:1 on `nord-light`, `text-warning`
136
+ // 1.53:1 on `carbonfox-light`, every slot failing on 14-22 of 63 palettes.
137
+ const failing: string[] = [];
138
+ for (const theme of THEMES) {
139
+ for (const slot of SIGNAL_SLOTS) {
140
+ if (worstTextContrast(signalTextColor(theme, slot), theme) < 4.5 - 0.001) {
141
+ failing.push(`${theme.id}/${slot}`);
142
+ }
143
+ }
144
+ }
145
+ expect(failing).toEqual([]);
146
+ });
147
+
148
+ test('a palette whose signal already reads keeps its own hex', () => {
149
+ expect(signalTextColor(paper, 'error')).toBe(paper.error);
150
+ });
151
+ });