@kabmo-labs/kabmo 0.18.0 → 0.21.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 (219) hide show
  1. package/README.md +43 -13
  2. package/dist/client/index.html +3 -3
  3. package/dist/client/index.js +485 -484
  4. package/dist/client/static/js/index-0721wrkf.css +1 -0
  5. package/dist/client/static/js/{index-tc09dtca.js → index-zg32n2sk.js} +778 -777
  6. package/dist/client/static/{manifest-42r8wcmg.webmanifest → manifest-q6h8k9e0.webmanifest} +1 -1
  7. package/index.html +1 -1
  8. package/marketplace/plugins/command-runner/package.json +3 -2
  9. package/marketplace/plugins/git-forge/package.json +3 -2
  10. package/marketplace/plugins/session-info/package.json +3 -2
  11. package/marketplace/plugins/stats/package.json +3 -2
  12. package/package.json +3 -1
  13. package/public/manifest.webmanifest +1 -1
  14. package/src/client/components/auth/login-screen/index.tsx +2 -1
  15. package/src/client/components/common/ComposerPicker.tsx +1 -1
  16. package/src/client/components/common/FolderPicker.tsx +2 -2
  17. package/src/client/components/common/Modal.tsx +2 -2
  18. package/src/client/components/common/PWAInstallButton.tsx +2 -2
  19. package/src/client/components/common/ViewportSelector.tsx +1 -1
  20. package/src/client/components/common/anchored-menu/index.tsx +5 -1
  21. package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
  22. package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
  23. package/src/client/components/common/brand-wordmark/index.tsx +13 -2
  24. package/src/client/components/common/checkbox/style.test.ts +142 -0
  25. package/src/client/components/common/checkbox/style.ts +51 -0
  26. package/src/client/components/common/context-usage-button/index.tsx +2 -2
  27. package/src/client/components/common/file-icon/index.tsx +23 -9
  28. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  29. package/src/client/components/common/markdown-review/ReviewPopover.tsx +1 -1
  30. package/src/client/components/common/panel-mark/index.test.tsx +124 -0
  31. package/src/client/components/common/panel-mark/index.tsx +105 -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/session-actions-menu/index.tsx +1 -1
  38. package/src/client/components/common/toolbar-row/index.tsx +1 -1
  39. package/src/client/components/layout/ActivityBar.tsx +22 -3
  40. package/src/client/components/layout/LeftDock.tsx +9 -2
  41. package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
  42. package/src/client/components/layout/WindowAura.tsx +27 -0
  43. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
  44. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
  45. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
  46. package/src/client/components/layout/desktop-layout/index.tsx +3 -1
  47. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +3 -3
  48. package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
  49. package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
  50. package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
  51. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -2
  52. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
  53. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +13 -5
  54. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  55. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
  56. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
  57. package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
  58. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  59. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
  60. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  61. package/src/client/components/mobile/panel-chips.tsx +10 -2
  62. package/src/client/components/settings/Modal.tsx +4 -4
  63. package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
  64. package/src/client/components/settings/apply-side-effects.test.ts +30 -0
  65. package/src/client/components/settings/apply-side-effects.ts +14 -0
  66. package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
  67. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
  68. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
  69. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
  70. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
  71. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
  72. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +2 -1
  73. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +2 -2
  74. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +1 -1
  75. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
  76. package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
  77. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +46 -0
  78. package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +1 -1
  79. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +7 -9
  80. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +149 -0
  81. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +34 -7
  82. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +66 -2
  83. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +47 -10
  84. package/src/client/components/settings/categories/panel-plugins/Section.tsx +7 -1
  85. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +35 -2
  86. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
  87. package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
  88. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
  89. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  90. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
  91. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
  92. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  93. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
  94. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +2 -1
  95. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
  96. package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
  97. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
  98. package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
  99. package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
  100. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  101. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
  102. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  103. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
  104. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
  105. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  106. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  107. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
  108. package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
  109. package/src/client/components/workspace/diff-panel/index.tsx +2 -2
  110. package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
  111. package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
  112. package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
  113. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  114. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
  115. package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
  116. package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
  117. package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
  118. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
  119. package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
  120. package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
  121. package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
  122. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
  123. package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
  124. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
  125. package/src/client/components/workspace/git-panel/index.tsx +7 -0
  126. package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
  127. package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
  128. package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
  129. package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
  130. package/src/client/components/workspace/search-panel/Body.tsx +1 -1
  131. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
  132. package/src/client/glass-sticky.test.ts +46 -0
  133. package/src/client/glass.css +795 -0
  134. package/src/client/glass.test.ts +306 -0
  135. package/src/client/hooks/ui/glass-support.ts +57 -0
  136. package/src/client/hooks/ui/icon-style.ts +59 -0
  137. package/src/client/hooks/ui/stuck-header.test.ts +213 -0
  138. package/src/client/hooks/ui/stuck-header.ts +122 -0
  139. package/src/client/hooks/ui/style-attributes.test.ts +120 -0
  140. package/src/client/hooks/ui/surface-style.ts +56 -0
  141. package/src/client/hooks/workspace/panel-hues.ts +23 -0
  142. package/src/client/hooks/workspace/panel-registry.ts +8 -4
  143. package/src/client/main.tsx +10 -0
  144. package/src/client/tailwind.css +264 -11
  145. package/src/server/lib/assets/shell-attributes.server.ts +80 -0
  146. package/src/server/lib/assets/shell-attributes.test.ts +86 -0
  147. package/src/server/lib/lifecycle/tls.test.ts +6 -1
  148. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
  149. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
  150. package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
  151. package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
  152. package/src/server/lib/omp/rpc/manager.ts +2 -2
  153. package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
  154. package/src/server/lib/omp/rpc/process.test.ts +106 -0
  155. package/src/server/lib/omp/rpc/process.ts +28 -4
  156. package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
  157. package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
  158. package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
  159. package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
  160. package/src/server/lib/omp/rpc/session-commands.ts +11 -0
  161. package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
  162. package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
  163. package/src/server/lib/panels/git-update.server.test.ts +20 -0
  164. package/src/server/lib/panels/git-update.server.ts +20 -4
  165. package/src/server/lib/panels/manifest.test.ts +20 -0
  166. package/src/server/lib/panels/manifest.ts +12 -0
  167. package/src/server/lib/panels/scan.server.ts +4 -0
  168. package/src/server/lib/panels/sync.server.ts +9 -1
  169. package/src/server/lib/panels/update.server.test.ts +193 -0
  170. package/src/server/lib/panels/update.server.ts +210 -0
  171. package/src/server/lib/plugins/server-half.server.ts +42 -0
  172. package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
  173. package/src/server/lib/queue/delivery-harness.ts +8 -4
  174. package/src/server/lib/queue/delivery.server.test.ts +29 -0
  175. package/src/server/lib/queue/delivery.server.ts +39 -0
  176. package/src/server/lib/queue/store.server.test.ts +22 -2
  177. package/src/server/lib/queue/store.server.ts +33 -11
  178. package/src/server/lib/terminal/attach-replay.test.ts +26 -8
  179. package/src/server/plugins/ssr.ts +22 -5
  180. package/src/server/routes/panels/install-route.test.ts +238 -0
  181. package/src/server/routes/panels/install.ts +36 -64
  182. package/src/server/routes/panels/panel-routes.test-util.ts +6 -1
  183. package/src/server/routes/panels/routes.test.ts +1 -118
  184. package/src/shared/lib/icons/file-brand-color.ts +38 -0
  185. package/src/shared/lib/icons/icon-paint-css.test.ts +235 -0
  186. package/src/shared/lib/icons/icon-paint-css.ts +285 -0
  187. package/src/shared/lib/icons/icon-paint-panel.ts +109 -0
  188. package/src/shared/lib/icons/icon-tone.ts +166 -0
  189. package/src/shared/lib/icons/tint-hues.generated.ts +277 -0
  190. package/src/shared/lib/icons/tint.test.ts +333 -0
  191. package/src/shared/lib/icons/tint.ts +248 -0
  192. package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
  193. package/src/shared/lib/models/provider/brand-color.ts +103 -0
  194. package/src/shared/lib/omp/rpc/frame.test.ts +65 -0
  195. package/src/shared/lib/omp/rpc/frame.ts +58 -3
  196. package/src/shared/lib/panels/update.test.ts +107 -0
  197. package/src/shared/lib/panels/update.ts +73 -0
  198. package/src/shared/lib/settings/defaults.ts +4 -0
  199. package/src/shared/lib/theme/catalog.test.ts +5 -4
  200. package/src/shared/lib/theme/catalog.ts +18 -3
  201. package/src/shared/lib/theme/color.ts +50 -0
  202. package/src/shared/lib/theme/glass-support.test.ts +38 -0
  203. package/src/shared/lib/theme/glass-support.ts +73 -0
  204. package/src/shared/lib/theme/icon-style.test.ts +74 -0
  205. package/src/shared/lib/theme/icon-style.ts +90 -0
  206. package/src/shared/lib/theme/legibility.ts +91 -0
  207. package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
  208. package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
  209. package/src/shared/lib/theme/surface-style.test.ts +68 -0
  210. package/src/shared/lib/theme/surface-style.ts +91 -0
  211. package/src/shared/lib/theme/theme.test.ts +11 -7
  212. package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
  213. package/src/shared/lib/workspace/panel-hues.ts +57 -0
  214. package/src/shared/types/panels-registry.ts +6 -0
  215. package/src/shared/types/panels.ts +14 -0
  216. package/src/shared/types/settings/state.ts +26 -0
  217. package/src/test-support/fake-omp-frames.ts +163 -0
  218. package/dist/client/static/js/index-hp75vsv9.css +0 -1
  219. /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
@@ -0,0 +1,248 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The colour every FUNCTIONAL glyph is painted in, in `color` mode.
8
+ *
9
+ * Lucide draws each icon as a stroke in `currentColor`, so "full colour" for a
10
+ * functional glyph can only mean a TINT — there is no second artwork to swap in.
11
+ * Two rules decide which tint, and they answer different questions:
12
+ *
13
+ * - **A signal icon means something, so it takes the palette's signal colour**
14
+ * ({@link ICON_TINTS}): a trash can is destructive, a check is a confirmation,
15
+ * a clock is waiting, an info dot is information. Those colours already exist
16
+ * in every palette, and a themed `--theme-error` follows the user's theme the
17
+ * way a literal red cannot.
18
+ * - **Every other icon gets its OWN hue** ({@link ICON_HUES}, generated). One
19
+ * shared accent for the remaining two hundred glyphs is the failure mode this
20
+ * avoids: a mode that colours a dozen icons and leaves the rest identical is
21
+ * not "full colour", it is one colour. The hue comes from a stable hash of the
22
+ * name, quantised to a 36-step wheel, so two neighbouring icons differ without
23
+ * the table being 250 hand-picked decisions.
24
+ *
25
+ * Both are DEFAULT paint, never an override: the stylesheet wraps every selector
26
+ * in `:where()`, so a `text-*` class a caller wrote on the element still wins
27
+ * (see `icon-paint-css.ts`).
28
+ *
29
+ * Keys are the names the code IMPORTS (`Trash2`), not the emitted class, so a
30
+ * row is checkable against the call site it describes; {@link lucideClassName}
31
+ * is the single translation to `lucide-trash-2`.
32
+ */
33
+
34
+ import { ICON_HUES, ICON_TONES } from '@/shared/lib/icons/tint-hues.generated';
35
+
36
+ export type IconTintRole = 'error' | 'success' | 'warning' | 'info';
37
+
38
+ /** The CSS value each role paints. Tokens only — never a hex. */
39
+ export const ICON_TINT_TOKENS: Readonly<Record<IconTintRole, string>> = {
40
+ error: 'var(--theme-error)',
41
+ success: 'var(--theme-success)',
42
+ warning: 'var(--theme-warning)',
43
+ info: 'var(--theme-info)',
44
+ };
45
+
46
+ /**
47
+ * How the DARK hue is painted. Light has no pair any more — see below.
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.
53
+ */
54
+ export const ICON_HUE_PAINT = {
55
+ light: { saturation: 60, lightness: 30 },
56
+ dark: { saturation: 65, lightness: 70 },
57
+ } as const;
58
+
59
+ /** The hue an icon with no row keeps — a neutral blue, never a sixth signal. */
60
+ export const DEFAULT_ICON_HUE = 210;
61
+
62
+ /** The wheel step nearest `hue` — every producer today is already on it. */
63
+ function wheelStep(hue: number): number {
64
+ return ((Math.round(hue / 10) * 10) % 360 + 360) % 360;
65
+ }
66
+
67
+ /**
68
+ * The LIGHT tone for a hue: a hex solved per hue, not one pair for all of them.
69
+ *
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.
74
+ *
75
+ * A hue off the wheel snaps to the nearest step: every producer here is a
76
+ * `hashHue` result (36 steps of 10°) or a table row, so the nearest step IS that
77
+ * hue; snapping is what keeps this a table lookup rather than a solve on load.
78
+ */
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}%)`;
88
+ }
89
+
90
+ /**
91
+ * The paint rule's value: the hue left to the custom property the class sets.
92
+ *
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.
97
+ */
98
+ export function iconHuePaint(variant: 'light' | 'dark'): string {
99
+ const { saturation, lightness } = ICON_HUE_PAINT[variant];
100
+ const fallback = `hsl(var(--icon-hue, ${DEFAULT_ICON_HUE}) ${saturation}% ${lightness}%)`;
101
+ return variant === 'light' ? `var(--icon-tone, ${fallback})` : fallback;
102
+ }
103
+
104
+ /** Glyph name → the signal it stands for. Everything else gets a generated hue. */
105
+ export const ICON_TINTS: Readonly<Record<string, IconTintRole>> = {
106
+ // Failures, destructive actions, and things that are broken.
107
+ AlertCircle: 'error',
108
+ AlertTriangle: 'error',
109
+ Ban: 'error',
110
+ Bug: 'error',
111
+ BugOff: 'error',
112
+ CircleAlert: 'error',
113
+ CircleSlash: 'error',
114
+ FileWarning: 'error',
115
+ FileX: 'error',
116
+ OctagonAlert: 'error',
117
+ OctagonX: 'error',
118
+ PackageX: 'error',
119
+ ShieldAlert: 'error',
120
+ Trash2: 'error',
121
+ XCircle: 'error',
122
+
123
+ // Confirmations and healthy state.
124
+ Check: 'success',
125
+ CheckCheck: 'success',
126
+ CheckCircle2: 'success',
127
+ CheckSquare: 'success',
128
+ PackageCheck: 'success',
129
+ ShieldCheck: 'success',
130
+
131
+ // A file whose VIEWER is the point: the hue is what tells a reader at a
132
+ // glance that the document opens as something other than source text. These
133
+ // carried fixed hexes before the mode existed, which made them the only icons
134
+ // that ignored it.
135
+ Braces: 'warning',
136
+ FileArchive: 'warning',
137
+ FileSpreadsheet: 'success',
138
+ FileType: 'warning',
139
+
140
+ // Attention: something is pending, scheduled or in flight.
141
+ Bell: 'warning',
142
+ Calendar: 'warning',
143
+ CalendarRange: 'warning',
144
+ Clock: 'warning',
145
+ Clock3: 'warning',
146
+ Hourglass: 'warning',
147
+
148
+ // Information, help and reading.
149
+ BookOpen: 'info',
150
+ CircleQuestionMark: 'info',
151
+ Compass: 'info',
152
+ HelpCircle: 'info',
153
+ Info: 'info',
154
+ };
155
+
156
+ /**
157
+ * `Trash2` -> `trash-2`: the class Lucide emits for that component.
158
+ *
159
+ * Lucide names the class from the icon's own canonical name and adds one per
160
+ * alias, so a legacy import name (`Trash2`, `AlertTriangle`) still matches its
161
+ * own class — which is why this conversion is enough and the table can stay in
162
+ * the vocabulary of the call sites.
163
+ */
164
+ export function kebabIconName(name: string): string {
165
+ return name
166
+ .replace(/([a-z0-9])([A-Z])/g, '$1-$2')
167
+ .replace(/([A-Z]+)([A-Z][a-z])/g, '$1-$2')
168
+ .replace(/([a-zA-Z])([0-9])/g, '$1-$2')
169
+ .toLowerCase();
170
+ }
171
+
172
+ /** The class Lucide puts on the `<svg>` for an imported icon name. */
173
+ export function lucideClassName(name: string): string {
174
+ return `lucide-${kebabIconName(name)}`;
175
+ }
176
+
177
+ /** The signal role for an imported icon name, or `null` when it has none. */
178
+ export function iconTintRole(name: string): IconTintRole | null {
179
+ return ICON_TINTS[name] ?? null;
180
+ }
181
+
182
+ /** The generated hue for an imported icon name. */
183
+ export function iconHue(name: string): number {
184
+ return ICON_HUES[name] ?? DEFAULT_ICON_HUE;
185
+ }
186
+
187
+ /** The wheel the hashes land on: 36 hues, 10° apart. */
188
+ export const HUE_STEPS = 36;
189
+
190
+ /**
191
+ * The hue of anything that is not in the generated table — a plugin's mark.
192
+ *
193
+ * Plugin names arrive at RUNTIME, so they cannot be baked into a table: the
194
+ * manifest is read from disk and a marketplace install adds rows no build could
195
+ * have seen. The hue is therefore computed here, with the SAME function that
196
+ * produced every generated row (`scripts/icon-tints.mjs`, asserted equal in
197
+ * `tint.test.ts`), so a plugin's colour sits on the same wheel as the glyphs
198
+ * around it instead of inventing a second palette.
199
+ *
200
+ * FNV-1a, 36 steps of 10°: stable across runs and platforms, which a colour for
201
+ * stored data has to be.
202
+ */
203
+ export function hashHue(name: string): number {
204
+ let hash = 2166136261 >>> 0;
205
+ for (const char of name) {
206
+ hash ^= char.codePointAt(0) ?? 0;
207
+ hash = Math.imul(hash, 16777619) >>> 0;
208
+ }
209
+ return (hash % HUE_STEPS) * (360 / HUE_STEPS);
210
+ }
211
+
212
+ /**
213
+ * One hue per PANEL, with collisions resolved.
214
+ *
215
+ * A rail draws ~14 marks and the wheel has 36 slots, so a plain hash collides
216
+ * about nine times in ten (birthday bound) — measured on the right rail: three
217
+ * of its fourteen icons landed on the same blue, which is the opposite of "each
218
+ * icon has its own colour". Panels are a KNOWN, stable set per rail, so the
219
+ * collision can be resolved deterministically: sort the ids, take each hash, and
220
+ * probe forward 10° at a time until the slot is free. Sorting makes the answer
221
+ * independent of the catalog's order, so reordering a rail never recolours it.
222
+ *
223
+ * A plugin and a built-in compete in the same space on purpose: they sit in one
224
+ * bar, and two neighbours in the same hue is the defect this avoids.
225
+ */
226
+ export function assignPanelHues(ids: readonly string[]): Map<string, number> {
227
+ const hues = new Map<string, number>();
228
+ const taken = new Set<number>();
229
+ for (const id of [...ids].sort()) {
230
+ let hue = hashHue(id);
231
+ for (let step = 0; step < HUE_STEPS && taken.has(hue); step += 1) {
232
+ hue = (hue + 360 / HUE_STEPS) % 360;
233
+ }
234
+ taken.add(hue);
235
+ hues.set(id, hue);
236
+ }
237
+ return hues;
238
+ }
239
+
240
+ /** Signal rows, as `{ className, role }`, for the stylesheet generator. */
241
+ export const ICON_TINT_ROWS: ReadonlyArray<{ className: string; role: IconTintRole }> = Object.entries(
242
+ ICON_TINTS,
243
+ ).map(([name, role]) => ({ className: lucideClassName(name), role }));
244
+
245
+ /** Generated-hue rows, as `{ className, hue }`, for the stylesheet generator. */
246
+ export const ICON_HUE_ROWS: ReadonlyArray<{ className: string; hue: number }> = Object.entries(ICON_HUES).map(
247
+ ([name, hue]) => ({ className: lucideClassName(name), hue }),
248
+ );
@@ -0,0 +1,116 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The brand-colour table's promises: nothing in it is illegible on any palette
8
+ * this build ships, and every row names a glyph that can actually be drawn.
9
+ *
10
+ * Contrast is recomputed from `THEMES`, not from one hardcoded surface — the
11
+ * worst light paper is `tokyonight-light`'s `#dee0ee` and the worst dark one
12
+ * `jetbrains-dark`'s `#2B2D30`, and neither is guessable from the shipped
13
+ * default palette.
14
+ */
15
+
16
+ import { describe, expect, test } from 'bun:test';
17
+ import { BRAND_COLORS, brandColorFor } from '@/shared/lib/models/provider/brand-color';
18
+ import { PROVIDER_GLYPHS } from '@/client/components/common/provider-icon/glyphs';
19
+ import { THEMES } from '@/shared/lib/theme/catalog';
20
+ import {
21
+ BRAND_CONTRAST_FLOOR,
22
+ contrastRatio,
23
+ isNearMonochrome,
24
+ legiblePair,
25
+ worstSurfaceContrast,
26
+ } from '@/shared/lib/theme/legibility';
27
+
28
+ const rows = Object.entries(BRAND_COLORS);
29
+ const HEX = /^#[0-9a-f]{6}$/i;
30
+
31
+ describe('the brand colours', () => {
32
+ test('there are rows to check', () => {
33
+ expect(rows.length).toBeGreaterThan(20);
34
+ });
35
+
36
+ test('every light value clears the floor on EVERY light palette', () => {
37
+ for (const [name, entry] of rows) {
38
+ expect(worstSurfaceContrast(entry.light, 'light'), `${name} light ${entry.light}`).toBeGreaterThanOrEqual(
39
+ BRAND_CONTRAST_FLOOR,
40
+ );
41
+ }
42
+ });
43
+
44
+ test('every dark value clears the floor on EVERY dark palette', () => {
45
+ for (const [name, entry] of rows) {
46
+ if (entry.dark === null) continue;
47
+ expect(worstSurfaceContrast(entry.dark, 'dark'), `${name} dark ${entry.dark}`).toBeGreaterThanOrEqual(
48
+ BRAND_CONTRAST_FLOOR,
49
+ );
50
+ }
51
+ });
52
+
53
+ test('the shipped values are the ones the shared rule derives', () => {
54
+ // One algorithm, not a hand-typed pair: a row that disagreed with
55
+ // `legiblePair` would be a second convention for the same job.
56
+ for (const [name, entry] of rows) {
57
+ expect(entry, name).toEqual({ base: entry.base, ...legiblePair(entry.base) });
58
+ }
59
+ });
60
+
61
+ test('a monochrome brand has no dark value, a chromatic one always does', () => {
62
+ for (const [name, entry] of rows) {
63
+ expect(entry.dark === null, `${name} (${entry.base})`).toBe(isNearMonochrome(entry.base));
64
+ }
65
+ });
66
+
67
+ test('every value is a 6-digit colour', () => {
68
+ for (const [name, entry] of rows) {
69
+ expect(entry.base, name).toMatch(HEX);
70
+ expect(entry.light, name).toMatch(HEX);
71
+ if (entry.dark !== null) expect(entry.dark, name).toMatch(HEX);
72
+ }
73
+ });
74
+
75
+ test('every row names a glyph this build can actually draw', () => {
76
+ for (const name of Object.keys(BRAND_COLORS)) {
77
+ expect(PROVIDER_GLYPHS[name], `${name} has no glyph`).toBeDefined();
78
+ }
79
+ });
80
+
81
+ test('a light value is the brand hex or a darker mix of it, never another hue', () => {
82
+ for (const [name, entry] of rows) {
83
+ if (entry.light === entry.base) continue;
84
+ // Mixed toward black: the light value is never brighter than the base.
85
+ expect(contrastRatio(entry.light, '#ffffff'), name).toBeGreaterThanOrEqual(
86
+ contrastRatio(entry.base, '#ffffff'),
87
+ );
88
+ }
89
+ });
90
+ });
91
+
92
+ describe('brandColorFor', () => {
93
+ test('answers the derived pair for each variant', () => {
94
+ // Pinned: these two numbers are what the shared rule produces for Claude,
95
+ // so a change in the mixer shows up here rather than in a screenshot.
96
+ expect(brandColorFor('claude', 'light')).toBe('#b8654a');
97
+ expect(brandColorFor('claude', 'dark')).toBe('#D97757');
98
+ });
99
+
100
+ test('a monochrome brand answers null on dark, which the caller paints in ink', () => {
101
+ expect(brandColorFor('openai', 'light')).toBeNull();
102
+ expect(brandColorFor('cursor', 'dark')).toBeNull();
103
+ });
104
+
105
+ test('a provider with no row keeps the ink in both modes', () => {
106
+ expect(brandColorFor('my-private-gateway', 'light')).toBeNull();
107
+ expect(brandColorFor(null, 'dark')).toBeNull();
108
+ });
109
+ });
110
+
111
+ describe('the palette the rule measures against', () => {
112
+ test('both variants are represented, so a worst case cannot be vacuous', () => {
113
+ expect(THEMES.some((theme) => theme.variant === 'light')).toBe(true);
114
+ expect(THEMES.some((theme) => theme.variant === 'dark')).toBe(true);
115
+ });
116
+ });
@@ -0,0 +1,103 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The brand colour of every provider mark Kabmo can draw in colour.
8
+ *
9
+ * **The table holds the brand's OWN hex, and nothing else.** The two values that
10
+ * get painted are derived by {@link legiblePair}, against the palettes this
11
+ * build actually ships, so there is no hand-maintained pair to drift from the
12
+ * rule: measured, `claude`'s `#D97757` reads 2.38:1 on `tokyonight-light`'s
13
+ * paper (`#dee0ee`) and 4.42:1 on `jetbrains-dark`'s (`#2B2D30`), so one hex
14
+ * cannot be legible on both halves and a second value has to exist — but it is
15
+ * computed, not typed.
16
+ *
17
+ * **A near-monochrome brand has no dark value** (`dark: null`): `#000000` mixed
18
+ * toward white lands on grey, which is indistinguishable from the ink it was
19
+ * meant to replace while claiming to be a brand colour. Those brands are drawn
20
+ * in the theme's ink instead — the same answer the reference implementation
21
+ * gives with `filter: invert()`.
22
+ *
23
+ * **Sources.** `simple-icons`' hex for the brand that owns the glyph, matched
24
+ * through its alias list because the slug and Kabmo's glyph name differ
25
+ * (`mistralai`/`mistral`, `googlegemini`/`gemini`, `x`/`xai`). A glyph with no
26
+ * row — 38 of the 73 in `provider-icon/glyphs.ts` — publishes no colour, and
27
+ * keeps the palette ink in both modes. That is the honest half of the feature:
28
+ * `color` means "brand colour where one exists", never "every mark is
29
+ * chromatic".
30
+ *
31
+ * These are third-party trademarks, used here to identify the provider each one
32
+ * belongs to. They are not covered by this project's licence.
33
+ */
34
+
35
+ import { legiblePair } from '@/shared/lib/theme/legibility';
36
+
37
+ /** The brand's own hex, per glyph name in `provider-icon/glyphs.ts`. */
38
+ const BRAND_BASES: Readonly<Record<string, string>> = {
39
+ alibaba: '#FF6A00',
40
+ anthropic: '#191919',
41
+ apple: '#000000',
42
+ baidu: '#2932E1',
43
+ claude: '#D97757',
44
+ cline: '#18181B',
45
+ cloudflare: '#F38020',
46
+ cursor: '#000000',
47
+ deepseek: '#5786FE',
48
+ gemini: '#8E75B2',
49
+ geminicli: '#8E75B2',
50
+ githubcopilot: '#000000',
51
+ gitlab: '#FC6D26',
52
+ google: '#4285F4',
53
+ huggingface: '#FFD21E',
54
+ kagi: '#FFB319',
55
+ kimi: '#000000',
56
+ lmstudio: '#000000',
57
+ meta: '#0467DF',
58
+ metaai: '#9844FF',
59
+ minimax: '#E73562',
60
+ mistral: '#FA520F',
61
+ moonshot: '#000000',
62
+ nvidia: '#76B900',
63
+ ollama: '#000000',
64
+ opencode: '#000000',
65
+ openrouter: '#94A3B8',
66
+ perplexity: '#1FB8CD',
67
+ qwen: '#6950EF',
68
+ stencil: '#5530FF',
69
+ vercel: '#000000',
70
+ vertexai: '#4285F4',
71
+ vllm: '#30A2FF',
72
+ xai: '#000000',
73
+ xiaomi: '#FF6900',
74
+ };
75
+
76
+ export interface BrandColor {
77
+ /** The brand's own hex, as published. Provenance and documentation. */
78
+ base: string;
79
+ /** Legible on every light palette; `null` means "use the theme ink". */
80
+ light: string;
81
+ /** Legible on every dark palette; `null` means "use the theme ink". */
82
+ dark: string | null;
83
+ }
84
+
85
+ /** Every row, with its two painted values derived from `base`. */
86
+ export const BRAND_COLORS: Readonly<Record<string, BrandColor>> = Object.fromEntries(
87
+ Object.entries(BRAND_BASES).map(([name, base]) => [name, { base, ...legiblePair(base) }]),
88
+ );
89
+
90
+ /**
91
+ * The colour a mark is painted in for one variant, or `null` when it should
92
+ * keep the surrounding ink.
93
+ *
94
+ * `null` covers both "no brand colour published" and "the brand is black", so a
95
+ * caller never has to distinguish them: the answer to "what paints this mark"
96
+ * is either a hex or the ink.
97
+ */
98
+ export function brandColorFor(name: string | null | undefined, variant: 'light' | 'dark'): string | null {
99
+ if (!name) return null;
100
+ const entry = BRAND_COLORS[name];
101
+ if (!entry) return null;
102
+ return variant === 'dark' ? entry.dark : entry.light;
103
+ }
@@ -240,3 +240,68 @@ describe('RpcFrameDecoder — sequence bookkeeping', () => {
240
240
  expect(decoder.push({ type: 'ready' })).toEqual({ type: 'ready' });
241
241
  });
242
242
  });
243
+
244
+ describe('RpcFrameDecoder — ceilings advertised in ready', () => {
245
+ test('a smaller reassembly ceiling rejects a chunk above it', () => {
246
+ const decoder = new RpcFrameDecoder();
247
+ decoder.setLimits({ maxReassembledFrameBytes: 2 * 1024 * 1024 });
248
+ expect(() =>
249
+ decoder.push(chunk({ byteLength: 3 * 1024 * 1024, data: new Uint8Array(1024).fill(65).toBase64() })),
250
+ ).toThrow('invalid RPC chunk metadata');
251
+ });
252
+
253
+ test('a smaller reassembly ceiling caps how many slices one sequence may claim', () => {
254
+ const decoder = new RpcFrameDecoder();
255
+ decoder.setLimits({ maxReassembledFrameBytes: 2 * 1024 * 1024 });
256
+ // 2 MiB / 256 KiB = 8 slices; a ninth cannot exist under that ceiling.
257
+ expect(() =>
258
+ decoder.push(chunk({ count: 9, byteLength: 2 * 1024 * 1024, data: new Uint8Array(1024).fill(65).toBase64() })),
259
+ ).toThrow('invalid RPC chunk metadata');
260
+ });
261
+
262
+ test('a larger frame ceiling makes a formerly chunk-worthy frame too small to chunk', () => {
263
+ const decoder = new RpcFrameDecoder();
264
+ decoder.setLimits({ maxFrameBytes: 4 * 1024 * 1024 });
265
+ expect(() =>
266
+ decoder.push(chunk({ byteLength: 2 * 1024 * 1024, data: new Uint8Array(1024).fill(65).toBase64() })),
267
+ ).toThrow('invalid RPC chunk metadata');
268
+ });
269
+
270
+ test('a zero, negative, fractional or non-numeric ceiling keeps the previous value', () => {
271
+ const decoder = new RpcFrameDecoder();
272
+ decoder.setLimits({ maxFrameBytes: 0, maxReassembledFrameBytes: -1 });
273
+ decoder.setLimits({ maxFrameBytes: Number.NaN, maxReassembledFrameBytes: '8192' });
274
+ decoder.setLimits({ maxFrameBytes: 1.5, maxReassembledFrameBytes: null });
275
+ // Defaults still in force: below 1 MiB is not chunk-worthy, at 1 MiB is.
276
+ expect(() => decoder.push(chunk({ byteLength: MAX_RPC_FRAME_BYTES - 1 }))).toThrow('invalid RPC chunk metadata');
277
+ expect(decoder.push(chunk({ data: new Uint8Array(1024).fill(65).toBase64() }))).toBeUndefined();
278
+ });
279
+ });
280
+
281
+ describe('RpcFrameDecoder — resync after a damaged sequence', () => {
282
+ test('swallows the damaged tail and resumes at the next ordinary frame', () => {
283
+ const decoder = new RpcFrameDecoder();
284
+ expect(decoder.push(chunk({ count: 3, data: new Uint8Array(1024).fill(65).toBase64() }))).toBeUndefined();
285
+ // What `process.ts` does when `push` throws: abandon the sequence, keep the session.
286
+ decoder.resync();
287
+ expect(decoder.push(chunk({ count: 3, index: 2, data: new Uint8Array(1024).fill(65).toBase64() }))).toBeUndefined();
288
+ expect(decoder.push({ type: 'ready' })).toEqual({ type: 'ready' });
289
+ });
290
+
291
+ test('resumes at a new sequence that starts over at index 0', () => {
292
+ const decoder = new RpcFrameDecoder();
293
+ decoder.resync();
294
+ const frame = frameOfBytes(MAX_RPC_FRAME_BYTES + 5_000);
295
+ const records = chunkSequence(frame, 'after-resync');
296
+ for (const record of records.slice(0, -1)) expect(decoder.push(record)).toBeUndefined();
297
+ expect(decoder.push(records.at(-1))).toEqual(frame);
298
+ });
299
+
300
+ test('a malformed frame that is not a chunk still throws', () => {
301
+ // Recovery is scoped to a damaged CHUNK sequence; a line that is not an
302
+ // object at all remains a protocol fault the caller must see.
303
+ const decoder = new RpcFrameDecoder();
304
+ expect(() => decoder.push(42)).toThrow('RPC frame must be an object');
305
+ expect(() => decoder.push({ noType: 1 })).toThrow('RPC frame must be an object');
306
+ });
307
+ });
@@ -84,22 +84,77 @@ function concatChunks(chunks: Uint8Array[], byteLength: number): Uint8Array {
84
84
  return merged;
85
85
  }
86
86
 
87
+ export interface RpcTransportLimits {
88
+ /** Largest physical stdout line, newline included. */
89
+ maxFrameBytes: number;
90
+ /** Largest logical frame the server will reassemble from chunks. */
91
+ maxReassembledBytes: number;
92
+ }
93
+
94
+ /** The documented defaults, used until a `ready` frame says otherwise. */
95
+ const DEFAULT_LIMITS: RpcTransportLimits = {
96
+ maxFrameBytes: MAX_RPC_FRAME_BYTES,
97
+ maxReassembledBytes: MAX_RPC_REASSEMBLED_BYTES,
98
+ };
99
+
87
100
  /** Decodes complete logical frames from parsed JSONL records. */
88
101
  export class RpcFrameDecoder {
89
102
  private pending: PendingChunks | undefined;
103
+ /** Set by `resync()`: swallow chunk records until a sequence starts over. */
104
+ private discarding = false;
105
+ private limits: RpcTransportLimits = { ...DEFAULT_LIMITS };
106
+
107
+ /**
108
+ * Adopt the ceilings the server advertised in `ready`.
109
+ *
110
+ * They are the server's own transport contract and may change without a
111
+ * protocol bump, so the decoder validates chunks against the advertised
112
+ * values rather than against the constants this module was compiled with.
113
+ */
114
+ setLimits(advertised: { maxFrameBytes?: unknown; maxReassembledFrameBytes?: unknown }): void {
115
+ const frameBytes = advertised.maxFrameBytes;
116
+ const reassembledBytes = advertised.maxReassembledFrameBytes;
117
+ this.limits = {
118
+ maxFrameBytes: isSafeInteger(frameBytes) && frameBytes > 0 ? frameBytes : this.limits.maxFrameBytes,
119
+ maxReassembledBytes:
120
+ isSafeInteger(reassembledBytes) && reassembledBytes > 0 ? reassembledBytes : this.limits.maxReassembledBytes,
121
+ };
122
+ }
123
+
124
+ /**
125
+ * Drop a damaged chunk sequence and keep reading.
126
+ *
127
+ * Chunk sequences are written without interruption, so the next ordinary
128
+ * frame — or the next sequence's `index: 0` — marks the end of the damage.
129
+ * The logical frame that was in flight is LOST: the caller reports that to
130
+ * the operator instead of killing the child, because a whole session (its
131
+ * LSP children, its prewarm slot) is not a fair price for one event.
132
+ */
133
+ resync(): void {
134
+ this.pending = undefined;
135
+ this.discarding = true;
136
+ }
90
137
 
91
138
  push(value: unknown): RpcFrameRecord | undefined {
92
139
  if (!isRecord(value) || value.type !== 'rpc_chunk') {
93
- if (this.pending) throw new Error('RPC chunk sequence interrupted');
140
+ if (this.pending && !this.discarding) throw new Error('RPC chunk sequence interrupted');
141
+ this.pending = undefined;
142
+ this.discarding = false;
94
143
  if (!isRecord(value) || typeof value.type !== 'string') throw new Error('RPC frame must be an object');
95
144
  return value as RpcFrameRecord;
96
145
  }
146
+ // Mid-resync: ignore the tail of the damaged sequence. `index: 0` proves a
147
+ // new sequence started, so normal handling resumes with it.
148
+ if (this.discarding && value.index !== 0) return undefined;
149
+ this.discarding = false;
150
+
97
151
  const { chunkId, index, count, byteLength } = value;
152
+ const { maxFrameBytes, maxReassembledBytes } = this.limits;
98
153
  if (
99
154
  typeof chunkId !== 'string' || chunkId.length === 0 || chunkId.length > 128 ||
100
155
  !isSafeInteger(index) || !isSafeInteger(count) || !isSafeInteger(byteLength) ||
101
- index < 0 || count < 2 || count > Math.ceil(MAX_RPC_REASSEMBLED_BYTES / RPC_CHUNK_PAYLOAD_BYTES) ||
102
- index >= count || byteLength < MAX_RPC_FRAME_BYTES || byteLength > MAX_RPC_REASSEMBLED_BYTES
156
+ index < 0 || count < 2 || count > Math.ceil(maxReassembledBytes / RPC_CHUNK_PAYLOAD_BYTES) ||
157
+ index >= count || byteLength < maxFrameBytes || byteLength > maxReassembledBytes
103
158
  ) throw new Error('invalid RPC chunk metadata');
104
159
 
105
160
  const bytes = decodeBase64(value.data);