@kabmo-labs/kabmo 0.18.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (191) hide show
  1. package/README.md +10 -7
  2. package/dist/client/index.html +1 -1
  3. package/dist/client/index.js +475 -474
  4. package/dist/client/static/js/{index-tc09dtca.js → index-fcee4c13.js} +766 -765
  5. package/dist/client/static/js/index-sxdw908m.css +1 -0
  6. package/marketplace/plugins/command-runner/package.json +3 -2
  7. package/marketplace/plugins/git-forge/package.json +3 -2
  8. package/marketplace/plugins/session-info/package.json +3 -2
  9. package/marketplace/plugins/stats/package.json +3 -2
  10. package/package.json +3 -1
  11. package/src/client/components/auth/login-screen/index.tsx +2 -1
  12. package/src/client/components/common/ComposerPicker.tsx +1 -1
  13. package/src/client/components/common/FolderPicker.tsx +2 -2
  14. package/src/client/components/common/Modal.tsx +2 -2
  15. package/src/client/components/common/PWAInstallButton.tsx +2 -2
  16. package/src/client/components/common/ViewportSelector.tsx +1 -1
  17. package/src/client/components/common/anchored-menu/index.tsx +5 -1
  18. package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
  19. package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
  20. package/src/client/components/common/brand-wordmark/index.tsx +13 -2
  21. package/src/client/components/common/checkbox/style.test.ts +139 -0
  22. package/src/client/components/common/checkbox/style.ts +51 -0
  23. package/src/client/components/common/context-usage-button/index.tsx +2 -2
  24. package/src/client/components/common/file-icon/index.tsx +23 -9
  25. package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
  26. package/src/client/components/common/markdown-review/ReviewPopover.tsx +1 -1
  27. package/src/client/components/common/panel-mark/index.tsx +97 -0
  28. package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
  29. package/src/client/components/common/provider-icon/index.test.ts +14 -0
  30. package/src/client/components/common/provider-icon/index.tsx +4 -0
  31. package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
  32. package/src/client/components/common/provider-icon/resolve.ts +16 -3
  33. package/src/client/components/common/session-actions-menu/index.tsx +1 -1
  34. package/src/client/components/common/toolbar-row/index.tsx +1 -1
  35. package/src/client/components/layout/ActivityBar.tsx +22 -3
  36. package/src/client/components/layout/LeftDock.tsx +9 -2
  37. package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
  38. package/src/client/components/layout/WindowAura.tsx +27 -0
  39. package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
  40. package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
  41. package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
  42. package/src/client/components/layout/desktop-layout/index.tsx +3 -1
  43. package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +3 -3
  44. package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
  45. package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
  46. package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
  47. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -2
  48. package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
  49. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +13 -5
  50. package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
  51. package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
  52. package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
  53. package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
  54. package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
  55. package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
  56. package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
  57. package/src/client/components/mobile/panel-chips.tsx +10 -2
  58. package/src/client/components/settings/Modal.tsx +4 -4
  59. package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
  60. package/src/client/components/settings/apply-side-effects.test.ts +30 -0
  61. package/src/client/components/settings/apply-side-effects.ts +14 -0
  62. package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
  63. package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
  64. package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
  65. package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
  66. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
  67. package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
  68. package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +2 -1
  69. package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +2 -2
  70. package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +1 -1
  71. package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
  72. package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
  73. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +1 -1
  74. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
  75. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
  76. package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
  77. package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
  78. package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
  79. package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
  80. package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
  81. package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
  82. package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
  83. package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
  84. package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +2 -1
  85. package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
  86. package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
  87. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
  88. package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
  89. package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
  90. package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
  91. package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
  92. package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
  93. package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
  94. package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
  95. package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
  96. package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
  97. package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
  98. package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
  99. package/src/client/components/workspace/diff-panel/index.tsx +2 -2
  100. package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
  101. package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
  102. package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
  103. package/src/client/components/workspace/editor/Tabs.tsx +1 -1
  104. package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
  105. package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
  106. package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
  107. package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
  108. package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
  109. package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
  110. package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
  111. package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
  112. package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
  113. package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
  114. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
  115. package/src/client/components/workspace/git-panel/index.tsx +7 -0
  116. package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
  117. package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
  118. package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
  119. package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
  120. package/src/client/components/workspace/search-panel/Body.tsx +1 -1
  121. package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
  122. package/src/client/glass.css +785 -0
  123. package/src/client/glass.test.ts +346 -0
  124. package/src/client/hooks/ui/glass-support.ts +57 -0
  125. package/src/client/hooks/ui/icon-style.ts +59 -0
  126. package/src/client/hooks/ui/stuck-header.test.ts +188 -0
  127. package/src/client/hooks/ui/stuck-header.ts +91 -0
  128. package/src/client/hooks/ui/style-attributes.test.ts +120 -0
  129. package/src/client/hooks/ui/surface-style.ts +56 -0
  130. package/src/client/hooks/workspace/panel-hues.ts +23 -0
  131. package/src/client/main.tsx +10 -0
  132. package/src/client/tailwind.css +264 -11
  133. package/src/server/lib/assets/shell-attributes.server.ts +80 -0
  134. package/src/server/lib/assets/shell-attributes.test.ts +86 -0
  135. package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
  136. package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
  137. package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
  138. package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
  139. package/src/server/lib/omp/rpc/manager.ts +2 -2
  140. package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
  141. package/src/server/lib/omp/rpc/process.test.ts +106 -0
  142. package/src/server/lib/omp/rpc/process.ts +28 -4
  143. package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
  144. package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
  145. package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
  146. package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
  147. package/src/server/lib/omp/rpc/session-commands.ts +11 -0
  148. package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
  149. package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
  150. package/src/server/lib/panels/manifest.test.ts +20 -0
  151. package/src/server/lib/panels/manifest.ts +12 -0
  152. package/src/server/lib/panels/scan.server.ts +4 -0
  153. package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
  154. package/src/server/lib/queue/delivery-harness.ts +8 -4
  155. package/src/server/lib/queue/delivery.server.test.ts +29 -0
  156. package/src/server/lib/queue/delivery.server.ts +39 -0
  157. package/src/server/lib/queue/store.server.test.ts +22 -2
  158. package/src/server/lib/queue/store.server.ts +33 -11
  159. package/src/server/plugins/ssr.ts +22 -5
  160. package/src/shared/lib/icons/file-brand-color.ts +38 -0
  161. package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
  162. package/src/shared/lib/icons/icon-paint-css.ts +284 -0
  163. package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
  164. package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
  165. package/src/shared/lib/icons/tint.test.ts +273 -0
  166. package/src/shared/lib/icons/tint.ts +219 -0
  167. package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
  168. package/src/shared/lib/models/provider/brand-color.ts +103 -0
  169. package/src/shared/lib/omp/rpc/frame.test.ts +65 -0
  170. package/src/shared/lib/omp/rpc/frame.ts +58 -3
  171. package/src/shared/lib/settings/defaults.ts +4 -0
  172. package/src/shared/lib/theme/catalog.test.ts +5 -4
  173. package/src/shared/lib/theme/catalog.ts +18 -3
  174. package/src/shared/lib/theme/glass-support.test.ts +38 -0
  175. package/src/shared/lib/theme/glass-support.ts +73 -0
  176. package/src/shared/lib/theme/icon-style.test.ts +74 -0
  177. package/src/shared/lib/theme/icon-style.ts +90 -0
  178. package/src/shared/lib/theme/legibility.ts +91 -0
  179. package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
  180. package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
  181. package/src/shared/lib/theme/surface-style.test.ts +68 -0
  182. package/src/shared/lib/theme/surface-style.ts +91 -0
  183. package/src/shared/lib/theme/theme.test.ts +11 -7
  184. package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
  185. package/src/shared/lib/workspace/panel-hues.ts +57 -0
  186. package/src/shared/types/panels-registry.ts +6 -0
  187. package/src/shared/types/panels.ts +14 -0
  188. package/src/shared/types/settings/state.ts +26 -0
  189. package/src/test-support/fake-omp-frames.ts +163 -0
  190. package/dist/client/static/js/index-hp75vsv9.css +0 -1
  191. /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Whether a `position: sticky` element is currently PINNED.
8
+ *
9
+ * A sticky header needs a surface only while it is overlapping content — that is
10
+ * the moment its text sits on top of a row and needs a field of its own. When it
11
+ * is at rest it is just the first line of the list, and painting it there is what
12
+ * draws a band across a surface that is otherwise uniform.
13
+ *
14
+ * The test is geometric and needs no sentinel: a stuck element's own top edge is
15
+ * at (or above) its scroll container's content top, because that is what sticky
16
+ * positioning does. A sentinel would have to be a second element in the DOM, and
17
+ * every caller would have to place it in the same flow — one more thing that can
18
+ * be forgotten.
19
+ *
20
+ * `root: null`-style viewport maths is deliberately NOT used: the sidebar is an
21
+ * inner scroll container, so the comparison has to be against THAT box.
22
+ */
23
+
24
+ import { useEffect, useState } from 'preact/hooks';
25
+ import type { RefObject } from 'preact';
26
+
27
+ /** The nearest ancestor that actually scrolls, or null for the document. */
28
+ function scrollParent(element: HTMLElement): HTMLElement | null {
29
+ let node = element.parentElement;
30
+ while (node) {
31
+ const style = getComputedStyle(node);
32
+ if (/(auto|scroll|overlay)/.test(style.overflowY) && node.scrollHeight > node.clientHeight) return node;
33
+ node = node.parentElement;
34
+ }
35
+ return null;
36
+ }
37
+
38
+ /**
39
+ * True while `ref`'s element is pinned against the top of its scroll container.
40
+ *
41
+ * Re-measured on the container's `scroll`, on resize, and once after mount
42
+ * (layout settles a frame later). A rAF coalesces the scroll events, so a fast
43
+ * scroll costs one measurement per frame rather than one per event.
44
+ */
45
+ export function useStuckHeader(ref: RefObject<HTMLElement | null>): boolean {
46
+ const [stuck, setStuck] = useState(false);
47
+
48
+ useEffect(() => {
49
+ const element = ref.current;
50
+ if (!element) return;
51
+ const container = scrollParent(element);
52
+ // A boolean rather than the frame handle: the handle is assigned AFTER the
53
+ // callback runs, so a synchronous `requestAnimationFrame` (a test seam, a
54
+ // polyfill) would leave it set and block every later measurement.
55
+ let pending = false;
56
+
57
+ const measure = () => {
58
+ pending = false;
59
+ const box = container ? container.getBoundingClientRect() : { top: 0 };
60
+ // The scroll offset is part of the test, not a detail: an element that
61
+ // starts at the container's top edge satisfies the geometric comparison at
62
+ // `scrollTop: 0` too, so without this the header would paint its stuck
63
+ // surface BEFORE anything scrolled under it — the band, restored by the
64
+ // very fix meant to remove it. "Stuck" means overlapping, and nothing is
65
+ // overlapping at offset zero.
66
+ const scrolled = container ? container.scrollTop > 0 : window.scrollY > 0;
67
+ // 0.5px of slack: sub-pixel scroll offsets otherwise flip the state on
68
+ // every frame while the user scrolls slowly. The lower bound matters too:
69
+ // a header whose section has scrolled past sits entirely above the
70
+ // container, and painting it would be work nobody can see.
71
+ const rect = element.getBoundingClientRect();
72
+ setStuck(scrolled && rect.top <= box.top + 0.5 && rect.bottom > box.top);
73
+ };
74
+ const schedule = () => {
75
+ if (pending) return;
76
+ pending = true;
77
+ requestAnimationFrame(measure);
78
+ };
79
+
80
+ measure();
81
+ (container ?? window).addEventListener('scroll', schedule, { passive: true });
82
+ window.addEventListener('resize', schedule);
83
+ return () => {
84
+ pending = false;
85
+ (container ?? window).removeEventListener('scroll', schedule);
86
+ window.removeEventListener('resize', schedule);
87
+ };
88
+ }, [ref]);
89
+
90
+ return stuck;
91
+ }
@@ -0,0 +1,120 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The two style attributes on `<html>`.
8
+ *
9
+ * Both writers exist because the value reaches CSS through the document, not a
10
+ * prop — so the facts worth pinning are the ones a wrong implementation breaks
11
+ * silently: the default must CLEAR the attribute (a document carrying it and a
12
+ * document not carrying it have to be the same state), an unknown stored value
13
+ * must not produce an attribute no rule matches, and the boot path must read
14
+ * the primed settings snapshot rather than hardcode the default.
15
+ *
16
+ * The settings client keeps a module-level snapshot, so each case primes it
17
+ * explicitly instead of relying on file order.
18
+ */
19
+
20
+ import { afterAll, beforeEach, describe, expect, test } from 'bun:test';
21
+ import { Window } from 'happy-dom';
22
+ import { applyIconStyle, initIconStyle } from '@/client/hooks/ui/icon-style';
23
+ import { applySurfaceStyle, initSurfaceStyle } from '@/client/hooks/ui/surface-style';
24
+ import { primeKabmoSettings } from '@/shared/lib/settings/client';
25
+ import { DEFAULT_SETTINGS } from '@/shared/lib/settings/defaults';
26
+ import { SURFACE_STYLE_SETTING_KEY } from '@/shared/lib/theme/surface-style';
27
+ import { ICON_STYLE_SETTING_KEY } from '@/shared/lib/theme/icon-style';
28
+
29
+ const DOM_GLOBALS = ['window', 'document'] as const;
30
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
31
+
32
+ beforeEach(() => {
33
+ const win = new Window({ url: 'http://localhost' });
34
+ const target = globalThis as unknown as Record<string, unknown>;
35
+ for (const key of DOM_GLOBALS) {
36
+ if (!(key in nativeGlobals)) nativeGlobals[key] = win[key as keyof Window];
37
+ target[key] = win[key as keyof Window];
38
+ }
39
+ document.documentElement.removeAttribute('data-surface');
40
+ document.documentElement.removeAttribute('data-icon-style');
41
+ });
42
+
43
+ afterAll(() => {
44
+ const target = globalThis as unknown as Record<string, unknown>;
45
+ for (const key of DOM_GLOBALS) {
46
+ if (key in nativeGlobals) target[key] = nativeGlobals[key];
47
+ else delete target[key];
48
+ }
49
+ });
50
+
51
+ describe('the stored keys', () => {
52
+ // The setting key and the `SettingsState` field must be the same string for a
53
+ // write to survive a reload: a mismatch saves under one name and reads the
54
+ // other. `defaults.ts` proves the FIELDS exist; this proves the KEYS name them.
55
+ test('each key names a real settings field', () => {
56
+ expect(Object.keys(DEFAULT_SETTINGS)).toContain(SURFACE_STYLE_SETTING_KEY);
57
+ expect(Object.keys(DEFAULT_SETTINGS)).toContain(ICON_STYLE_SETTING_KEY);
58
+ });
59
+ });
60
+
61
+ describe('applySurfaceStyle', () => {
62
+ test('writes the non-default style as the attribute CSS keys on', () => {
63
+ applySurfaceStyle('glass');
64
+
65
+ expect(document.documentElement.getAttribute('data-surface')).toBe('glass');
66
+ });
67
+
68
+ test('the default CLEARS the attribute instead of writing it', () => {
69
+ applySurfaceStyle('glass');
70
+ applySurfaceStyle('classic');
71
+
72
+ expect(document.documentElement.hasAttribute('data-surface')).toBe(false);
73
+ });
74
+
75
+ test('an unknown value resolves to the default rather than an unmatched rule', () => {
76
+ applySurfaceStyle('liquid');
77
+
78
+ expect(document.documentElement.hasAttribute('data-surface')).toBe(false);
79
+ });
80
+ });
81
+
82
+ describe('applyIconStyle', () => {
83
+ test('writes colour mode', () => {
84
+ applyIconStyle('color');
85
+
86
+ expect(document.documentElement.getAttribute('data-icon-style')).toBe('color');
87
+ });
88
+
89
+ test('monochrome is the absence of the attribute', () => {
90
+ applyIconStyle('color');
91
+ applyIconStyle('monochrome');
92
+
93
+ expect(document.documentElement.hasAttribute('data-icon-style')).toBe(false);
94
+ });
95
+ });
96
+
97
+ describe('the boot path', () => {
98
+ test('a stored glass style is applied from the primed snapshot', () => {
99
+ primeKabmoSettings({ kabmo_settings: { surfaceStyle: 'glass' } });
100
+ initSurfaceStyle();
101
+
102
+ expect(document.documentElement.getAttribute('data-surface')).toBe('glass');
103
+ });
104
+
105
+ test('a stored colour style is applied from the primed snapshot', () => {
106
+ primeKabmoSettings({ kabmo_settings: { iconStyle: 'color' } });
107
+ initIconStyle();
108
+
109
+ expect(document.documentElement.getAttribute('data-icon-style')).toBe('color');
110
+ });
111
+
112
+ test('an install with no stored preference boots opaque and monochrome', () => {
113
+ primeKabmoSettings({});
114
+ initSurfaceStyle();
115
+ initIconStyle();
116
+
117
+ expect(document.documentElement.hasAttribute('data-surface')).toBe(false);
118
+ expect(document.documentElement.hasAttribute('data-icon-style')).toBe(false);
119
+ });
120
+ });
@@ -0,0 +1,56 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The single writer for the app's surface style.
8
+ *
9
+ * The style is an ATTRIBUTE on `<html>`, and CSS is its only consumer: the
10
+ * frosted plane, the translucent panel tints and the rim/shadow tokens all live
11
+ * in `src/client/tailwind.css`, keyed by `[data-surface]`. That is why this
12
+ * module exports no hook — nothing in the shell reads the value in JavaScript,
13
+ * and a hook would exist only to re-render subtrees CSS already repaints.
14
+ *
15
+ * The attribute is written at boot (`initSurfaceStyle`, before the first
16
+ * render) so a glass document never paints one opaque frame first, and on every
17
+ * change from the settings modal (`applySurfaceStyle`).
18
+ *
19
+ * There is deliberately no document observer, unlike `theme.ts`: the theme has
20
+ * runtime consumers that cannot read CSS (the mermaid hydrator repaints
21
+ * diagrams per palette), so it needs an event. A surface material has none.
22
+ */
23
+
24
+ import { readKabmoSetting } from '@/shared/lib/settings/client';
25
+ import {
26
+ DEFAULT_SURFACE_STYLE,
27
+ SURFACE_ATTRIBUTE,
28
+ SURFACE_STYLE_SETTING_KEY,
29
+ resolveSurfaceStyle,
30
+ } from '@/shared/lib/theme/surface-style';
31
+
32
+ /**
33
+ * Point the document at `style`.
34
+ *
35
+ * The default is REMOVED rather than written, so a document carrying `classic`
36
+ * and a document carrying nothing are the same state — which is what makes the
37
+ * `:root` fallback in CSS the single statement of the opaque default.
38
+ */
39
+ export function applySurfaceStyle(style: unknown): void {
40
+ if (typeof document === 'undefined') return;
41
+ const root = document.documentElement;
42
+ const resolved = resolveSurfaceStyle(style);
43
+ if (resolved === DEFAULT_SURFACE_STYLE) root.removeAttribute(SURFACE_ATTRIBUTE);
44
+ else root.setAttribute(SURFACE_ATTRIBUTE, resolved);
45
+ }
46
+
47
+ /**
48
+ * Apply the stored style before the first render.
49
+ *
50
+ * Called from `main.tsx` right after `primeKabmoSettings`, because the boot
51
+ * payload is what `readKabmoSetting` answers from. Without it a glass install
52
+ * would paint the opaque shell for one frame and then swap it.
53
+ */
54
+ export function initSurfaceStyle(): void {
55
+ applySurfaceStyle(readKabmoSetting<unknown>(SURFACE_STYLE_SETTING_KEY));
56
+ }
@@ -0,0 +1,23 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The panel hue map, as a hook, so every surface reads the same one.
8
+ *
9
+ * The map covers the BUILT-IN views only, and it is computed over all of them
10
+ * rather than over the ones a surface is drawing (`shared/lib/workspace/panel-hues.ts`
11
+ * explains why). A plugin panel keeps its own mark colour instead — the brand
12
+ * hex from its manifest, else the hue of its name — so it looks the same here as
13
+ * on its marketplace card.
14
+ */
15
+
16
+ import { useMemo } from 'preact/hooks';
17
+ import { resolvePanelHues } from '@/shared/lib/workspace/panel-hues';
18
+
19
+ /** The hue map, keyed by built-in panel id. */
20
+ export function usePanelHues(): ReadonlyMap<string, number> {
21
+ // The universe is static, so this resolves once for the life of the page.
22
+ return useMemo(resolvePanelHues, []);
23
+ }
@@ -5,6 +5,8 @@ import { warmSyntaxTokenizers } from '@/shared/lib/code/highlighter-warmup';
5
5
  import { primeKabmoSettings } from '@/shared/lib/settings/client';
6
6
  import { initDocumentTheme } from '@/client/hooks/ui/theme';
7
7
  import { initChatWidthMode } from '@/client/hooks/chat/timeline/width-mode';
8
+ import { initSurfaceStyle } from '@/client/hooks/ui/surface-style';
9
+ import { initIconStyle } from '@/client/hooks/ui/icon-style';
8
10
  import { primeWindowChrome } from '@/client/hooks/ui/window-chrome';
9
11
  import { installAuthFetchBridge, primeAuthState } from '@/client/hooks/ui/auth';
10
12
  import { installPluginRuntime } from '@/client/lib/plugins/runtime';
@@ -19,6 +21,7 @@ import { installOpenPaths } from '@/client/lib/native/open-paths';
19
21
  import { installDeviceFiles } from '@/client/lib/launch/device-files';
20
22
 
21
23
  import '@/client/tailwind.css';
24
+ import '@/client/glass.css';
22
25
  import '@/shared/lib/markdown/katex-fonts.css';
23
26
  import '@/shared/lib/markdown/fira-code-fonts.css';
24
27
  import '@/shared/lib/fonts/nerd-symbols.css';
@@ -41,6 +44,13 @@ primeKabmoSettings(bootstrap?.appSettings);
41
44
  // lazily mounted subtree, and a hook would not run until it mounted.
42
45
  initChatWidthMode();
43
46
 
47
+ // The surface material and the brand-mark paint, also before the first render:
48
+ // a glass install that painted the opaque shell first would swap every panel
49
+ // one frame later, and a colour install would draw ink marks and then repaint
50
+ // them. Both write an attribute CSS reads — no event, no re-render.
51
+ initSurfaceStyle();
52
+ initIconStyle();
53
+
44
54
  // BEFORE the theme init, which writes the chrome meta: a phone that repainted
45
55
  // it from the module default would flash the desktop's color for a frame. The
46
56
  // server's two facts (user agent, authentication) are baked into the document,
@@ -92,6 +92,209 @@
92
92
  }
93
93
  }
94
94
 
95
+ /* The veil behind a dialog.
96
+ *
97
+ * It must DARKEN the app in both variants, and `bg-ink/40` cannot: `ink` is the
98
+ * foreground, so it is dark on a light theme and LIGHT on a dark one — measured
99
+ * on `one-dark-pro-soft`, every dialog sat in a `rgb(127,136,149)` field, i.e.
100
+ * lit from behind, and a dialog then read as a dark hole. One class, one fact:
101
+ * the ink on light, black on dark. */
102
+ .modal-scrim {
103
+ background-color: color-mix(in srgb, var(--theme-ink) 40%, transparent);
104
+ }
105
+
106
+ [data-theme-variant='dark'] .modal-scrim {
107
+ /* 58% black put the dialog at 1.01:1 against its own scrim — measured, the
108
+ * panel disappeared into the veil. The veil's job is to recede, not to match:
109
+ * 42% leaves the paper visibly above it while still dimming the app. */
110
+ background-color: color-mix(in srgb, #000 42%, transparent);
111
+ }
112
+
113
+ /* Under the glass surface the veil is FROSTED, not just dimmed.
114
+ *
115
+ * A dialog's own 96% tint contributes almost nothing of what is behind it, so
116
+ * the material has to be legible in the margin AROUND the panel — and there a
117
+ * flat wash reads as "the app is off", not as glass. Blurring the veil is what
118
+ * turns that margin into a pane: the app stays in place, its detail goes soft,
119
+ * and the panel's edge sits on a field that is visibly blurred rather than
120
+ * merely dark. The tint is NOT touched, so the panel's own luminance and every
121
+ * text contrast on it are exactly what they were measured at.
122
+ *
123
+ * One blur pass, only while a modal is open — a modal is exclusive, so this
124
+ * never stacks with a streaming transcript. */
125
+ [data-surface='glass'] .modal-scrim {
126
+ backdrop-filter: blur(20px) saturate(120%);
127
+ -webkit-backdrop-filter: blur(20px) saturate(120%);
128
+ }
129
+
130
+ /* The checkbox, drawn here rather than by the engine.
131
+ *
132
+ * A native `<input type="checkbox">` is the right CONTROL and the wrong
133
+ * RENDERING. The engine paints an unchecked box that is barely there and a
134
+ * checked one in its own accent; measured in the session sidebar, the unchecked
135
+ * box composited to `(236,238,235)` on a `(250,248,242)` row — **1.10:1** —
136
+ * against 10.84:1 for the checked one, which is "checkbox gk kelihatan on off
137
+ * nya". The input stays (semantics, keyboard, `indeterminate`); its box is
138
+ * replaced.
139
+ *
140
+ * Three numbers here, each a budget:
141
+ *
142
+ * - **The ring is `ink 75%`.** WCAG's non-text floor is 3:1, and across all 43
143
+ * palettes `ink 75%` is the first alpha whose worst case clears it (3.02:1 on
144
+ * `solarized-light`). 60% is 2.34:1; the `border-ink/30` these shipped with is
145
+ * 1.71:1 — the bug.
146
+ * - **The checked fill is the full ink**, so the tick is `paper` and the pair is
147
+ * the palette's own ink/paper contrast: 17.5:1 on `paper`, 4.85:1 worst case.
148
+ * - **The dash uses the same ink**, because indeterminate is a THIRD state and
149
+ * has to read as "on, partly" rather than as "off with a line in it".
150
+ *
151
+ * `accent-color` stays set at the call sites: an engine that cannot draw the
152
+ * pseudo-element falls back to the platform control instead of a blank square.
153
+ *
154
+ * The pseudo-elements only carry `content`, so the shared `box-sizing` and the
155
+ * palette tokens do the rest; `:disabled` dims instead of changing colour, so a
156
+ * disabled checked box still reads as checked.
157
+ */
158
+ @layer components {
159
+ .kabmo-checkbox {
160
+ appearance: none;
161
+ -webkit-appearance: none;
162
+ position: relative;
163
+ display: inline-block;
164
+ flex-shrink: 0;
165
+ /* A DEFAULT size, because `appearance: none` removes the intrinsic one: a
166
+ * call site that never passed `w-3.5` (the settings rows relied on the
167
+ * engine's 13px box) measured **4x4px** — the border box with nothing
168
+ * inside. This sits in `@layer components`, so a call site's `w-4`/`size-3.5`
169
+ * utility still wins. */
170
+ width: 0.875rem;
171
+ height: 0.875rem;
172
+ box-sizing: border-box;
173
+ /* 2px, not 1.5px: at a device pixel ratio of 1 a 1.5px border lands on a
174
+ * half pixel and antialiases into a ~50% blend, so the intended
175
+ * `ink 75%` ring rendered as `(166,169,166)` on a `(223,229,220)` row — 1.85:1,
176
+ * below the floor the alpha was chosen for. 2px gives two full device pixels
177
+ * with no partial coverage in the middle. */
178
+ border: 2px solid color-mix(in srgb, var(--theme-ink) 75%, transparent);
179
+ border-radius: 3px;
180
+ background-color: transparent;
181
+ transition: background-color 120ms ease, border-color 120ms ease;
182
+ }
183
+
184
+ .kabmo-checkbox:hover:not(:disabled) {
185
+ border-color: var(--theme-ink);
186
+ }
187
+
188
+ .kabmo-checkbox::after {
189
+ content: '';
190
+ position: absolute;
191
+ /* 1px, not 3px: `inset` is measured from the PADDING box, so on a 14px
192
+ * control with a 2px ring the interior is 10px — a 3px inset left a 4px
193
+ * mark, which renders as a blob rather than a tick. 1px leaves 8px, the
194
+ * size a checkmark needs at this scale. */
195
+ inset: 1px;
196
+ transform: scale(0);
197
+ transition: transform 100ms ease;
198
+ /* The tick is a mask, not a glyph: an SVG path in `currentColor` would inherit
199
+ * whatever the caller's text colour is, and these controls sit in rows that
200
+ * set `text-ink/NN` for their own reasons. A masked box paints `paper`, which
201
+ * is the pair the fill guarantees. */
202
+ background-color: var(--theme-paper);
203
+ mask: center / contain no-repeat
204
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5 9.5 18 20 6.5'/%3E%3C/svg%3E");
205
+ -webkit-mask: center / contain no-repeat
206
+ url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 12.5 9.5 18 20 6.5'/%3E%3C/svg%3E");
207
+ }
208
+
209
+ .kabmo-checkbox:checked,
210
+ .kabmo-checkbox:indeterminate {
211
+ background-color: var(--theme-ink);
212
+ border-color: var(--theme-ink);
213
+ }
214
+
215
+ .kabmo-checkbox:checked::after {
216
+ transform: scale(1);
217
+ }
218
+
219
+ /* Indeterminate is a DASH: the tick is replaced, not overlaid, so the two states
220
+ * cannot be confused at 14px. */
221
+ .kabmo-checkbox:indeterminate::after {
222
+ inset: auto 2px;
223
+ top: calc(50% - 1px);
224
+ height: 2px;
225
+ border-radius: 1px;
226
+ transform: scale(1);
227
+ mask: none;
228
+ -webkit-mask: none;
229
+ }
230
+
231
+ /* No `opacity` here: the call sites already say `disabled:opacity-60` /
232
+ * `disabled:opacity-50`, and an unlayered declaration would beat every one of
233
+ * them — a control that dims to 0.45 no matter what its owner asked for. */
234
+ .kabmo-checkbox:disabled {
235
+ cursor: not-allowed;
236
+ }
237
+ }
238
+
239
+ /* FULL COLOUR MODE: on is GREEN, off is RED.
240
+ *
241
+ * The colour mode is the one place a user asks for chroma, so the checkbox
242
+ * answers it: a checked box fills with the palette's success colour and an
243
+ * unchecked one shows the error colour in its ring. Monochrome — the absence of
244
+ * the attribute — keeps the ink-based pair, because that mode has no colour to
245
+ * state a state with.
246
+ *
247
+ * Both are MIXED TOWARD THE INK, and that is a contrast budget, not taste. At
248
+ * full strength the ring measures 2.73:1 worst case (`mono-light`) and the fill
249
+ * 1.75:1 (`nord-light`) against the surface they sit on — both below the 3:1
250
+ * non-text floor. Mixing toward the ink moves them along the one axis the
251
+ * palette already guarantees: `error 75%` clears 3.56:1 and `success 55%`
252
+ * 3.63:1 across all 63 palettes, measured on the REAL chrome composite (paper
253
+ * over plane over canvas), not on bare paper.
254
+ *
255
+ * The tick stays `--theme-paper`: on the green fill that is the palette's own
256
+ * paper/ink relationship read backwards, 3.60:1 worst case.
257
+ */
258
+ [data-icon-style="color"] .kabmo-checkbox {
259
+ border-color: color-mix(in srgb, var(--theme-error) 75%, var(--theme-ink));
260
+ }
261
+
262
+ /* Hover deepens toward the error colour, but stops at 85%: at full strength the
263
+ * ring measures 2.77:1 on `mono-light` — under the floor the resting state was
264
+ * chosen to clear — so the hover would be LESS legible than the idle box it is
265
+ * trying to highlight. 85% reads 3.47:1 and is still visibly warmer. */
266
+ [data-icon-style="color"] .kabmo-checkbox:hover:not(:disabled) {
267
+ border-color: color-mix(in srgb, var(--theme-error) 85%, var(--theme-ink));
268
+ }
269
+
270
+ [data-icon-style="color"] .kabmo-checkbox:checked,
271
+ [data-icon-style="color"] .kabmo-checkbox:indeterminate {
272
+ background-color: color-mix(in srgb, var(--theme-success) 55%, var(--theme-ink));
273
+ border-color: color-mix(in srgb, var(--theme-success) 55%, var(--theme-ink));
274
+ }
275
+
276
+ /* A SWITCH states the same two facts as a checkbox, so it states them in the same
277
+ * two colours — keyed on the ROLE and `aria-checked`, not on a class, because
278
+ * six call sites paint their track with five different utilities (`bg-ink`,
279
+ * `bg-ink/70`, `bg-ink/20`, `bg-ink/15`) and none of them is the thing that
280
+ * means "on".
281
+ *
282
+ * The alphas are the checkbox's, and for the same reason: measured over all 43
283
+ * palettes, `success 55%` clears 3.60:1 and `error 75%` 3.46:1 against the panel
284
+ * a switch sits on, while the canvas knob clears 3.72:1 / 3.87:1 against those
285
+ * tracks. The raw signal colours do not: `success` reaches 1.75:1 worst case.
286
+ *
287
+ * `[aria-checked="false"]` rather than `:not([aria-checked="true"])`: a switch
288
+ * that forgot the attribute is a bug in the control, and painting it red would
289
+ * hide that behind a plausible state. */
290
+ [data-icon-style="color"] [role="switch"][aria-checked="true"] {
291
+ background-color: color-mix(in srgb, var(--theme-success) 55%, var(--theme-ink));
292
+ }
293
+
294
+ [data-icon-style="color"] [role="switch"][aria-checked="false"] {
295
+ background-color: color-mix(in srgb, var(--theme-error) 75%, var(--theme-ink));
296
+ }
297
+
95
298
  /* Dot grain texture for Hero production card */
96
299
  .dot-grain-texture {
97
300
  background-image: radial-gradient(color-mix(in srgb, var(--theme-ink) 6%, transparent) 0.65px, transparent 0.65px);
@@ -380,19 +583,36 @@
380
583
  * paper. It has a real subject when the phone STRETCHES the composer over the
381
584
  * transcript (`fixed inset-0`), which is the state the effect was drawn for.
382
585
  */
586
+ /* The material comes from `glass.css`, NOT from a second recipe here: one
587
+ * `--glass-*` token set states tint, bloom, sheen, shadow and the two blur
588
+ * budgets. The card takes `--glass-card-filter`, not the plane's — a 30px blur
589
+ * behind a card floating over a static transcript is a pass nobody can see.
590
+ * Under the classic look every token resolves to the values this block used to
591
+ * hardcode, so the style is unchanged when the surface is.
592
+ *
593
+ * Four layers, because one tint cannot be a pane of glass: the tint
594
+ * (`--glass-card`), the bloom (`--glass-bloom`, the light that passed through
595
+ * and landed in the corners), the sheen (`--glass-sheen`, the specular
596
+ * reflection on the face) and the rim + shadow (`--glass-edge`,
597
+ * `--glass-shadow`). Measured on the docked card, tint-only read 1.03:1
598
+ * (light) / 1.04:1 (dark) against the surface beside it — a card you could not
599
+ * see. The corner bloom is what makes the frost legible where nothing is
600
+ * behind it to blur. */
383
601
  [data-composer-style="glass"] {
384
602
  border-radius: 1.25rem;
385
- border-color: color-mix(in srgb, var(--theme-ink) 12%, transparent);
386
- background-color: color-mix(in srgb, var(--theme-paper) 58%, transparent);
387
- background-image: linear-gradient(
388
- 180deg,
389
- color-mix(in srgb, var(--theme-ink) 5%, transparent) 0%,
390
- color-mix(in srgb, var(--theme-ink) 1.5%, transparent) 38%,
391
- transparent 100%
392
- );
393
- backdrop-filter: blur(16px) saturate(1.15);
394
- -webkit-backdrop-filter: blur(16px) saturate(1.15);
395
- box-shadow: 0 1px 0 0 color-mix(in srgb, var(--theme-ink) 6%, transparent);
603
+ /* The RIM is what makes the surface legible — the fill cannot, because the
604
+ * plane under a docked composer is within 3 points of paper. It is the CARD's
605
+ * rim (`--glass-card-edge`), not the window's: the window's 1.5px `#fff 95%`
606
+ * line is right for a 1400px frame and reads as glare across 620px. */
607
+ border-color: transparent;
608
+ background-color: var(--glass-card);
609
+ /* NOT the plane's gradient stack (`--glass-glow`): that belongs to the window,
610
+ * and a card that borrowed it would paint a second highlight inside the first.
611
+ * The reflection sits ABOVE the transmitted light, as it does on real glass. */
612
+ background-image: var(--glass-sheen), var(--glass-bloom);
613
+ backdrop-filter: var(--glass-card-filter);
614
+ -webkit-backdrop-filter: var(--glass-card-filter);
615
+ box-shadow: var(--glass-card-edge), var(--glass-shadow);
396
616
  }
397
617
  [data-composer-style="glass"] .composer-attach-row {
398
618
  padding-bottom: 0.25rem;
@@ -757,6 +977,39 @@ html[data-theme-variant="dark"] .shiki span { color: var(--shiki-dark); }
757
977
  will-change: transform;
758
978
  }
759
979
 
980
+ /* The header wordmark's halo (`common/brand-wordmark`, `glow`).
981
+ *
982
+ * Why it exists: the lockup ends in `text-ink` and starts in a warm gradient,
983
+ * and on a dark palette both sit on a near-black bar — the word is legible but
984
+ * flat, which is the state a title should not be in. The halo is what gives it
985
+ * a light source.
986
+ *
987
+ * Two `drop-shadow`s, not `text-shadow`: the first run is an SVG (the K's
988
+ * plate) and the second is gradient-clipped text, so a glyph shadow would paint
989
+ * under neither. `drop-shadow` follows the rendered alpha of all three runs.
990
+ *
991
+ * WHITE at 10%, and that is a decision with a measurement behind it. The halo
992
+ * started as `--color-brand` and was rejected twice — at 40%/22% it was
993
+ * invisible (the ring 1–8px outside the lockup moved +3 in mean red), and at
994
+ * full strength it tinted the whole bar and read as a lamp, not as light (that
995
+ * ring moved +41 in warm bias). The chroma was the problem: the lockup's own
996
+ * ink is near-white, so an orange halo is a second colour fighting the first.
997
+ * White at the same radius is the letters' own light — the warm bias does not
998
+ * move at all (−10.7 against the bare header's −10.8) while luminance rises
999
+ * +3.0 in the 1–8px ring and +0.7 in the 8–22px one, and the profile falls off
1000
+ * over ~25px. Alphas stay at 10% on BOTH layers: raising one is what made the
1001
+ * earlier attempts either invisible or heavy, and the visible edge of a halo is
1002
+ * its radius, not its opacity.
1003
+ *
1004
+ * DARK VARIANTS ONLY: on paper a white glow is a no-op at best, and the light
1005
+ * palettes never had the problem this fixes. Values are in `em` so the halo
1006
+ * scales with the size the caller sets. */
1007
+ html[data-theme-variant='dark'] .brand-wordmark-glow {
1008
+ filter:
1009
+ drop-shadow(0 0 0.35em rgb(255 255 255 / 10%))
1010
+ drop-shadow(0 0 0.9em rgb(255 255 255 / 10%));
1011
+ }
1012
+
760
1013
  /* PWA Window Controls Overlay and Native Titlebar Styling */
761
1014
  .titlebar-drag-region {
762
1015
  -webkit-app-region: drag;