@kabmo-labs/kabmo 0.19.0 → 0.21.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +32 -5
  2. package/dist/client/index.html +3 -3
  3. package/dist/client/index.js +340 -340
  4. package/dist/client/static/js/{index-sxdw908m.css → index-0721wrkf.css} +1 -1
  5. package/dist/client/static/js/{index-fcee4c13.js → index-thwqf24c.js} +685 -685
  6. package/dist/client/static/{manifest-42r8wcmg.webmanifest → manifest-q6h8k9e0.webmanifest} +1 -1
  7. package/index.html +1 -1
  8. package/package.json +1 -1
  9. package/public/manifest.webmanifest +1 -1
  10. package/src/client/components/common/checkbox/style.test.ts +11 -8
  11. package/src/client/components/common/panel-mark/index.test.tsx +124 -0
  12. package/src/client/components/common/panel-mark/index.tsx +9 -1
  13. package/src/client/components/settings/categories/panel-plugins/GitFreshness.test.tsx +46 -0
  14. package/src/client/components/settings/categories/panel-plugins/GitFreshness.tsx +1 -1
  15. package/src/client/components/settings/categories/panel-plugins/InstalledList.tsx +7 -9
  16. package/src/client/components/settings/categories/panel-plugins/PluginCard.test.tsx +149 -0
  17. package/src/client/components/settings/categories/panel-plugins/PluginCard.tsx +33 -6
  18. package/src/client/components/settings/categories/panel-plugins/PluginMark.test.ts +15 -0
  19. package/src/client/components/settings/categories/panel-plugins/PluginMark.tsx +6 -2
  20. package/src/client/components/settings/categories/panel-plugins/Section.tsx +7 -1
  21. package/src/client/components/settings/categories/panel-plugins/Toolbar.tsx +35 -2
  22. package/src/client/glass-sticky.test.ts +46 -0
  23. package/src/client/glass.css +27 -17
  24. package/src/client/glass.test.ts +21 -61
  25. package/src/client/hooks/ui/stuck-header.test.ts +28 -3
  26. package/src/client/hooks/ui/stuck-header.ts +36 -5
  27. package/src/client/hooks/workspace/panel-registry.ts +8 -4
  28. package/src/server/lib/lifecycle/tls.test.ts +6 -1
  29. package/src/server/lib/panels/git-update.server.test.ts +20 -0
  30. package/src/server/lib/panels/git-update.server.ts +20 -4
  31. package/src/server/lib/panels/sync.server.ts +9 -1
  32. package/src/server/lib/panels/update.server.test.ts +193 -0
  33. package/src/server/lib/panels/update.server.ts +210 -0
  34. package/src/server/lib/plugins/server-half.server.ts +42 -0
  35. package/src/server/lib/terminal/attach-replay.test.ts +26 -8
  36. package/src/server/routes/panels/install-route.test.ts +238 -0
  37. package/src/server/routes/panels/install.ts +36 -64
  38. package/src/server/routes/panels/panel-routes.test-util.ts +6 -1
  39. package/src/server/routes/panels/routes.test.ts +1 -118
  40. package/src/shared/lib/icons/icon-paint-css.test.ts +104 -25
  41. package/src/shared/lib/icons/icon-paint-css.ts +60 -50
  42. package/src/shared/lib/icons/icon-paint-panel.ts +16 -7
  43. package/src/shared/lib/icons/icon-paint-weight.ts +123 -0
  44. package/src/shared/lib/icons/icon-tone.ts +166 -0
  45. package/src/shared/lib/icons/tint-hues.generated.ts +50 -3
  46. package/src/shared/lib/icons/tint.test.ts +75 -15
  47. package/src/shared/lib/icons/tint.ts +40 -11
  48. package/src/shared/lib/panels/update.test.ts +107 -0
  49. package/src/shared/lib/panels/update.ts +73 -0
  50. package/src/shared/lib/theme/color.ts +50 -0
@@ -2,7 +2,7 @@
2
2
  "id": "/",
3
3
  "name": "Kabmo",
4
4
  "short_name": "Kabmo",
5
- "description": "Browser console and diagnostic workbench for AI coding agents.",
5
+ "description": "Web console and diagnostic workbench for AI coding agents.",
6
6
  "display": "standalone",
7
7
  "display_override": ["window-controls-overlay", "standalone"],
8
8
  "background_color": "#0B5D3B",
package/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <meta name="apple-mobile-web-app-title" content="Kabmo" />
13
13
  <meta
14
14
  name="description"
15
- content="A light e-ink paper developer dashboard for AI Oh-My-Pi agent sessions — a browser console for CI/CD deployments."
15
+ content="A light e-ink paper developer dashboard for AI Oh-My-Pi agent sessions — a web console for CI/CD deployments."
16
16
  />
17
17
  <title>Kabmo</title>
18
18
  <!-- Inline and in the head on purpose: this has to be registered BEFORE the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kabmo-labs/kabmo",
3
- "version": "0.19.0",
3
+ "version": "0.21.1",
4
4
  "description": "Web console and diagnostic workbench for AI coding agents — Elysia + Preact on Bun.",
5
5
  "license": "MIT",
6
6
  "author": "Wijanarko Putra Rajeb <wijanarko.rajeb@gmail.com>",
@@ -2,7 +2,7 @@
2
2
  "id": "/",
3
3
  "name": "Kabmo",
4
4
  "short_name": "Kabmo",
5
- "description": "Browser console and diagnostic workbench for AI coding agents.",
5
+ "description": "Web console and diagnostic workbench for AI coding agents.",
6
6
  "display": "standalone",
7
7
  "display_override": ["window-controls-overlay", "standalone"],
8
8
  "background_color": "#0B5D3B",
@@ -127,13 +127,16 @@ describe('switch knob', () => {
127
127
 
128
128
  test('a knob on a switch keeps its fill under the glass surface', async () => {
129
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);
130
+ // The exemption lives INSIDE the well rule, as an `:not()`. It was a second
131
+ // rule first ("…except a knob on a switch"), and that rule never applied:
132
+ // `[role="switch"] .bg-canvas` is (0,4,0) against the well's (0,5,0), so the
133
+ // well won and every knob computed `rgba(0,0,0,0)` — a plain pill with no
134
+ // "on" position, on both layouts.
135
+ const start = glass.indexOf('[data-surface="glass"] .app-window .bg-canvas');
136
+ expect(start).toBeGreaterThan(-1);
137
+ const selector = glass.slice(start, glass.indexOf('{', start));
138
+ expect(selector).toContain(':not([role="switch"] *)');
139
+ // A same-property override anywhere would be the same race again.
140
+ expect(glass).not.toContain('[data-surface="glass"] .app-window [role="switch"] .bg-canvas');
138
141
  });
139
142
  });
@@ -0,0 +1,124 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * A PANEL's mark — one colour per panel, on every surface.
8
+ *
9
+ * Rendered with `h()` (no JSX) against happy-dom.
10
+ *
11
+ * Three facts are load-bearing here, and each was a real defect:
12
+ *
13
+ * - **A built-in view takes its PANEL id's hue**, and it says so with `builtin`,
14
+ * not by inference from whether it has an icon. The rail used to hash the panel
15
+ * id while Settings drew the bare glyph and took the GLYPH's hue, so `Files`
16
+ * was `hsl(0 …)` in one place and `hsl(320 …)` in the other.
17
+ * - **A plugin keeps its OWN mark colour**, which is keyed by its name — the same
18
+ * key its marketplace card uses.
19
+ * - **Both stamp the LIGHT TONE** for that hue. Light's paint is a solved hex
20
+ * (`icon-tone.ts`), so a runtime hue with no tone falls back to the dated pair
21
+ * the tone replaced — visible as one dull mark in an otherwise bright rail.
22
+ */
23
+
24
+ import { afterAll, afterEach, beforeEach, describe, expect, test } from 'bun:test';
25
+ import { Window } from 'happy-dom';
26
+ import { h, render } from 'preact';
27
+ import type { ComponentChild } from 'preact';
28
+ import { act } from 'preact/test-utils';
29
+ import { PanelMark } from '@/client/components/common/panel-mark';
30
+ import { ICON_TONES } from '@/shared/lib/icons/tint-hues.generated';
31
+ import { hashHue } from '@/shared/lib/icons/tint';
32
+ import { resolvePanelHues } from '@/shared/lib/workspace/panel-hues';
33
+
34
+ const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
35
+ const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
36
+
37
+ let container: HTMLElement;
38
+
39
+ beforeEach(() => {
40
+ const win = new Window({ url: 'http://localhost' });
41
+ const target = globalThis as unknown as Record<string, unknown>;
42
+ for (const key of DOM_GLOBALS) {
43
+ if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
44
+ target[key] = (win as unknown as Record<string, unknown>)[key];
45
+ }
46
+ container = document.createElement('div');
47
+ document.body.appendChild(container);
48
+ });
49
+
50
+ afterEach(() => {
51
+ render(null, container);
52
+ container.remove();
53
+ });
54
+
55
+ afterAll(() => {
56
+ const target = globalThis as unknown as Record<string, unknown>;
57
+ for (const key of DOM_GLOBALS) {
58
+ if (key in nativeGlobals) target[key] = nativeGlobals[key];
59
+ else delete target[key];
60
+ }
61
+ });
62
+
63
+ function paint(node: ComponentChild): HTMLElement {
64
+ act(() => {
65
+ render(node, container);
66
+ });
67
+ const mark = container.querySelector<HTMLElement>('[data-panel-mark]');
68
+ if (!mark) throw new Error('no panel mark rendered');
69
+ return mark;
70
+ }
71
+
72
+ describe('PanelMark', () => {
73
+ test('a built-in view takes the hue of its PANEL id, resolved over the whole set', () => {
74
+ // Not the glyph's hue: `Files` draws `lucide-files` (320°), but the panel's
75
+ // own id hashes to 0°. One panel, one colour, on every surface.
76
+ const mark = paint(h(PanelMark, { panelId: 'files', builtin: true, name: 'Files', size: 20 }));
77
+ const hue = Number(mark.style.getPropertyValue('--panel-hue'));
78
+
79
+ expect(hue).toBe(resolvePanelHues().get('files')!);
80
+ expect(mark.style.getPropertyValue('--panel-tone')).toBe(ICON_TONES[hue]!);
81
+ });
82
+
83
+ test('a plugin mark is keyed by its NAME, the same key its card uses', () => {
84
+ // Keying a plugin panel by its slot id gave one plugin two colours: the rail
85
+ // drew the slot's hash, its marketplace card drew the name's.
86
+ const mark = paint(h(PanelMark, { panelId: 'plugin:git-forge', builtin: false, name: 'git-forge', size: 20 }));
87
+ const hue = hashHue('git-forge');
88
+
89
+ expect(Number(mark.style.getPropertyValue('--panel-hue'))).toBe(hue);
90
+ expect(mark.style.getPropertyValue('--panel-tone')).toBe(ICON_TONES[hue]!);
91
+ });
92
+
93
+ test('a declared brand colour rides alongside the tone, as a clamped pair', () => {
94
+ // The plugin author's colour is theirs: it is surfaced as a pair the
95
+ // stylesheet reads BEFORE the hue, and `data-declared` exempts it from the
96
+ // rail's idle filter so one brand is not two shades in two places.
97
+ const mark = paint(
98
+ h(PanelMark, { panelId: 'plugin:stats', builtin: false, name: 'stats', color: '#f59e0b', size: 20 }),
99
+ );
100
+
101
+ expect(mark.getAttribute('data-declared')).toBe('');
102
+ expect(mark.style.getPropertyValue('--panel-color-light')).toMatch(/^#[0-9a-f]{6}$/);
103
+ expect(mark.style.getPropertyValue('--panel-color-dark')).toMatch(/^#[0-9a-f]{6}$/);
104
+ // The tone is still stamped: a declared colour that cannot be parsed must not
105
+ // leave the mark on the dated fallback.
106
+ expect(mark.style.getPropertyValue('--panel-tone')).toMatch(/^#[0-9a-f]{6}$/);
107
+ });
108
+
109
+ test('no declared colour leaves both colour variables unset', () => {
110
+ const mark = paint(h(PanelMark, { panelId: 'files', builtin: true, name: 'Files', size: 20 }));
111
+
112
+ expect(mark.getAttribute('data-declared')).toBeNull();
113
+ expect(mark.style.getPropertyValue('--panel-color-light')).toBe('');
114
+ expect(mark.style.getPropertyValue('--panel-color-dark')).toBe('');
115
+ });
116
+
117
+ test('an idle mark says so through the attribute, not through its colour', () => {
118
+ // The state is a luminance filter in the stylesheet; a caller's `text-ink/30`
119
+ // would outrank the hue and paint the rail monochrome, which is what the
120
+ // attribute replaced.
121
+ expect(paint(h(PanelMark, { panelId: 'files', builtin: true, name: 'Files', size: 20, idle: true })).getAttribute('data-idle')).toBe('');
122
+ expect(paint(h(PanelMark, { panelId: 'git', builtin: true, name: 'Git', size: 20 })).getAttribute('data-idle')).toBeNull();
123
+ });
124
+ });
@@ -32,6 +32,7 @@
32
32
 
33
33
  import type { ReactNode } from 'preact/compat';
34
34
  import { legiblePair } from '@/shared/lib/theme/legibility';
35
+ import { hashHue, iconTone } from '@/shared/lib/icons/tint';
35
36
  import { usePanelHues } from '@/client/hooks/workspace/panel-hues';
36
37
  import { panelHueOf } from '@/shared/lib/workspace/panel-hues';
37
38
  import { PluginMark } from '@/client/components/settings/categories/panel-plugins/PluginMark';
@@ -77,6 +78,12 @@ export function PanelMark({
77
78
  }: PanelMarkProps) {
78
79
  const hues = usePanelHues();
79
80
  const declared = color ? legiblePair(color) : null;
81
+ // The panel's hue, whichever family it is. A built-in view takes its id's hue
82
+ // (resolved over the whole set, so the answer cannot depend on the surface); a
83
+ // plugin takes the hue of its name, which is the one its own mark stamps. Both
84
+ // then need the LIGHT TONE for that hue — the solved table, since a panel's
85
+ // hue is only known at runtime and therefore cannot be a generated CSS row.
86
+ const hue = builtin ? panelHueOf(hues, panelId) : hashHue(name);
80
87
  return (
81
88
  <span
82
89
  className={className ?? 'inline-flex'}
@@ -86,7 +93,8 @@ export function PanelMark({
86
93
  // the rail's idle filter is exempted by this attribute.
87
94
  data-declared={declared ? '' : undefined}
88
95
  style={{
89
- ...(builtin ? { '--panel-hue': String(panelHueOf(hues, panelId)) } : {}),
96
+ '--panel-hue': String(hue),
97
+ '--panel-tone': iconTone(hue),
90
98
  ...(declared ? { '--panel-color-light': declared.light } : {}),
91
99
  ...(declared?.dark ? { '--panel-color-dark': declared.dark } : {}),
92
100
  }}
@@ -131,6 +131,8 @@ describe('PluginToolbar', () => {
131
131
  gitCount: 1,
132
132
  onSetAutoUpdate: async () => true,
133
133
  onCheckUpdates: async () => true,
134
+ updateCount: 0,
135
+ onUpdateAll: async () => true,
134
136
  onRefresh: () => {},
135
137
  }),
136
138
  );
@@ -146,6 +148,8 @@ describe('PluginToolbar', () => {
146
148
  gitCount: 1,
147
149
  onSetAutoUpdate: async () => true,
148
150
  onCheckUpdates: async () => true,
151
+ updateCount: 0,
152
+ onUpdateAll: async () => true,
149
153
  onRefresh: () => {},
150
154
  }),
151
155
  );
@@ -162,6 +166,8 @@ describe('PluginToolbar', () => {
162
166
  gitCount: 0,
163
167
  onSetAutoUpdate: async () => true,
164
168
  onCheckUpdates: async () => true,
169
+ updateCount: 0,
170
+ onUpdateAll: async () => true,
165
171
  onRefresh: () => {},
166
172
  }),
167
173
  );
@@ -170,6 +176,46 @@ describe('PluginToolbar', () => {
170
176
  expect(check?.hasAttribute('disabled')).toBe(true);
171
177
  expect(check?.getAttribute('title')).toContain('No git-installed plugins');
172
178
  });
179
+
180
+ test('Update all is disabled with nothing to apply and counts what it would', () => {
181
+ const none = mount(
182
+ h(PluginToolbar, {
183
+ autoUpdate: false,
184
+ busy: null,
185
+ gitCount: 1,
186
+ onSetAutoUpdate: async () => true,
187
+ onCheckUpdates: async () => true,
188
+ updateCount: 0,
189
+ onUpdateAll: async () => true,
190
+ onRefresh: () => {},
191
+ }),
192
+ );
193
+ const idle = Array.from(none.querySelectorAll('button')).find((button) =>
194
+ button.textContent?.includes('Update all'),
195
+ );
196
+ expect(idle?.hasAttribute('disabled')).toBe(true);
197
+ expect(idle?.textContent).toBe('Update all');
198
+
199
+ render(null, container);
200
+ const waiting = mount(
201
+ h(PluginToolbar, {
202
+ autoUpdate: false,
203
+ busy: null,
204
+ gitCount: 1,
205
+ onSetAutoUpdate: async () => true,
206
+ onCheckUpdates: async () => true,
207
+ updateCount: 2,
208
+ onUpdateAll: async () => true,
209
+ onRefresh: () => {},
210
+ }),
211
+ );
212
+ const ready = Array.from(waiting.querySelectorAll('button')).find((button) =>
213
+ button.textContent?.includes('Update all'),
214
+ );
215
+ expect(ready?.hasAttribute('disabled')).toBe(false);
216
+ // The count is on the button, so one press says how much it will move.
217
+ expect(ready?.textContent).toBe('Update all (2)');
218
+ });
173
219
  });
174
220
 
175
221
  describe('SyncBlockedNotice', () => {
@@ -42,7 +42,7 @@ function shortSha(sha: string | null): string {
42
42
  }
43
43
 
44
44
  export function GitFreshness({ status, origin, busy, pluginId, onUpdate, latestVersion }: GitFreshnessProps) {
45
- const updating = busy === `update_git:${pluginId}`;
45
+ const updating = busy === `update:${pluginId}`;
46
46
 
47
47
  if (!status) {
48
48
  return (
@@ -3,7 +3,7 @@ import type { PanelGitStatus, PanelPluginStatus } from '@/shared/types';
3
3
  import { PluginCard } from '@/client/components/settings/categories/panel-plugins/PluginCard';
4
4
  import { PluginReadmeModal } from '@/client/components/settings/categories/panel-plugins/ReadmeModal';
5
5
  import type { PluginSlots } from '@/client/lib/plugins/slots';
6
- import { isNewer } from '@/shared/lib/updates/semver';
6
+ import { countPluginUpdates } from '@/shared/lib/panels/update';
7
7
  import type { LeftDockHandle } from '@/client/hooks/workspace/left-dock';
8
8
 
9
9
  interface InstalledGridProps {
@@ -24,7 +24,7 @@ interface InstalledGridProps {
24
24
  onSetEnabled: (pluginId: string, enabled: boolean) => Promise<boolean>;
25
25
  /** The last known freshness of each git-installed plugin. */
26
26
  gitStatus: Record<string, PanelGitStatus>;
27
- onUpdateGit: (pluginId: string) => Promise<boolean>;
27
+ onUpdate: (pluginId: string) => Promise<boolean>;
28
28
  }
29
29
 
30
30
  /**
@@ -52,15 +52,13 @@ export function InstalledList({
52
52
  onRemove,
53
53
  onSetEnabled,
54
54
  gitStatus,
55
- onUpdateGit,
55
+ onUpdate,
56
56
  }: InstalledGridProps) {
57
57
  const [reading, setReading] = useState<PanelPluginStatus | null>(null);
58
58
  const enabledCount = plugins.filter((plugin) => plugin.enabled).length;
59
- // `isNewer`, not `!==`: a clone whose remote is at the SAME version is current,
60
- // and counting it would announce an update that changes nothing.
61
- const updates = plugins.filter(
62
- (plugin) => plugin.latestVersion !== undefined && isNewer(plugin.latestVersion, plugin.version),
63
- ).length;
59
+ // The SAME predicate the cards and the Update-all button use, so the header
60
+ // cannot announce a count no button would act on.
61
+ const updates = countPluginUpdates(plugins, gitStatus);
64
62
 
65
63
  return (
66
64
  <section>
@@ -92,7 +90,7 @@ export function InstalledList({
92
90
  onBuild={onBuild}
93
91
  onRemove={onRemove}
94
92
  onSetEnabled={onSetEnabled}
95
- onUpdateGit={onUpdateGit}
93
+ onUpdate={onUpdate}
96
94
  />
97
95
  ))}
98
96
  </div>
@@ -0,0 +1,149 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The Update button on an INSTALLED plugin card.
8
+ *
9
+ * One button for two sources, and the card is where the difference shows: a git
10
+ * clone's Update sits in its freshness row beside the commit pair it would move,
11
+ * while a bundled install's sits in the footer because the store has no commit to
12
+ * show. A card that rendered neither — the reported shape before this change —
13
+ * left a plugin with a pending update and no way to apply it.
14
+ *
15
+ * The negative cases are the load-bearing ones: a current plugin, an unknown one
16
+ * and a local directory must offer NO button, because a button that does nothing
17
+ * is worse than none.
18
+ *
19
+ * Rendered with `h()` against happy-dom, following the panel suites.
20
+ */
21
+
22
+ import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
23
+ import { Window } from 'happy-dom';
24
+ import { h, render } from 'preact';
25
+ import { act } from 'preact/test-utils';
26
+ import { PluginCard } from '@/client/components/settings/categories/panel-plugins/PluginCard';
27
+ import type { LeftDockHandle } from '@/client/hooks/workspace/left-dock';
28
+ import type { PanelGitStatus, PanelPluginStatus } from '@/shared/types';
29
+ import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
30
+
31
+ let container: HTMLElement;
32
+
33
+ beforeAll(() => {
34
+ installDomGlobals(new Window({ url: 'http://localhost' }));
35
+ });
36
+
37
+ afterEach(() => {
38
+ if (container) render(null, container);
39
+ });
40
+
41
+ afterAll(() => {
42
+ restoreDomGlobals();
43
+ });
44
+
45
+ function mount(node: h.JSX.Element): HTMLElement {
46
+ container = document.createElement('div');
47
+ document.body.append(container);
48
+ act(() => render(node, container));
49
+ return container;
50
+ }
51
+
52
+ /** Only a real shape matters here: the card reads it for placement chips. */
53
+ const DOCK = {
54
+ enabled: false,
55
+ panels: [],
56
+ setEnabled: () => {},
57
+ setSide: () => {},
58
+ widthOf: () => 320,
59
+ commitWidth: () => {},
60
+ } satisfies LeftDockHandle;
61
+
62
+ const BASE: PanelPluginStatus = {
63
+ pluginId: 'demo',
64
+ name: 'Demo',
65
+ version: '1.0.0',
66
+ built: true,
67
+ isPackage: true,
68
+ enabled: true,
69
+ bundled: true,
70
+ origin: 'bundled',
71
+ gitOrigin: null,
72
+ };
73
+
74
+ const GIT_STATUS: PanelGitStatus = {
75
+ current: 'aaaaaaa',
76
+ latest: 'bbbbbbb',
77
+ updateAvailable: true,
78
+ checkedAt: Date.now(),
79
+ };
80
+
81
+ function card(plugin: PanelPluginStatus, gitStatus: PanelGitStatus | undefined, onUpdate = async () => true) {
82
+ return mount(
83
+ h(PluginCard, {
84
+ plugin,
85
+ entry: undefined,
86
+ failure: undefined,
87
+ iconUrl: undefined,
88
+ readmeUrl: undefined,
89
+ busy: null,
90
+ gitStatus,
91
+ dock: DOCK,
92
+ onReadme: () => {},
93
+ onBuild: async () => true,
94
+ onRemove: async () => true,
95
+ onSetEnabled: async () => true,
96
+ onUpdate,
97
+ }),
98
+ );
99
+ }
100
+
101
+ /** Every button whose label is exactly Update (the freshness row's and the footer's). */
102
+ function updateButtons(el: HTMLElement): HTMLButtonElement[] {
103
+ return Array.from(el.querySelectorAll('button')).filter((button) => button.textContent?.trim() === 'Update');
104
+ }
105
+
106
+ describe('a bundled install with an update', () => {
107
+ test('offers Update in the footer, and says what it would apply', () => {
108
+ const el = card({ ...BASE, latestVersion: '1.1.0' }, undefined);
109
+ const buttons = updateButtons(el);
110
+ expect(buttons).toHaveLength(1);
111
+ expect(buttons[0].getAttribute('title')).toContain('v1.1.0');
112
+ });
113
+
114
+ test('does not offer one when the store ships the same version', () => {
115
+ expect(updateButtons(card({ ...BASE, latestVersion: '1.0.0' }, undefined))).toHaveLength(0);
116
+ expect(updateButtons(card(BASE, undefined))).toHaveLength(0);
117
+ });
118
+ });
119
+
120
+ describe('a git clone', () => {
121
+ test('offers Update in its freshness row, and none in the footer', () => {
122
+ const el = card(
123
+ { ...BASE, bundled: false, origin: 'git', gitOrigin: 'https://x/y.git' },
124
+ GIT_STATUS,
125
+ );
126
+ const buttons = updateButtons(el);
127
+ expect(buttons).toHaveLength(1);
128
+ // The row's own button names the origin it would fetch from.
129
+ expect(buttons[0].getAttribute('title')).toContain('https://x/y.git');
130
+ });
131
+
132
+ test('offers none when the probe found nothing to fetch', () => {
133
+ const el = card(
134
+ { ...BASE, bundled: false, origin: 'git', gitOrigin: 'https://x/y.git' },
135
+ { ...GIT_STATUS, updateAvailable: false, latest: 'aaaaaaa' },
136
+ );
137
+ expect(updateButtons(el)).toHaveLength(0);
138
+ });
139
+ });
140
+
141
+ describe('a local directory', () => {
142
+ test('never offers Update, even with a newer version beside it', () => {
143
+ const el = card(
144
+ { ...BASE, bundled: false, origin: 'local', gitOrigin: null, latestVersion: '2.0.0' },
145
+ GIT_STATUS,
146
+ );
147
+ expect(updateButtons(el)).toHaveLength(0);
148
+ });
149
+ });
@@ -24,8 +24,9 @@
24
24
  * now share the version, author, origin and slot pieces in `Meta.tsx`.
25
25
  */
26
26
 
27
- import { Hammer, Loader2, BookOpen } from 'lucide-preact';
27
+ import { ArrowDownToLine, Hammer, Loader2, BookOpen } from 'lucide-preact';
28
28
  import type { PanelGitStatus, PanelPluginStatus } from '@/shared/types';
29
+ import { pluginUpdate } from '@/shared/lib/panels/update';
29
30
  import { PluginMark } from '@/client/components/settings/categories/panel-plugins/PluginMark';
30
31
  import { RemovePluginButton } from '@/client/components/settings/categories/panel-plugins/InstallForm';
31
32
  import { GitFreshness } from '@/client/components/settings/categories/panel-plugins/GitFreshness';
@@ -61,7 +62,7 @@ interface PluginCardProps {
61
62
  onBuild: (pluginId: string) => Promise<boolean>;
62
63
  onRemove: (pluginId: string) => Promise<boolean>;
63
64
  onSetEnabled: (pluginId: string, enabled: boolean) => Promise<boolean>;
64
- onUpdateGit: (pluginId: string) => Promise<boolean>;
65
+ onUpdate: (pluginId: string) => Promise<boolean>;
65
66
  }
66
67
 
67
68
  export function PluginCard({
@@ -77,7 +78,7 @@ export function PluginCard({
77
78
  onBuild,
78
79
  onRemove,
79
80
  onSetEnabled,
80
- onUpdateGit,
81
+ onUpdate,
81
82
  }: PluginCardProps) {
82
83
  // The ENABLEMENT key is the panel key, not the plugin id: it is the id the
83
84
  // client filters its panel catalog by, so a switch that wrote the bare id
@@ -86,6 +87,9 @@ export function PluginCard({
86
87
  const toggling = busy === `enable:${panelKey}` || busy === `disable:${panelKey}`;
87
88
  const contributions = usePluginContributions(plugin.pluginId);
88
89
  const badges = contributionBadges(contributions, plugin.slots);
90
+ // One answer for both surfaces: a clone's Update lives in its freshness row,
91
+ // a bundled install's in the footer, and both ask this.
92
+ const pending = pluginUpdate(plugin, gitStatus);
89
93
 
90
94
  return (
91
95
  <article
@@ -211,14 +215,15 @@ export function PluginCard({
211
215
 
212
216
  {/* A git-installed plugin's freshness. Rendered for a clone only — a
213
217
  bundled install is kept current by Kabmo's own update, so a git row
214
- there would describe a remote it does not have. */}
218
+ there would describe a remote it does not have. A clone's Update sits
219
+ INSIDE this row, beside the commit pair it would move. */}
215
220
  {plugin.gitOrigin ? (
216
221
  <GitFreshness
217
222
  status={gitStatus}
218
223
  origin={plugin.gitOrigin}
219
224
  busy={busy}
220
225
  pluginId={plugin.pluginId}
221
- onUpdate={onUpdateGit}
226
+ onUpdate={onUpdate}
222
227
  latestVersion={plugin.latestVersion}
223
228
  />
224
229
  ) : null}
@@ -240,7 +245,29 @@ export function PluginCard({
240
245
  Rebuild
241
246
  </button>
242
247
  ) : null}
243
- {plugin.gitOrigin && gitStatus?.updateAvailable ? null : null}
248
+ {/* A BUNDLED install's Update, in the footer rather than a freshness row:
249
+ its source is the store, which has no commit to show. A clone's update
250
+ is the one above, so this would be a second button for one action. */}
251
+ {pending && !plugin.gitOrigin ? (
252
+ <button
253
+ type="button"
254
+ onClick={() => void onUpdate(plugin.pluginId)}
255
+ disabled={busy !== null}
256
+ title={
257
+ pending.version
258
+ ? `Apply the store's copy of v${pending.version} — your edited files are left untouched, and the update is refused if they conflict`
259
+ : "Apply the store's copy — your edited files are left untouched, and the update is refused if they conflict"
260
+ }
261
+ className="flex items-center gap-1 px-1.5 py-0.5 text-[10px] rounded border border-warning/50 text-warning hover:bg-warning/10 disabled:opacity-40"
262
+ >
263
+ {busy === `update:${plugin.pluginId}` ? (
264
+ <Loader2 size={11} className="animate-spin" />
265
+ ) : (
266
+ <ArrowDownToLine size={11} />
267
+ )}
268
+ Update
269
+ </button>
270
+ ) : null}
244
271
  <span className="ml-auto flex items-center gap-1">
245
272
  {readmeUrl ? (
246
273
  <button
@@ -21,6 +21,7 @@ import { h, render } from 'preact';
21
21
  import type { ComponentChild } from 'preact';
22
22
  import { act } from 'preact/test-utils';
23
23
  import { PluginMark } from '@/client/components/settings/categories/panel-plugins/PluginMark';
24
+ import { ICON_TONES } from '@/shared/lib/icons/tint-hues.generated';
24
25
 
25
26
  const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'Event'] as const;
26
27
  /** The runner's own globals, restored on teardown — deleting them would strip
@@ -125,6 +126,20 @@ describe('PluginMark', () => {
125
126
  expect(paint(h(PluginMark, { name: 'Another Plugin' })).querySelector('span')?.style.getPropertyValue('--icon-hue')).not.toBe(hue);
126
127
  });
127
128
 
129
+ test('a plugin mark stamps the LIGHT tone for its hue, not just the hue', () => {
130
+ // The hue alone is enough for dark (one `hsl()` pair) but not for light: the
131
+ // light paint is a solved per-hue hex, and a plugin's hue exists only at
132
+ // runtime, so no generated CSS row can carry it. Without this stamp a plugin
133
+ // would fall back to the dated `hsl(H 60% 30%)` while every glyph beside it
134
+ // got the brighter tone — the reported muddiness, on one icon only.
135
+ const badge = paint(h(PluginMark, { name: 'Demo Plugin' })).querySelector('span');
136
+ const hue = Number(badge?.style.getPropertyValue('--icon-hue'));
137
+ const tone = badge?.style.getPropertyValue('--icon-tone') ?? '';
138
+
139
+ expect(tone).toMatch(/^#[0-9a-f]{6}$/);
140
+ expect(tone).toBe(ICON_TONES[hue]);
141
+ });
142
+
128
143
  test('the initials fallback takes the same colour hook as a vector mark', () => {
129
144
  const badge = paint(h(PluginMark, { name: 'Session Info' })).querySelector('span');
130
145
 
@@ -40,7 +40,7 @@
40
40
  */
41
41
 
42
42
  import { providerInitials } from '@/shared/lib/models/provider/glyph';
43
- import { hashHue } from '@/shared/lib/icons/tint';
43
+ import { hashHue, iconTone } from '@/shared/lib/icons/tint';
44
44
  import { legiblePair } from '@/shared/lib/theme/legibility';
45
45
 
46
46
  interface PluginMarkProps {
@@ -70,8 +70,12 @@ export function PluginMark({ name, iconUrl, color, size = 16, tile = false }: Pl
70
70
  // (`legiblePair`): a bright hex like `#34d399` is 1.9:1 on white paper, so the
71
71
  // light and dark values are derived instead of trusted.
72
72
  const declared = color ? legiblePair(color) : null;
73
+ const hueValue = hashHue(name);
73
74
  const hue = {
74
- '--icon-hue': String(hashHue(name)),
75
+ '--icon-hue': String(hueValue),
76
+ // The LIGHT tone for that hue, from the same solved table the glyph rows
77
+ // emit: a plugin's hue is runtime-only, so it cannot be a generated CSS row.
78
+ '--icon-tone': iconTone(hueValue),
75
79
  ...(declared ? { '--plugin-declared-light': declared.light } : {}),
76
80
  ...(declared?.dark ? { '--plugin-declared-dark': declared.dark } : {}),
77
81
  } as Record<string, string>;