@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,346 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ import { describe, expect, test } from 'bun:test';
7
+ import { THEMES } from '@/shared/lib/theme/catalog';
8
+ import { mixHex } from '@/shared/lib/theme/color';
9
+ import { contrastRatio } from '@/shared/lib/theme/legibility';
10
+
11
+ /**
12
+ * The composer's `glass` style is a STYLE, not a surface style: it is offered in
13
+ * the classic look too, where `[data-surface="glass"]` is not set. A `--glass-*`
14
+ * token that is only declared inside that attribute block therefore does not
15
+ * exist for the composer, and `background-color: var(--glass-card)` silently
16
+ * computes to `rgba(0,0,0,0)` — a card with no fill at all. That is not
17
+ * hypothetical: it shipped for the length of one edit, and the browser reported
18
+ * it as a transparent composer while `getComputedStyle` on the token returned an
19
+ * empty string.
20
+ *
21
+ * This asserts the shape of the contract rather than one value: every material
22
+ * token the composer rule READS has to be declared where the rule can see it,
23
+ * i.e. in `:root` (or a variant block), never only under the surface attribute.
24
+ */
25
+ const read = (file: string): Promise<string> => Bun.file(new URL(file, import.meta.url)).text();
26
+
27
+ /** The body of the first rule whose selector starts a line, e.g. `[x] {`. */
28
+ function ruleBody(css: string, selector: string): string {
29
+ const start = css.search(new RegExp(`^${selector.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')} \\{`, 'm'));
30
+ if (start < 0) throw new Error(`no rule for ${selector}`);
31
+ const open = css.indexOf('{', start);
32
+ const close = css.indexOf('\n}', open);
33
+ if (close < 0) throw new Error(`unterminated rule for ${selector}`);
34
+ return css.slice(open + 1, close);
35
+ }
36
+
37
+ describe('glass composer material', () => {
38
+ test('every --glass token the composer reads is declared in :root', async () => {
39
+ const [glass, tailwind] = await Promise.all([read('./glass.css'), read('./tailwind.css')]);
40
+ const composer = ruleBody(tailwind, '[data-composer-style="glass"]');
41
+ const root = ruleBody(glass, ':root');
42
+
43
+ const readTokens = [...new Set([...composer.matchAll(/var\((--glass-[a-z-]+)\)/g)].map((m) => m[1]))];
44
+ // The rule reads its whole material from tokens; a literal here would mean a
45
+ // second recipe for the same material, which is the defect this file guards.
46
+ expect(readTokens.length).toBeGreaterThanOrEqual(6);
47
+
48
+ for (const token of readTokens) {
49
+ expect({ token, declared: new RegExp(`${token}\\s*:`).test(root) }).toEqual({ token, declared: true });
50
+ }
51
+ });
52
+
53
+ test('the card carries a tint, transmitted light, a reflection and an edge', async () => {
54
+ const [glass, tailwind] = await Promise.all([read('./glass.css'), read('./tailwind.css')]);
55
+ const composer = ruleBody(tailwind, '[data-composer-style="glass"]');
56
+ const root = ruleBody(glass, ':root');
57
+
58
+ // Tint only is what read 1.03:1 against the surface beside it — a card you
59
+ // could not see. The four layers are the material.
60
+ expect(composer).toContain('background-color: var(--glass-card)');
61
+ expect(composer).toContain('background-image: var(--glass-sheen), var(--glass-bloom)');
62
+ expect(composer).toContain('box-shadow: var(--glass-card-edge), var(--glass-shadow)');
63
+ // The CARD's rim, not the window's: the window edge carries `#fff 95%` at
64
+ // 1.5px, which is a hard white line across a 620px card ("silau").
65
+ expect(root).toContain('--glass-card-edge:');
66
+ const cardEdge = root.slice(root.indexOf('--glass-card-edge:'), root.indexOf('--glass-edge:'));
67
+ expect(cardEdge).not.toContain('#fff 95%');
68
+ expect(root).toContain('--glass-bloom:');
69
+ // The bloom is light that came THROUGH the pane: its hue is the palette's,
70
+ // never a hardcoded colour — and it is the DARK variant's, because a palette
71
+ // hue is darker than paper and smudges a light card instead of lighting it.
72
+ const dark = glass.slice(glass.indexOf('[data-theme-variant="dark"]'));
73
+ expect(dark).toContain('--glass-bloom:');
74
+ expect(dark.slice(dark.indexOf('--glass-bloom:'))).toContain('var(--theme-info)');
75
+ expect(root).toContain('--glass-bloom: none;');
76
+ });
77
+
78
+ test('a browser without a blur gets no bloom either', async () => {
79
+ const glass = await read('./glass.css');
80
+ // Two blocks restate the token list because CSS cannot OR a `@supports` with
81
+ // a `@media`; both have to drop the bloom, or the decoration outlives the
82
+ // translucency it exists for.
83
+ const supports = glass.slice(glass.indexOf('@supports not ('), glass.indexOf('@media (prefers-reduced-transparency'));
84
+ const reduced = glass.slice(glass.indexOf('@media (prefers-reduced-transparency'));
85
+ for (const block of [supports, reduced]) {
86
+ for (const token of ['--glass-bloom', '--glass-popover-bloom', '--glass-overlay-filter']) {
87
+ expect({ token, dropped: block.includes(`${token}: none;`) }).toEqual({ token, dropped: true });
88
+ }
89
+ }
90
+ });
91
+ });
92
+
93
+ /**
94
+ * The popover tier is the same argument as the composer's, one size down: a
95
+ * dropdown that carries only a tint reads as a LIFTED BOX, because on a dark
96
+ * palette a translucent paper only ever darkens it. Measured on the
97
+ * session-actions menu before the bloom — corner `(56,61,71)` over a body of
98
+ * `(41,44,52)` on a sidebar of `(51,58,67)`, 1.09:1 against what it covers.
99
+ */
100
+ describe('glass popover material', () => {
101
+ test('the popover adds its own bloom on top of the shared material', async () => {
102
+ const [glass, tailwind] = await Promise.all([read('./glass.css'), read('./tailwind.css')]);
103
+ const root = ruleBody(glass, ':root');
104
+ expect(root).toContain('--glass-popover-bloom:');
105
+
106
+ // The shared block styles BOTH tiers and carries no bloom; the popover's own
107
+ // rule is the one that paints it, and it must name the popover ALONE — a
108
+ // shared rule would put a bloom inside a dialog's paragraph.
109
+ expect(glass).toContain(
110
+ '[data-surface="glass"] .glass-popover {\n background-image: var(--glass-sheen), var(--glass-popover-bloom);',
111
+ );
112
+
113
+ const shared = glass.split('[data-surface="glass"] .glass-overlay,')[1] ?? '';
114
+ const sharedBody = shared.slice(0, shared.indexOf('}'));
115
+ expect(sharedBody).not.toContain('--glass-popover-bloom');
116
+ expect(sharedBody).toContain('background-image: linear-gradient(');
117
+
118
+ // A dialog keeps the sheen and the rim it was measured with: a dialog has
119
+ // prose in the middle, and the bloom's whole point is that it stays in the
120
+ // corners — which a dialog cannot afford to guess at.
121
+ expect(tailwind).toContain('[data-composer-style="glass"]');
122
+ });
123
+
124
+ test('an anchored menu is a popover by construction, not by its caller', async () => {
125
+ const menu = await read('./components/common/anchored-menu/index.tsx');
126
+ const list = await read('./components/common/session-actions-menu/index.tsx');
127
+ // The primitive stamps the tier, so a caller that forgets it is the only way
128
+ // an anchored menu stays opaque under the glass surface.
129
+ expect(menu).toContain('glass-popover fixed');
130
+ expect(list).toContain('glass-popover fixed');
131
+ });
132
+ });
133
+
134
+ /**
135
+ * A workspace column is the same chrome as the sidebar beside it. Every view
136
+ * under it opens with its own `bg-paper` root, which is right in the classic look
137
+ * and wrong under the glass surface — measured, the 293px column composited to
138
+ * the palette's solid paper while the sidebar was the plane's chrome.
139
+ */
140
+ describe('glass column material', () => {
141
+ test('a workspace column is chrome, and its view roots step aside for it', async () => {
142
+ const [glass, panels] = await Promise.all([
143
+ read('./glass.css'),
144
+ read('./components/layout/desktop-layout/WorkspacePanels.tsx'),
145
+ ]);
146
+ // Measured: every right-panel view opens with its own `bg-paper` root, so the
147
+ // 293px column composited to solid paper while the sidebar beside it was the
148
+ // plane's chrome — two materials in one window ("right panel juga belum glass
149
+ // banget"). The marker is on the SLOT (one owner), never on each view.
150
+ expect(panels).toContain('data-panel-chrome=""');
151
+ expect(panels).toContain('glass-chrome w-full h-full');
152
+ expect(glass).toContain('[data-surface="glass"] [data-panel-chrome] > .bg-paper,');
153
+ });
154
+
155
+ test('a PLUGIN panel is reached through its scope span', async () => {
156
+ const [glass, dock] = await Promise.all([
157
+ read('./glass.css'),
158
+ read('./components/layout/LeftDock.tsx'),
159
+ ]);
160
+ // A plugin's component renders inside `<span data-plugin-surface style="display: contents">`
161
+ // — the scope the server wraps its stylesheet in — and that span has a BOX
162
+ // even though it paints none, so the child combinator stops there. Measured
163
+ // on the three bundled marketplace plugins, every one painted
164
+ // `rgb(40,44,52)` over the column before this selector existed.
165
+ expect(glass).toContain('[data-surface="glass"] [data-panel-chrome] > [data-plugin-surface] > .bg-paper {');
166
+ // And the LEFT column carries the same marker: a plugin placed on the left
167
+ // draws its own `bg-paper` root too.
168
+ expect(dock).toContain('data-panel-chrome=""');
169
+ });
170
+ });
171
+
172
+ /**
173
+ * A dialog is the largest surface in the app and the one that showed the least:
174
+ * at 96% tint the veil contributes 4%, so a settings panel measured as a uniform
175
+ * fill with no material at all ("setting modal juga belum glass"). The material
176
+ * is LOCAL light plus a frosted veil, and both have to survive the fallbacks.
177
+ */
178
+ describe('glass dialog material', () => {
179
+ test('the dialog paints its own light, and the popover does not borrow it', async () => {
180
+ const glass = await read('./glass.css');
181
+ expect(ruleBody(glass, ':root')).toContain('--glass-dialog-bloom:');
182
+ expect(glass).toContain('[data-surface="glass"] .glass-overlay {\n background-image: var(--glass-dialog-bloom);');
183
+
184
+ // The peak sits OUTSIDE the frame: on it, the light lands on the settings nav
185
+ // and drags its 12px labels from 3.8:1 to 3.0:1.
186
+ const dialog = glass.slice(glass.indexOf('--glass-dialog-bloom:'));
187
+ const dark = dialog.slice(dialog.indexOf('[data-theme-variant="dark"]'));
188
+ expect(dark.slice(0, dark.indexOf('}'))).toContain('at -4% -8%');
189
+ });
190
+
191
+ test('a dialog chrome strip steps aside, and only the direct child does', async () => {
192
+ const glass = await read('./glass.css');
193
+ // Measured on the git commit history modal: its 1198x109 `bg-paper` header
194
+ // painted the palette's SOLID paper across the top of a 1200x792 panel, so the
195
+ // panel's highlight and top-left bloom never rendered and the face read as one
196
+ // flat value. The dialog's BODY keeps every card it draws.
197
+ expect(glass).toContain('[data-surface="glass"] .glass-overlay > .bg-paper {\n background-color: transparent;');
198
+ });
199
+
200
+ test('both fallback blocks outrank the dark palette block', async () => {
201
+ const glass = await read('./glass.css');
202
+ // The dark tokens live in `[data-surface="glass"][data-theme-variant="dark"]`
203
+ // (0,2,0). A plain `[data-surface="glass"]` fallback is (0,1,0) and LOSES on
204
+ // every dark palette — measured, `.glass-chrome` kept alpha 0.38 under the
205
+ // block meant to make it opaque, i.e. a translucent plane with no blur behind
206
+ // it, the exact state these blocks exist to prevent. `:root` adds the
207
+ // pseudo-class that ties, and source order then wins.
208
+ const supports = glass.slice(glass.indexOf('@supports not ('), glass.indexOf('@media (prefers-reduced-transparency'));
209
+ const reduced = glass.slice(glass.indexOf('@media (prefers-reduced-transparency'));
210
+ for (const block of [supports, reduced]) {
211
+ expect(block).toContain(':root[data-surface="glass"] {');
212
+ // Not enough on its own: the token list has to be inside that block.
213
+ expect(block).toContain('--glass-chrome: var(--theme-paper);');
214
+ }
215
+ });
216
+
217
+ test('the veil is frosted under the glass surface and only there', async () => {
218
+ const [tailwind, glass] = await Promise.all([read('./tailwind.css'), read('./glass.css')]);
219
+ expect(tailwind).toContain("[data-surface='glass'] .modal-scrim {\n backdrop-filter: blur(20px) saturate(120%);");
220
+
221
+ // Both fallback blocks drop it with the rest of the material.
222
+ const supports = glass.slice(glass.indexOf('@supports not ('), glass.indexOf('@media (prefers-reduced-transparency'));
223
+ const reduced = glass.slice(glass.indexOf('@media (prefers-reduced-transparency'));
224
+ for (const block of [supports, reduced]) {
225
+ expect(block).toContain('--glass-dialog-bloom: none;');
226
+ expect(block).toContain('.modal-scrim {\n backdrop-filter: none;');
227
+ }
228
+ });
229
+ });
230
+
231
+ /**
232
+ * The material has to hold on EVERY palette in the catalog, not on the eighteen
233
+ * it was tuned against. The alphas are read out of `glass.css` itself, so this
234
+ * cannot drift from the shipped values, and the composite it measures is the one
235
+ * the browser computes: `color-mix(… paper N%, transparent)` over the plane,
236
+ * which is itself paper over canvas.
237
+ *
238
+ * The invariant is the one a new palette can break without anyone noticing: body
239
+ * text on the chrome and on a card keeps the 4.5:1 floor. Measured across all 63
240
+ * palettes, the worst is `solarized-light` at 4.89:1 — the same number its
241
+ * opaque paper has, which is what "the tint costs no contrast" means.
242
+ */
243
+ describe('glass material across the catalog', () => {
244
+ const alphaOf = (body: string, token: string): number => {
245
+ const match = new RegExp(`${token}: color-mix\\(in srgb, var\\(--theme-paper\\) (\\d+)%, transparent\\)`).exec(body);
246
+ if (!match) throw new Error(`no ${token} alpha`);
247
+ return Number(match[1]) / 100;
248
+ };
249
+ const percentOf = (body: string, token: string): number => {
250
+ const match = new RegExp(`${token}: (\\d+)%;`).exec(body);
251
+ if (!match) throw new Error(`no ${token}`);
252
+ return Number(match[1]) / 100;
253
+ };
254
+
255
+ test('every palette keeps body text legible on the plane, the chrome and a card', async () => {
256
+ const glass = await read('./glass.css');
257
+ const light = ruleBody(glass, '[data-surface="glass"]');
258
+ const dark = ruleBody(glass, '[data-surface="glass"][data-theme-variant="dark"]');
259
+ const root = ruleBody(glass, ':root');
260
+ const darkVariant = ruleBody(glass, '[data-theme-variant="dark"]');
261
+
262
+ const alphas = {
263
+ light: {
264
+ tint: percentOf(light, '--glass-tint'),
265
+ chrome: alphaOf(light, '--glass-chrome'),
266
+ // A card's fill is surface-INDEPENDENT (the composer's `glass` style is
267
+ // offered in the classic look), so it lives on `:root` / the variant.
268
+ card: alphaOf(root, '--glass-card'),
269
+ },
270
+ dark: {
271
+ tint: percentOf(dark, '--glass-tint'),
272
+ chrome: alphaOf(dark, '--glass-chrome'),
273
+ card: alphaOf(darkVariant, '--glass-card'),
274
+ },
275
+ };
276
+
277
+ for (const theme of THEMES) {
278
+ const alpha = alphas[theme.variant];
279
+ const plane = mixHex(theme.canvas, theme.paper, alpha.tint);
280
+ const chrome = mixHex(plane, theme.paper, alpha.chrome);
281
+ const card = mixHex(plane, theme.paper, alpha.card);
282
+ for (const [tier, surface] of [['plane', plane], ['chrome', chrome], ['card', card]] as const) {
283
+ expect({ id: theme.id, tier, ratio: contrastRatio(theme.ink, surface) >= 4.5 }).toEqual({
284
+ id: theme.id,
285
+ tier,
286
+ ratio: true,
287
+ });
288
+ }
289
+ }
290
+ });
291
+ });
292
+
293
+ /**
294
+ * The material is DERIVED from the palette — `--glass-panel` is
295
+ * `color-mix(paper N%, transparent)` and the chrome is one more mix over it — so
296
+ * a theme does not "support glass" by declaring something; it supports it when
297
+ * its two surfaces and its ink survive the composite. That makes a bad port
298
+ * invisible in the classic look and illegible under the material, which is the
299
+ * failure this sweep exists to catch.
300
+ *
301
+ * The alphas are read out of `glass.css` rather than repeated here, so the test
302
+ * cannot drift from the shipped values, and the composite is the browser's own:
303
+ * plane = paper over canvas, chrome/card = paper over plane.
304
+ */
305
+ describe('glass material on every catalog palette', () => {
306
+ /** A percentage out of a token, whether bare (`50%`) or inside a `color-mix`. */
307
+ const percentOf = (body: string, token: string): number => {
308
+ const match = new RegExp(`--glass-${token}:\\s*(?:color-mix\\(in srgb, var\\(--theme-paper\\)\\s*)?(\\d+(?:\\.\\d+)?)%`).exec(body);
309
+ if (!match) throw new Error(`--glass-${token} is not a percentage in this block`);
310
+ return Number(match[1]) / 100;
311
+ };
312
+
313
+ test('body text keeps the 4.5:1 floor on the plane, the chrome and a card', async () => {
314
+ const glass = await read('./glass.css');
315
+ const surface = ruleBody(glass, '[data-surface="glass"]');
316
+ const surfaceDark = ruleBody(glass, '[data-surface="glass"][data-theme-variant="dark"]');
317
+ const root = ruleBody(glass, ':root');
318
+ const variantDark = ruleBody(glass, '[data-theme-variant="dark"]');
319
+
320
+ // The card's fill is surface-INDEPENDENT (the composer's `glass` style is
321
+ // offered in the classic look too), so it lives on `:root` and the variant
322
+ // block, not under the surface attribute.
323
+ const alphas = {
324
+ light: { tint: percentOf(surface, 'tint'), chrome: percentOf(surface, 'chrome'), card: percentOf(root, 'card') },
325
+ dark: { tint: percentOf(surfaceDark, 'tint'), chrome: percentOf(surfaceDark, 'chrome'), card: percentOf(variantDark, 'card') },
326
+ };
327
+ expect(alphas.light.tint).toBeGreaterThan(alphas.dark.tint - 1);
328
+ expect(alphas.light.chrome).toBeLessThan(alphas.dark.chrome + 0.5);
329
+
330
+ const failures: string[] = [];
331
+ for (const theme of THEMES) {
332
+ const alpha = alphas[theme.variant];
333
+ const plane = mixHex(theme.canvas, theme.paper, alpha.tint);
334
+ const tiers = {
335
+ plane,
336
+ chrome: mixHex(plane, theme.paper, alpha.chrome),
337
+ card: mixHex(plane, theme.paper, alpha.card),
338
+ };
339
+ for (const [tier, fill] of Object.entries(tiers)) {
340
+ const ratio = contrastRatio(theme.ink, fill);
341
+ if (ratio < 4.5) failures.push(`${theme.id} ${tier} ${ratio.toFixed(2)}:1`);
342
+ }
343
+ }
344
+ expect(failures).toEqual([]);
345
+ });
346
+ });
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The live answers to "can this engine draw the glass material", subscribed.
8
+ *
9
+ * `glassLimits` states the rule; this hook is the only place that ASKS the
10
+ * platform, so the settings control never touches `window` itself.
11
+ *
12
+ * Three facts about the asking:
13
+ *
14
+ * - **Both spellings are tested.** Chromium shipped `backdrop-filter`
15
+ * unprefixed only in 76, and the Android shell's floor is `minSdk 24`; the
16
+ * stylesheets always write the `-webkit-` pair, so the probe tests the pair
17
+ * too. Testing one and not the other reports "unsupported" on a device that
18
+ * renders the frost correctly.
19
+ * - **Computed ONCE.** `CSS.supports` is a parse check on a constant string; it
20
+ * cannot change while the document lives, and calling it per render would be a
21
+ * style recalc for a constant.
22
+ * - **`matchMedia` is SUBSCRIBED.** The OS setting can be toggled while the
23
+ * window is open (System Settings → Accessibility, next to the app), and the
24
+ * media query then flips without a reload — a stale `false` would leave the
25
+ * notice hidden on a window that had just gone opaque.
26
+ */
27
+
28
+ import { useEffect, useState } from 'preact/hooks';
29
+ import { glassLimits, type GlassLimit } from '@/shared/lib/theme/glass-support';
30
+
31
+ const REDUCED_TRANSPARENCY = '(prefers-reduced-transparency: reduce)';
32
+
33
+ function supportsBackdropFilter(): boolean {
34
+ if (typeof CSS === 'undefined' || typeof CSS.supports !== 'function') return false;
35
+ return (
36
+ CSS.supports('backdrop-filter', 'blur(1px)') ||
37
+ CSS.supports('-webkit-backdrop-filter', 'blur(1px)')
38
+ );
39
+ }
40
+
41
+ export function useGlassLimits(): GlassLimit[] {
42
+ const [reduced, setReduced] = useState(() =>
43
+ typeof window === 'undefined' ? false : window.matchMedia(REDUCED_TRANSPARENCY).matches,
44
+ );
45
+
46
+ useEffect(() => {
47
+ const media = window.matchMedia(REDUCED_TRANSPARENCY);
48
+ const update = () => setReduced(media.matches);
49
+ // The query can change between the initial render and this effect, so read it
50
+ // once on the way in — the same reason `useViewportAtLeast` does.
51
+ update();
52
+ media.addEventListener('change', update);
53
+ return () => media.removeEventListener('change', update);
54
+ }, []);
55
+
56
+ return glassLimits({ backdropFilter: supportsBackdropFilter(), reducedTransparency: reduced });
57
+ }
@@ -0,0 +1,59 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The single writer for the brand-mark paint style.
8
+ *
9
+ * Same contract as `surface-style.ts`: an attribute on `<html>`, read by CSS
10
+ * only, because `ProviderIconPlate` is drawn in 26 places across five surfaces
11
+ * and a prop would be 26 chances to miss one. The rules live in
12
+ * `src/client/tailwind.css` (`[data-icon-style]`) and read the brand table in
13
+ * `provider-icon/brand-colors.ts` — never a colour written at a call site.
14
+ */
15
+
16
+ import { readKabmoSetting } from '@/shared/lib/settings/client';
17
+ import {
18
+ DEFAULT_ICON_STYLE,
19
+ ICON_STYLE_ATTRIBUTE,
20
+ ICON_STYLE_SETTING_KEY,
21
+ resolveIconStyle,
22
+ } from '@/shared/lib/theme/icon-style';
23
+ import {
24
+ ICON_PAINT_STYLE_ELEMENT_ID,
25
+ iconPaintStyleSheet,
26
+ } from '@/shared/lib/icons/icon-paint-css';
27
+
28
+ /**
29
+ * Point the document at `style`.
30
+ *
31
+ * The default is REMOVED rather than written, so the ink rule in CSS is the
32
+ * single statement of what "no attribute" means.
33
+ */
34
+ export function applyIconStyle(style: unknown): void {
35
+ if (typeof document === 'undefined') return;
36
+ const root = document.documentElement;
37
+ const resolved = resolveIconStyle(style);
38
+ if (resolved === DEFAULT_ICON_STYLE) root.removeAttribute(ICON_STYLE_ATTRIBUTE);
39
+ else root.setAttribute(ICON_STYLE_ATTRIBUTE, resolved);
40
+ }
41
+
42
+ /**
43
+ * Apply the stored style before the first render, and make sure the generated
44
+ * icon-paint stylesheet is in the document.
45
+ *
46
+ * The stylesheet is written by the server shell (it is generated from a TS
47
+ * table, so the bundler cannot carry it — the same split `themeStyleSheet` uses).
48
+ * This only repairs a document served by a build that predates it; without the
49
+ * repair, `color` mode would set the attribute and paint nothing.
50
+ */
51
+ export function initIconStyle(): void {
52
+ if (typeof document !== 'undefined' && !document.getElementById(ICON_PAINT_STYLE_ELEMENT_ID)) {
53
+ const style = document.createElement('style');
54
+ style.id = ICON_PAINT_STYLE_ELEMENT_ID;
55
+ style.textContent = iconPaintStyleSheet();
56
+ document.head.appendChild(style);
57
+ }
58
+ applyIconStyle(readKabmoSetting<unknown>(ICON_STYLE_SETTING_KEY));
59
+ }
@@ -0,0 +1,188 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * `useStuckHeader`: a sticky element's PINNED state.
8
+ *
9
+ * The rule this pins is the one the sidebar depends on: a sticky header paints a
10
+ * surface only while it is overlapping content. Measured with happy-dom's scroll
11
+ * geometry, because the alternative — trusting the CSS — is what shipped a band
12
+ * across a uniform sidebar twice.
13
+ */
14
+
15
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
16
+ import { Window } from 'happy-dom';
17
+ import { h, render } from 'preact';
18
+ import { act } from 'preact/test-utils';
19
+ import { useRef } from 'preact/hooks';
20
+ import { useStuckHeader } from '@/client/hooks/ui/stuck-header';
21
+
22
+ // `requestAnimationFrame` is in the list because the HOOK schedules through it
23
+ // and happy-dom keeps it on its window, not on the runner's global.
24
+ const DOM_GLOBALS = [
25
+ 'window',
26
+ 'document',
27
+ 'navigator',
28
+ 'Node',
29
+ 'Element',
30
+ 'HTMLElement',
31
+ 'Event',
32
+ 'requestAnimationFrame',
33
+ 'cancelAnimationFrame',
34
+ // `preact/test-utils`' `act` reads this one to flush effects.
35
+ 'getComputedStyle',
36
+ ] as const;
37
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
38
+
39
+ let container: HTMLElement;
40
+ let scroller: HTMLElement;
41
+ /** The header's current top, in container coordinates. Mutated per assertion. */
42
+ let headerTop = 0;
43
+ /** The container's scroll offset. Zero is "at rest" — nothing overlapping. */
44
+ let scrollTop = 0;
45
+
46
+ beforeEach(() => {
47
+ const win = new Window({ url: 'http://localhost' });
48
+ const target = globalThis as unknown as Record<string, unknown>;
49
+ for (const key of DOM_GLOBALS) {
50
+ if (!(key in nativeGlobals)) nativeGlobals[key] = win[key as keyof Window];
51
+ target[key] = win[key as keyof Window];
52
+ }
53
+ // A SYNCHRONOUS frame: the hook coalesces scroll events through
54
+ // `requestAnimationFrame`, and a real one is a timer this suite would have to
55
+ // wait on. Running the callback inline measures the same logic with no clock.
56
+ target.requestAnimationFrame = ((callback: FrameRequestCallback) => {
57
+ callback(0);
58
+ return 1;
59
+ }) as typeof requestAnimationFrame;
60
+ target.cancelAnimationFrame = (() => {}) as typeof cancelAnimationFrame;
61
+
62
+ container = document.createElement('div');
63
+ document.body.appendChild(container);
64
+ headerTop = 0;
65
+ scrollTop = 0;
66
+ });
67
+
68
+ afterEach(() => {
69
+ render(null, container);
70
+ container.remove();
71
+ });
72
+
73
+ afterAll(() => {
74
+ const target = globalThis as unknown as Record<string, unknown>;
75
+ for (const key of DOM_GLOBALS) {
76
+ if (key in nativeGlobals) target[key] = nativeGlobals[key];
77
+ else delete target[key];
78
+ }
79
+ });
80
+
81
+ /**
82
+ * A scroll container with a sticky header inside it.
83
+ *
84
+ * happy-dom has no layout engine, so the geometry is supplied: the container's
85
+ * `getBoundingClientRect().top` and the header's are both overridden, which is
86
+ * exactly what `useStuckHeader` reads. The header's rect is a LIVE getter over
87
+ * `headerTop`, so a test scrolls by changing one number.
88
+ */
89
+ function mountHarness(): HTMLElement {
90
+ function Probe() {
91
+ const ref = useRef<HTMLDivElement>(null);
92
+ const stuck = useStuckHeader(ref);
93
+ return h('div', { ref, 'data-stuck': stuck ? '' : undefined, 'data-testid': 'header' });
94
+ }
95
+
96
+ scroller = document.createElement('div');
97
+ scroller.style.overflowY = 'auto';
98
+ Object.defineProperty(scroller, 'scrollHeight', { value: 1000, configurable: true });
99
+ Object.defineProperty(scroller, 'clientHeight', { value: 300, configurable: true });
100
+ Object.defineProperty(scroller, 'scrollTop', {
101
+ get: () => scrollTop,
102
+ set: (value: number) => {
103
+ scrollTop = value;
104
+ },
105
+ configurable: true,
106
+ });
107
+ scroller.getBoundingClientRect = () => ({ top: 0 }) as DOMRect;
108
+ container.appendChild(scroller);
109
+
110
+ // `act` so the effect runs (and attaches its listener) before the geometry is
111
+ // supplied; without it the mount measurement reads happy-dom's zero rect and
112
+ // no later scroll would be heard.
113
+ act(() => {
114
+ render(h(Probe, null), scroller);
115
+ });
116
+ const header = scroller.querySelector('[data-testid="header"]') as HTMLElement;
117
+ header.getBoundingClientRect = () => ({ top: headerTop, bottom: headerTop + 26 }) as DOMRect;
118
+ return header;
119
+ }
120
+
121
+ /**
122
+ * Scroll the harness and wait for the hook's OWN measurement.
123
+ *
124
+ * The hook coalesces scroll events into a `requestAnimationFrame`, so the signal
125
+ * to await is that frame — awaited directly rather than guessed at with a sleep,
126
+ * which would pay real latency per run and still flake under load.
127
+ */
128
+ /** Move the list: `top` is where the header now sits, `offset` how far it scrolled. */
129
+ function scrollTo(top: number, offset: number) {
130
+ headerTop = top;
131
+ scrollTop = offset;
132
+ act(() => {
133
+ scroller.dispatchEvent(new Event('scroll'));
134
+ });
135
+ }
136
+
137
+ describe('useStuckHeader', () => {
138
+ test('a header below the container top is at rest', () => {
139
+ const header = mountHarness();
140
+ scrollTo(120, 0);
141
+
142
+ expect(header.hasAttribute('data-stuck')).toBe(false);
143
+ });
144
+
145
+ test('a header at the container top is NOT stuck before the list scrolls', () => {
146
+ // The regression this guards: the geometric test alone is true at
147
+ // `scrollTop: 0` for a header that starts at the top edge, so the surface
148
+ // appeared before anything overlapped it.
149
+ const header = mountHarness();
150
+ headerTop = 0;
151
+ scrollTop = 0;
152
+ act(() => {
153
+ scroller.dispatchEvent(new Event('scroll'));
154
+ });
155
+
156
+ expect(header.hasAttribute('data-stuck')).toBe(false);
157
+ });
158
+
159
+ test('a header level with the container top is stuck', () => {
160
+ const header = mountHarness();
161
+ scrollTo(0, 120);
162
+
163
+ expect(header.hasAttribute('data-stuck')).toBe(true);
164
+ });
165
+
166
+ test('a header whose section scrolled past is not painted', () => {
167
+ // It sits entirely above the container: sticky keeps it out of sight, so a
168
+ // fill there is work for a surface nobody can see.
169
+ const header = mountHarness();
170
+ scrollTo(-60, 400);
171
+
172
+ expect(header.hasAttribute('data-stuck')).toBe(false);
173
+ });
174
+
175
+ test('scrolling re-measures, in both directions', () => {
176
+ const header = mountHarness();
177
+ scrollTo(120, 0);
178
+ expect(header.hasAttribute('data-stuck')).toBe(false);
179
+
180
+ // The user scrolls the list: the sticky header is now pinned.
181
+ scrollTo(0, 120);
182
+ expect(header.hasAttribute('data-stuck')).toBe(true);
183
+
184
+ // …and scrolls back to the top: it is the first line of the list again.
185
+ scrollTo(40, 0);
186
+ expect(header.hasAttribute('data-stuck')).toBe(false);
187
+ });
188
+ });