@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.
- package/README.md +10 -7
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +475 -474
- package/dist/client/static/js/{index-tc09dtca.js → index-fcee4c13.js} +766 -765
- package/dist/client/static/js/index-sxdw908m.css +1 -0
- 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/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 +139 -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.tsx +97 -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/PluginCard.tsx +1 -1
- package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +51 -2
- package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +43 -10
- 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.css +785 -0
- package/src/client/glass.test.ts +346 -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 +188 -0
- package/src/client/hooks/ui/stuck-header.ts +91 -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/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/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/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/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/plugins/ssr.ts +22 -5
- package/src/shared/lib/icons/file-brand-color.ts +38 -0
- package/src/shared/lib/icons/icon-paint-css.test.ts +234 -0
- package/src/shared/lib/icons/icon-paint-css.ts +284 -0
- package/src/shared/lib/icons/icon-paint-panel.ts +100 -0
- package/src/shared/lib/icons/tint-hues.generated.ts +230 -0
- package/src/shared/lib/icons/tint.test.ts +273 -0
- package/src/shared/lib/icons/tint.ts +219 -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/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/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
|
@@ -131,7 +131,11 @@ export function AnchoredMenu({
|
|
|
131
131
|
ref={panelRef}
|
|
132
132
|
role={role}
|
|
133
133
|
aria-label={ariaLabel}
|
|
134
|
-
|
|
134
|
+
// `glass-popover` belongs to the PRIMITIVE, not to each caller: every
|
|
135
|
+
// menu this renders is an anchored floating panel, and the tier is inert
|
|
136
|
+
// in the classic look (all of its rules are `[data-surface="glass"]`), so
|
|
137
|
+
// a caller that forgets it is the only way a dropdown stays opaque.
|
|
138
|
+
className={`glass-popover fixed z-[70] overflow-y-auto overscroll-contain ${className}`}
|
|
135
139
|
style={style}
|
|
136
140
|
onClick={(event) => event.stopPropagation()}
|
|
137
141
|
>
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
*/
|
|
18
18
|
|
|
19
19
|
import { useEffect, useRef } from 'preact/hooks';
|
|
20
|
+
import { CHECKBOX_CLASS } from '@/client/components/common/checkbox/style';
|
|
20
21
|
|
|
21
22
|
export interface SelectionCheckboxProps {
|
|
22
23
|
checked: boolean;
|
|
@@ -50,7 +51,7 @@ export function SelectionCheckbox({
|
|
|
50
51
|
aria-label={label}
|
|
51
52
|
onChange={onChange}
|
|
52
53
|
onClick={(event) => event.stopPropagation()}
|
|
53
|
-
className={
|
|
54
|
+
className={`${CHECKBOX_CLASS} shrink-0 accent-ink cursor-pointer ${
|
|
54
55
|
size === 'md' ? 'w-3.5 h-3.5' : 'w-3 h-3'
|
|
55
56
|
}`}
|
|
56
57
|
/>
|
|
@@ -47,10 +47,10 @@ afterEach(() => {
|
|
|
47
47
|
container?.remove();
|
|
48
48
|
});
|
|
49
49
|
|
|
50
|
-
function mount(className?: string): HTMLElement {
|
|
50
|
+
function mount(className?: string, glow = false): HTMLElement {
|
|
51
51
|
container = document.createElement('div');
|
|
52
52
|
document.body.appendChild(container);
|
|
53
|
-
render(h(BrandWordmark, className ? { className } : {}), container);
|
|
53
|
+
render(h(BrandWordmark, { ...(className ? { className } : {}), ...(glow ? { glow } : {}) }), container);
|
|
54
54
|
return container;
|
|
55
55
|
}
|
|
56
56
|
|
|
@@ -112,4 +112,15 @@ describe('BrandWordmark', () => {
|
|
|
112
112
|
expect(root.className).toContain('tracking-tight');
|
|
113
113
|
expect(root.className).toContain('font-extrabold');
|
|
114
114
|
});
|
|
115
|
+
|
|
116
|
+
test('the halo is opt-in and rides with the size, never instead of it', () => {
|
|
117
|
+
// The default (login screen, About dialog) is unchanged: the halo belongs
|
|
118
|
+
// to the four header surfaces that pass it.
|
|
119
|
+
const plain = mount().firstElementChild as HTMLElement;
|
|
120
|
+
expect(plain.className).not.toContain('brand-wordmark-glow');
|
|
121
|
+
const halo = mount('text-sm', true).firstElementChild as HTMLElement;
|
|
122
|
+
expect(halo.className).toContain('brand-wordmark-glow');
|
|
123
|
+
expect(halo.className).toContain('text-sm');
|
|
124
|
+
expect(halo.className).toContain('tracking-tight');
|
|
125
|
+
});
|
|
115
126
|
});
|
|
@@ -42,12 +42,23 @@
|
|
|
42
42
|
* `className` carries the SIZE (each surface sets its own) and nothing else: the
|
|
43
43
|
* colour split and the tracking are the brand and are not a per-call-site
|
|
44
44
|
* decision.
|
|
45
|
+
*
|
|
46
|
+
* `glow` adds the soft halo every HEADER surface wears — both layouts' sidebar
|
|
47
|
+
* headers and both top navbars — and nothing else does. It is a variant rather
|
|
48
|
+
* than another `className` value for the reason above: the effect is the same
|
|
49
|
+
* brand decision on all four, and a caller that spelled it itself would be the
|
|
50
|
+
* second copy this module exists to prevent. All four or none: the desktop
|
|
51
|
+
* draws its sidebar and its navbar side by side, so a wordmark that glowed in
|
|
52
|
+
* one and not the other would be two products on one screen. The halo is drawn
|
|
53
|
+
* by `.brand-wordmark-glow` in `tailwind.css`, which applies it on dark
|
|
54
|
+
* palettes only: on a near-black canvas the lockup needs the light, on paper a
|
|
55
|
+
* white glow would only muddy the ink it is drawn on.
|
|
45
56
|
*/
|
|
46
57
|
import { BrandMark } from '@/client/components/common/brand-wordmark/Mark';
|
|
47
58
|
|
|
48
|
-
export function BrandWordmark({ className = 'text-[15px]' }: { className?: string }) {
|
|
59
|
+
export function BrandWordmark({ className = 'text-[15px]', glow = false }: { className?: string; glow?: boolean }) {
|
|
49
60
|
return (
|
|
50
|
-
<span className={`font-extrabold tracking-tight ${className}`}>
|
|
61
|
+
<span className={`font-extrabold tracking-tight${glow ? ' brand-wordmark-glow' : ''} ${className}`}>
|
|
51
62
|
<BrandMark />
|
|
52
63
|
<span className="sr-only">K</span>
|
|
53
64
|
<span className="text-transparent bg-clip-text bg-gradient-to-r from-amber-500 to-orange-600" style={{ paddingRight: '0.06em', marginRight: '-0.06em' }}>ab</span>
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The checkbox's own contract: the class is applied everywhere, and the styles
|
|
8
|
+
* that make "on" and "off" readable exist.
|
|
9
|
+
*
|
|
10
|
+
* Both halves are pinned because they failed for different reasons. The MARKUP
|
|
11
|
+
* half is a count: 22 `<input type="checkbox">` call sites across the app, and a
|
|
12
|
+
* control that is styled in the sidebar but native in Settings is two controls
|
|
13
|
+
* that disagree about what a checkbox looks like. The CSS half is a measurement:
|
|
14
|
+
* the native unchecked box composited 1.10:1 against its row while the checked
|
|
15
|
+
* one was 10.84:1 — "checkbox gk kelihatan on off nya".
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { describe, expect, test } from 'bun:test';
|
|
19
|
+
import { Glob } from 'bun';
|
|
20
|
+
|
|
21
|
+
describe('checkbox', () => {
|
|
22
|
+
test('every checkbox input carries the shared class', async () => {
|
|
23
|
+
// The glob is rooted at the REPOSITORY, not at this folder: a path that
|
|
24
|
+
// resolves wrong walks zero files and every assertion passes vacuously —
|
|
25
|
+
// which is exactly what the first version of this test did.
|
|
26
|
+
//
|
|
27
|
+
// `Bun.fileURLToPath` and `new URL(file, repoUrl)`, never `URL.pathname`:
|
|
28
|
+
// on Windows the pathname is `/D:/a/kabmo/kabmo/`, which walks nothing —
|
|
29
|
+
// the same vacuous pass this comment warns about, arriving by another
|
|
30
|
+
// route. `Bun.fileURLToPath` rather than `node:url` because this module is
|
|
31
|
+
// under `src/`, where a `node:` import is not allowed.
|
|
32
|
+
const repoUrl = new URL('../../../../..', import.meta.url);
|
|
33
|
+
const repo = Bun.fileURLToPath(repoUrl);
|
|
34
|
+
const glob = new Glob('src/client/**/*.tsx');
|
|
35
|
+
const offenders: string[] = [];
|
|
36
|
+
for await (const file of glob.scan({ cwd: repo })) {
|
|
37
|
+
if (file.includes('.test.')) continue;
|
|
38
|
+
// Comments first: `SelectionCheckbox` documents itself with the literal
|
|
39
|
+
// markup (`A native <input type="checkbox"> rather than a styled span`),
|
|
40
|
+
// and a scanner that reads prose reports the file that explains the rule.
|
|
41
|
+
const source = (await Bun.file(new URL(file, repoUrl)).text())
|
|
42
|
+
.replace(/\/\*[\s\S]*?\*\//g, '')
|
|
43
|
+
.replace(/^\s*\/\/.*$/gm, '');
|
|
44
|
+
if (!source.includes('type="checkbox"')) continue;
|
|
45
|
+
// Every `<input … type="checkbox" … />` element must name the class; the
|
|
46
|
+
// primitive itself imports the constant rather than spelling it.
|
|
47
|
+
const inputs = source.split('<input').filter((chunk) => chunk.includes('type="checkbox"'));
|
|
48
|
+
for (const chunk of inputs) {
|
|
49
|
+
const tag = chunk.slice(0, chunk.indexOf('/>') + 2);
|
|
50
|
+
if (!tag.includes('CHECKBOX_CLASS') && !tag.includes('kabmo-checkbox')) {
|
|
51
|
+
offenders.push(`${file}: ${tag.slice(0, 60).replace(/\s+/g, ' ')}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
expect(offenders).toEqual([]);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
test('the styles state all three states in palette tokens', async () => {
|
|
59
|
+
const css = await Bun.file(new URL('../../../tailwind.css', import.meta.url)).text();
|
|
60
|
+
// The recipe lives in `@layer components`, NOT unlayered: an unlayered
|
|
61
|
+
// `width` beat every call site's `w-4`, so six Settings rows collapsed to the
|
|
62
|
+
// border box ("4x4"). A layer loses to utilities, which is the whole point.
|
|
63
|
+
const layer = css.slice(css.indexOf('@layer components {'), css.indexOf('/* Dot grain texture'));
|
|
64
|
+
expect(layer).toContain('.kabmo-checkbox {');
|
|
65
|
+
expect(layer).toContain('appearance: none;');
|
|
66
|
+
// A DEFAULT size, because `appearance: none` removes the intrinsic one.
|
|
67
|
+
expect(layer).toContain('width: 0.875rem;');
|
|
68
|
+
|
|
69
|
+
// The ring's alpha is a contrast budget: `ink 75%` is the first alpha whose
|
|
70
|
+
// worst case over all 63 palettes clears WCAG's 3:1 non-text floor
|
|
71
|
+
// (3.02:1 on solarized-light); 40% measured 1.71:1, which was the bug. The
|
|
72
|
+
// COLOURED ring below clears 3.56:1 on the same sweep. 2px
|
|
73
|
+
// rather than 1.5px because a half-pixel border antialiases into a 50% blend
|
|
74
|
+
// and the intended alpha never reaches the screen.
|
|
75
|
+
expect(layer).toContain('border: 2px solid color-mix(in srgb, var(--theme-ink) 75%, transparent);');
|
|
76
|
+
// Checked is the full ink, so the tick is `paper` — the palette's own pair.
|
|
77
|
+
expect(layer).toContain('.kabmo-checkbox:checked,');
|
|
78
|
+
expect(layer).toContain('background-color: var(--theme-ink);');
|
|
79
|
+
// The tick is a MASK, not a glyph: a glyph would inherit the row's text
|
|
80
|
+
// colour, and these rows set `text-ink/NN` for their own reasons.
|
|
81
|
+
expect(layer).toContain('background-color: var(--theme-paper);');
|
|
82
|
+
expect(layer).toContain('mask: center / contain no-repeat');
|
|
83
|
+
expect(layer).toContain('.kabmo-checkbox:indeterminate::after {');
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test('the colour mode states on as green and off as red, and mono does not', async () => {
|
|
87
|
+
const css = await Bun.file(new URL('../../../tailwind.css', import.meta.url)).text();
|
|
88
|
+
// The colour mode is the one place a user asks for chroma, so the states are
|
|
89
|
+
// colour there. Both are MIXED TOWARD THE INK, which is a contrast budget:
|
|
90
|
+
// at full strength the ring measured 2.73:1 and the fill 1.75:1 worst case
|
|
91
|
+
// over the 63 palettes, both under the 3:1 non-text floor; 75%/55% clear
|
|
92
|
+
// 3.56:1 (`solarized-dark`) and 3.63:1 (`nord-light`) on the real chrome
|
|
93
|
+
// composite, and the tick's `paper` clears 3.59:1 on the same fill.
|
|
94
|
+
expect(css).toContain('[data-icon-style="color"] .kabmo-checkbox {\n border-color: color-mix(in srgb, var(--theme-error) 75%, var(--theme-ink));');
|
|
95
|
+
expect(css).toContain('background-color: color-mix(in srgb, var(--theme-success) 55%, var(--theme-ink));');
|
|
96
|
+
// Hover stops at 85%, not the raw error colour: at 100% the ring drops to
|
|
97
|
+
// 2.77:1 on `mono-light`, i.e. the highlight would be less legible than the
|
|
98
|
+
// idle state it is meant to emphasise.
|
|
99
|
+
expect(css).toContain('border-color: color-mix(in srgb, var(--theme-error) 85%, var(--theme-ink));');
|
|
100
|
+
// Gated on the attribute: monochrome has no colour to state a state with, so
|
|
101
|
+
// it keeps the ink pair the base layer declares.
|
|
102
|
+
expect(css).not.toContain(':root:not([data-icon-style="color"]) .kabmo-checkbox {');
|
|
103
|
+
const mono = css.slice(0, css.indexOf('[data-icon-style="color"] .kabmo-checkbox'));
|
|
104
|
+
expect(mono).toContain('background-color: var(--theme-ink);');
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* The switch knob is a SHAPE, and `bg-canvas` is the app's ground.
|
|
110
|
+
*
|
|
111
|
+
* Under the glass surface a canvas well goes transparent — correct for a chat
|
|
112
|
+
* well, fatal for a knob: measured on the plugin switches in dark, the 12px knob
|
|
113
|
+
* composited to `rgba(0,0,0,0)` and the control rendered as a plain pill with no
|
|
114
|
+
* "on" position at all. The mark is the switch ROLE, so any control that declares
|
|
115
|
+
* itself a switch owns its knob whatever it paints it with.
|
|
116
|
+
*/
|
|
117
|
+
describe('switch knob', () => {
|
|
118
|
+
test('the switch track states on/off in the same two colours as the checkbox', async () => {
|
|
119
|
+
const css = await Bun.file(new URL('../../../tailwind.css', import.meta.url)).text();
|
|
120
|
+
// Keyed on the ROLE and `aria-checked`, not a class: six call sites paint the
|
|
121
|
+
// track with five different utilities, and none of them is the fact "on".
|
|
122
|
+
expect(css).toContain('[data-icon-style="color"] [role="switch"][aria-checked="true"] {');
|
|
123
|
+
expect(css).toContain('background-color: color-mix(in srgb, var(--theme-success) 55%, var(--theme-ink));');
|
|
124
|
+
expect(css).toContain('[data-icon-style="color"] [role="switch"][aria-checked="false"] {');
|
|
125
|
+
expect(css).toContain('background-color: color-mix(in srgb, var(--theme-error) 75%, var(--theme-ink));');
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
test('a knob on a switch keeps its fill under the glass surface', async () => {
|
|
129
|
+
const glass = await Bun.file(new URL('../../../glass.css', import.meta.url)).text();
|
|
130
|
+
expect(glass).toContain('[data-surface="glass"] .app-window [role="switch"] .bg-canvas {');
|
|
131
|
+
expect(glass).toContain('background-color: var(--theme-canvas);');
|
|
132
|
+
// The exemption must come AFTER the well rule it overrides, or source order
|
|
133
|
+
// hands the knob back to the transparent one at equal specificity.
|
|
134
|
+
const well = glass.indexOf('[data-surface="glass"] .app-window .bg-canvas:not(.app-window) {');
|
|
135
|
+
const knob = glass.indexOf('[data-surface="glass"] .app-window [role="switch"] .bg-canvas {');
|
|
136
|
+
expect(well).toBeGreaterThan(-1);
|
|
137
|
+
expect(knob).toBeGreaterThan(well);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The checkbox, drawn by us instead of by the engine.
|
|
8
|
+
*
|
|
9
|
+
* A native `<input type="checkbox">` with `accent-color` is the right CONTROL —
|
|
10
|
+
* it carries checked/indeterminate, keyboard behaviour and the announcement for
|
|
11
|
+
* free — but its rendering is the platform's, and the platform disagrees with
|
|
12
|
+
* this app about what "on" and "off" look like:
|
|
13
|
+
*
|
|
14
|
+
* - **The unchecked box is nearly invisible.** Measured in the session sidebar
|
|
15
|
+
* (batch selection), the unchecked box composited to `(236,238,235)` on a
|
|
16
|
+
* `(250,248,242)` row — **1.10:1** — while the checked one was 10.84:1. Two
|
|
17
|
+
* states 10 points apart in luminance are not a control you can read; the
|
|
18
|
+
* report was "checkbox gk kelihatan on off nya".
|
|
19
|
+
* - **The checked box is the platform's accent**, not the palette's: Chromium
|
|
20
|
+
* paints `accent-color` as a FILL and then whichever glyph it likes, so the
|
|
21
|
+
* tint tracks `--theme-ink` here but the tick colour, the corner radius and the
|
|
22
|
+
* size are the engine's.
|
|
23
|
+
* - **The indeterminate dash** is a property with no attribute equivalent, so a
|
|
24
|
+
* styled span could not carry it anyway.
|
|
25
|
+
*
|
|
26
|
+
* So the input STAYS (same semantics, same `indeterminate` assignment) and only
|
|
27
|
+
* its box is replaced: `appearance: none` plus a pseudo-element that states each
|
|
28
|
+
* state explicitly, in palette tokens.
|
|
29
|
+
*
|
|
30
|
+
* **The numbers are a contrast budget, not taste.** The unchecked ring needs 3:1
|
|
31
|
+
* against the surface it sits on — WCAG's non-text floor, the same one the brand
|
|
32
|
+
* marks use — and a `text-ink/NN` alpha is the only way to reach it on every
|
|
33
|
+
* palette: measured across all 43, `ink 75%` is the first alpha whose worst case
|
|
34
|
+
* clears the floor (3.02:1 on `solarized-light`); 60% is 2.34:1 and 40% — the
|
|
35
|
+
* `border-ink/30` these controls shipped with — is **1.71:1**. The checked fill
|
|
36
|
+
* is the full ink, which makes the tick `paper`, so the pair is the palette's
|
|
37
|
+
* own `ink`/`paper` contrast: 4.85:1 worst case, 17.5:1 on `paper`.
|
|
38
|
+
*
|
|
39
|
+
* `accent-color` is left set as well: a browser that cannot draw the
|
|
40
|
+
* pseudo-element still gets the platform control rather than a blank square.
|
|
41
|
+
*/
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `appearance: none` plus a state pseudo-element, in ONE class so 22 call sites
|
|
45
|
+
* cannot drift into 22 slightly different boxes.
|
|
46
|
+
*
|
|
47
|
+
* The rules live in `tailwind.css` (`.kabmo-checkbox`) rather than here because
|
|
48
|
+
* they are CSS-only facts about a state selector — `checked`, `indeterminate`,
|
|
49
|
+
* `disabled` — that no component can express.
|
|
50
|
+
*/
|
|
51
|
+
export const CHECKBOX_CLASS = 'kabmo-checkbox';
|
|
@@ -99,8 +99,8 @@ export function ContextUsageButton({ sessionId, layout = 'desktop' }: ContextUsa
|
|
|
99
99
|
aria-label="Context usage"
|
|
100
100
|
className={
|
|
101
101
|
layout === 'mobile'
|
|
102
|
-
? 'fixed z-50 bg-paper border border-ink/20 rounded-xl shadow-xl p-3 text-xs font-mono'
|
|
103
|
-
: 'absolute right-0 top-full z-50 mt-2 w-56 bg-paper border border-ink/20 rounded-xl shadow-xl p-3 text-xs font-mono'
|
|
102
|
+
? 'glass-popover fixed z-50 bg-paper border border-ink/20 rounded-xl shadow-xl p-3 text-xs font-mono'
|
|
103
|
+
: 'glass-popover absolute right-0 top-full z-50 mt-2 w-56 bg-paper border border-ink/20 rounded-xl shadow-xl p-3 text-xs font-mono'
|
|
104
104
|
}
|
|
105
105
|
style={
|
|
106
106
|
layout === 'mobile'
|
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
FolderOpen,
|
|
12
12
|
} from 'lucide-preact';
|
|
13
13
|
import type { ReactNode } from 'preact/compat';
|
|
14
|
-
import { BRAND_ICONS, BRAND_VIEWBOX, type BrandIconName } from '@/
|
|
14
|
+
import { BRAND_ICONS, BRAND_VIEWBOX, type BrandIconName } from '@/shared/lib/icons/file-brand-paths';
|
|
15
15
|
import { getImageMimeType } from '@/shared/lib/fs/file-kind';
|
|
16
16
|
|
|
17
17
|
interface FileIconProps {
|
|
@@ -22,9 +22,18 @@ interface FileIconProps {
|
|
|
22
22
|
className?: string;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
25
|
+
/**
|
|
26
|
+
* A brand icon rendered from static path data.
|
|
27
|
+
*
|
|
28
|
+
* The paint is CSS, not a prop: the mark is always `fill="currentColor"` and
|
|
29
|
+
* carries `data-file-brand`, which `icon-paint-css.ts` colours under
|
|
30
|
+
* `[data-icon-style="color"]` (and leaves ink otherwise). That is what makes the
|
|
31
|
+
* setting reach 30-odd call sites without a prop at any of them.
|
|
32
|
+
*
|
|
33
|
+
* `monochrome` is the explicit OPT-OUT, for a surface that must stay free of
|
|
34
|
+
* chroma whatever the setting says — the chat's tool cards, where a coloured
|
|
35
|
+
* logo beside every tool name would compete with the tool's own state colour.
|
|
36
|
+
*/
|
|
28
37
|
function BrandIconSvg({ name, size, className, monochrome = false }: { name: BrandIconName; size: number; className?: string; monochrome?: boolean }) {
|
|
29
38
|
const brand = BRAND_ICONS[name];
|
|
30
39
|
return (
|
|
@@ -32,7 +41,8 @@ function BrandIconSvg({ name, size, className, monochrome = false }: { name: Bra
|
|
|
32
41
|
viewBox={BRAND_VIEWBOX}
|
|
33
42
|
width={size}
|
|
34
43
|
height={size}
|
|
35
|
-
fill=
|
|
44
|
+
fill="currentColor"
|
|
45
|
+
data-file-brand={monochrome ? undefined : name}
|
|
36
46
|
className={className}
|
|
37
47
|
aria-hidden="true"
|
|
38
48
|
>
|
|
@@ -126,7 +136,7 @@ export function FileIcon({ name, isFolder, isOpen, size = 14, className = '' }:
|
|
|
126
136
|
}
|
|
127
137
|
|
|
128
138
|
if (lowerName.endsWith('.json')) {
|
|
129
|
-
return <Braces size={size}
|
|
139
|
+
return <Braces size={size} className={className} />;
|
|
130
140
|
}
|
|
131
141
|
if (lowerName.endsWith('.css') || lowerName.endsWith('.scss')) {
|
|
132
142
|
return <BrandIconSvg name="Css" size={size} className={className} />;
|
|
@@ -138,11 +148,15 @@ export function FileIcon({ name, isFolder, isOpen, size = 14, className = '' }:
|
|
|
138
148
|
// document icon for PDF/Word. Each has a viewer behind it, so the glyph is
|
|
139
149
|
// what tells a user at a glance that the file opens as something other than
|
|
140
150
|
// source text.
|
|
151
|
+
// These four used to carry inline hexes (`#22c55e`, `#f97316`, `#c084fc`),
|
|
152
|
+
// which made them the only icons in the app that ignored BOTH modes. Their
|
|
153
|
+
// hue is now a role in `shared/lib/icons/tint.ts`, so the palette decides it
|
|
154
|
+
// and `monochrome` finally reaches them.
|
|
141
155
|
if (lowerName.endsWith('.csv') || lowerName.endsWith('.tsv') || lowerName.endsWith('.xlsx') || lowerName.endsWith('.xlsm')) {
|
|
142
|
-
return <FileSpreadsheet size={size}
|
|
156
|
+
return <FileSpreadsheet size={size} className={className} />;
|
|
143
157
|
}
|
|
144
158
|
if (lowerName.endsWith('.pdf') || lowerName.endsWith('.docx')) {
|
|
145
|
-
return <FileType size={size}
|
|
159
|
+
return <FileType size={size} className={className} />;
|
|
146
160
|
}
|
|
147
161
|
if (lowerName.endsWith('.md') || lowerName.endsWith('.txt')) {
|
|
148
162
|
return <FileText size={size} className={`text-ink/70 ${className}`} />;
|
|
@@ -150,7 +164,7 @@ export function FileIcon({ name, isFolder, isOpen, size = 14, className = '' }:
|
|
|
150
164
|
// SVG is text the editor edits as code, but it is still a picture to the eye,
|
|
151
165
|
// so the icon stays the image glyph for it.
|
|
152
166
|
if (getImageMimeType(lowerName) || lowerName.endsWith('.svg')) {
|
|
153
|
-
return <FileImage size={size}
|
|
167
|
+
return <FileImage size={size} className={className} />;
|
|
154
168
|
}
|
|
155
169
|
if (lowerName.endsWith('.sh') || lowerName.endsWith('.bash')) {
|
|
156
170
|
return <BrandIconSvg name="Gnubash" size={size} className={className} />;
|
|
@@ -111,7 +111,7 @@ export function HeaderMoreMenu({ entries = [] }: { entries?: HeaderEntry[] }) {
|
|
|
111
111
|
{open && (
|
|
112
112
|
<div
|
|
113
113
|
role="menu"
|
|
114
|
-
className="absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-xl shadow-lg z-50 py-1 text-xs"
|
|
114
|
+
className="glass-popover absolute right-0 top-full mt-1 w-44 bg-paper border border-ink/15 rounded-xl shadow-lg z-50 py-1 text-xs"
|
|
115
115
|
>
|
|
116
116
|
<button
|
|
117
117
|
type="button"
|
|
@@ -70,7 +70,7 @@ export function ReviewPopover({ block, verdict, note, anchor, onSave, onRemove,
|
|
|
70
70
|
aria-label={`Review block ${rangeOf(block)}`}
|
|
71
71
|
// `fixed`, from the click's own rectangle — see the module note.
|
|
72
72
|
style={{ top: `${anchor.top}px`, left: `${anchor.left}px` }}
|
|
73
|
-
className="fixed z-[65] w-[min(24rem,calc(100vw-2rem))] rounded-md border border-ink/15 bg-paper shadow-lg p-2 font-sans text-[11.5px] text-ink"
|
|
73
|
+
className="glass-popover fixed z-[65] w-[min(24rem,calc(100vw-2rem))] rounded-md border border-ink/15 bg-paper shadow-lg p-2 font-sans text-[11.5px] text-ink"
|
|
74
74
|
onClick={(event) => event.stopPropagation()}
|
|
75
75
|
>
|
|
76
76
|
<div className="flex items-center gap-1.5 text-[10.5px] font-mono text-ink/50">
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A PANEL's mark, wherever a panel is listed.
|
|
8
|
+
*
|
|
9
|
+
* The activity bar, the phone's chip strip and the Built-in list in Settings all
|
|
10
|
+
* draw the same thing, and before this component each one decided its colour for
|
|
11
|
+
* itself: the rail stamped the PANEL id's hue, while the two lists drew the bare
|
|
12
|
+
* glyph and therefore took the GLYPH's hue — so `Files` was `hsl(0 …)` in one
|
|
13
|
+
* place and `hsl(320 …)` in the other, and `Wiki`'s `BookOpen` fell through to
|
|
14
|
+
* the `info` signal colour because it means something as a glyph but nothing as
|
|
15
|
+
* a panel.
|
|
16
|
+
*
|
|
17
|
+
* Two rules, and the split between them is the point:
|
|
18
|
+
*
|
|
19
|
+
* - **A BUILT-IN view** takes the hue of its PANEL ID (`usePanelHues`, resolved
|
|
20
|
+
* over the whole set of built-in views so the answer cannot depend on what a
|
|
21
|
+
* surface is drawing). That is one colour per view, everywhere.
|
|
22
|
+
* - **A PLUGIN panel** takes the plugin's OWN mark colour — the brand hex its
|
|
23
|
+
* manifest declares, else the hue of its name — because that is what its
|
|
24
|
+
* marketplace card draws. Keying it by the slot id instead gave one plugin two
|
|
25
|
+
* colours, which is the defect this component exists to remove.
|
|
26
|
+
*
|
|
27
|
+
* A declared brand colour still wins over everything: it is surfaced as the
|
|
28
|
+
* `--panel-color-light`/`-dark` pair, which the stylesheet reads before the hue.
|
|
29
|
+
* `data-declared` says the mark carries one, because the rail must not dim a
|
|
30
|
+
* colour the plugin author chose (see `icon-paint-css.ts`).
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
import type { ReactNode } from 'preact/compat';
|
|
34
|
+
import { legiblePair } from '@/shared/lib/theme/legibility';
|
|
35
|
+
import { usePanelHues } from '@/client/hooks/workspace/panel-hues';
|
|
36
|
+
import { panelHueOf } from '@/shared/lib/workspace/panel-hues';
|
|
37
|
+
import { PluginMark } from '@/client/components/settings/categories/panel-plugins/PluginMark';
|
|
38
|
+
|
|
39
|
+
interface PanelMarkProps {
|
|
40
|
+
/** The panel id a BUILT-IN view's hue is keyed by. */
|
|
41
|
+
panelId: string;
|
|
42
|
+
/**
|
|
43
|
+
* Which KIND of panel this is: a built-in view takes the panel-id hue, a
|
|
44
|
+
* plugin keeps its own mark colour. Stated rather than inferred from `icon`,
|
|
45
|
+
* because a built-in view may have no glyph of its own and would otherwise be
|
|
46
|
+
* recoloured as if it were a plugin.
|
|
47
|
+
*/
|
|
48
|
+
builtin: boolean;
|
|
49
|
+
/** A built-in view's own glyph, when it has one. */
|
|
50
|
+
icon?: ReactNode;
|
|
51
|
+
/** The plugin's display name; also the fallback mark when it ships no icon. */
|
|
52
|
+
name: string;
|
|
53
|
+
iconUrl?: string;
|
|
54
|
+
/** The colour the plugin's manifest declares, when it declares one. */
|
|
55
|
+
color?: string;
|
|
56
|
+
size: number;
|
|
57
|
+
/**
|
|
58
|
+
* The mark's state, when the surface has one. `undefined` means "no state":
|
|
59
|
+
* the rail is the only caller that dims an inactive mark, and it must be able
|
|
60
|
+
* to say so without every other surface pretending to be inactive.
|
|
61
|
+
*/
|
|
62
|
+
idle?: boolean;
|
|
63
|
+
/** Extra classes for the wrapper — a surface's own layout, nothing about colour. */
|
|
64
|
+
className?: string;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function PanelMark({
|
|
68
|
+
panelId,
|
|
69
|
+
builtin,
|
|
70
|
+
icon,
|
|
71
|
+
name,
|
|
72
|
+
iconUrl,
|
|
73
|
+
color,
|
|
74
|
+
size,
|
|
75
|
+
idle,
|
|
76
|
+
className,
|
|
77
|
+
}: PanelMarkProps) {
|
|
78
|
+
const hues = usePanelHues();
|
|
79
|
+
const declared = color ? legiblePair(color) : null;
|
|
80
|
+
return (
|
|
81
|
+
<span
|
|
82
|
+
className={className ?? 'inline-flex'}
|
|
83
|
+
data-panel-mark=""
|
|
84
|
+
data-idle={idle === true ? '' : undefined}
|
|
85
|
+
// Stamped from the DATA (`panel.color`), not guessed from the stylesheet:
|
|
86
|
+
// the rail's idle filter is exempted by this attribute.
|
|
87
|
+
data-declared={declared ? '' : undefined}
|
|
88
|
+
style={{
|
|
89
|
+
...(builtin ? { '--panel-hue': String(panelHueOf(hues, panelId)) } : {}),
|
|
90
|
+
...(declared ? { '--panel-color-light': declared.light } : {}),
|
|
91
|
+
...(declared?.dark ? { '--panel-color-dark': declared.dark } : {}),
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{icon ?? <PluginMark name={name} iconUrl={iconUrl} color={color} size={size} />}
|
|
95
|
+
</span>
|
|
96
|
+
);
|
|
97
|
+
}
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
import { describe, expect, test } from 'bun:test';
|
|
21
|
-
import { BRAND_ICONS, BRAND_VIEWBOX } from '@/
|
|
21
|
+
import { BRAND_ICONS, BRAND_VIEWBOX } from '@/shared/lib/icons/file-brand-paths';
|
|
22
22
|
import { PROVIDER_GLYPHS } from '@/client/components/common/provider-icon/glyphs';
|
|
23
23
|
|
|
24
24
|
describe('PROVIDER_GLYPHS', () => {
|
|
@@ -104,4 +104,18 @@ describe('ProviderIcon ink', () => {
|
|
|
104
104
|
expect(el.querySelector('svg')).toBeNull();
|
|
105
105
|
expect(el.textContent).toBe('ti.');
|
|
106
106
|
});
|
|
107
|
+
|
|
108
|
+
test('a built-in mark names itself, so the colour rule has a key', () => {
|
|
109
|
+
const svg = paint(h(ProviderIcon, { slug: 'claude' })).querySelector('svg');
|
|
110
|
+
|
|
111
|
+
expect(svg?.getAttribute('data-provider')).toBe('claude');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('the attribute is the GLYPH name, not the spelling the caller passed', () => {
|
|
115
|
+
// `claude-code` folds to the `claude` glyph; the colour row is keyed on the
|
|
116
|
+
// glyph, so a caller's spelling cannot miss it.
|
|
117
|
+
const svg = paint(h(ProviderIcon, { slug: 'claude-code' })).querySelector('svg');
|
|
118
|
+
|
|
119
|
+
expect(svg?.getAttribute('data-provider')).toBe('claude');
|
|
120
|
+
});
|
|
107
121
|
});
|
|
@@ -132,6 +132,10 @@ export function ProviderIcon({
|
|
|
132
132
|
// carry their own attributes (`azure`'s `fill-opacity`, `synthetic`'s
|
|
133
133
|
// stroked outline, the baked `currentColor` paths) keep them.
|
|
134
134
|
fill="currentColor"
|
|
135
|
+
// The colour rule's key: `<html data-icon-style="color">` paints
|
|
136
|
+
// `svg[data-provider=…]` from the brand table, and the attribute is absent
|
|
137
|
+
// for a plugin's own art so no guessed brand colour can land on it.
|
|
138
|
+
data-provider={glyph.brandKey ?? undefined}
|
|
135
139
|
// `block` + the explicit width/height are the containment contract: an
|
|
136
140
|
// inline SVG sits on the text baseline and adds descender space, which is
|
|
137
141
|
// how a mark "fits" its attributes yet still pushes a plate's edge.
|
|
@@ -58,18 +58,18 @@ describe('resolveProviderMark', () => {
|
|
|
58
58
|
test('a registered glyph wins over the built-in mark for that provider', () => {
|
|
59
59
|
const mark = resolveProviderMark(['deepseek'], [row('demo', 'deepseek', CUSTOM)]);
|
|
60
60
|
|
|
61
|
-
expect(mark).toEqual({ viewBox: '0 0 32 32', body: '<path d="M4 4h24v24H4z"/>' });
|
|
61
|
+
expect(mark).toEqual({ viewBox: '0 0 32 32', body: '<path d="M4 4h24v24H4z"/>', brandKey: null });
|
|
62
62
|
});
|
|
63
63
|
|
|
64
64
|
test('a registration leaves every other provider on its built-in mark', () => {
|
|
65
65
|
const rows = [row('demo', 'deepseek', CUSTOM)];
|
|
66
66
|
|
|
67
|
-
expect(resolveProviderMark(['openai'], rows)).
|
|
68
|
-
expect(resolveProviderMark(['deepseek'], rows)).
|
|
67
|
+
expect(resolveProviderMark(['openai'], rows)).toEqual({ ...PROVIDER_GLYPHS.openai, brandKey: 'openai' });
|
|
68
|
+
expect(resolveProviderMark(['deepseek'], rows)?.brandKey).toBeNull();
|
|
69
69
|
});
|
|
70
70
|
|
|
71
71
|
test('an unregistered provider is unchanged, unknown ones still fall to initials', () => {
|
|
72
|
-
expect(resolveProviderMark(['deepseek'], [])).
|
|
72
|
+
expect(resolveProviderMark(['deepseek'], [])).toEqual({ ...PROVIDER_GLYPHS.deepseek, brandKey: 'deepseek' });
|
|
73
73
|
expect(resolveProviderMark(['my-private-gateway'], [])).toBeNull();
|
|
74
74
|
});
|
|
75
75
|
|
|
@@ -95,9 +95,10 @@ describe('resolveProviderMark', () => {
|
|
|
95
95
|
|
|
96
96
|
test('a malformed glyph falls through instead of rendering a broken mark', () => {
|
|
97
97
|
// On a provider the built-in table knows, the built-in mark comes back.
|
|
98
|
-
expect(resolveProviderMark(['deepseek'], [row('demo', 'deepseek', MALFORMED)])).
|
|
99
|
-
PROVIDER_GLYPHS.deepseek,
|
|
100
|
-
|
|
98
|
+
expect(resolveProviderMark(['deepseek'], [row('demo', 'deepseek', MALFORMED)])).toEqual({
|
|
99
|
+
...PROVIDER_GLYPHS.deepseek,
|
|
100
|
+
brandKey: 'deepseek',
|
|
101
|
+
});
|
|
101
102
|
// With no built-in either, there is nothing to draw and the badge runs.
|
|
102
103
|
expect(resolveProviderMark(['acme'], [row('demo', 'acme', MALFORMED)])).toBeNull();
|
|
103
104
|
});
|
|
@@ -62,6 +62,18 @@ export function parseRegisteredGlyph(source: string): ProviderGlyph | null {
|
|
|
62
62
|
return { viewBox: box, body };
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
+
/**
|
|
66
|
+
* A mark ready to draw, plus the built-in name it came from.
|
|
67
|
+
*
|
|
68
|
+
* `brandKey` is what the colour rule keys on (`BRAND_COLORS` in
|
|
69
|
+
* `shared/lib/models/provider/brand-color.ts`) and is `null` for a plugin's own
|
|
70
|
+
* art: a registration is the user's SVG, and painting it in a brand colour this
|
|
71
|
+
* build guessed would be a colour the author never chose.
|
|
72
|
+
*/
|
|
73
|
+
export interface ResolvedProviderMark extends ProviderGlyph {
|
|
74
|
+
brandKey: string | null;
|
|
75
|
+
}
|
|
76
|
+
|
|
65
77
|
/**
|
|
66
78
|
* The mark to draw for a provider: a plugin's registration when one matches,
|
|
67
79
|
* otherwise the built-in table entry.
|
|
@@ -78,7 +90,7 @@ export function parseRegisteredGlyph(source: string): ProviderGlyph | null {
|
|
|
78
90
|
export function resolveProviderMark(
|
|
79
91
|
candidates: ReadonlyArray<string | null | undefined>,
|
|
80
92
|
registered: ListSlotRows<ProviderIconRegistration>,
|
|
81
|
-
):
|
|
93
|
+
): ResolvedProviderMark | null {
|
|
82
94
|
for (const candidate of candidates) {
|
|
83
95
|
if (!candidate) continue;
|
|
84
96
|
const key = foldProviderKey(candidate);
|
|
@@ -86,9 +98,10 @@ export function resolveProviderMark(
|
|
|
86
98
|
const entry = registered.find((row) => foldProviderKey(row.registration.provider) === key);
|
|
87
99
|
if (!entry) continue;
|
|
88
100
|
const glyph = parseRegisteredGlyph(entry.registration.glyph);
|
|
89
|
-
if (glyph) return glyph;
|
|
101
|
+
if (glyph) return { ...glyph, brandKey: null };
|
|
90
102
|
break;
|
|
91
103
|
}
|
|
92
104
|
const name = resolveProviderGlyph(...candidates);
|
|
93
|
-
|
|
105
|
+
const glyph = name ? PROVIDER_GLYPHS[name] : undefined;
|
|
106
|
+
return glyph ? { ...glyph, brandKey: name ?? null } : null;
|
|
94
107
|
}
|
|
@@ -167,7 +167,7 @@ export function SessionActionsMenu({
|
|
|
167
167
|
// the position before the browser paints, so this never flashes.
|
|
168
168
|
visibility: pos ? 'visible' : 'hidden',
|
|
169
169
|
}}
|
|
170
|
-
className="fixed z-[70] w-44 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs text-ink font-sans"
|
|
170
|
+
className="glass-popover fixed z-[70] w-44 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs text-ink font-sans"
|
|
171
171
|
onClick={(e) => e.stopPropagation()}
|
|
172
172
|
>
|
|
173
173
|
{onRename && (
|
|
@@ -231,7 +231,7 @@ function OverflowMenu({ actions }: { actions: ToolbarOverflowAction[] }) {
|
|
|
231
231
|
// settles the position before the browser paints.
|
|
232
232
|
visibility: position ? 'visible' : 'hidden',
|
|
233
233
|
}}
|
|
234
|
-
className="fixed z-[80] w-52 bg-paper border border-ink/15 rounded-lg shadow-lg py-1 text-xs"
|
|
234
|
+
className="glass-popover fixed z-[80] w-52 bg-paper border border-ink/15 rounded-lg shadow-lg py-1 text-xs"
|
|
235
235
|
>
|
|
236
236
|
{actions.map((action) => (
|
|
237
237
|
<button
|