@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,122 @@
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
+ * ## The scrollport is found by `overflow-y`, never by "does it overflow"
24
+ *
25
+ * From a sentinel-free test it is tempting to require `scrollHeight > clientHeight`
26
+ * when picking the container — "the nearest ancestor that actually scrolls".
27
+ * That test reads ZERO for a subtree mounted hidden, and the phone drawer IS
28
+ * mounted hidden: its screen is a sibling carrying `hidden`, so at mount the
29
+ * scroller measures 0/0. The hook then fell through to `window` (`scrollY`),
30
+ * which never moves for an inner scroller — measured on a 412x900 viewport with
31
+ * the drawer open and 420px scrolled, the folder header sat pinned at the
32
+ * container's top edge with **no** `data-stuck`, i.e. an active sticky header
33
+ * with a transparent background, while the desktop column (mounted visible)
34
+ * painted its fill. Per spec a `position: sticky` element is bound to its
35
+ * nearest SCROLL CONTAINER whether or not it overflows at this instant, so the
36
+ * `overflow-y` test alone is the accurate one — and it answers correctly for a
37
+ * hidden subtree, because computed style does not depend on the ancestor's
38
+ * `display`.
39
+ *
40
+ * Showing the drawer then has to re-measure by itself: a hidden subtree resizes
41
+ * from 0x0, so a `ResizeObserver` on the header (and on the container) is the
42
+ * signal that layout became real.
43
+ */
44
+
45
+ import { useEffect, useState } from 'preact/hooks';
46
+ import type { RefObject } from 'preact';
47
+
48
+ /** The nearest ancestor that scrolls (the sticky containing block), or null. */
49
+ function scrollParent(element: HTMLElement): HTMLElement | null {
50
+ let node = element.parentElement;
51
+ while (node) {
52
+ const style = getComputedStyle(node);
53
+ if (/(auto|scroll|overlay)/.test(style.overflowY)) return node;
54
+ node = node.parentElement;
55
+ }
56
+ return null;
57
+ }
58
+
59
+ /**
60
+ * True while `ref`'s element is pinned against the top of its scroll container.
61
+ *
62
+ * Re-measured on the container's `scroll`, on resize, whenever the header or its
63
+ * container changes SIZE, and once after mount (layout settles a frame later). A
64
+ * rAF coalesces the scroll events, so a fast scroll costs one measurement per
65
+ * frame rather than one per event.
66
+ */
67
+ export function useStuckHeader(ref: RefObject<HTMLElement | null>): boolean {
68
+ const [stuck, setStuck] = useState(false);
69
+
70
+ useEffect(() => {
71
+ const element = ref.current;
72
+ if (!element) return;
73
+ const container = scrollParent(element);
74
+ // A boolean rather than the frame handle: the handle is assigned AFTER the
75
+ // callback runs, so a synchronous `requestAnimationFrame` (a test seam, a
76
+ // polyfill) would leave it set and block every later measurement.
77
+ let pending = false;
78
+
79
+ const measure = () => {
80
+ pending = false;
81
+ const box = container ? container.getBoundingClientRect() : { top: 0 };
82
+ // The scroll offset is part of the test, not a detail: an element that
83
+ // starts at the container's top edge satisfies the geometric comparison at
84
+ // `scrollTop: 0` too, so without this the header would paint its stuck
85
+ // surface BEFORE anything scrolled under it — the band, restored by the
86
+ // very fix meant to remove it. "Stuck" means overlapping, and nothing is
87
+ // overlapping at offset zero.
88
+ const scrolled = container ? container.scrollTop > 0 : window.scrollY > 0;
89
+ // 0.5px of slack: sub-pixel scroll offsets otherwise flip the state on
90
+ // every frame while the user scrolls slowly. The lower bound matters too:
91
+ // a header whose section has scrolled past sits entirely above the
92
+ // container, and painting it would be work nobody can see.
93
+ const rect = element.getBoundingClientRect();
94
+ setStuck(scrolled && rect.top <= box.top + 0.5 && rect.bottom > box.top);
95
+ };
96
+ const schedule = () => {
97
+ if (pending) return;
98
+ pending = true;
99
+ requestAnimationFrame(measure);
100
+ };
101
+
102
+ measure();
103
+ // A hidden subtree mounts at 0x0 and its sticky geometry only becomes real
104
+ // when the ancestor stops being `hidden` — which is the phone drawer's whole
105
+ // lifecycle (`SessionSidebar` keeps the list mounted behind a hidden
106
+ // screen). Both boxes are watched: the container for the drawer appearing,
107
+ // the header for a density or label-height change.
108
+ const resize = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(schedule);
109
+ resize?.observe(element);
110
+ if (container) resize?.observe(container);
111
+ (container ?? window).addEventListener('scroll', schedule, { passive: true });
112
+ window.addEventListener('resize', schedule);
113
+ return () => {
114
+ pending = false;
115
+ resize?.disconnect();
116
+ (container ?? window).removeEventListener('scroll', schedule);
117
+ window.removeEventListener('resize', schedule);
118
+ };
119
+ }, [ref]);
120
+
121
+ return stuck;
122
+ }
@@ -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
+ }
@@ -244,8 +244,10 @@ export interface PanelPluginActions {
244
244
  setEnabled: (pluginId: string, enabled: boolean) => Promise<boolean>;
245
245
  /** Probe every git-installed plugin's remote for a newer commit. */
246
246
  checkUpdates: () => Promise<boolean>;
247
- /** Bring one git-installed plugin up to its remote, and rebuild it. */
248
- updateGit: (pluginId: string) => Promise<boolean>;
247
+ /** Bring one installed plugin up to its source — a remote, or the store's copy. */
248
+ update: (pluginId: string) => Promise<boolean>;
249
+ /** Apply every update that is available, in one pass. */
250
+ updateAll: () => Promise<boolean>;
249
251
  /** Turn automatic updating of git-installed plugins on or off. */
250
252
  setAutoUpdate: (enabled: boolean) => Promise<boolean>;
251
253
  /** Replace a blocked bundled plugin's edited files with the store's copy. */
@@ -317,7 +319,8 @@ export function usePanelPluginActions(): PanelPluginActions {
317
319
  [run],
318
320
  );
319
321
  const checkUpdates = useCallback(() => run('check_updates', { type: 'check_updates' }), [run]);
320
- const updateGit = useCallback((pluginId: string) => run(`update_git:${pluginId}`, { type: 'update_git', pluginId }), [run]);
322
+ const update = useCallback((pluginId: string) => run(`update:${pluginId}`, { type: 'update', pluginId }), [run]);
323
+ const updateAll = useCallback(() => run('update_all', { type: 'update_all' }), [run]);
321
324
  const setAutoUpdate = useCallback(
322
325
  (enabled: boolean) => run('set_auto_update', { type: 'set_auto_update', enabled }),
323
326
  [run],
@@ -335,7 +338,8 @@ export function usePanelPluginActions(): PanelPluginActions {
335
338
  build,
336
339
  setEnabled,
337
340
  checkUpdates,
338
- updateGit,
341
+ update,
342
+ updateAll,
339
343
  setAutoUpdate,
340
344
  forceSync,
341
345
  };
@@ -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,