@kabmo-labs/kabmo 0.14.0 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +1 -1
  3. package/dist/client/static/js/index-28pwtt69.css +1 -0
  4. package/dist/client/static/js/{index-nfsg1jpt.js → index-mx658m43.js} +624 -624
  5. package/marketplace/plugins/command-runner/README.md +5 -3
  6. package/marketplace/plugins/command-runner/package.json +2 -2
  7. package/marketplace/plugins/command-runner/src/app.tsx +3 -3
  8. package/marketplace/plugins/command-runner/src/panel/Groups.test.tsx +25 -21
  9. package/marketplace/plugins/command-runner/src/panel/Groups.tsx +4 -1
  10. package/marketplace/plugins/command-runner/src/server/ring.test.ts +41 -0
  11. package/marketplace/plugins/command-runner/src/server/run-types.ts +6 -0
  12. package/marketplace/plugins/command-runner/src/server/runner-harness.ts +69 -0
  13. package/marketplace/plugins/command-runner/src/server/runner-path.test.ts +127 -0
  14. package/marketplace/plugins/command-runner/src/server/runner.test.ts +2 -72
  15. package/marketplace/plugins/command-runner/src/server/runner.ts +31 -3
  16. package/package.json +2 -2
  17. package/src/client/components/common/session-row/index.tsx +11 -1
  18. package/src/client/components/common/session-row/session-row.test.tsx +10 -0
  19. package/src/client/components/layout/session-sidebar/modern/Skeleton.tsx +5 -4
  20. package/src/client/components/layout/session-sidebar/modern/WorkspaceHeader.tsx +11 -2
  21. package/src/client/components/layout/session-sidebar/modern/workspace-header.test.tsx +111 -0
  22. package/src/client/components/mobile/LayoutWrapper.tsx +11 -10
  23. package/src/client/components/mobile/open-file-payload.test.ts +29 -1
  24. package/src/client/components/mobile/open-file-payload.ts +28 -0
  25. package/src/client/components/settings/Modal.tsx +2 -2
  26. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +1 -0
  27. package/src/client/components/workspace/chat-timeline/ThinkingSection.test.tsx +117 -0
  28. package/src/client/components/workspace/chat-timeline/ThinkingSection.tsx +10 -9
  29. package/src/client/components/workspace/chat-timeline/block-chrome.test.tsx +21 -1
  30. package/src/client/components/workspace/editor/index.tsx +6 -8
  31. package/src/client/components/workspace/editor/viewers/SvgPreview.tsx +16 -2
  32. package/src/client/components/workspace/git-panel/branch-modal/index.tsx +4 -3
  33. package/src/client/components/workspace/git-panel/commit-modal/index.tsx +1 -1
  34. package/src/client/hooks/chat/timeline/index.ts +3 -6
  35. package/src/client/hooks/chat/timeline/jump-landing.ts +121 -0
  36. package/src/client/hooks/chat/timeline/jump-rail.ts +19 -10
  37. package/src/client/hooks/chat/timeline/row-window-reveal.ts +130 -0
  38. package/src/client/hooks/chat/timeline/row-window.test.ts +35 -0
  39. package/src/client/hooks/chat/timeline/row-window.ts +100 -134
  40. package/src/client/hooks/chat/timeline/scroll-probe.test-util.ts +23 -10
  41. package/src/client/hooks/chat/timeline/scroll.test.ts +61 -4
  42. package/src/client/hooks/chat/timeline/scroll.ts +77 -26
  43. package/src/client/hooks/chat/timeline/thinking-open.ts +67 -0
  44. package/src/client/hooks/workspace/missing-files.test.ts +20 -3
  45. package/src/client/hooks/workspace/missing-files.ts +41 -7
  46. package/src/client/tailwind.css +12 -1
  47. package/src/server/routes/fs/exists.test.ts +26 -1
  48. package/src/shared/lib/chat/timeline/trace-groups.test.ts +12 -0
  49. package/src/shared/lib/chat/timeline/trace-groups.ts +29 -2
  50. package/src/shared/lib/workspace/session-state/store.ts +5 -0
  51. package/dist/client/static/js/index-tsgy3gd1.css +0 -1
@@ -122,9 +122,11 @@ The custom group's header is **not** a disclosure: the `+` lives in it, and a
122
122
  button inside a button is invalid HTML whose inner click never fires.
123
123
 
124
124
  A **group header** is one command FILE — it collapses its rows, and carries the
125
- count. A **row** is one command — it collapses its own output. Both use the same
126
- reveal, and a collapsed body leaves the tab order entirely (its rows cannot be
127
- reached with `Tab` or announced), so a closed group is genuinely closed.
125
+ count. Every group starts CLOSED, so the panel opens as a list of files; the
126
+ sketch above shows the ones the reader opened. A **row** is one command — it
127
+ collapses its own output. Both use the same reveal, and a collapsed body leaves
128
+ the tab order entirely (its rows cannot be reached with `Tab` or announced), so a
129
+ closed group is genuinely closed.
128
130
 
129
131
  ## Every command is a row that opens
130
132
 
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "command-runner",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "private": true,
5
5
  "description": "Lists a repository's commands and runs them, in the foreground or as background jobs.",
6
6
  "type": "module",
7
7
  "kabmo": {
8
8
  "id": "command-runner",
9
9
  "name": "Runner",
10
- "version": "0.1.1",
10
+ "version": "0.2.0",
11
11
  "description": "Lists a repository's commands and runs them, in the foreground or as background jobs.",
12
12
  "app": "dist/app.js",
13
13
  "server": "dist/server.js",
@@ -77,9 +77,9 @@ function CommandRunnerPanel() {
77
77
  // prefix is what keeps a plugin out of the host's key space. They are the two
78
78
  // panel-wide checkboxes this panel used to carry (`Output`, `Background`),
79
79
  // moved onto each command because the answer differs per command.
80
- // Which FILES the reader collapsed. Absent means expanded — the same shape the
81
- // todo panel uses for its phases, and the reason a workspace seen for the first
82
- // time shows its commands rather than hiding them.
80
+ // Which FILES the reader expanded. Absent means COLLAPSED — a workspace seen
81
+ // for the first time opens as a list of command files rather than every
82
+ // command in the repository; only an explicit `false` keeps one open.
83
83
  const [collapsedGroups, setCollapsedGroups] = useSessionState<Record<string, boolean>>(
84
84
  'commandRunner.collapsedGroups',
85
85
  {},
@@ -171,38 +171,32 @@ function rowDisclosures(): HTMLButtonElement[] {
171
171
  }
172
172
 
173
173
  describe('CommandGroups', () => {
174
- test('renders one collapsible group per file, expanded by default', async () => {
174
+ test('renders one collapsible group per file, collapsed by default', async () => {
175
175
  await mount();
176
176
 
177
177
  const headers = groupHeaders();
178
178
  expect(headers).toHaveLength(2);
179
179
  expect(headers[0].textContent).toContain('package.json');
180
180
  expect(headers[1].textContent).toContain('Makefile');
181
- // Absent from the map means EXPANDED: a workspace seen for the first time
182
- // must show its commands.
183
- expect(headers.every((h) => h.getAttribute('aria-expanded') === 'true')).toBe(true);
184
- // The group bodies are expanded, and every command row is inside one — the
185
- // two levels default independently: a group shows its rows, a row does not
186
- // show output it was never asked to keep.
181
+ // Absent from the map means COLLAPSED: the panel opens as a list of files,
182
+ // not every command in the repository.
183
+ expect(headers.every((h) => h.getAttribute('aria-expanded') === 'false')).toBe(true);
187
184
  for (const header of headers) {
188
- expect(bodyOf(header).getAttribute('data-expanded')).toBe('true');
185
+ expect(bodyOf(header).getAttribute('data-expanded')).toBe('false');
186
+ expect(bodyOf(header).hasAttribute('inert')).toBe(true);
189
187
  }
188
+ // The row level is independent: a row still does not show output it was
189
+ // never asked to keep.
190
190
  for (const row of rowDisclosures()) {
191
191
  expect(row.getAttribute('aria-expanded')).toBe('false');
192
192
  }
193
193
  });
194
194
 
195
- test('a collapsed group hides its rows AND takes them out of the tab order', async () => {
196
- await mount({ collapsedGroups: { 'package.json': true } });
195
+ test('an explicitly expanded group shows its rows AND puts them back in the tab order', async () => {
196
+ // Only the map's explicit `false` opens a group; the other file, absent
197
+ // from it, stays closed — an expansion is per file.
198
+ await mount({ collapsedGroups: { Makefile: false } });
197
199
 
198
- const pkgHeader = headerFor('package.json');
199
- expect(pkgHeader.getAttribute('aria-expanded')).toBe('false');
200
-
201
- const pkgBody = bodyOf(pkgHeader);
202
- expect(pkgBody.getAttribute('data-expanded')).toBe('false');
203
- expect(pkgBody.hasAttribute('inert')).toBe(true);
204
-
205
- // The OTHER group is untouched — a collapse is per file.
206
200
  const makeHeader = headerFor('Makefile');
207
201
  expect(makeHeader.getAttribute('aria-expanded')).toBe('true');
208
202
  const makeBody = bodyOf(makeHeader);
@@ -213,6 +207,13 @@ describe('CommandGroups', () => {
213
207
  // from whether the group hides it.)
214
208
  const row = rowDisclosures().find((b) => makeBody.contains(b))!;
215
209
  expect(hasInertAncestor(row)).toBe(false);
210
+
211
+ // The OTHER group is untouched — a collapse is per file.
212
+ const pkgHeader = headerFor('package.json');
213
+ expect(pkgHeader.getAttribute('aria-expanded')).toBe('false');
214
+ const pkgBody = bodyOf(pkgHeader);
215
+ expect(pkgBody.getAttribute('data-expanded')).toBe('false');
216
+ expect(pkgBody.hasAttribute('inert')).toBe(true);
216
217
  // In the COLLAPSED group the same question answers yes: the group is what
217
218
  // takes its rows out of the tab order.
218
219
  const hiddenRow = rowDisclosures().find((b) => pkgBody.contains(b))!;
@@ -221,9 +222,10 @@ describe('CommandGroups', () => {
221
222
 
222
223
  test('the group toggle reports the FILE, so the caller can persist it per file', async () => {
223
224
  await mount();
225
+ // The group starts collapsed, so the first click EXPANDS it.
224
226
  await act(async () => headerFor('Makefile').click());
225
227
  // Reporting an index would break the moment the scan reorders the list.
226
- expect(calls).toEqual(['group:Makefile:true']);
228
+ expect(calls).toEqual(['group:Makefile:false']);
227
229
  });
228
230
 
229
231
  test('every group header carries aria-controls naming its own body', async () => {
@@ -238,9 +240,11 @@ describe('CommandGroups', () => {
238
240
 
239
241
  test('a command row collapses independently of its group', async () => {
240
242
  // A run, so the row has something to open — without one its disclosure is
241
- // disabled, which is a different test.
243
+ // disabled, which is a different test. The group is explicitly opened, or
244
+ // the row's controls are inert behind it.
242
245
  const dev = finishedRun('package.json#package:dev', 'run-dev');
243
- await mount({ runs: [dev] });
246
+ await mount({ runs: [dev], collapsedGroups: { 'package.json': false } });
247
+ expect(headerFor('package.json').getAttribute('aria-expanded')).toBe('true');
244
248
 
245
249
  const rowDisclosure = rowDisclosures()[0];
246
250
  // A run OPENS the row, so it starts expanded and the click closes it.
@@ -266,7 +266,10 @@ export function CommandGroups({
266
266
  key={group.file}
267
267
  group={group}
268
268
  latest={latest}
269
- collapsed={collapsedGroups[group.file] === true}
269
+ // Absent means COLLAPSED: the panel opens as a list of files, and a
270
+ // reader opens the one they came for. Only an explicit `false`
271
+ // (the user expanded it) shows the rows.
272
+ collapsed={collapsedGroups[group.file] !== false}
270
273
  background={background}
271
274
  logs={logs}
272
275
  onToggleGroup={onToggleGroup}
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The pure half of the log buffer: the ring's tail read, and the ANSI strip a
8
+ * log is rendered through.
9
+ *
10
+ * Split from `runner.test.ts` when that file carried a third subject and crossed
11
+ * the ceiling. These cases need no process, so they are also the fast ones.
12
+ */
13
+
14
+ import { describe, expect, test } from 'bun:test';
15
+
16
+ import { ringText, stripAnsi } from './ring';
17
+
18
+ describe('ringText', () => {
19
+ test('returns the last N bytes of the ring', () => {
20
+ expect(ringText({ chunks: [Buffer.from('abcdefghij')], held: 10 }, 4)).toBe('ghij');
21
+ });
22
+
23
+ test('returns everything when the tail is larger than the buffer', () => {
24
+ expect(ringText({ chunks: [Buffer.from('abc')], held: 3 }, 1024)).toBe('abc');
25
+ });
26
+ });
27
+
28
+ describe('stripAnsi', () => {
29
+ test('removes colour and cursor sequences', () => {
30
+ // What a coloured build actually emits, including a 256-colour code.
31
+ expect(stripAnsi('\u001b[0m\u001b[2;38;5;11m$\u001b[0m make build')).toBe('$ make build');
32
+ });
33
+
34
+ test('removes an OSC sequence terminated by BEL', () => {
35
+ expect(stripAnsi('\u001b]0;title\u0007plain')).toBe('plain');
36
+ });
37
+
38
+ test('leaves ordinary text alone', () => {
39
+ expect(stripAnsi('12 pass · 0 fail')).toBe('12 pass · 0 fail');
40
+ });
41
+ });
@@ -54,4 +54,10 @@ export interface RunnerDeps {
54
54
  log(message: string, detail?: unknown): void;
55
55
  /** Read a plugin setting. */
56
56
  setting<T extends string | number | boolean>(key: string): Promise<T | undefined>;
57
+ /**
58
+ * The environment a run starts from — Kabmo's own, because this plugin's
59
+ * server half runs inside the host's process. A test hands in a minimal one
60
+ * to exercise the PATH repair without touching the runner's real environ.
61
+ */
62
+ env?: Record<string, string | undefined>;
57
63
  }
@@ -0,0 +1,69 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * The harness the registry's suites share: a registry whose host calls are
8
+ * recorded instead of sent, and a way to wait for a REAL process to reach a
9
+ * state.
10
+ *
11
+ * Extracted when `runner.test.ts` crossed the file ceiling with a second subject
12
+ * (executable resolution) beside the first (the run lifecycle). Both suites drive
13
+ * the same class against real processes, so the alternative — two copies of
14
+ * `makeRegistry` and `waitFor` — would let the two drift and would hide which
15
+ * one a failing assertion came from.
16
+ */
17
+
18
+ import { expect } from 'bun:test';
19
+
20
+ import { RunRegistry } from './runner';
21
+ import { scopeKeyOf } from './run-store';
22
+ import type { RunnerState } from '../protocol';
23
+
24
+ /** The scope every test run is recorded against. */
25
+ export const SCOPE = scopeKeyOf('/ws', '.');
26
+
27
+ /** A registry whose publish/log/setting calls are recorded instead of sent. */
28
+ export function makeRegistry(
29
+ settings: Record<string, unknown> = {},
30
+ env?: Record<string, string | undefined>,
31
+ ) {
32
+ const published: RunnerState[] = [];
33
+ const logs: string[] = [];
34
+ const registry = new RunRegistry({
35
+ publish: (state) => published.push(state),
36
+ log: (message) => logs.push(message),
37
+ setting: async <T extends string | number | boolean>(key: string) => settings[key] as T | undefined,
38
+ ...(env ? { env } : {}),
39
+ });
40
+ return { registry, published, logs };
41
+ }
42
+
43
+ /**
44
+ * Wait for a condition, so a test never sleeps for a FIXED time.
45
+ *
46
+ * The clock is real here on purpose, and this is the documented exception:
47
+ * every condition below is "an actual OS process reached a state" — a `sleep 30`
48
+ * child that the group kill reaped, a pipe that drained. Fake timers cannot
49
+ * advance a real process, and awaiting the registry's own promise is not
50
+ * possible because it deliberately keeps no per-run promise (a panel reads state,
51
+ * it does not await a run). The poll interval is 10 ms and the bound is generous,
52
+ * so a pass costs milliseconds and a failure names the condition.
53
+ */
54
+ export async function waitFor(done: () => boolean, timeoutMs = 10_000): Promise<void> {
55
+ const deadline = Date.now() + timeoutMs;
56
+ for (;;) {
57
+ if (done()) return;
58
+ if (Date.now() >= deadline) throw new Error('waitFor timed out');
59
+ const gate = Promise.withResolvers<void>();
60
+ setTimeout(gate.resolve, 10);
61
+ await gate.promise;
62
+ }
63
+ }
64
+
65
+ /** The run a registry holds, by its only id. */
66
+ export function onlyRun(state: RunnerState) {
67
+ expect(state.runs).toHaveLength(1);
68
+ return state.runs[0];
69
+ }
@@ -0,0 +1,127 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * Where a run's executable comes from, when the host itself was started with
8
+ * almost no PATH.
9
+ *
10
+ * This is the reported failure: a Kabmo started by launchd (the desktop app, a
11
+ * LaunchAgent, `--launch-mode=daemon`) inherits
12
+ * `/usr/bin:/bin:/usr/sbin:/sbin`, so `Bun.spawn` answered
13
+ * `Executable not found in $PATH: "bun"` for every row in the Command Runner
14
+ * panel — while the same command in the user's terminal ran, because a terminal
15
+ * launches a LOGIN shell that re-reads the profile and a plugin's `Bun.spawn`
16
+ * has no profile to read.
17
+ *
18
+ * The run is driven against a REAL process for the same reason the lifecycle
19
+ * suite is: the property under test is "the OS found and started this binary",
20
+ * which no fake spawn can show.
21
+ */
22
+
23
+ import { describe, expect, test } from 'bun:test';
24
+ import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
25
+ import { tmpdir } from 'node:os';
26
+ import { join } from 'node:path';
27
+
28
+ import { onlyRun, makeRegistry, waitFor, SCOPE } from './runner-harness';
29
+
30
+ /**
31
+ * Both cases are POSIX-only, for the two reasons `src/test-support/platform.ts`
32
+ * names — a plugin cannot import it, so the guard is the same one
33
+ * `runner.test.ts` uses beside it:
34
+ *
35
+ * - the probe is a `#!/bin/sh` stub whose only "executability" is mode `0o755`,
36
+ * and `CreateProcess` cannot start that file;
37
+ * - the repair under test is itself a no-op on Windows (`toolchainPathDirs`
38
+ * returns nothing there), so there is no PATH to assert about.
39
+ *
40
+ * A skip is named in the log rather than weakened into an assertion that passes
41
+ * on both platforms while proving nothing.
42
+ */
43
+ const testPosix = process.platform === 'win32' ? test.skip : test;
44
+
45
+ describe('RunRegistry executable resolution', () => {
46
+ testPosix('a command resolves when the host PATH has no toolchain directories', async () => {
47
+ // The probe binary exists ONLY under `$HOME/.bun/bin`, which the inherited
48
+ // PATH does not name, so a resolved run proves the repair appended it.
49
+ const home = mkdtempSync(join(tmpdir(), 'cr-path-'));
50
+ const bin = join(home, '.bun', 'bin');
51
+ mkdirSync(bin, { recursive: true });
52
+ const tool = join(bin, 'cr-probe-tool');
53
+ writeFileSync(tool, '#!/bin/sh\necho probe-ok\n');
54
+ chmodSync(tool, 0o755);
55
+ const env = { PATH: '/usr/bin:/bin', HOME: home };
56
+
57
+ try {
58
+ const { registry } = makeRegistry({}, env);
59
+ const started = await registry.start({
60
+ id: 'path',
61
+ sessionId: null,
62
+ scopeKey: SCOPE,
63
+ commandId: 'x#package:probe',
64
+ file: 'package.json',
65
+ cwd: home,
66
+ argv: ['cr-probe-tool'],
67
+ label: 'cr-probe-tool',
68
+ background: false,
69
+ });
70
+ expect(started).toEqual({ runId: 'path' });
71
+ await waitFor(() => onlyRun(registry.state()).status !== 'running');
72
+ expect(onlyRun(registry.state()).status).toBe('exited');
73
+ expect(registry.log('path', 4096)!.text).toContain('probe-ok');
74
+
75
+ // The repair has to reach the CHILD too, not just the spawn: `bun run dev`
76
+ // resolves `vite` from the PATH its own process was given.
77
+ const { registry: shell } = makeRegistry({}, env);
78
+ await shell.start({
79
+ id: 'path-child',
80
+ sessionId: null,
81
+ scopeKey: SCOPE,
82
+ commandId: 'x#package:path',
83
+ file: 'package.json',
84
+ cwd: home,
85
+ argv: ['sh', '-c', 'echo "CHILD_PATH=$PATH"'],
86
+ label: 'path probe',
87
+ background: false,
88
+ });
89
+ await waitFor(() => onlyRun(shell.state()).status !== 'running');
90
+ const childPath = /CHILD_PATH=(.*)/.exec(shell.log('path-child', 4096)!.text)?.[1] ?? '';
91
+ const segments = childPath.trim().split(':');
92
+ expect(segments).toContain(bin);
93
+ // The inherited entries keep their precedence.
94
+ expect(segments.slice(0, 2)).toEqual(['/usr/bin', '/bin']);
95
+ } finally {
96
+ rmSync(home, { recursive: true, force: true });
97
+ }
98
+ }, 20_000);
99
+
100
+ testPosix('a name that is already a path is left alone', async () => {
101
+ // A detector may write `./scripts/build.sh`; resolving that against PATH
102
+ // would run a different file than the one the command names.
103
+ const dir = mkdtempSync(join(tmpdir(), 'cr-path-rel-'));
104
+ const script = join(dir, 'run-me.sh');
105
+ writeFileSync(script, '#!/bin/sh\necho relative-ok\n');
106
+ chmodSync(script, 0o755);
107
+ try {
108
+ const { registry } = makeRegistry({}, { PATH: '/usr/bin:/bin', HOME: dir });
109
+ await registry.start({
110
+ id: 'relative',
111
+ sessionId: null,
112
+ scopeKey: SCOPE,
113
+ commandId: 'x#make:relative',
114
+ file: 'Makefile',
115
+ cwd: dir,
116
+ argv: ['./run-me.sh'],
117
+ label: './run-me.sh',
118
+ background: false,
119
+ });
120
+ await waitFor(() => onlyRun(registry.state()).status !== 'running');
121
+ expect(onlyRun(registry.state()).status).toBe('exited');
122
+ expect(registry.log('relative', 4096)!.text).toContain('relative-ok');
123
+ } finally {
124
+ rmSync(dir, { recursive: true, force: true });
125
+ }
126
+ }, 20_000);
127
+ });
@@ -28,52 +28,8 @@
28
28
 
29
29
  import { describe, expect, test } from 'bun:test';
30
30
 
31
- import { RunRegistry } from './runner';
32
- import { scopeKeyOf } from './run-store';
33
- import { RUN_BUFFER_BYTES, ringText, stripAnsi } from './ring';
34
- import type { RunnerState } from '../protocol';
35
-
36
- /** A registry whose publish/log/setting calls are recorded instead of sent. */
37
- function makeRegistry(settings: Record<string, unknown> = {}) {
38
- const published: RunnerState[] = [];
39
- const logs: string[] = [];
40
- const registry = new RunRegistry({
41
- publish: (state) => published.push(state),
42
- log: (message) => logs.push(message),
43
- setting: async <T extends string | number | boolean>(key: string) => settings[key] as T | undefined,
44
- });
45
- return { registry, published, logs };
46
- }
47
-
48
- /**
49
- * Wait for a condition, so a test never sleeps for a FIXED time.
50
- *
51
- * The clock is real here on purpose, and this is the documented exception:
52
- * every condition below is "an actual OS process reached a state" — a `sleep 30`
53
- * child that the group kill reaped, a pipe that drained. Fake timers cannot
54
- * advance a real process, and awaiting the registry's own promise is not
55
- * possible because it deliberately keeps no per-run promise (a panel reads state,
56
- * it does not await a run). The poll interval is 10 ms and the bound is generous,
57
- * so a pass costs milliseconds and a failure names the condition.
58
- */
59
- async function waitFor(done: () => boolean, timeoutMs = 10_000): Promise<void> {
60
- const deadline = Date.now() + timeoutMs;
61
- for (;;) {
62
- if (done()) return;
63
- if (Date.now() >= deadline) throw new Error('waitFor timed out');
64
- const gate = Promise.withResolvers<void>();
65
- setTimeout(gate.resolve, 10);
66
- await gate.promise;
67
- }
68
- }
69
-
70
- const SCOPE = scopeKeyOf('/ws', '.');
71
-
72
- /** The run a registry holds, by its only id. */
73
- function onlyRun(state: RunnerState) {
74
- expect(state.runs).toHaveLength(1);
75
- return state.runs[0];
76
- }
31
+ import { RUN_BUFFER_BYTES } from './ring';
32
+ import { makeRegistry, onlyRun, SCOPE, waitFor } from './runner-harness';
77
33
 
78
34
  describe('RunRegistry', () => {
79
35
  test('runs a command and records its output and exit code', async () => {
@@ -307,29 +263,3 @@ describe('RunRegistry', () => {
307
263
  expect(registry.log('nope', 1024)).toBeNull();
308
264
  });
309
265
  });
310
-
311
- describe('ringText', () => {
312
- test('returns the last N bytes of the ring', () => {
313
- expect(ringText({ chunks: [Buffer.from('abcdefghij')], held: 10 }, 4)).toBe('ghij');
314
- });
315
-
316
- test('returns everything when the tail is larger than the buffer', () => {
317
- expect(ringText({ chunks: [Buffer.from('abc')], held: 3 }, 1024)).toBe('abc');
318
- });
319
- });
320
-
321
- describe('stripAnsi', () => {
322
- test('removes colour and cursor sequences', () => {
323
- // What a coloured build actually emits, including a 256-colour code.
324
- expect(stripAnsi('\u001b[0m\u001b[2;38;5;11m$\u001b[0m make build')).toBe('$ make build');
325
- });
326
-
327
- test('removes an OSC sequence terminated by BEL', () => {
328
- expect(stripAnsi('\u001b]0;title\u0007plain')).toBe('plain');
329
- });
330
-
331
- test('leaves ordinary text alone', () => {
332
- expect(stripAnsi('12 pass · 0 fail')).toBe('12 pass · 0 fail');
333
- });
334
- });
335
-
@@ -12,7 +12,7 @@
12
12
  * ONE run and needs the process, while everything there happens to the SET.
13
13
  */
14
14
 
15
- import { signalName, stripKabmoHostEnv } from '@kabmo-labs/kabmo-sdk';
15
+ import { signalName, stripKabmoHostEnv, withToolchainPath } from '@kabmo-labs/kabmo-sdk';
16
16
 
17
17
  import type { Run } from './run-types';
18
18
  import { appendToRing, emptyRing } from './ring';
@@ -21,6 +21,23 @@ import { RunStore } from './run-store';
21
21
  /** How often a growing buffer is announced on the topic, per run. */
22
22
  const OUTPUT_PUBLISH_MS = 250;
23
23
 
24
+ /**
25
+ * The absolute path of a bare executable, or the name unchanged.
26
+ *
27
+ * `Bun.spawn` resolves a bare name against the `PATH` of the env it is handed —
28
+ * measured on 1.4.4, and that is why the repaired PATH alone would be enough.
29
+ * An absolute path removes the dependency on that detail anyway, and it is what
30
+ * turns "the file is there but the spawn searched elsewhere" into an ordinary
31
+ * `Executable not found` only when the binary really is absent.
32
+ *
33
+ * A name that already carries a separator is a path the detector wrote, so it is
34
+ * left alone: rewriting it would resolve it against the wrong directory.
35
+ */
36
+ function resolveExecutable(name: string, path: string | undefined): string {
37
+ if (!name || !path || name.includes('/') || name.includes('\\')) return name;
38
+ return Bun.which(name, { PATH: path }) ?? name;
39
+ }
40
+
24
41
  /** The registry the server half holds: one instance per plugin load. */
25
42
  export class RunRegistry extends RunStore {
26
43
  /**
@@ -73,8 +90,19 @@ export class RunRegistry extends RunStore {
73
90
 
74
91
  let proc: Bun.Subprocess;
75
92
  try {
93
+ // The environment the child gets, in two steps that answer two different
94
+ // problems: the host's own variables are REMOVED (see below), and the
95
+ // toolchain directories a GUI/launchd launch never had are ADDED. Without
96
+ // the second, every command this panel offers fails at `Bun.spawn` with
97
+ // `Executable not found in $PATH: "bun"` — measured under a daemon started
98
+ // by launchd, whose PATH is `/usr/bin:/bin:/usr/sbin:/sbin`, while the
99
+ // same command in the user's terminal ran fine.
100
+ const env = withToolchainPath(
101
+ stripKabmoHostEnv(this.deps.env ?? Bun.env, process.platform),
102
+ process.platform,
103
+ );
76
104
  proc = Bun.spawn({
77
- cmd: input.argv,
105
+ cmd: [resolveExecutable(input.argv[0], env.PATH), ...input.argv.slice(1)],
78
106
  cwd: input.cwd,
79
107
  stdout: 'pipe',
80
108
  stderr: 'pipe',
@@ -89,7 +117,7 @@ export class RunRegistry extends RunStore {
89
117
  // served by Kabmo" while the same command in a plain terminal (where
90
118
  // `PORT` is unset) ran on 3000. The rule is the SDK's, shared with the
91
119
  // host's own child spawns so the two cannot drift.
92
- env: stripKabmoHostEnv(Bun.env, process.platform),
120
+ env,
93
121
  });
94
122
  } catch (error) {
95
123
  // A missing binary THROWS here (measured), so this is the only path that
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kabmo-labs/kabmo",
3
- "version": "0.14.0",
3
+ "version": "0.15.0",
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>",
@@ -74,7 +74,7 @@
74
74
  "@codemirror/state": "6.7.6",
75
75
  "@codemirror/view": "6.43.15",
76
76
  "@fontsource/fira-code": "^5.3.0",
77
- "@kabmo-labs/kabmo-sdk": "0.1.1",
77
+ "@kabmo-labs/kabmo-sdk": "0.1.2",
78
78
  "@kabmo-labs/kabmo-ui": "0.0.2",
79
79
  "@shikijs/langs": "^4.4.3",
80
80
  "@shikijs/themes": "^4.4.3",
@@ -32,6 +32,16 @@
32
32
  * with: the header's own `px-1` is inside a container that starts at the list's
33
33
  * edge, and matching the row's padding to the header's is what makes the columns
34
34
  * line up.
35
+ *
36
+ * ## The touch row is exactly as tall as the folder header
37
+ *
38
+ * `h-8` — 32px — is the workspace header's height on touch (`WorkspaceHeader`),
39
+ * and the rows under it must match it or the list reads as two rhythms: a thin
40
+ * name over tall items. The row's own height is driven by its tallest child,
41
+ * the 28px trailing action box (`p-1.5` + a 16px glyph, see `TrailingSlot`), so
42
+ * 2px of vertical padding lands on 32px. `py-0.5`, not a fixed `h-8`: a row that
43
+ * carries a second line (a held prompt, a worktree badge) has to grow, and a
44
+ * fixed height would clip it.
35
45
  */
36
46
 
37
47
  import type { TargetedMouseEvent } from 'preact';
@@ -139,7 +149,7 @@ export function SessionRow({
139
149
  onClick={selectable ? onToggleSelect : onClick}
140
150
  onContextMenu={hasActions && !selectable ? menu.openAtCursor : undefined}
141
151
  className={`group/item relative flex w-full items-center rounded-lg text-xs transition-colors select-none cursor-pointer ${
142
- touch ? 'py-2.5 pl-1 pr-1' : 'py-[7px] pl-1 pr-1'
152
+ touch ? 'py-0.5 pl-1 pr-1' : 'py-[7px] pl-1 pr-1'
143
153
  } ${
144
154
  selectable && selected
145
155
  ? 'bg-ink/10 text-ink ring-1 ring-inset ring-ink/20'
@@ -137,6 +137,16 @@ describe('modern session row', () => {
137
137
  expect(el.textContent).toContain('5m');
138
138
  });
139
139
 
140
+ test('the touch row is as tall as the folder header, and can still grow', async () => {
141
+ const el = await mount({ density: 'touch', onRename: () => {} });
142
+ const row = el.querySelector('[data-testid="session-item"]');
143
+ // 2px of padding around the 28px trailing action box = the header's `h-8`.
144
+ expect(row?.className).toContain('py-0.5');
145
+ // Padding, never a fixed height: a held prompt or a worktree badge adds a
146
+ // line, and `h-8` would clip it.
147
+ expect(row?.className ?? '').not.toMatch(/\bh-8\b/);
148
+ });
149
+
140
150
  test('a row with nothing to offer draws no menu trigger', async () => {
141
151
  const el = await mount();
142
152
  expect(el.querySelector('[aria-label="Session actions"]')).toBeNull();
@@ -16,9 +16,10 @@
16
16
  *
17
17
  * The geometry is the live geometry, measured rather than approximated: the
18
18
  * workspace header is 26px (32 on touch) with its mark in the same 4px + 16px
19
- * (18px) gutter the real header uses, and the rows are 31px (44 on touch) —
20
- * the live row's own measured height, not `padding + bar`. A placeholder whose
21
- * heights differ from the content is a layout shift with extra steps.
19
+ * (18px) gutter the real header uses, and the rows are 31px (32 on touch, the
20
+ * header's own `h-8` — see `common/session-row`) — the live row's own measured
21
+ * height, not `padding + bar`. A placeholder whose heights differ from the
22
+ * content is a layout shift with extra steps.
22
23
  */
23
24
 
24
25
  const PLACEHOLDER_FOLDERS = [3, 2];
@@ -35,7 +36,7 @@ export function ModernSidebarSkeleton({ touch = false }: { touch?: boolean }) {
35
36
  {Array.from({ length: rows }, (_, rowIndex) => (
36
37
  <div
37
38
  key={rowIndex}
38
- className={`flex items-center gap-2 pl-1 pr-2 ${touch ? 'h-11' : 'h-[31px]'}`}
39
+ className={`flex items-center gap-2 pl-1 pr-2 ${touch ? 'h-8' : 'h-[31px]'}`}
39
40
  >
40
41
  <span
41
42
  className={`shrink-0 animate-pulse rounded-full bg-ink/10 ${