@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.
- package/README.md +43 -13
- package/dist/client/index.html +3 -3
- package/dist/client/index.js +485 -484
- package/dist/client/static/js/index-0721wrkf.css +1 -0
- package/dist/client/static/js/{index-tc09dtca.js → index-zg32n2sk.js} +778 -777
- package/dist/client/static/{manifest-42r8wcmg.webmanifest → manifest-q6h8k9e0.webmanifest} +1 -1
- package/index.html +1 -1
- package/marketplace/plugins/command-runner/package.json +3 -2
- package/marketplace/plugins/git-forge/package.json +3 -2
- package/marketplace/plugins/session-info/package.json +3 -2
- package/marketplace/plugins/stats/package.json +3 -2
- package/package.json +3 -1
- package/public/manifest.webmanifest +1 -1
- package/src/client/components/auth/login-screen/index.tsx +2 -1
- package/src/client/components/common/ComposerPicker.tsx +1 -1
- package/src/client/components/common/FolderPicker.tsx +2 -2
- package/src/client/components/common/Modal.tsx +2 -2
- package/src/client/components/common/PWAInstallButton.tsx +2 -2
- package/src/client/components/common/ViewportSelector.tsx +1 -1
- package/src/client/components/common/anchored-menu/index.tsx +5 -1
- package/src/client/components/common/batch-selection/SelectionCheckbox.tsx +2 -1
- package/src/client/components/common/brand-wordmark/index.test.tsx +13 -2
- package/src/client/components/common/brand-wordmark/index.tsx +13 -2
- package/src/client/components/common/checkbox/style.test.ts +142 -0
- package/src/client/components/common/checkbox/style.ts +51 -0
- package/src/client/components/common/context-usage-button/index.tsx +2 -2
- package/src/client/components/common/file-icon/index.tsx +23 -9
- package/src/client/components/common/header-controls/MoreMenu.tsx +1 -1
- package/src/client/components/common/markdown-review/ReviewPopover.tsx +1 -1
- package/src/client/components/common/panel-mark/index.test.tsx +124 -0
- package/src/client/components/common/panel-mark/index.tsx +105 -0
- package/src/client/components/common/provider-icon/glyphs.test.ts +1 -1
- package/src/client/components/common/provider-icon/index.test.ts +14 -0
- package/src/client/components/common/provider-icon/index.tsx +4 -0
- package/src/client/components/common/provider-icon/resolve.test.ts +8 -7
- package/src/client/components/common/provider-icon/resolve.ts +16 -3
- package/src/client/components/common/session-actions-menu/index.tsx +1 -1
- package/src/client/components/common/toolbar-row/index.tsx +1 -1
- package/src/client/components/layout/ActivityBar.tsx +22 -3
- package/src/client/components/layout/LeftDock.tsx +9 -2
- package/src/client/components/layout/PanelVisibilityMenu.tsx +1 -1
- package/src/client/components/layout/WindowAura.tsx +27 -0
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +1 -1
- package/src/client/components/layout/desktop-layout/TopNavbar.tsx +2 -2
- package/src/client/components/layout/desktop-layout/WorkspacePanels.tsx +11 -2
- package/src/client/components/layout/desktop-layout/index.tsx +3 -1
- package/src/client/components/layout/session-sidebar/CategoryHeader.tsx +3 -3
- package/src/client/components/layout/session-sidebar/Header.tsx +1 -1
- package/src/client/components/layout/session-sidebar/OverflowMenu.tsx +1 -1
- package/src/client/components/layout/session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/modern/ActionRow.tsx +1 -1
- package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +13 -5
- package/src/client/components/layout/session-sidebar/new-workspace-modal/index.tsx +2 -2
- package/src/client/components/layout/session-sidebar/scheduler-modal/TaskForm.tsx +2 -1
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -2
- package/src/client/components/mobile/LayoutWrapper.tsx +3 -1
- package/src/client/components/mobile/mobile-main-view/Header.tsx +2 -2
- package/src/client/components/mobile/mobile-session-sidebar/Header.tsx +1 -1
- package/src/client/components/mobile/mobile-session-sidebar/Toolbar.tsx +1 -1
- package/src/client/components/mobile/panel-chips.tsx +10 -2
- package/src/client/components/settings/Modal.tsx +4 -4
- package/src/client/components/settings/ProjectSelectorDropdown.tsx +2 -2
- package/src/client/components/settings/apply-side-effects.test.ts +30 -0
- package/src/client/components/settings/apply-side-effects.ts +14 -0
- package/src/client/components/settings/categories/AppearanceSettings.tsx +6 -0
- package/src/client/components/settings/categories/appearance-settings/EditorBlameSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/EditorTypingSection.tsx +2 -1
- package/src/client/components/settings/categories/appearance-settings/IconStyleSection.tsx +144 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.test.tsx +120 -0
- package/src/client/components/settings/categories/appearance-settings/SurfaceStyleSection.tsx +180 -0
- package/src/client/components/settings/categories/mcp-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/mcp-settings/ImportModal.tsx +2 -2
- package/src/client/components/settings/categories/omp-settings/OrderedChips.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/AvailableList.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/BuiltinList.tsx +21 -3
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +46 -0
- package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +7 -9
- package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +149 -0
- package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +34 -7
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +66 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +47 -10
- package/src/client/components/settings/categories/panel-plugins/Section.tsx +7 -1
- package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +35 -2
- package/src/client/components/settings/categories/plugin-settings/DetailPane.tsx +2 -1
- package/src/client/components/settings/categories/plugin-settings/SettingsSection.tsx +2 -1
- package/src/client/components/settings/categories/project-settings/ModelDropdown.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/provider-settings/DeleteProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/provider-settings/EntryAdvanced.tsx +3 -2
- package/src/client/components/settings/categories/provider-settings/LogoutProviderModal.tsx +2 -2
- package/src/client/components/settings/categories/skill-catalog/GitImportPanel.tsx +3 -2
- package/src/client/components/settings/categories/skill-settings/DetailHeader.tsx +2 -1
- package/src/client/components/settings/categories/token-usage-settings/Controls.tsx +1 -1
- package/src/client/components/workspace/btw-panel/TopicMenu.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/NewChatModal.tsx +3 -3
- package/src/client/components/workspace/chat-timeline/UndoConfirmModal.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/chat-input/AccessDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/GoalModal.tsx +4 -3
- package/src/client/components/workspace/chat-timeline/chat-input/ThinkingLevelDropdown.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/chat-input/WaitingDependencyPicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/plan-review/index.tsx +2 -2
- package/src/client/components/workspace/chat-timeline/target-picker/WorkspacePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +1 -1
- package/src/client/components/workspace/chat-timeline/tool-renderers/extension-dialog/index.tsx +2 -6
- package/src/client/components/workspace/context-panel/CostBreakdownPopover.tsx +1 -1
- package/src/client/components/workspace/diff-panel/index.tsx +2 -2
- package/src/client/components/workspace/editor/PluginRail.tsx +1 -1
- package/src/client/components/workspace/editor/SaveDeletedFileModal.tsx +2 -2
- package/src/client/components/workspace/editor/TabContextMenu.tsx +1 -1
- package/src/client/components/workspace/editor/Tabs.tsx +1 -1
- package/src/client/components/workspace/file-explorer/ContextMenu.tsx +1 -1
- package/src/client/components/workspace/file-explorer/Modals.tsx +10 -10
- package/src/client/components/workspace/file-explorer/RootMenu.tsx +1 -1
- package/src/client/components/workspace/git-panel/BranchToolbar.test.tsx +130 -0
- package/src/client/components/workspace/git-panel/BranchToolbar.tsx +21 -11
- package/src/client/components/workspace/git-panel/CommitBox.tsx +2 -1
- package/src/client/components/workspace/git-panel/Modals.tsx +2 -2
- package/src/client/components/workspace/git-panel/StashSection.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/DeleteDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/branch-modal/RenameDialog.tsx +2 -1
- package/src/client/components/workspace/git-panel/commit-modal/index.tsx +2 -2
- package/src/client/components/workspace/git-panel/index.tsx +7 -0
- package/src/client/components/workspace/model-dropdown/Panel.tsx +1 -1
- package/src/client/components/workspace/model-dropdown/SpecsTooltip.tsx +1 -1
- package/src/client/components/workspace/plugin-panel/catalog.tsx +7 -0
- package/src/client/components/workspace/plugin-panel/resolve.tsx +4 -0
- package/src/client/components/workspace/search-panel/Body.tsx +1 -1
- package/src/client/components/workspace/usage-panel/ProviderSelect.tsx +1 -1
- package/src/client/glass-sticky.test.ts +46 -0
- package/src/client/glass.css +795 -0
- package/src/client/glass.test.ts +306 -0
- package/src/client/hooks/ui/glass-support.ts +57 -0
- package/src/client/hooks/ui/icon-style.ts +59 -0
- package/src/client/hooks/ui/stuck-header.test.ts +213 -0
- package/src/client/hooks/ui/stuck-header.ts +122 -0
- package/src/client/hooks/ui/style-attributes.test.ts +120 -0
- package/src/client/hooks/ui/surface-style.ts +56 -0
- package/src/client/hooks/workspace/panel-hues.ts +23 -0
- package/src/client/hooks/workspace/panel-registry.ts +8 -4
- package/src/client/main.tsx +10 -0
- package/src/client/tailwind.css +264 -11
- package/src/server/lib/assets/shell-attributes.server.ts +80 -0
- package/src/server/lib/assets/shell-attributes.test.ts +86 -0
- package/src/server/lib/lifecycle/tls.test.ts +6 -1
- package/src/server/lib/omp/rpc/frame-fold-host.test-util.ts +1 -0
- package/src/server/lib/omp/rpc/frame-fold-signals.test.ts +2 -30
- package/src/server/lib/omp/rpc/frame-fold.test.ts +55 -0
- package/src/server/lib/omp/rpc/frame-fold.ts +4 -0
- package/src/server/lib/omp/rpc/manager.ts +2 -2
- package/src/server/lib/omp/rpc/process-helpers.ts +11 -0
- package/src/server/lib/omp/rpc/process.test.ts +106 -0
- package/src/server/lib/omp/rpc/process.ts +28 -4
- package/src/server/lib/omp/rpc/run-settle.server.ts +12 -0
- package/src/server/lib/omp/rpc/run-settle.test.ts +22 -0
- package/src/server/lib/omp/rpc/session-command-guards.ts +5 -0
- package/src/server/lib/omp/rpc/session-commands.test.ts +9 -1
- package/src/server/lib/omp/rpc/session-commands.ts +11 -0
- package/src/server/lib/omp/rpc/terminal-settle.ts +29 -7
- package/src/server/lib/panels/bundled-catalog.server.ts +1 -0
- package/src/server/lib/panels/git-update.server.test.ts +20 -0
- package/src/server/lib/panels/git-update.server.ts +20 -4
- package/src/server/lib/panels/manifest.test.ts +20 -0
- package/src/server/lib/panels/manifest.ts +12 -0
- package/src/server/lib/panels/scan.server.ts +4 -0
- package/src/server/lib/panels/sync.server.ts +9 -1
- package/src/server/lib/panels/update.server.test.ts +193 -0
- package/src/server/lib/panels/update.server.ts +210 -0
- package/src/server/lib/plugins/server-half.server.ts +42 -0
- package/src/server/lib/queue/delivery-dispatch.server.test.ts +48 -0
- package/src/server/lib/queue/delivery-harness.ts +8 -4
- package/src/server/lib/queue/delivery.server.test.ts +29 -0
- package/src/server/lib/queue/delivery.server.ts +39 -0
- package/src/server/lib/queue/store.server.test.ts +22 -2
- package/src/server/lib/queue/store.server.ts +33 -11
- package/src/server/lib/terminal/attach-replay.test.ts +26 -8
- package/src/server/plugins/ssr.ts +22 -5
- package/src/server/routes/panels/install-route.test.ts +238 -0
- package/src/server/routes/panels/install.ts +36 -64
- package/src/server/routes/panels/panel-routes.test-util.ts +6 -1
- package/src/server/routes/panels/routes.test.ts +1 -118
- package/src/shared/lib/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +235 -0
- package/src/shared/lib/icons/icon-paint-css.ts +285 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +109 -0
- package/src/shared/lib/icons/icon-tone.ts +166 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +277 -0
- package/src/shared/lib/icons/tint.test.ts +333 -0
- package/src/shared/lib/icons/tint.ts +248 -0
- package/src/shared/lib/models/provider/brand-color.test.ts +116 -0
- package/src/shared/lib/models/provider/brand-color.ts +103 -0
- package/src/shared/lib/omp/rpc/frame.test.ts +65 -0
- package/src/shared/lib/omp/rpc/frame.ts +58 -3
- package/src/shared/lib/panels/update.test.ts +107 -0
- package/src/shared/lib/panels/update.ts +73 -0
- package/src/shared/lib/settings/defaults.ts +4 -0
- package/src/shared/lib/theme/catalog.test.ts +5 -4
- package/src/shared/lib/theme/catalog.ts +18 -3
- package/src/shared/lib/theme/color.ts +50 -0
- package/src/shared/lib/theme/glass-support.test.ts +38 -0
- package/src/shared/lib/theme/glass-support.ts +73 -0
- package/src/shared/lib/theme/icon-style.test.ts +74 -0
- package/src/shared/lib/theme/icon-style.ts +90 -0
- package/src/shared/lib/theme/legibility.ts +91 -0
- package/src/shared/lib/theme/palettes/dark-extended.ts +152 -0
- package/src/shared/lib/theme/palettes/light-extended.ts +157 -0
- package/src/shared/lib/theme/surface-style.test.ts +68 -0
- package/src/shared/lib/theme/surface-style.ts +91 -0
- package/src/shared/lib/theme/theme.test.ts +11 -7
- package/src/shared/lib/workspace/panel-hues.test.ts +68 -0
- package/src/shared/lib/workspace/panel-hues.ts +57 -0
- package/src/shared/types/panels-registry.ts +6 -0
- package/src/shared/types/panels.ts +14 -0
- package/src/shared/types/settings/state.ts +26 -0
- package/src/test-support/fake-omp-frames.ts +163 -0
- package/dist/client/static/js/index-hp75vsv9.css +0 -1
- /package/src/{client/components/common/file-icon/brand-paths.ts → shared/lib/icons/file-brand-paths.ts} +0 -0
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The one answer three surfaces ask: is there an update, and to what.
|
|
8
|
+
*
|
|
9
|
+
* The states that matter are the ones a naive comparison gets wrong, and each is
|
|
10
|
+
* pinned here because the surfaces disagreeing is invisible until a header counts
|
|
11
|
+
* a button that will not render:
|
|
12
|
+
*
|
|
13
|
+
* - a GIT clone is behind when its remote's COMMIT differs, even at the same
|
|
14
|
+
* version — a fix shipped without a bump;
|
|
15
|
+
* - a BUNDLED install is behind only on a strictly newer version, because the
|
|
16
|
+
* store's copy is what it would install;
|
|
17
|
+
* - a LOCAL directory has no source at all and never has an update.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { describe, expect, test } from 'bun:test';
|
|
21
|
+
import { countPluginUpdates, pluginUpdate } from '@/shared/lib/panels/update';
|
|
22
|
+
import type { PanelGitStatus, PanelPluginStatus } from '@/shared/types';
|
|
23
|
+
|
|
24
|
+
const clone = (overrides: Partial<PanelPluginStatus> = {}): PanelPluginStatus => ({
|
|
25
|
+
pluginId: 'git-plugin',
|
|
26
|
+
name: 'Git Plugin',
|
|
27
|
+
version: '1.0.0',
|
|
28
|
+
built: true,
|
|
29
|
+
isPackage: true,
|
|
30
|
+
enabled: true,
|
|
31
|
+
bundled: false,
|
|
32
|
+
origin: 'git',
|
|
33
|
+
gitOrigin: 'https://example.test/plugin.git',
|
|
34
|
+
...overrides,
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
const status = (overrides: Partial<PanelGitStatus> = {}): PanelGitStatus => ({
|
|
38
|
+
current: 'aaaaaaa',
|
|
39
|
+
latest: 'bbbbbbb',
|
|
40
|
+
updateAvailable: true,
|
|
41
|
+
checkedAt: Date.now(),
|
|
42
|
+
...overrides,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('a git clone', () => {
|
|
46
|
+
test('is behind when the probe says its commit moved', () => {
|
|
47
|
+
expect(pluginUpdate(clone(), status())).toEqual({});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
test('names the version the remote declares, so the button can say what it installs', () => {
|
|
51
|
+
expect(pluginUpdate(clone(), status({ latestVersion: '1.1.0' }))).toEqual({ version: '1.1.0' });
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
test('is current when the probe found nothing, whatever the versions say', () => {
|
|
55
|
+
// The probe is the authority: a remote at the same commit cannot install
|
|
56
|
+
// anything, so a stale `latestVersion` must not resurrect the button.
|
|
57
|
+
expect(pluginUpdate(clone({ latestVersion: '9.9.9' }), status({ updateAvailable: false }))).toBeNull();
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
test('is unknown, not current, when it was never probed', () => {
|
|
61
|
+
// A `latestVersion` with no probe behind it describes a status the probe
|
|
62
|
+
// never wrote, so the button stays off until the remote is actually asked.
|
|
63
|
+
expect(pluginUpdate(clone({ latestVersion: '1.2.0' }), undefined)).toBeNull();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
test('is unknown, not current, when the probe errored', () => {
|
|
67
|
+
expect(pluginUpdate(clone(), status({ updateAvailable: false, error: 'unreachable' }))).toBeNull();
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
describe('a bundled install', () => {
|
|
72
|
+
const bundled = (overrides: Partial<PanelPluginStatus> = {}) =>
|
|
73
|
+
clone({ pluginId: 'store-plugin', origin: 'bundled', bundled: true, gitOrigin: null, ...overrides });
|
|
74
|
+
|
|
75
|
+
test('is behind when the store ships a newer version', () => {
|
|
76
|
+
expect(pluginUpdate(bundled({ latestVersion: '2.0.0' }), undefined)).toEqual({ version: '2.0.0' });
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
test('is current at the same version', () => {
|
|
80
|
+
expect(pluginUpdate(bundled({ latestVersion: '1.0.0' }), undefined)).toBeNull();
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
test('is current when the store version is unknown', () => {
|
|
84
|
+
expect(pluginUpdate(bundled(), undefined)).toBeNull();
|
|
85
|
+
});
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
describe('a local directory', () => {
|
|
89
|
+
test('never has an update, even when a version looks newer', () => {
|
|
90
|
+
expect(
|
|
91
|
+
pluginUpdate(clone({ origin: 'local', gitOrigin: null, latestVersion: '2.0.0' }), status()),
|
|
92
|
+
).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
describe('the count', () => {
|
|
97
|
+
test('counts exactly the cards that would render an Update', () => {
|
|
98
|
+
const plugins = [
|
|
99
|
+
clone({ pluginId: 'a' }),
|
|
100
|
+
clone({ pluginId: 'b', origin: 'bundled', bundled: true, gitOrigin: null, latestVersion: '2.0.0' }),
|
|
101
|
+
clone({ pluginId: 'c', origin: 'local', gitOrigin: null }),
|
|
102
|
+
clone({ pluginId: 'd', origin: 'bundled', bundled: true, gitOrigin: null, latestVersion: '1.0.0' }),
|
|
103
|
+
];
|
|
104
|
+
// `a` is behind by commit, `b` by version; `c` and `d` are current.
|
|
105
|
+
expect(countPluginUpdates(plugins, { a: status() })).toBe(2);
|
|
106
|
+
});
|
|
107
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Is an installed plugin behind whatever publishes it?
|
|
8
|
+
*
|
|
9
|
+
* ONE answer, asked by three surfaces — the card's Update button, the Installed
|
|
10
|
+
* header's count and the Update-all button — because they answer the same
|
|
11
|
+
* question and disagreeing once is the whole bug: a header saying "2 updates
|
|
12
|
+
* available" over a single button is a count of nothing.
|
|
13
|
+
*
|
|
14
|
+
* Two sources, and the two are probed differently:
|
|
15
|
+
*
|
|
16
|
+
* - a BUNDLED install's source is the store, whose manifest sits on disk, so the
|
|
17
|
+
* comparison is a version against a version;
|
|
18
|
+
* - a GIT clone's source is its remote, whose HEAD only a probe knows. A commit
|
|
19
|
+
* difference therefore counts even when the versions are equal (a fix shipped
|
|
20
|
+
* without a bump), which is why the probe's own `updateAvailable` is read
|
|
21
|
+
* rather than a version pair alone.
|
|
22
|
+
*
|
|
23
|
+
* A local directory has no source and never updates; `false` is its honest
|
|
24
|
+
* answer, and its card offers no button at all.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
import type { PanelGitStatus, PanelPluginStatus } from '@/shared/types';
|
|
28
|
+
import { isNewer } from '@/shared/lib/updates/semver';
|
|
29
|
+
|
|
30
|
+
/** Where the update would come from, when one is pending. */
|
|
31
|
+
export interface PluginUpdate {
|
|
32
|
+
/** The version the update would install, when the source declares one. */
|
|
33
|
+
version?: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The pending update for one plugin, or null when there is nothing to apply.
|
|
38
|
+
*
|
|
39
|
+
* Returns the target version rather than a bare boolean so a button can name
|
|
40
|
+
* what it would install — `Update to v0.3.0` — instead of leaving the reader to
|
|
41
|
+
* compare two numbers themselves.
|
|
42
|
+
*/
|
|
43
|
+
export function pluginUpdate(
|
|
44
|
+
plugin: Pick<PanelPluginStatus, 'version' | 'latestVersion' | 'origin'>,
|
|
45
|
+
gitStatus: PanelGitStatus | undefined,
|
|
46
|
+
): PluginUpdate | null {
|
|
47
|
+
if (plugin.origin === 'local') return null;
|
|
48
|
+
|
|
49
|
+
// A clone: the PROBE is the verdict, not a version pair. Its `latestVersion`
|
|
50
|
+
// is written only on the branch where the commits differ, so it doubles as the
|
|
51
|
+
// target — and a clone that was never probed is unknown rather than current,
|
|
52
|
+
// which is what the card's own freshness row says too.
|
|
53
|
+
if (plugin.origin === 'git') {
|
|
54
|
+
if (gitStatus?.updateAvailable !== true) return null;
|
|
55
|
+
const target = plugin.latestVersion ?? gitStatus.latestVersion;
|
|
56
|
+
return target ? { version: target } : {};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// A store install: the store's version is the answer, and "same" means there
|
|
60
|
+
// is nothing to fetch — except for a shipped fix that forgot its bump, which
|
|
61
|
+
// only the server can see and which the boot sync applies without asking.
|
|
62
|
+
const target = plugin.latestVersion;
|
|
63
|
+
if (!target || !isNewer(target, plugin.version)) return null;
|
|
64
|
+
return { version: target };
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** How many installed plugins have an update waiting. */
|
|
68
|
+
export function countPluginUpdates(
|
|
69
|
+
plugins: readonly Pick<PanelPluginStatus, 'pluginId' | 'version' | 'latestVersion' | 'origin'>[],
|
|
70
|
+
gitStatus: Readonly<Record<string, PanelGitStatus>>,
|
|
71
|
+
): number {
|
|
72
|
+
return plugins.filter((plugin) => pluginUpdate(plugin, gitStatus[plugin.pluginId]) !== null).length;
|
|
73
|
+
}
|
|
@@ -24,6 +24,8 @@ import { DEFAULT_CHAT_WIDTH_MODE } from '@/shared/lib/chat/timeline/width-mode';
|
|
|
24
24
|
import { DEFAULT_TOOL_RENDER_MODE } from '@/shared/lib/chat/timeline/tool-render-mode';
|
|
25
25
|
import { DEFAULT_SIDEBAR_STYLE } from '@/shared/lib/workspace/sidebar-style';
|
|
26
26
|
import { DEFAULT_COMPOSER_STYLE } from '@/shared/lib/chat/composer/style';
|
|
27
|
+
import { DEFAULT_SURFACE_STYLE } from '@/shared/lib/theme/surface-style';
|
|
28
|
+
import { DEFAULT_ICON_STYLE } from '@/shared/lib/theme/icon-style';
|
|
27
29
|
import { EDITOR_DEFAULT_FONT_FAMILY } from '@/shared/lib/code/editor/typography';
|
|
28
30
|
import { EDITOR_DEFAULT_THEME_ID } from '@/shared/lib/code/editor/themes';
|
|
29
31
|
|
|
@@ -41,6 +43,8 @@ export const DEFAULT_SETTINGS = {
|
|
|
41
43
|
toolRenderStyle: DEFAULT_TOOL_RENDER_MODE,
|
|
42
44
|
sidebarStyle: DEFAULT_SIDEBAR_STYLE,
|
|
43
45
|
composerStyle: DEFAULT_COMPOSER_STYLE,
|
|
46
|
+
surfaceStyle: DEFAULT_SURFACE_STYLE,
|
|
47
|
+
iconStyle: DEFAULT_ICON_STYLE,
|
|
44
48
|
followUpBehavior: 'queue',
|
|
45
49
|
keybindingSend: 'Enter',
|
|
46
50
|
keybindingNewLine: 'Shift + Enter',
|
|
@@ -30,10 +30,11 @@ const COLOR_VALUE = /^(#[0-9a-f]{3}|#[0-9a-f]{6}|#[0-9a-f]{8})$/i;
|
|
|
30
30
|
|
|
31
31
|
describe('theme catalog', () => {
|
|
32
32
|
test('ships Kabmo palettes plus every ported variant', () => {
|
|
33
|
-
expect(THEMES.length).toBe(
|
|
34
|
-
// 21 ported light +
|
|
35
|
-
|
|
36
|
-
expect(THEMES.filter((t) => t.variant === '
|
|
33
|
+
expect(THEMES.length).toBe(63);
|
|
34
|
+
// 21 ported light (upstream snapshot) + 9 newer light + paper/contrast;
|
|
35
|
+
// 21 ported dark + 9 newer dark + one-dark-pro-soft.
|
|
36
|
+
expect(THEMES.filter((t) => t.variant === 'light').length).toBe(32);
|
|
37
|
+
expect(THEMES.filter((t) => t.variant === 'dark').length).toBe(31);
|
|
37
38
|
});
|
|
38
39
|
|
|
39
40
|
test('ids are unique and each palette carries a paintable color for every slot', () => {
|
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
import type { ThemePalette, ThemeSwatch } from '@/shared/types/theme';
|
|
18
18
|
import { KABMO_PALETTES } from '@/shared/lib/theme/palettes/kabmo';
|
|
19
19
|
import { DARK_PALETTES } from '@/shared/lib/theme/palettes/dark';
|
|
20
|
+
import { DARK_EXTENDED_PALETTES } from '@/shared/lib/theme/palettes/dark-extended';
|
|
20
21
|
import { LIGHT_PALETTES } from '@/shared/lib/theme/palettes/light';
|
|
22
|
+
import { LIGHT_EXTENDED_PALETTES } from '@/shared/lib/theme/palettes/light-extended';
|
|
21
23
|
|
|
22
24
|
/** The shipped default, and the fallback for any id the catalog does not know. */
|
|
23
25
|
export const DEFAULT_THEME_ID = 'paper';
|
|
@@ -30,9 +32,17 @@ export const DEFAULT_THEME_ID = 'paper';
|
|
|
30
32
|
export type ThemeId =
|
|
31
33
|
| (typeof KABMO_PALETTES)[number]['id']
|
|
32
34
|
| (typeof LIGHT_PALETTES)[number]['id']
|
|
33
|
-
| (typeof
|
|
35
|
+
| (typeof LIGHT_EXTENDED_PALETTES)[number]['id']
|
|
36
|
+
| (typeof DARK_PALETTES)[number]['id']
|
|
37
|
+
| (typeof DARK_EXTENDED_PALETTES)[number]['id'];
|
|
34
38
|
|
|
35
|
-
const ALL_PALETTES = [
|
|
39
|
+
const ALL_PALETTES = [
|
|
40
|
+
...KABMO_PALETTES,
|
|
41
|
+
...LIGHT_PALETTES,
|
|
42
|
+
...LIGHT_EXTENDED_PALETTES,
|
|
43
|
+
...DARK_PALETTES,
|
|
44
|
+
...DARK_EXTENDED_PALETTES,
|
|
45
|
+
];
|
|
36
46
|
|
|
37
47
|
const BY_ID: Record<string, ThemePalette | undefined> = Object.fromEntries(
|
|
38
48
|
ALL_PALETTES.map((theme) => [theme.id, theme]),
|
|
@@ -50,7 +60,12 @@ const DEFAULT_PALETTE: ThemePalette = KABMO_PALETTES[0];
|
|
|
50
60
|
*/
|
|
51
61
|
export const THEMES: readonly ThemePalette[] = (() => {
|
|
52
62
|
const families = new Map<string, ThemePalette[]>();
|
|
53
|
-
for (const palette of [
|
|
63
|
+
for (const palette of [
|
|
64
|
+
...LIGHT_PALETTES,
|
|
65
|
+
...DARK_PALETTES,
|
|
66
|
+
...LIGHT_EXTENDED_PALETTES,
|
|
67
|
+
...DARK_EXTENDED_PALETTES,
|
|
68
|
+
]) {
|
|
54
69
|
const group = families.get(palette.family);
|
|
55
70
|
if (group) group.push(palette);
|
|
56
71
|
else families.set(palette.family, [palette]);
|
|
@@ -76,6 +76,56 @@ export function mixHex(base: string, blend: string, ratio: number): string {
|
|
|
76
76
|
});
|
|
77
77
|
}
|
|
78
78
|
|
|
79
|
+
/**
|
|
80
|
+
* OKLCH, for the one place sRGB arithmetic is measurably wrong: shading a hue
|
|
81
|
+
* toward another tone.
|
|
82
|
+
*
|
|
83
|
+
* The icon tones are the reason. Mixing `#FFD21E` toward black in sRGB keeps
|
|
84
|
+
* 63% of its chroma where the same move in OKLCH keeps it whole, because sRGB
|
|
85
|
+
* channels are not perceptually spaced — a dark yellow drifts to olive. So the
|
|
86
|
+
* light icon tone is *solved* here: hold the hue, take the most chroma sRGB can
|
|
87
|
+
* actually show at that lightness, and then check the result with WCAG contrast.
|
|
88
|
+
*
|
|
89
|
+
* Values are the standard Björn Ottosson transform: OKLab is the linear part,
|
|
90
|
+
* OKLCH is that in polar form.
|
|
91
|
+
*/
|
|
92
|
+
export function oklchToRgb(lightness: number, chroma: number, hue: number): Rgba & { inGamut: boolean } {
|
|
93
|
+
const radians = (hue * Math.PI) / 180;
|
|
94
|
+
const a = chroma * Math.cos(radians);
|
|
95
|
+
const b = chroma * Math.sin(radians);
|
|
96
|
+
|
|
97
|
+
const l = (lightness + 0.3963377774 * a + 0.2158037573 * b) ** 3;
|
|
98
|
+
const m = (lightness - 0.1055613458 * a - 0.0638541728 * b) ** 3;
|
|
99
|
+
const s = (lightness - 0.0894841775 * a - 1.291485548 * b) ** 3;
|
|
100
|
+
|
|
101
|
+
// Linear-light sRGB, then the transfer function.
|
|
102
|
+
const linear = [
|
|
103
|
+
4.0767416621 * l - 3.3077115913 * m + 0.2309699292 * s,
|
|
104
|
+
-1.2684380046 * l + 2.6097574011 * m - 0.3413193965 * s,
|
|
105
|
+
-0.0041960863 * l - 0.7034186147 * m + 1.707614701 * s,
|
|
106
|
+
] as const;
|
|
107
|
+
const channel = (value: number) => {
|
|
108
|
+
const encoded = value <= 0.0031308 ? 12.92 * value : 1.055 * value ** (1 / 2.4) - 0.055;
|
|
109
|
+
return encoded * 255;
|
|
110
|
+
};
|
|
111
|
+
// A hair of slack: at the gamut surface the transform lands on `-1e-8`, and
|
|
112
|
+
// an exact test would reject colours that round to a perfectly valid byte.
|
|
113
|
+
const inGamut = linear.every((value) => value >= -0.0005 && value <= 1.0005);
|
|
114
|
+
return { r: channel(linear[0]), g: channel(linear[1]), b: channel(linear[2]), a: 1, inGamut };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/** The most chroma sRGB can show at this lightness and hue. */
|
|
118
|
+
export function maxChromaInGamut(lightness: number, hue: number): number {
|
|
119
|
+
let low = 0;
|
|
120
|
+
let high = 0.4;
|
|
121
|
+
for (let step = 0; step < 16; step += 1) {
|
|
122
|
+
const mid = (low + high) / 2;
|
|
123
|
+
if (oklchToRgb(lightness, mid, hue).inGamut) low = mid;
|
|
124
|
+
else high = mid;
|
|
125
|
+
}
|
|
126
|
+
return low;
|
|
127
|
+
}
|
|
128
|
+
|
|
79
129
|
/** WCAG relative luminance, used to order two palette colors light-to-dark. */
|
|
80
130
|
export function relativeLuminance(value: string): number {
|
|
81
131
|
const color = parseHexColor(value);
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, test } from 'bun:test';
|
|
7
|
+
import { GLASS_LIMIT_COPY, glassLimits, type GlassLimit } from '@/shared/lib/theme/glass-support';
|
|
8
|
+
|
|
9
|
+
describe('glass support', () => {
|
|
10
|
+
test('a supported engine with no preference reports nothing', () => {
|
|
11
|
+
expect(glassLimits({ backdropFilter: true, reducedTransparency: false })).toEqual([]);
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
test('a missing backdrop-filter is named even when the system also asked for less transparency', () => {
|
|
15
|
+
// The ORDER is the point: with no blur, the media query has nothing to switch
|
|
16
|
+
// off, so naming the preference first would send the reader to an OS setting
|
|
17
|
+
// that changes nothing on that engine.
|
|
18
|
+
expect(glassLimits({ backdropFilter: false, reducedTransparency: true })).toEqual([
|
|
19
|
+
'no-backdrop-filter',
|
|
20
|
+
'reduced-transparency',
|
|
21
|
+
]);
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('reduced transparency alone is a limit, because the frost really is off', () => {
|
|
25
|
+
expect(glassLimits({ backdropFilter: true, reducedTransparency: true })).toEqual([
|
|
26
|
+
'reduced-transparency',
|
|
27
|
+
]);
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
test('every limit has copy long enough to act on', () => {
|
|
31
|
+
const limits: GlassLimit[] = ['no-backdrop-filter', 'reduced-transparency'];
|
|
32
|
+
for (const limit of limits) {
|
|
33
|
+
// A limit with no sentence is a warning nobody can act on; the number is the
|
|
34
|
+
// shortest of the two shipped strings.
|
|
35
|
+
expect(GLASS_LIMIT_COPY[limit].length).toBeGreaterThan(80);
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Whether the machine running this document can actually draw the glass
|
|
8
|
+
* material, and if not, WHY.
|
|
9
|
+
*
|
|
10
|
+
* The `glass` surface style is pure CSS: one `backdrop-filter` on the window
|
|
11
|
+
* plane plus the tiers above it. Every shell Kabmo ships renders the same page —
|
|
12
|
+
* Android's `WebView`, iOS/macOS `WKWebView`, Windows' WebView2 and Linux's
|
|
13
|
+
* WebKitGTK 4.1 — so the style is not per-platform. What IS per-platform is the
|
|
14
|
+
* two ways it silently stops working:
|
|
15
|
+
*
|
|
16
|
+
* - **The engine has no `backdrop-filter`.** Then `glass.css`'s `@supports not
|
|
17
|
+
* (…)` block hands back the opaque palette, and the window looks exactly like
|
|
18
|
+
* `classic` while the setting says `glass`. The prefix matters here: Chromium
|
|
19
|
+
* only shipped the UNPREFIXED property in 76, so an Android 7 device
|
|
20
|
+
* (`minSdk 24`) whose WebView was never updated still needs
|
|
21
|
+
* `-webkit-backdrop-filter`, which the stylesheets always write.
|
|
22
|
+
* - **The system asked apps to reduce transparency.** macOS/iOS "Reduce
|
|
23
|
+
* Transparency", GNOME's equivalent: the `prefers-reduced-transparency` media
|
|
24
|
+
* query fires and every translucent token resolves to opaque paper. That is
|
|
25
|
+
* the intended behaviour — a frosted window is exactly what the setting exists
|
|
26
|
+
* to remove — but a user who switched the surface style ON and sees no change
|
|
27
|
+
* reads it as a bug ("glass doesn't work on my mac").
|
|
28
|
+
*
|
|
29
|
+
* Both are REPORTED rather than papered over (`AGENTS.md` §6: a substitution has
|
|
30
|
+
* to name itself), which is the whole reason this module exists: the fallback in
|
|
31
|
+
* CSS cannot say anything, so the settings control says it once, in the place the
|
|
32
|
+
* choice is made.
|
|
33
|
+
*
|
|
34
|
+
* This module is pure — the caller passes what the platform's own APIs answered —
|
|
35
|
+
* so the rule is testable without a browser, and the same answers can be checked
|
|
36
|
+
* from a terminal (`CSS.supports`, `matchMedia`) when a shell misbehaves.
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
export type GlassLimit = 'no-backdrop-filter' | 'reduced-transparency';
|
|
40
|
+
|
|
41
|
+
/** What the platform APIs answered. Both are cheap and synchronous. */
|
|
42
|
+
export interface GlassProbe {
|
|
43
|
+
/** `CSS.supports('backdrop-filter', …) || CSS.supports('-webkit-backdrop-filter', …)`. */
|
|
44
|
+
backdropFilter: boolean;
|
|
45
|
+
/** `matchMedia('(prefers-reduced-transparency: reduce)').matches`. */
|
|
46
|
+
reducedTransparency: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Every reason the frost will not appear, in the order they matter.
|
|
51
|
+
*
|
|
52
|
+
* An engine that cannot blur is the FIRST reason even when the system also asked
|
|
53
|
+
* for less transparency: with no `backdrop-filter` the media query has nothing to
|
|
54
|
+
* switch off, and naming the preference first would send the reader to an OS
|
|
55
|
+
* setting that changes nothing.
|
|
56
|
+
*/
|
|
57
|
+
export function glassLimits({ backdropFilter, reducedTransparency }: GlassProbe): GlassLimit[] {
|
|
58
|
+
const limits: GlassLimit[] = [];
|
|
59
|
+
if (!backdropFilter) limits.push('no-backdrop-filter');
|
|
60
|
+
if (reducedTransparency) limits.push('reduced-transparency');
|
|
61
|
+
return limits;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* What the settings control says. `null` for a limit is not allowed — a limit
|
|
66
|
+
* with no sentence is a warning nobody can act on.
|
|
67
|
+
*/
|
|
68
|
+
export const GLASS_LIMIT_COPY: Record<GlassLimit, string> = {
|
|
69
|
+
'no-backdrop-filter':
|
|
70
|
+
'This engine reports no backdrop blur, so the frost falls back to opaque panels here — the window keeps the glass colours but loses the blur.',
|
|
71
|
+
'reduced-transparency':
|
|
72
|
+
'Your system asks apps to reduce transparency, so the frost is switched off. Turn that system setting off to see the glass material.',
|
|
73
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The icon style's contract.
|
|
8
|
+
*
|
|
9
|
+
* Two facts are pinned here: the default must be what shipped (monochrome ink),
|
|
10
|
+
* and an unreadable stored value must land on it rather than leaving every mark
|
|
11
|
+
* with no rule to paint it.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { describe, expect, test } from 'bun:test';
|
|
15
|
+
import {
|
|
16
|
+
DEFAULT_ICON_STYLE,
|
|
17
|
+
ICON_STYLE_ATTRIBUTE,
|
|
18
|
+
ICON_STYLES,
|
|
19
|
+
ICON_STYLE_COPY,
|
|
20
|
+
isIconStyle,
|
|
21
|
+
resolveIconStyle,
|
|
22
|
+
} from '@/shared/lib/theme/icon-style';
|
|
23
|
+
|
|
24
|
+
describe('isIconStyle', () => {
|
|
25
|
+
test('accepts exactly the two styles', () => {
|
|
26
|
+
expect(ICON_STYLES.map(isIconStyle)).toEqual([true, true]);
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test('refuses what another build or a corrupted blob could carry', () => {
|
|
30
|
+
for (const value of ['', 'Color', 'colour', 'full-color', 0, 1, true, null, undefined, {}, ['color']]) {
|
|
31
|
+
expect(isIconStyle(value)).toBe(false);
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe('resolveIconStyle', () => {
|
|
37
|
+
test('keeps a style this build draws', () => {
|
|
38
|
+
expect(resolveIconStyle('monochrome')).toBe('monochrome');
|
|
39
|
+
expect(resolveIconStyle('color')).toBe('color');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('an unknown value lands on the shipped default, not on undefined', () => {
|
|
43
|
+
expect(resolveIconStyle('vivid')).toBe(DEFAULT_ICON_STYLE);
|
|
44
|
+
expect(resolveIconStyle(undefined)).toBe(DEFAULT_ICON_STYLE);
|
|
45
|
+
expect(resolveIconStyle(null)).toBe(DEFAULT_ICON_STYLE);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
describe('the style table', () => {
|
|
50
|
+
test('the default is monochrome, which is what every mark shipped as', () => {
|
|
51
|
+
expect(DEFAULT_ICON_STYLE).toBe('monochrome');
|
|
52
|
+
expect(ICON_STYLES).toContain(DEFAULT_ICON_STYLE);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
test('the attribute is a plain `data-` name', () => {
|
|
56
|
+
expect(ICON_STYLE_ATTRIBUTE).toBe('data-icon-style');
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
test('every style carries its own label and description', () => {
|
|
60
|
+
const labels = ICON_STYLES.map((style) => ICON_STYLE_COPY[style].label);
|
|
61
|
+
expect(new Set(labels).size).toBe(ICON_STYLES.length);
|
|
62
|
+
for (const style of ICON_STYLES) {
|
|
63
|
+
expect(ICON_STYLE_COPY[style].description.length).toBeGreaterThan(0);
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
test('the colour copy names what it colours, so the mode promises no literal hex', () => {
|
|
68
|
+
// Every icon family is covered by the setting; the copy has to say so or a
|
|
69
|
+
// user cannot tell what they just switched on.
|
|
70
|
+
const description = ICON_STYLE_COPY.color.description;
|
|
71
|
+
expect(description).toContain('glyphs');
|
|
72
|
+
expect(description).toContain('brand');
|
|
73
|
+
});
|
|
74
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* How EVERY icon is painted, as ONE of two styles.
|
|
8
|
+
*
|
|
9
|
+
* Three families of icon ship in this app and this setting covers all three:
|
|
10
|
+
*
|
|
11
|
+
* 1. **Functional glyphs** — Lucide's stroke icons (247 imports, 346 files).
|
|
12
|
+
* There is no second artwork to swap in, so `color` can only mean a TINT.
|
|
13
|
+
* Each glyph gets its own hue from a generated table (`icons/tint.ts`), except
|
|
14
|
+
* the ones whose meaning IS a signal (a trash can, a check, a clock, an info
|
|
15
|
+
* dot), which take the palette's `--theme-error` / `-success` / `-warning` /
|
|
16
|
+
* `-info`.
|
|
17
|
+
* 2. **Provider and model marks** (`provider-icon/`) — brand logos, painted in
|
|
18
|
+
* the brand's own colour where it publishes one.
|
|
19
|
+
* 3. **File-type marks** (`file-icon/`) — the language and tool logos a file
|
|
20
|
+
* list is read by.
|
|
21
|
+
*
|
|
22
|
+
* - `monochrome` — every icon in the surrounding ink. The DEFAULT, because it
|
|
23
|
+
* is what Kabmo ships today: an upgrade must not repaint a window the user
|
|
24
|
+
* did not ask to change.
|
|
25
|
+
* - `color` — each icon in its own colour. A brand colour that would
|
|
26
|
+
* vanish on the active variant (a black logo on a dark theme) keeps the ink
|
|
27
|
+
* instead, and the generated hues are stated at a lightness that clears the
|
|
28
|
+
* 3:1 non-text floor on every palette of that variant, so this never trades a
|
|
29
|
+
* legible row for a literal hex.
|
|
30
|
+
*
|
|
31
|
+
* Every rule is `:where()`-wrapped, so this is a DEFAULT paint and never an
|
|
32
|
+
* override: a caller's own `text-error` on a missing file, or `text-ink/40` on a
|
|
33
|
+
* muted row, still wins. That is what makes one global switch safe over 346
|
|
34
|
+
* files that never agreed to it.
|
|
35
|
+
*
|
|
36
|
+
* The style reaches the document as `data-icon-style` on `<html>`, read by CSS
|
|
37
|
+
* only: `ProviderIconPlate` alone is drawn in 26 places across five surfaces,
|
|
38
|
+
* and a prop would be 26 chances to miss one.
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
export type IconStyle = 'monochrome' | 'color';
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* The style a document with no stored preference renders at. Every provider
|
|
45
|
+
* mark was ink before this setting existed, so this is the no-change default.
|
|
46
|
+
*/
|
|
47
|
+
export const DEFAULT_ICON_STYLE: IconStyle = 'monochrome';
|
|
48
|
+
|
|
49
|
+
/** Document attribute carrying the style. Read by CSS only. */
|
|
50
|
+
export const ICON_STYLE_ATTRIBUTE = 'data-icon-style';
|
|
51
|
+
|
|
52
|
+
/** `app_settings` key holding the style — see `SURFACE_STYLE_SETTING_KEY`. */
|
|
53
|
+
export const ICON_STYLE_SETTING_KEY = 'iconStyle';
|
|
54
|
+
|
|
55
|
+
/** Every style, in the order the settings control lists them. */
|
|
56
|
+
export const ICON_STYLES = ['monochrome', 'color'] as const;
|
|
57
|
+
|
|
58
|
+
/** A stored value written by another build is not a style this one can draw. */
|
|
59
|
+
export function isIconStyle(value: unknown): value is IconStyle {
|
|
60
|
+
return value === 'monochrome' || value === 'color';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* The style to APPLY for a stored value. Anything this build cannot draw
|
|
65
|
+
* resolves to the default, so a corrupted blob cannot leave every mark
|
|
66
|
+
* unpainted.
|
|
67
|
+
*/
|
|
68
|
+
export function resolveIconStyle(value: unknown): IconStyle {
|
|
69
|
+
return isIconStyle(value) ? value : DEFAULT_ICON_STYLE;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface IconStyleCopy {
|
|
73
|
+
label: string;
|
|
74
|
+
/** The tradeoff, stated once — including what the mode cannot colour. */
|
|
75
|
+
description: string;
|
|
76
|
+
caption: string;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export const ICON_STYLE_COPY: Record<IconStyle, IconStyleCopy> = {
|
|
80
|
+
monochrome: {
|
|
81
|
+
label: 'Monochrome',
|
|
82
|
+
description: 'Every icon inherits the palette ink — toolbar glyphs, provider logos and file marks alike. The most uniform reading.',
|
|
83
|
+
caption: 'Palette ink',
|
|
84
|
+
},
|
|
85
|
+
color: {
|
|
86
|
+
label: 'Full colour',
|
|
87
|
+
description: 'Each icon gets its own colour: glyphs a per-icon hue, brand marks their own logo colour, a project its accent. Tool cards in a transcript stay ink — they are read, not scanned.',
|
|
88
|
+
caption: 'Per-icon colour',
|
|
89
|
+
},
|
|
90
|
+
};
|