@kabmo-labs/kabmo 0.24.0 → 0.25.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/dist/client/index.html +1 -1
- package/dist/client/index.js +579 -510
- package/dist/client/static/js/index-bc9aa4mx.css +1 -0
- package/dist/client/static/js/{index-jcr5twtp.js → index-ga8cbpt4.js} +1072 -1174
- package/package.json +2 -4
- package/src/cli/lib/args.js +24 -1
- package/src/cli/lib/args.test.js +16 -0
- package/src/cli/lib/commands/session.js +233 -0
- package/src/cli/lib/commands/session.test.js +103 -0
- package/src/cli/main.js +1 -1
- package/src/client/components/common/ComposerPicker.tsx +3 -0
- package/src/client/components/common/code-surface/shiki.test.ts +82 -0
- package/src/client/components/common/code-surface/shiki.ts +28 -7
- package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +113 -0
- package/src/client/components/common/session-actions-menu/index.tsx +33 -2
- package/src/client/components/common/session-row/StatusSlot.tsx +4 -4
- package/src/client/components/common/session-row/index.tsx +27 -1
- package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +25 -12
- package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +66 -0
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +28 -3
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +36 -5
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +94 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +120 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +47 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +28 -35
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +18 -5
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +21 -4
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +27 -5
- package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
- package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +135 -118
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +4 -0
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
- package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +3 -1
- package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
- package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
- package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
- package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
- package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
- package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
- package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
- package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
- package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
- package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
- package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
- package/src/client/data/settings/omp-schema.json +1 -1
- package/src/client/data/theme/terminal.test.ts +25 -0
- package/src/client/data/theme/terminal.ts +96 -79
- package/src/client/hooks/chat/composer/items.test.ts +12 -26
- package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
- package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
- package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
- package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
- package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
- package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
- package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
- package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
- package/src/client/hooks/chat/timeline/send.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.ts +51 -50
- package/src/client/hooks/chat/timeline/use-fork-session.ts +49 -0
- package/src/client/hooks/models/use-harness-update.test.ts +193 -0
- package/src/client/hooks/models/use-harness-update.ts +202 -0
- package/src/client/hooks/workspace/child-expansion.ts +33 -0
- package/src/client/hooks/workspace/terminal/index.ts +17 -3
- package/src/client/hooks/workspace/terminal/socket.ts +9 -4
- package/src/client/lib/session-tree.test.ts +50 -0
- package/src/client/lib/session-tree.ts +59 -0
- package/src/client/tailwind.css +17 -11
- package/src/server/index.ts +2 -0
- package/src/server/lib/auth/guard.ts +10 -0
- package/src/server/lib/btw/session-copy.server.ts +6 -44
- package/src/server/lib/btw/session-copy.test.ts +2 -1
- package/src/server/lib/db/schema.ts +4 -0
- package/src/server/lib/db/seed-terminal.test.ts +1 -1
- package/src/server/lib/db/seed.test.ts +1 -1
- package/src/server/lib/harness/acp/background-work.test.ts +262 -0
- package/src/server/lib/harness/acp/background-work.ts +320 -0
- package/src/server/lib/harness/acp/client.ts +2 -2
- package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
- package/src/server/lib/harness/acp/gateway-env.ts +70 -0
- package/src/server/lib/harness/acp/prompt.test.ts +20 -0
- package/src/server/lib/harness/acp/prompt.ts +19 -3
- package/src/server/lib/harness/acp/session-background.test.ts +129 -0
- package/src/server/lib/harness/acp/session-exit.ts +31 -0
- package/src/server/lib/harness/acp/session-handshake.test.ts +108 -0
- package/src/server/lib/harness/acp/session-handshake.ts +27 -1
- package/src/server/lib/harness/acp/session-listeners.ts +31 -0
- package/src/server/lib/harness/acp/session-requests.ts +47 -0
- package/src/server/lib/harness/acp/session-turns.ts +20 -5
- package/src/server/lib/harness/acp/session.test-util.ts +23 -1
- package/src/server/lib/harness/acp/session.ts +59 -59
- package/src/server/lib/harness/acp/turn.test.ts +81 -0
- package/src/server/lib/harness/acp/turn.ts +26 -9
- package/src/server/lib/harness/acp/verbs.ts +12 -2
- package/src/server/lib/harness/launch.ts +3 -1
- package/src/server/lib/harness/spawn.server.ts +15 -2
- package/src/server/lib/harness/update-job-store.test.ts +126 -0
- package/src/server/lib/harness/update-job-store.ts +109 -0
- package/src/server/lib/harness/update-job.server.ts +203 -0
- package/src/server/lib/harness/update-worker.test.ts +153 -0
- package/src/server/lib/harness/update-worker.ts +197 -0
- package/src/server/lib/lifecycle/paths.ts +23 -0
- package/src/server/lib/omp/rpc/manager.ts +5 -5
- package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
- package/src/server/lib/omp/rpc/session-registry.ts +14 -2
- package/src/server/lib/omp/rpc/terminal-settle.ts +53 -5
- package/src/server/lib/omp/session/delete-flow.server.ts +47 -0
- package/src/server/lib/omp/session/delete.server.ts +5 -0
- package/src/server/lib/omp/session/rewind-file.ts +39 -21
- package/src/server/lib/omp/session/sidebar-data.server.ts +6 -6
- package/src/server/lib/omp/session/transcript-copy.ts +123 -0
- package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
- package/src/server/lib/sessions/agent-token.server.ts +134 -0
- package/src/server/lib/sessions/answers.server.test.ts +33 -0
- package/src/server/lib/sessions/answers.server.ts +37 -0
- package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
- package/src/server/lib/sessions/dispatch.server.ts +128 -0
- package/src/server/lib/sessions/fork.server.test.ts +209 -0
- package/src/server/lib/sessions/fork.server.ts +304 -0
- package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
- package/src/server/lib/sessions/lifecycle.server.ts +71 -0
- package/src/server/lib/sessions/notify.server.test.ts +112 -0
- package/src/server/lib/sessions/notify.server.ts +212 -0
- package/src/server/lib/sessions/relation-types.ts +76 -0
- package/src/server/lib/sessions/relations.server.test.ts +207 -0
- package/src/server/lib/sessions/relations.server.ts +337 -0
- package/src/server/lib/sessions/resolve.server.ts +106 -0
- package/src/server/lib/sessions/schema.server.ts +82 -0
- package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
- package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
- package/src/server/lib/sessions/spawn.server.test.ts +196 -0
- package/src/server/lib/sessions/spawn.server.ts +310 -0
- package/src/server/lib/terminal/attach-replay.test.ts +2 -2
- package/src/server/lib/terminal/output.test.ts +2 -2
- package/src/server/lib/terminal/output.ts +1 -1
- package/src/server/lib/terminal/resize.test.ts +99 -0
- package/src/server/lib/terminal/runtime.server.ts +26 -6
- package/src/server/lib/terminal/send-result.test.ts +18 -1
- package/src/server/lib/terminal/send-result.ts +26 -2
- package/src/server/lib/terminal/session.server.ts +6 -6
- package/src/server/lib/usage/new-api.test.ts +92 -0
- package/src/server/lib/usage/new-api.ts +131 -0
- package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
- package/src/server/lib/usage/provider-key.ts +33 -0
- package/src/server/lib/usage/providers.server.ts +10 -3
- package/src/server/lib/usage/vendor-balance.server.ts +4 -53
- package/src/server/lib/usage/vendor-http.ts +41 -0
- package/src/server/lib/usage/window.ts +55 -0
- package/src/server/routes/agent/command.ts +14 -1
- package/src/server/routes/agent/harness-command.ts +6 -0
- package/src/server/routes/agent/new.ts +15 -0
- package/src/server/routes/harness/add-provider.test.ts +9 -1
- package/src/server/routes/harness/import-action.ts +4 -0
- package/src/server/routes/harness/import.test.ts +1 -1
- package/src/server/routes/harness/index.ts +5 -1
- package/src/server/routes/harness/update-status.ts +26 -0
- package/src/server/routes/harness/update.test.ts +119 -0
- package/src/server/routes/harness/update.ts +59 -147
- package/src/server/routes/sessions/answer.ts +24 -0
- package/src/server/routes/sessions/batch-delete.ts +11 -5
- package/src/server/routes/sessions/delete.ts +4 -2
- package/src/server/routes/sessions/fork.ts +74 -0
- package/src/server/routes/sessions/index.ts +14 -0
- package/src/server/routes/sessions/relations.ts +85 -0
- package/src/server/routes/sessions/session.ts +4 -0
- package/src/server/routes/sessions/spawn.ts +134 -0
- package/src/server/routes/terminal/ws.ts +3 -3
- package/src/shared/lib/chat/composer/client.ts +31 -2
- package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
- package/src/shared/lib/chat/composer/delegation.ts +206 -0
- package/src/shared/lib/chat/notice-text.ts +1 -1
- package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
- package/src/shared/lib/code/ansi.ts +1 -1
- package/src/shared/lib/fonts/nerd-symbols.css +4 -3
- package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
- package/src/shared/lib/harness/provider-facts.test.ts +27 -0
- package/src/shared/lib/harness/providers.ts +35 -1
- package/src/shared/lib/harness/update-job.ts +33 -0
- package/src/shared/lib/harness/update-plan.test.ts +21 -6
- package/src/shared/lib/harness/update-plan.ts +12 -4
- package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
- package/src/shared/lib/omp/session/wait-idle.ts +12 -2
- package/src/shared/lib/theme/catalog.test.ts +13 -9
- package/src/shared/lib/theme/color.test.ts +2 -2
- package/src/shared/lib/theme/color.ts +4 -4
- package/src/shared/lib/theme/theme.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
- package/src/shared/lib/workspace/terminal/input.ts +33 -0
- package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/keys.ts +7 -7
- package/src/shared/types/chat.ts +1 -1
- package/src/shared/types/harness-update.ts +65 -0
- package/src/shared/types/omp/agent.ts +19 -2
- package/src/shared/types/workspace.ts +4 -0
- package/src/test-support/fake-omp-fork.ts +16 -2
- package/src/test-support/harness-table.test-util.ts +15 -1
- package/dist/client/static/js/index-z3w7n85q.css +0 -1
- package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
- package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The dialog's half of the background harness update.
|
|
8
|
+
*
|
|
9
|
+
* Three properties, and each one is a failure this design exists to prevent:
|
|
10
|
+
* a `202` means the install is running in a WORKER (so the card must follow it),
|
|
11
|
+
* a `409` must come back as the refusal it is (no second install), and a run
|
|
12
|
+
* already in flight must be ADOPTED when the card opens — otherwise a reload
|
|
13
|
+
* loses the spinner and the user presses the button again.
|
|
14
|
+
*
|
|
15
|
+
* Every wait here is on the settle callback, not on a duration: the poll cadence
|
|
16
|
+
* is handed in at 1ms, so a race shows up as a missing signal rather than as a
|
|
17
|
+
* sleep that "usually" covers it.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { afterEach, beforeEach, describe, expect, test } from 'bun:test';
|
|
21
|
+
import { Window } from 'happy-dom';
|
|
22
|
+
import { h, render } from 'preact';
|
|
23
|
+
import { act } from 'preact/test-utils';
|
|
24
|
+
import { useHarnessUpdate } from '@/client/hooks/models/use-harness-update';
|
|
25
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
26
|
+
import type { HarnessUpdateJob } from '@/shared/types/harness-update';
|
|
27
|
+
|
|
28
|
+
const realFetch = Bun.fetch;
|
|
29
|
+
const TEST_POLL_MS = 1;
|
|
30
|
+
let container: HTMLElement;
|
|
31
|
+
let calls: string[] = [];
|
|
32
|
+
let postPayload: { status: number; body: unknown } = { status: 202, body: {} };
|
|
33
|
+
let statusPayload: HarnessUpdateJob | null = null;
|
|
34
|
+
|
|
35
|
+
function job(overrides: Partial<HarnessUpdateJob> = {}): HarnessUpdateJob {
|
|
36
|
+
return {
|
|
37
|
+
harness: 'claude',
|
|
38
|
+
label: 'claude',
|
|
39
|
+
startedAt: Date.now(),
|
|
40
|
+
finishedAt: null,
|
|
41
|
+
pid: 1234,
|
|
42
|
+
steps: [{ part: 'adapter', command: 'npm install -g x', argv: ['npm', 'install', '-g', 'x'], state: 'running', code: null }],
|
|
43
|
+
output: '',
|
|
44
|
+
ok: null,
|
|
45
|
+
message: null,
|
|
46
|
+
applied: false,
|
|
47
|
+
repointed: null,
|
|
48
|
+
...overrides,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
beforeEach(() => {
|
|
53
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
54
|
+
container = document.createElement('div');
|
|
55
|
+
document.body.appendChild(container);
|
|
56
|
+
calls = [];
|
|
57
|
+
statusPayload = null;
|
|
58
|
+
postPayload = { status: 202, body: {} };
|
|
59
|
+
(globalThis as unknown as Record<string, unknown>).fetch = async (input: unknown, init?: { method?: string }) => {
|
|
60
|
+
calls.push(`${init?.method ?? 'GET'} ${String(input)}`);
|
|
61
|
+
if (init?.method === 'POST') {
|
|
62
|
+
return new Response(JSON.stringify(postPayload.body), { status: postPayload.status });
|
|
63
|
+
}
|
|
64
|
+
return new Response(JSON.stringify({ job: statusPayload }), { status: 200 });
|
|
65
|
+
};
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
afterEach(() => {
|
|
69
|
+
render(null, container);
|
|
70
|
+
container.remove();
|
|
71
|
+
restoreDomGlobals();
|
|
72
|
+
(globalThis as unknown as Record<string, unknown>).fetch = realFetch;
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
interface Harness {
|
|
76
|
+
current: () => ReturnType<typeof useHarnessUpdate>;
|
|
77
|
+
/** Resolves with what the card was told when the run settled. */
|
|
78
|
+
settled: Promise<{ message: string; ok: boolean }>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function mount(): Harness {
|
|
82
|
+
const { promise, resolve } = Promise.withResolvers<{ message: string; ok: boolean }>();
|
|
83
|
+
const box = { latest: null as ReturnType<typeof useHarnessUpdate> | null };
|
|
84
|
+
function Consumer() {
|
|
85
|
+
box.latest = useHarnessUpdate((message, ok) => resolve({ message, ok }), { pollMs: TEST_POLL_MS });
|
|
86
|
+
return null;
|
|
87
|
+
}
|
|
88
|
+
const host = document.createElement('div');
|
|
89
|
+
container.appendChild(host);
|
|
90
|
+
act(() => render(h(Consumer, {}), host));
|
|
91
|
+
return {
|
|
92
|
+
current: () => {
|
|
93
|
+
if (!box.latest) throw new Error('consumer did not render');
|
|
94
|
+
return box.latest;
|
|
95
|
+
},
|
|
96
|
+
settled: promise,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/** Let the mount's own status read settle. */
|
|
101
|
+
async function flush(): Promise<void> {
|
|
102
|
+
await act(async () => {
|
|
103
|
+
await Promise.resolve();
|
|
104
|
+
await Promise.resolve();
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
describe('useHarnessUpdate', () => {
|
|
109
|
+
test('a 202 starts a run and the finished record settles it', async () => {
|
|
110
|
+
const harness = mount();
|
|
111
|
+
await flush();
|
|
112
|
+
expect(harness.current().updating).toBeNull();
|
|
113
|
+
|
|
114
|
+
postPayload = { status: 202, body: { started: true, job: job() } };
|
|
115
|
+
// The worker is already done by the time the first status read lands: this
|
|
116
|
+
// is the spinners-then-message path, with no real delay anywhere.
|
|
117
|
+
statusPayload = job({ finishedAt: Date.now(), pid: null, ok: true, applied: true, message: 'claude updated (adapter)' });
|
|
118
|
+
|
|
119
|
+
const started: { problem: string | null } = { problem: 'unset' };
|
|
120
|
+
await act(async () => {
|
|
121
|
+
started.problem = await harness.current().start('claude');
|
|
122
|
+
});
|
|
123
|
+
expect(started.problem).toBeNull();
|
|
124
|
+
// The spinner's own state is pinned by the adoption case below; here the
|
|
125
|
+
// record was already finished, so the run settles inside the same flush.
|
|
126
|
+
expect(await harness.settled).toEqual({ message: 'claude updated (adapter)', ok: true });
|
|
127
|
+
expect(harness.current().updating).toBeNull();
|
|
128
|
+
// The record outlives the spinner: the log panel reads it AFTER the run, and
|
|
129
|
+
// a cleared `job` would close the reader's only view of what was installed.
|
|
130
|
+
expect(harness.current().job?.message).toBe('claude updated (adapter)');
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
test('a 409 comes back as the refusal, and its record is still readable', async () => {
|
|
134
|
+
// The refusal carries the RUNNING record (`job`), so the press that lost the
|
|
135
|
+
// race can still open the log of the install it collided with.
|
|
136
|
+
postPayload = {
|
|
137
|
+
status: 409,
|
|
138
|
+
body: { error: 'claude update is already running — it continues in the background', job: job({ pid: 999 }) },
|
|
139
|
+
};
|
|
140
|
+
const harness = mount();
|
|
141
|
+
await flush();
|
|
142
|
+
|
|
143
|
+
const refusal: { problem: string | null } = { problem: null };
|
|
144
|
+
await act(async () => {
|
|
145
|
+
refusal.problem = await harness.current().start('claude');
|
|
146
|
+
});
|
|
147
|
+
expect(refusal.problem).toContain('already running');
|
|
148
|
+
expect(harness.current().updating).toBeNull();
|
|
149
|
+
expect(harness.current().job?.pid).toBe(999);
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
test('an in-flight run is adopted when the card opens', async () => {
|
|
153
|
+
statusPayload = job();
|
|
154
|
+
const harness = mount();
|
|
155
|
+
await flush();
|
|
156
|
+
// The spinner belongs to a run this page did not start — a second tab, or
|
|
157
|
+
// this one after a reload.
|
|
158
|
+
expect(harness.current().updating).toBe('claude');
|
|
159
|
+
|
|
160
|
+
statusPayload = job({ finishedAt: Date.now(), pid: null, ok: false, applied: true, message: 'claude update failed (exit 1)' });
|
|
161
|
+
expect(await harness.settled).toEqual({ message: 'claude update failed (exit 1)', ok: false });
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
test('a finished record on open is history, not a run to follow', async () => {
|
|
165
|
+
statusPayload = job({ finishedAt: Date.now(), pid: null, ok: true, applied: true, message: 'claude updated (adapter)' });
|
|
166
|
+
const harness = mount();
|
|
167
|
+
await flush();
|
|
168
|
+
expect(harness.current().updating).toBeNull();
|
|
169
|
+
// No spinner, but the row can still offer the log of what ran.
|
|
170
|
+
expect(harness.current().job?.harness).toBe('claude');
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
test('"already up to date" is reported without following a job', async () => {
|
|
174
|
+
postPayload = {
|
|
175
|
+
status: 200,
|
|
176
|
+
body: { success: true, id: 'claude', message: 'claude is already up to date (adapter 0.102.0)' },
|
|
177
|
+
};
|
|
178
|
+
const harness = mount();
|
|
179
|
+
await flush();
|
|
180
|
+
|
|
181
|
+
const current: { problem: string | null } = { problem: null };
|
|
182
|
+
await act(async () => {
|
|
183
|
+
current.problem = await harness.current().start('claude');
|
|
184
|
+
});
|
|
185
|
+
expect(current.problem).toBeNull();
|
|
186
|
+
expect(harness.current().updating).toBeNull();
|
|
187
|
+
// Nothing ran, so there is no record for a row to show a log of.
|
|
188
|
+
expect(harness.current().job).toBeNull();
|
|
189
|
+
expect(await harness.settled).toEqual({ message: 'claude is already up to date (adapter 0.102.0)', ok: true });
|
|
190
|
+
// One read — the mount's — and no poll for a job that does not exist.
|
|
191
|
+
expect(calls.filter((call) => call.startsWith('GET /api/harness/update/status'))).toHaveLength(1);
|
|
192
|
+
});
|
|
193
|
+
});
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Starting a harness update, and following the background job it becomes.
|
|
8
|
+
*
|
|
9
|
+
* The POST used to hold the request open for the whole install; now it answers
|
|
10
|
+
* `202` and the run continues in a detached worker. So the dialog's job has two
|
|
11
|
+
* halves: start it, then poll `GET /api/harness/update/status` until the record
|
|
12
|
+
* says it finished — and, on open, ADOPT a run that is already in flight. That
|
|
13
|
+
* second half is what makes the update really background: closing About, or
|
|
14
|
+
* reloading the page, does not lose the button's state, and a reopened card
|
|
15
|
+
* shows the spinner for the run that is still installing.
|
|
16
|
+
*
|
|
17
|
+
* The rows are re-read once the run settles (`invalidateHarnessVersions`): the
|
|
18
|
+
* update forgot the cached probe, so the next read is the first honest one.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useCallback, useEffect, useRef, useState } from 'preact/hooks';
|
|
22
|
+
import { invalidateHarnessVersions } from '@/client/hooks/models/use-harness-versions';
|
|
23
|
+
import { isHarnessUpdateJob, updateJobFrom } from '@/shared/lib/harness/update-job';
|
|
24
|
+
import type { HarnessUpdateJob } from '@/shared/types/harness-update';
|
|
25
|
+
|
|
26
|
+
/** One poll per second: the worker flushes at 400ms, and this is a dialog. */
|
|
27
|
+
export const HARNESS_UPDATE_POLL_MS = 1_000;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Stop polling after this long and hand the control back.
|
|
31
|
+
*
|
|
32
|
+
* The install itself is bounded per step by the worker; this only stops an
|
|
33
|
+
* open dialog from asking forever if the record stopped moving. The run is not
|
|
34
|
+
* cancelled — closing the dialog never cancels anything.
|
|
35
|
+
*/
|
|
36
|
+
const MAX_FOLLOW_MS = 45 * 60_000;
|
|
37
|
+
|
|
38
|
+
/** How the hook behaves, for the two callers that need to differ from the
|
|
39
|
+
* default: the dialog passes its own open state, and a test its own cadence. */
|
|
40
|
+
export interface HarnessUpdateOptions {
|
|
41
|
+
/** The poll cadence. One second suits a dialog. */
|
|
42
|
+
pollMs?: number;
|
|
43
|
+
/** Is the surface that owns this hook on screen? While it is not, no status is
|
|
44
|
+
* read and no run is followed — a run already in flight is ADOPTED on the
|
|
45
|
+
* next open, which is what "background" means here. */
|
|
46
|
+
enabled?: boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface HarnessUpdateController {
|
|
50
|
+
/** The harness whose run this dialog is following, or null. */
|
|
51
|
+
updating: string | null;
|
|
52
|
+
/** The step the worker is on (`adapter`, `Claude Code`, …), when it says. */
|
|
53
|
+
progress: string | null;
|
|
54
|
+
/**
|
|
55
|
+
* The record itself — the last one read, running or finished.
|
|
56
|
+
*
|
|
57
|
+
* The log dialog renders from this: the worker streams every command's output
|
|
58
|
+
* into it, so the panel is the install's own console. It is NOT cleared when a
|
|
59
|
+
* run settles, because the interesting moment to read the log is often after
|
|
60
|
+
* it failed.
|
|
61
|
+
*/
|
|
62
|
+
job: HarnessUpdateJob | null;
|
|
63
|
+
/** Start an update; resolves to a refusal, or null when the run was started
|
|
64
|
+
* (or there was nothing to move). */
|
|
65
|
+
start: (id: string) => Promise<string | null>;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
type Settled = (message: string, ok: boolean) => void;
|
|
69
|
+
|
|
70
|
+
function runningStep(job: HarnessUpdateJob | null): string | null {
|
|
71
|
+
const steps = job && Array.isArray(job.steps) ? job.steps : [];
|
|
72
|
+
return steps.find((step) => step.state === 'running')?.part ?? null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function useHarnessUpdate(
|
|
76
|
+
onSettled: Settled,
|
|
77
|
+
{ pollMs = HARNESS_UPDATE_POLL_MS, enabled = true }: HarnessUpdateOptions = {},
|
|
78
|
+
): HarnessUpdateController {
|
|
79
|
+
const [updating, setUpdating] = useState<string | null>(null);
|
|
80
|
+
const [progress, setProgress] = useState<string | null>(null);
|
|
81
|
+
const [job, setJob] = useState<HarnessUpdateJob | null>(null);
|
|
82
|
+
const alive = useRef(true);
|
|
83
|
+
// The callback is read through a ref so an inline arrow from the caller does
|
|
84
|
+
// not restart the mount effect (and re-adopt the job) on every render.
|
|
85
|
+
const settled = useRef(onSettled);
|
|
86
|
+
settled.current = onSettled;
|
|
87
|
+
|
|
88
|
+
const follow = useCallback(async (id: string): Promise<void> => {
|
|
89
|
+
const startedAt = Date.now();
|
|
90
|
+
while (alive.current) {
|
|
91
|
+
let job: HarnessUpdateJob | null = null;
|
|
92
|
+
try {
|
|
93
|
+
const response = await fetch('/api/harness/update/status', { cache: 'no-store' });
|
|
94
|
+
if (!response.ok) throw new Error(String(response.status));
|
|
95
|
+
job = updateJobFrom(await response.json());
|
|
96
|
+
} catch {
|
|
97
|
+
// A transient failure is not the update failing: the record lives on
|
|
98
|
+
// disk and the next poll reads it.
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (!alive.current) return;
|
|
102
|
+
// Kept even once it finishes: the log stays readable while the panel is
|
|
103
|
+
// open, and a failure is the case a reader wants the output for.
|
|
104
|
+
if (job) setJob(job);
|
|
105
|
+
if (job?.finishedAt != null) {
|
|
106
|
+
setUpdating(null);
|
|
107
|
+
setProgress(null);
|
|
108
|
+
invalidateHarnessVersions();
|
|
109
|
+
settled.current(job.message ?? (job.ok ? 'Update finished' : 'Update failed'), Boolean(job.ok));
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (job?.harness === id) setProgress(runningStep(job));
|
|
113
|
+
|
|
114
|
+
if (Date.now() - startedAt > MAX_FOLLOW_MS) {
|
|
115
|
+
setUpdating(null);
|
|
116
|
+
setProgress(null);
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const { promise, resolve } = Promise.withResolvers<void>();
|
|
120
|
+
setTimeout(resolve, pollMs);
|
|
121
|
+
await promise;
|
|
122
|
+
}
|
|
123
|
+
}, [pollMs]);
|
|
124
|
+
|
|
125
|
+
// Adopt a run that is already going: another tab, or this dialog reopened.
|
|
126
|
+
useEffect(() => {
|
|
127
|
+
// A closed card has nothing to show and nothing to poll for; the run keeps
|
|
128
|
+
// going in its worker either way.
|
|
129
|
+
if (!enabled) {
|
|
130
|
+
alive.current = false;
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
alive.current = true;
|
|
134
|
+
void (async () => {
|
|
135
|
+
try {
|
|
136
|
+
const response = await fetch('/api/harness/update/status', { cache: 'no-store' });
|
|
137
|
+
if (!response.ok) return;
|
|
138
|
+
const running = updateJobFrom(await response.json());
|
|
139
|
+
if (!alive.current || !running) return;
|
|
140
|
+
setJob(running);
|
|
141
|
+
if (running.finishedAt !== null) return;
|
|
142
|
+
setUpdating(running.harness);
|
|
143
|
+
setProgress(runningStep(running));
|
|
144
|
+
void follow(running.harness);
|
|
145
|
+
} catch {
|
|
146
|
+
// Nothing running, or no server to ask: the list still renders.
|
|
147
|
+
}
|
|
148
|
+
})();
|
|
149
|
+
return () => {
|
|
150
|
+
alive.current = false;
|
|
151
|
+
};
|
|
152
|
+
}, [follow, enabled]);
|
|
153
|
+
|
|
154
|
+
const start = useCallback(async (id: string): Promise<string | null> => {
|
|
155
|
+
let response: Response;
|
|
156
|
+
try {
|
|
157
|
+
response = await fetch('/api/harness/update', {
|
|
158
|
+
method: 'POST',
|
|
159
|
+
headers: { 'Content-Type': 'application/json' },
|
|
160
|
+
body: JSON.stringify({ harness: id }),
|
|
161
|
+
});
|
|
162
|
+
} catch (cause) {
|
|
163
|
+
return cause instanceof Error ? cause.message : 'Update failed';
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const payload = (await response.json().catch(() => ({}))) as {
|
|
167
|
+
error?: string;
|
|
168
|
+
message?: string;
|
|
169
|
+
success?: boolean;
|
|
170
|
+
started?: boolean;
|
|
171
|
+
job?: HarnessUpdateJob;
|
|
172
|
+
};
|
|
173
|
+
|
|
174
|
+
// The POST's own record is trusted only if it IS a record; a payload that
|
|
175
|
+
// fails the guard still means "started", just without a step to name.
|
|
176
|
+
const posted = isHarnessUpdateJob(payload.job) ? payload.job : null;
|
|
177
|
+
|
|
178
|
+
if (response.status === 202 && payload.started) {
|
|
179
|
+
setUpdating(id);
|
|
180
|
+
setJob(posted);
|
|
181
|
+
setProgress(runningStep(posted));
|
|
182
|
+
void follow(id);
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
if (!response.ok) {
|
|
186
|
+
// A refusal carries the run that caused it: the reader can open ITS log
|
|
187
|
+
// instead of only being told to wait.
|
|
188
|
+
if (response.status === 409 && posted) setJob(posted);
|
|
189
|
+
return payload.error ?? `Update failed (HTTP ${response.status})`;
|
|
190
|
+
}
|
|
191
|
+
if (payload.success) {
|
|
192
|
+
// Nothing to move: the row is already current, so there is no job to
|
|
193
|
+
// follow. Re-read it anyway — the previous run may have moved it.
|
|
194
|
+
invalidateHarnessVersions();
|
|
195
|
+
settled.current(payload.message ?? 'Update finished', true);
|
|
196
|
+
return null;
|
|
197
|
+
}
|
|
198
|
+
return payload.error ?? 'Update failed';
|
|
199
|
+
}, [follow]);
|
|
200
|
+
|
|
201
|
+
return { updating, progress, job, start };
|
|
202
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Which session rows have their child tree open.
|
|
8
|
+
*
|
|
9
|
+
* Deliberately separate from `useExpandedSessions` (the subagent roster): one
|
|
10
|
+
* chevron cannot mean two different lists. Local, not persisted — a collapsed
|
|
11
|
+
* tree is one click away, while a persisted roster is what the phone and the
|
|
12
|
+
* desktop must agree on.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { useCallback, useState } from 'preact/hooks';
|
|
16
|
+
|
|
17
|
+
export interface ChildExpansion {
|
|
18
|
+
expandedChildIds: Set<string>;
|
|
19
|
+
toggleChild: (sessionId: string) => void;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function useChildExpansion(): ChildExpansion {
|
|
23
|
+
const [expandedChildIds, setExpandedChildIds] = useState<Set<string>>(() => new Set());
|
|
24
|
+
const toggleChild = useCallback((sessionId: string) => {
|
|
25
|
+
setExpandedChildIds((prev) => {
|
|
26
|
+
const next = new Set(prev);
|
|
27
|
+
if (next.has(sessionId)) next.delete(sessionId);
|
|
28
|
+
else next.add(sessionId);
|
|
29
|
+
return next;
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
return { expandedChildIds, toggleChild };
|
|
33
|
+
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Live terminal session for the right panel: the socket, its status, and the
|
|
8
|
-
* attach/resize/input verbs the
|
|
8
|
+
* attach/resize/input verbs the terminal view drives.
|
|
9
9
|
*
|
|
10
10
|
* The terminal id is per Kabmo session and persisted, which is what makes the
|
|
11
11
|
* shell survive a page reload: the panel reattaches to the id it already owns
|
|
@@ -48,6 +48,12 @@ export interface UseTerminalResult {
|
|
|
48
48
|
input: (data: Uint8Array) => void;
|
|
49
49
|
/** Replace the shell with a fresh one. */
|
|
50
50
|
restart: () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Re-open the socket for the same terminal id. The server replays its
|
|
53
|
+
* retained scrollback, which is what lets a rebuilt renderer (a theme switch)
|
|
54
|
+
* regain its history without a new shell.
|
|
55
|
+
*/
|
|
56
|
+
reattach: () => void;
|
|
51
57
|
}
|
|
52
58
|
|
|
53
59
|
export function useTerminal(options: UseTerminalOptions = {}): UseTerminalResult {
|
|
@@ -57,6 +63,8 @@ export function useTerminal(options: UseTerminalOptions = {}): UseTerminalResult
|
|
|
57
63
|
const [shell, setShell] = useState('');
|
|
58
64
|
const [exitCode, setExitCode] = useState<number | null>(null);
|
|
59
65
|
const [error, setError] = useState<string | null>(null);
|
|
66
|
+
/** Incremented by `reattach`; the socket effect owns the reconnect. */
|
|
67
|
+
const [generation, setGeneration] = useState(0);
|
|
60
68
|
|
|
61
69
|
const socketRef = useRef<TerminalSocket | null>(null);
|
|
62
70
|
// The grid the view reported, replayed on attach so a reconnect lands on the
|
|
@@ -133,7 +141,7 @@ export function useTerminal(options: UseTerminalOptions = {}): UseTerminalResult
|
|
|
133
141
|
socket.release();
|
|
134
142
|
socketRef.current = null;
|
|
135
143
|
};
|
|
136
|
-
}, [ready, terminalId]);
|
|
144
|
+
}, [ready, terminalId, generation]);
|
|
137
145
|
|
|
138
146
|
const restart = useCallback(() => {
|
|
139
147
|
// Kill the old shell before minting a new id: leaving it to the idle
|
|
@@ -182,5 +190,11 @@ export function useTerminal(options: UseTerminalOptions = {}): UseTerminalResult
|
|
|
182
190
|
socketRef.current?.input(data);
|
|
183
191
|
}, []);
|
|
184
192
|
|
|
185
|
-
|
|
193
|
+
const reattach = useCallback(() => {
|
|
194
|
+
// The effect's cleanup releases the old socket and a new one attaches with
|
|
195
|
+
// the remembered size, so the server replays the same terminal id.
|
|
196
|
+
setGeneration((value) => value + 1);
|
|
197
|
+
}, []);
|
|
198
|
+
|
|
199
|
+
return { status, shell, exitCode, error, attach, resize, input, restart, reattach };
|
|
186
200
|
}
|
|
@@ -13,9 +13,10 @@
|
|
|
13
13
|
* bytes and is handed straight to `term.write(Uint8Array)`; the client never
|
|
14
14
|
* decodes UTF-8 itself, which is what keeps a character split across two PTY
|
|
15
15
|
* reads intact.
|
|
16
|
-
* -
|
|
17
|
-
*
|
|
18
|
-
*
|
|
16
|
+
* - **Non-UTF-8 payloads take the byte channel.** ghostty-web has no `onBinary`:
|
|
17
|
+
* it reports every keystroke and mouse report as one `onData` string, so
|
|
18
|
+
* `terminalInputFrame` splits the legacy X10 report back into bytes before the
|
|
19
|
+
* socket sees it. Encoding that payload as text would corrupt it.
|
|
19
20
|
* - **Reconnect, not re-create.** A dropped socket re-dials the same terminal
|
|
20
21
|
* id, so the shell and its scrollback survive a network blip or a page reload
|
|
21
22
|
* instead of a second shell appearing.
|
|
@@ -99,7 +100,11 @@ export function connectTerminal(terminalId: string, handlers: TerminalSocketHand
|
|
|
99
100
|
handleOutput(new Uint8Array(event.data));
|
|
100
101
|
return;
|
|
101
102
|
}
|
|
102
|
-
|
|
103
|
+
// Anything that is not a binary frame is a control frame. The server
|
|
104
|
+
// sends PTY bytes as Buffer views, so `event.data` is an ArrayBuffer and
|
|
105
|
+
// this branch only ever sees JSON.
|
|
106
|
+
if (typeof event.data !== 'string') return;
|
|
107
|
+
const frame = decodeServerFrame(event.data);
|
|
103
108
|
if (frame) applyFrame(frame);
|
|
104
109
|
};
|
|
105
110
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, test } from 'bun:test';
|
|
7
|
+
import { buildSessionTree, descendantsOf } from '@/client/lib/session-tree';
|
|
8
|
+
import type { SessionItemData } from '@/shared/types';
|
|
9
|
+
|
|
10
|
+
function session(id: string, parentSessionId?: string): SessionItemData {
|
|
11
|
+
return {
|
|
12
|
+
id,
|
|
13
|
+
folder_id: 1,
|
|
14
|
+
title: id,
|
|
15
|
+
...(parentSessionId ? { parentSessionId } : {}),
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
describe('buildSessionTree', () => {
|
|
20
|
+
test('nests children under their parent and keeps orphans as roots', () => {
|
|
21
|
+
const tree = buildSessionTree([
|
|
22
|
+
session('root'),
|
|
23
|
+
session('child', 'root'),
|
|
24
|
+
session('grandchild', 'child'),
|
|
25
|
+
session('orphan', 'missing'),
|
|
26
|
+
]);
|
|
27
|
+
expect(tree.roots.map((row) => row.id)).toEqual(['root', 'orphan']);
|
|
28
|
+
expect(tree.childrenOf.get('root')?.map((row) => row.id)).toEqual(['child']);
|
|
29
|
+
expect(tree.childrenOf.get('child')?.map((row) => row.id)).toEqual(['grandchild']);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('a self-parent is a root rather than an invisible row', () => {
|
|
33
|
+
const tree = buildSessionTree([session('self', 'self')]);
|
|
34
|
+
expect(tree.roots.map((row) => row.id)).toEqual(['self']);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test('descendants carry depth and stop at a cycle', () => {
|
|
38
|
+
const childrenOf = new Map<string, SessionItemData[]>([
|
|
39
|
+
['a', [session('b', 'a')]],
|
|
40
|
+
['b', [session('c', 'b')]],
|
|
41
|
+
]);
|
|
42
|
+
expect(descendantsOf('a', childrenOf).map((row) => [row.session.id, row.depth])).toEqual([
|
|
43
|
+
['b', 1],
|
|
44
|
+
['c', 2],
|
|
45
|
+
]);
|
|
46
|
+
// A cycle is not walked forever.
|
|
47
|
+
childrenOf.set('c', [session('a', 'c')]);
|
|
48
|
+
expect(descendantsOf('a', childrenOf).map((row) => row.session.id)).toEqual(['b', 'c']);
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* A flat session list → roots plus a parent→children map.
|
|
8
|
+
*
|
|
9
|
+
* A child session is a session, so the sidebar draws it under its parent. A
|
|
10
|
+
* session whose parent is not in the same folder (a cross-folder relation, or
|
|
11
|
+
* one the current filter/window removed) stays a root: hiding it would make a
|
|
12
|
+
* row the user can still open by URL unreachable from the sidebar.
|
|
13
|
+
*
|
|
14
|
+
* Pure and order-preserving: the list's own sort is the tree's sort.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type { SessionItemData } from '@/shared/types';
|
|
18
|
+
|
|
19
|
+
export interface SessionTree {
|
|
20
|
+
roots: SessionItemData[];
|
|
21
|
+
childrenOf: Map<string, SessionItemData[]>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function buildSessionTree(sessions: readonly SessionItemData[]): SessionTree {
|
|
25
|
+
const present = new Set(sessions.map((session) => String(session.id)));
|
|
26
|
+
const childrenOf = new Map<string, SessionItemData[]>();
|
|
27
|
+
const roots: SessionItemData[] = [];
|
|
28
|
+
|
|
29
|
+
for (const session of sessions) {
|
|
30
|
+
const parentId = session.parentSessionId;
|
|
31
|
+
if (!parentId || !present.has(parentId) || parentId === String(session.id)) {
|
|
32
|
+
roots.push(session);
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
const bucket = childrenOf.get(parentId);
|
|
36
|
+
if (bucket) bucket.push(session);
|
|
37
|
+
else childrenOf.set(parentId, [session]);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return { roots, childrenOf };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** Every descendant of a session, depth-first, with its depth (root child = 1). */
|
|
44
|
+
export function descendantsOf(
|
|
45
|
+
sessionId: string,
|
|
46
|
+
childrenOf: Map<string, SessionItemData[]>,
|
|
47
|
+
depth = 1,
|
|
48
|
+
seen = new Set<string>(),
|
|
49
|
+
): Array<{ session: SessionItemData; depth: number }> {
|
|
50
|
+
if (seen.has(sessionId)) return [];
|
|
51
|
+
seen.add(sessionId);
|
|
52
|
+
const out: Array<{ session: SessionItemData; depth: number }> = [];
|
|
53
|
+
for (const child of childrenOf.get(sessionId) ?? []) {
|
|
54
|
+
if (seen.has(String(child.id))) continue;
|
|
55
|
+
out.push({ session: child, depth });
|
|
56
|
+
out.push(...descendantsOf(String(child.id), childrenOf, depth + 1, seen));
|
|
57
|
+
}
|
|
58
|
+
return out;
|
|
59
|
+
}
|
package/src/client/tailwind.css
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
@import "tailwindcss";
|
|
2
|
-
@import "@xterm/xterm/css/xterm.css";
|
|
3
2
|
|
|
4
3
|
@theme {
|
|
5
4
|
/* The UI font stack, with the Nerd Font families LAST.
|
|
@@ -7,7 +6,7 @@
|
|
|
7
6
|
* omp heads a session title with a card icon — a private-use glyph
|
|
8
7
|
* (`title.icons: nf+emoji`, the default) that no Latin face contains. The
|
|
9
8
|
* terminal already names a Nerd Font for exactly this reason
|
|
10
|
-
* (`
|
|
9
|
+
* (`TERMINAL_GLYPH_FALLBACKS` + `NERD_SYMBOLS_FAMILY` in
|
|
11
10
|
* `data/theme/terminal.ts`), but the UI stack did not, so a title card
|
|
12
11
|
* rendered only where the DEVICE happened to have a Nerd Font installed: on
|
|
13
12
|
* the developer's desktop Chromium fell back to one, and on a phone — which
|
|
@@ -24,7 +23,7 @@
|
|
|
24
23
|
* fallback and downloads it on every machine.
|
|
25
24
|
*
|
|
26
25
|
* The family names are literals here because Tailwind's `@theme` cannot
|
|
27
|
-
* import a TS constant; they must stay equal to `
|
|
26
|
+
* import a TS constant; they must stay equal to `TERMINAL_GLYPH_FALLBACKS` and
|
|
28
27
|
* `NERD_SYMBOLS_FAMILY`, which `nerd-symbols.test.ts` asserts. */
|
|
29
28
|
--font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji", "FiraCode Nerd Font Mono", "FiraCode Nerd Font", "JetBrainsMono Nerd Font", "JetBrainsMono NF", "JetBrains Mono Nerd Font", "Hack Nerd Font", "MesloLGS NF", "MesloLGM Nerd Font", "CaskaydiaCove Nerd Font", "SauceCodePro Nerd Font", "Symbols Nerd Font Mono", "Symbols Nerd Font", "PowerlineSymbols", "Kabmo Nerd Symbols";
|
|
30
29
|
--color-ink: var(--theme-ink);
|
|
@@ -553,16 +552,23 @@
|
|
|
553
552
|
display: none;
|
|
554
553
|
}
|
|
555
554
|
|
|
556
|
-
/* The terminal
|
|
557
|
-
*
|
|
558
|
-
*
|
|
559
|
-
*
|
|
560
|
-
*
|
|
561
|
-
*
|
|
562
|
-
*
|
|
563
|
-
|
|
555
|
+
/* The terminal host: ghostty-web draws its scrollbar inside the canvas, so
|
|
556
|
+
* there is no native viewport to style. The drag-to-scroll handlers in
|
|
557
|
+
* `terminal-panel/mount.ts` own the gesture; `pan-y` keeps the browser from
|
|
558
|
+
* claiming it first, and momentum stays the platform's.
|
|
559
|
+
*
|
|
560
|
+
* `caret-color: transparent` is not cosmetic. ghostty-web marks the host it is
|
|
561
|
+
* opened on `contenteditable="true"` and `tabindex="0"` (the IME/`beforeinput`
|
|
562
|
+
* path), and its visible input is a hidden textarea — so a click on the 6px
|
|
563
|
+
* padding focuses the DIV itself and the browser paints a NATIVE caret there:
|
|
564
|
+
* a black blinking bar at the left edge, whose height follows the host's
|
|
565
|
+
* inherited 16px/24px line box (measured in Chromium: 24px, and it changes
|
|
566
|
+
* with the content beside the click point). The terminal's cursor is the
|
|
567
|
+
* canvas block, so the DOM caret is never wanted. */
|
|
568
|
+
.kabmo-terminal {
|
|
564
569
|
touch-action: pan-y;
|
|
565
570
|
-webkit-overflow-scrolling: touch;
|
|
571
|
+
caret-color: transparent;
|
|
566
572
|
}
|
|
567
573
|
|
|
568
574
|
/* The chat column's width, in ONE variable and ONE class.
|