@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,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The row's link to its update log.
|
|
8
|
+
*
|
|
9
|
+
* A harness update runs in a background worker, so the row can only show *that*
|
|
10
|
+
* something is installing — never what it printed. That output lives in the
|
|
11
|
+
* job record, and these cases pin the row's half of the deal: while the worker
|
|
12
|
+
* runs the row names the step and offers `View log`; once it settles the row
|
|
13
|
+
* keeps offering the log with the run's own sentence, because a failure is
|
|
14
|
+
* exactly when the output is worth reading; and a record never leaks onto a row
|
|
15
|
+
* that does not own it.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
import { render } from 'preact';
|
|
21
|
+
|
|
22
|
+
import {
|
|
23
|
+
harnessRows,
|
|
24
|
+
installHarnessTableDom,
|
|
25
|
+
mountHarnessTable,
|
|
26
|
+
restoreHarnessTableDom,
|
|
27
|
+
summary,
|
|
28
|
+
version,
|
|
29
|
+
} from '@/test-support/harness-table.test-util';
|
|
30
|
+
|
|
31
|
+
let container: HTMLElement;
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
installHarnessTableDom();
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
beforeEach(() => {
|
|
38
|
+
container = document.createElement('div');
|
|
39
|
+
document.body.appendChild(container);
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterEach(() => {
|
|
43
|
+
render(null, container);
|
|
44
|
+
container.remove();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
afterAll(() => {
|
|
48
|
+
restoreHarnessTableDom();
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
/** The claude row, with an update record attached. */
|
|
52
|
+
function mountClaude(state: Parameters<typeof mountHarnessTable>[5]): HTMLElement {
|
|
53
|
+
return mountHarnessTable(
|
|
54
|
+
container,
|
|
55
|
+
[summary()],
|
|
56
|
+
[version({ updateAvailable: true, agent: { version: '0.100.0', latest: '0.102.0', updateAvailable: true } })],
|
|
57
|
+
undefined,
|
|
58
|
+
undefined,
|
|
59
|
+
state,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
describe('harness row update log', () => {
|
|
64
|
+
test('while the worker runs, the row names the step and offers the log', () => {
|
|
65
|
+
let opened = 0;
|
|
66
|
+
const el = mountClaude({
|
|
67
|
+
updating: 'claude',
|
|
68
|
+
progress: 'adapter',
|
|
69
|
+
log: { harness: 'claude', message: null },
|
|
70
|
+
onOpenLog: () => { opened += 1; },
|
|
71
|
+
});
|
|
72
|
+
const row = harnessRows(el)[0];
|
|
73
|
+
expect(row.textContent).toContain('Installing adapter…');
|
|
74
|
+
const log = row.querySelector<HTMLButtonElement>('[data-update-log]');
|
|
75
|
+
expect(log?.textContent).toBe('View log');
|
|
76
|
+
act(() => log!.click());
|
|
77
|
+
expect(opened).toBe(1);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
test('after the run settles the log stays, with the run’s sentence', () => {
|
|
81
|
+
const el = mountClaude({
|
|
82
|
+
log: { harness: 'claude', message: 'claude update failed (exit 3)' },
|
|
83
|
+
onOpenLog: () => {},
|
|
84
|
+
});
|
|
85
|
+
const row = harnessRows(el)[0];
|
|
86
|
+
expect(row.textContent).toContain('claude update failed (exit 3)');
|
|
87
|
+
expect(row.querySelector('[data-update-log]')).not.toBeNull();
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
test('a record for another harness does not appear on this row', () => {
|
|
91
|
+
const el = mountClaude({ log: { harness: 'codex', message: 'codex updated' } });
|
|
92
|
+
expect(harnessRows(el)[0].querySelector('[data-update-log]')).toBeNull();
|
|
93
|
+
});
|
|
94
|
+
});
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The panel a reader opens when a harness update is running (or just failed).
|
|
8
|
+
*
|
|
9
|
+
* The complaint it answers was concrete: press Update on `claude`, and the card
|
|
10
|
+
* showed a spinner with no way to see what the install was printing — so a
|
|
11
|
+
* failure said "update failed" with the reason already gone. These cases pin the
|
|
12
|
+
* three things the panel must state: every step and its command, the streamed
|
|
13
|
+
* output, and the finished run's own sentence.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { render } from 'preact';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
import { UpdateLogDialog } from '@/client/components/layout/session-sidebar/about-modal/UpdateLogDialog';
|
|
21
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
22
|
+
import type { HarnessUpdateJob } from '@/shared/types/harness-update';
|
|
23
|
+
|
|
24
|
+
beforeAll(() => {
|
|
25
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterAll(() => {
|
|
29
|
+
restoreDomGlobals();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let container: HTMLElement | null = null;
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
if (container) act(() => render(null, container!));
|
|
36
|
+
container?.remove();
|
|
37
|
+
container = null;
|
|
38
|
+
for (const node of Array.from(document.body.children)) node.remove();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function job(overrides: Partial<HarnessUpdateJob> = {}): HarnessUpdateJob {
|
|
42
|
+
return {
|
|
43
|
+
harness: 'claude',
|
|
44
|
+
label: 'claude',
|
|
45
|
+
startedAt: Date.now(),
|
|
46
|
+
finishedAt: null,
|
|
47
|
+
pid: 4242,
|
|
48
|
+
steps: [
|
|
49
|
+
{
|
|
50
|
+
part: 'adapter',
|
|
51
|
+
command: 'npm install -g @agentclientprotocol/claude-agent-acp@0.102.0',
|
|
52
|
+
argv: ['npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.102.0'],
|
|
53
|
+
state: 'running',
|
|
54
|
+
code: null,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
output: '',
|
|
58
|
+
ok: null,
|
|
59
|
+
message: null,
|
|
60
|
+
applied: false,
|
|
61
|
+
repointed: null,
|
|
62
|
+
...overrides,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Mount the panel and hand back its dialog element. */
|
|
67
|
+
function mountPanel(record: HarnessUpdateJob, onClose: () => void = () => {}): HTMLElement {
|
|
68
|
+
container = document.createElement('div');
|
|
69
|
+
document.body.appendChild(container);
|
|
70
|
+
act(() => render(<UpdateLogDialog job={record} onClose={onClose} />, container!));
|
|
71
|
+
const panel = document.querySelector('[role="dialog"]');
|
|
72
|
+
if (!panel) throw new Error('the log panel did not mount');
|
|
73
|
+
return panel as HTMLElement;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
describe('UpdateLogDialog', () => {
|
|
77
|
+
test('a running step shows its command and says it is waiting for output', () => {
|
|
78
|
+
const panel = mountPanel(job());
|
|
79
|
+
expect(panel.textContent).toContain('Updating claude');
|
|
80
|
+
expect(panel.textContent).toContain('Installing…');
|
|
81
|
+
expect(panel.textContent).toContain('adapter');
|
|
82
|
+
// The command is the reader's way to repeat a step by hand after a failure.
|
|
83
|
+
expect(panel.textContent).toContain('npm install -g @agentclientprotocol/claude-agent-acp@0.102.0');
|
|
84
|
+
expect(panel.textContent).toContain('Waiting for output…');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('the streamed output is rendered verbatim', () => {
|
|
88
|
+
const panel = mountPanel(job({ output: 'added 1 package in 3s\nnpm warn deprecated x' }));
|
|
89
|
+
expect(panel.querySelector('pre')?.textContent).toContain('added 1 package in 3s');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('a failed step names its exit code, and the run its sentence', () => {
|
|
93
|
+
const panel = mountPanel(job({
|
|
94
|
+
finishedAt: Date.now(),
|
|
95
|
+
pid: null,
|
|
96
|
+
ok: false,
|
|
97
|
+
applied: true,
|
|
98
|
+
message: 'claude update failed (exit 3)',
|
|
99
|
+
output: 'boom',
|
|
100
|
+
steps: [{
|
|
101
|
+
part: 'Claude Code',
|
|
102
|
+
command: 'claude update',
|
|
103
|
+
argv: ['claude', 'update'],
|
|
104
|
+
state: 'failed',
|
|
105
|
+
code: 3,
|
|
106
|
+
}],
|
|
107
|
+
}));
|
|
108
|
+
expect(panel.textContent).toContain('Failed');
|
|
109
|
+
expect(panel.textContent).toContain('claude update');
|
|
110
|
+
expect(panel.textContent).toContain('exit 3');
|
|
111
|
+
expect(panel.textContent).toContain('claude update failed (exit 3)');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a finished run with no output says so instead of showing an empty box', () => {
|
|
115
|
+
const panel = mountPanel(job({ finishedAt: Date.now(), pid: null, ok: true, message: 'claude updated (adapter)' }));
|
|
116
|
+
expect(panel.textContent).toContain('The commands printed nothing.');
|
|
117
|
+
expect(panel.textContent).toContain('claude updated (adapter)');
|
|
118
|
+
expect(panel.textContent).toContain('Finished');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('the close control asks to close', () => {
|
|
122
|
+
let closed = 0;
|
|
123
|
+
const panel = mountPanel(job(), () => { closed += 1; });
|
|
124
|
+
const close = panel.querySelector<HTMLButtonElement>('button[aria-label="Close"]')
|
|
125
|
+
?? panel.querySelector<HTMLButtonElement>('button');
|
|
126
|
+
expect(close).not.toBeNull();
|
|
127
|
+
act(() => close!.click());
|
|
128
|
+
expect(closed).toBe(1);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The install's own console, opened from the row that is updating.
|
|
8
|
+
*
|
|
9
|
+
* A harness update is a background job now, so the dialog's spinner says that
|
|
10
|
+
* *something* is running and nothing about what it is doing — and when a press
|
|
11
|
+
* fails, "claude update failed" without the command's output is not actionable.
|
|
12
|
+
* The worker already streams every step's stdout/stderr into the job record
|
|
13
|
+
* (throttled to 400 ms), so this panel is only a view of that: the steps, and
|
|
14
|
+
* the output, pinned to the newest line.
|
|
15
|
+
*
|
|
16
|
+
* It stays open after the run settles — the failure case is exactly when the log
|
|
17
|
+
* matters — and the record it renders is the last one the card polled, so a
|
|
18
|
+
* finished run keeps its output until another update replaces it.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useEffect, useRef } from 'preact/hooks';
|
|
22
|
+
import { createPortal } from 'preact/compat';
|
|
23
|
+
import { Ban, CheckCircle2, CircleDashed, Loader2 } from 'lucide-preact';
|
|
24
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
25
|
+
import type { HarnessUpdateJob, HarnessUpdateJobStep } from '@/shared/types/harness-update';
|
|
26
|
+
|
|
27
|
+
export interface UpdateLogDialogProps {
|
|
28
|
+
job: HarnessUpdateJob;
|
|
29
|
+
onClose: () => void;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The mark for one step's state. */
|
|
33
|
+
function StepMark({ state }: { state: HarnessUpdateJobStep['state'] }) {
|
|
34
|
+
if (state === 'ok') return <CheckCircle2 size={12} className="shrink-0 text-ink/55" />;
|
|
35
|
+
if (state === 'failed') return <Ban size={12} className="shrink-0 text-error" />;
|
|
36
|
+
if (state === 'running') return <Loader2 size={12} className="shrink-0 animate-spin text-ink motion-reduce:animate-none" />;
|
|
37
|
+
return <CircleDashed size={12} className="shrink-0 text-ink/25" />;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** How the panel describes the run, in the same words the toast uses. */
|
|
41
|
+
function phaseLabel(job: HarnessUpdateJob): string {
|
|
42
|
+
if (job.finishedAt === null) return 'Installing…';
|
|
43
|
+
return job.ok ? 'Finished' : 'Failed';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function UpdateLogDialog({ job, onClose }: UpdateLogDialogProps) {
|
|
47
|
+
const output = useRef<HTMLPreElement | null>(null);
|
|
48
|
+
const running = job.finishedAt === null;
|
|
49
|
+
|
|
50
|
+
// Pin to the newest line while the worker streams. Without it the panel shows
|
|
51
|
+
// the top of npm's output and the reason for a failure is always below the
|
|
52
|
+
// fold.
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
const node = output.current;
|
|
55
|
+
if (node) node.scrollTop = node.scrollHeight;
|
|
56
|
+
}, [job.output]);
|
|
57
|
+
|
|
58
|
+
return createPortal(
|
|
59
|
+
<Modal
|
|
60
|
+
onClose={onClose}
|
|
61
|
+
// Above About (`z-50`) — the log is opened FROM that card, not instead of it.
|
|
62
|
+
zClass="z-[65]"
|
|
63
|
+
maxWidthClass="max-w-3xl"
|
|
64
|
+
ariaLabel={`Update log for ${job.label}`}
|
|
65
|
+
header={
|
|
66
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
67
|
+
{running
|
|
68
|
+
? <Loader2 size={15} className="shrink-0 animate-spin text-ink/70 motion-reduce:animate-none" />
|
|
69
|
+
: <StepMark state={job.ok ? 'ok' : 'failed'} />}
|
|
70
|
+
<div className="min-w-0">
|
|
71
|
+
<h2 className="truncate text-sm font-semibold text-ink">Updating {job.label}</h2>
|
|
72
|
+
<p className="truncate font-mono text-[11px] text-ink/50">
|
|
73
|
+
{phaseLabel(job)}
|
|
74
|
+
{job.steps.length > 0 ? ` · ${job.steps.filter((step) => step.state === 'ok').length}/${job.steps.length} steps` : ''}
|
|
75
|
+
</p>
|
|
76
|
+
</div>
|
|
77
|
+
</div>
|
|
78
|
+
}
|
|
79
|
+
footer={
|
|
80
|
+
job.message ? (
|
|
81
|
+
<div className="border-t border-ink/10 px-5 py-2.5">
|
|
82
|
+
<p className="text-[11px] leading-4 text-ink/65">{job.message}</p>
|
|
83
|
+
</div>
|
|
84
|
+
) : undefined
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
<div className="flex min-h-0 flex-col gap-3 px-5 py-4">
|
|
88
|
+
{/* What the run will do, and what it is doing: the commands are the
|
|
89
|
+
reader's way to repeat a step by hand after a failure. */}
|
|
90
|
+
<ul className="space-y-1">
|
|
91
|
+
{job.steps.map((step, index) => (
|
|
92
|
+
<li key={`${step.part}-${index}`} className="flex items-start gap-2">
|
|
93
|
+
<span className="mt-0.5 flex h-3.5 items-center"><StepMark state={step.state} /></span>
|
|
94
|
+
<span className="min-w-0 flex-1">
|
|
95
|
+
<span className="block text-[11px] leading-4 text-ink">{step.part}</span>
|
|
96
|
+
<span className="block break-all font-mono text-[10px] leading-[15px] text-ink/45">
|
|
97
|
+
{step.command}
|
|
98
|
+
{step.state === 'failed' && step.code !== null ? ` — exit ${step.code}` : ''}
|
|
99
|
+
</span>
|
|
100
|
+
</span>
|
|
101
|
+
{/* One line per STATE, because a press can run two installs: the
|
|
102
|
+
reader has to see which half is done. */}
|
|
103
|
+
<span className="shrink-0 text-[10px] leading-4 text-ink/40">{step.state}</span>
|
|
104
|
+
</li>
|
|
105
|
+
))}
|
|
106
|
+
</ul>
|
|
107
|
+
|
|
108
|
+
{/* The output box scrolls on its own — the modal body must not, or the
|
|
109
|
+
step list would scroll away from the log it explains. */}
|
|
110
|
+
<pre
|
|
111
|
+
ref={output}
|
|
112
|
+
className="max-h-[38vh] min-h-[8rem] overflow-auto rounded-lg border border-ink/10 bg-ink/[0.03] px-3 py-2 font-mono text-[10px] leading-[15px] whitespace-pre-wrap break-all text-ink/75"
|
|
113
|
+
>
|
|
114
|
+
{job.output || (running ? 'Waiting for output…' : 'The commands printed nothing.')}
|
|
115
|
+
</pre>
|
|
116
|
+
</div>
|
|
117
|
+
</Modal>,
|
|
118
|
+
document.body,
|
|
119
|
+
);
|
|
120
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The in-flow line an updating harness row carries: what the background worker
|
|
8
|
+
* is doing, and the way into its log.
|
|
9
|
+
*
|
|
10
|
+
* It is a LINE under the row rather than a second icon in the action cell,
|
|
11
|
+
* because that cell is a fixed `1.75rem` track measured for one 24px button —
|
|
12
|
+
* two of them overflow it, which is the same defect the earlier `7rem` track
|
|
13
|
+
* caused in the other direction. In flow it can also carry the step's name,
|
|
14
|
+
* which a bare icon cannot.
|
|
15
|
+
*
|
|
16
|
+
* After the run settles the line stays, showing what happened and keeping
|
|
17
|
+
* `View log` available: the failure case is exactly when the output matters, and
|
|
18
|
+
* the record it lives in survives until the next update replaces it.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export interface UpdateLogLineProps {
|
|
22
|
+
/** Is the worker still installing? */
|
|
23
|
+
running: boolean;
|
|
24
|
+
/** The step it is on (`adapter`, `Claude Code`, …), when the record says. */
|
|
25
|
+
progress: string | null;
|
|
26
|
+
/** The finished run's sentence, once it has one. */
|
|
27
|
+
message: string | null;
|
|
28
|
+
onOpenLog?: () => void;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function UpdateLogLine({ running, progress, message, onOpenLog }: UpdateLogLineProps) {
|
|
32
|
+
return (
|
|
33
|
+
<span className="col-span-3 flex items-center gap-2 pb-1 text-[10px] text-ink/60">
|
|
34
|
+
{running
|
|
35
|
+
? <span>{progress ? `Installing ${progress}…` : 'Updating…'}</span>
|
|
36
|
+
: <span className="min-w-0 truncate">{message ?? 'Update finished'}</span>}
|
|
37
|
+
<button
|
|
38
|
+
type="button"
|
|
39
|
+
data-update-log
|
|
40
|
+
onClick={() => onOpenLog?.()}
|
|
41
|
+
className="shrink-0 cursor-pointer font-medium text-ink underline decoration-ink/30 underline-offset-2 transition-colors hover:decoration-ink"
|
|
42
|
+
>
|
|
43
|
+
View log
|
|
44
|
+
</button>
|
|
45
|
+
</span>
|
|
46
|
+
);
|
|
47
|
+
}
|
|
@@ -12,6 +12,8 @@ import { useKabmoEvent } from '@/client/hooks/ui/window-event';
|
|
|
12
12
|
import { useHarnesses } from '@/client/hooks/models/use-harnesses';
|
|
13
13
|
import { HarnessTable, harnessCategoryFor } from '@/client/components/layout/session-sidebar/about-modal/HarnessTable';
|
|
14
14
|
import { useHarnessVersions } from '@/client/hooks/models/use-harness-versions';
|
|
15
|
+
import { useHarnessUpdate } from '@/client/hooks/models/use-harness-update';
|
|
16
|
+
import { UpdateLogDialog } from '@/client/components/layout/session-sidebar/about-modal/UpdateLogDialog';
|
|
15
17
|
import { useDialogBehaviour } from '@/client/hooks/ui/dialog-behaviour';
|
|
16
18
|
import { UPDATE_POPUP_OPEN_EVENT } from '@/shared/lib/updates/popup-state';
|
|
17
19
|
import type { UpdateTarget } from '@/shared/types/updates';
|
|
@@ -29,6 +31,9 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
29
31
|
// Which product's "what am I running" notes are open. The dialog draws above
|
|
30
32
|
// this panel instead of replacing it, so closing it returns here.
|
|
31
33
|
const [notesTarget, setNotesTarget] = useState<UpdateTarget | null>(null);
|
|
34
|
+
// The update log panel. It is a boolean and not a harness id: one update runs
|
|
35
|
+
// at a time, and the record the hook holds IS the one that was opened.
|
|
36
|
+
const [logOpen, setLogOpen] = useState(false);
|
|
32
37
|
// The About sheet is a dialog to assistive tech and to the keyboard. It had
|
|
33
38
|
// neither: measured in the running console it carried no `role`, no
|
|
34
39
|
// `aria-modal`, and Escape did nothing while focus sat inside it.
|
|
@@ -38,39 +43,20 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
38
43
|
// made in either appears here without a reload.
|
|
39
44
|
const { harnesses, isLoading: harnessesLoading } = useHarnesses();
|
|
40
45
|
const versions = useHarnessVersions();
|
|
41
|
-
// Which harness is mid-update
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if (!response.ok) {
|
|
56
|
-
return payload.error ?? `Update failed (HTTP ${response.status})`;
|
|
57
|
-
}
|
|
58
|
-
// The version the agent reports only changes after a restart, so the row is
|
|
59
|
-
// refreshed rather than optimistic: it will read the OLD number until the
|
|
60
|
-
// agent is probed again, and saying otherwise would be a claim Kabmo cannot
|
|
61
|
-
// stand behind.
|
|
62
|
-
// `refresh`, not `reload(false)`: the rows must be re-read, but forcing a
|
|
63
|
-
// registry request per npm harness after every update is a cost with no
|
|
64
|
-
// answer — the number this update just installed IS the latest one.
|
|
65
|
-
versions.refresh();
|
|
66
|
-
onToast?.(payload.message ?? 'Update finished', 'success');
|
|
67
|
-
return null;
|
|
68
|
-
} catch (cause) {
|
|
69
|
-
return cause instanceof Error ? cause.message : 'Update failed';
|
|
70
|
-
} finally {
|
|
71
|
-
setUpdating(null);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
46
|
+
// Which harness is mid-update, and the step it is on. The run is a BACKGROUND
|
|
47
|
+
// worker, so this hook also ADOPTS a run that is still going when the card
|
|
48
|
+
// opens — a reload no longer loses the update's state.
|
|
49
|
+
const update = useHarnessUpdate(
|
|
50
|
+
(message, ok) => {
|
|
51
|
+
// The hook re-reads the version rows itself once a run settles (the update
|
|
52
|
+
// forgot the cached probe), so what is left here is telling the user what
|
|
53
|
+
// happened. The row will still read the OLD number until the agent is
|
|
54
|
+
// probed again, and saying otherwise would be a claim Kabmo cannot stand
|
|
55
|
+
// behind.
|
|
56
|
+
onToast?.(message, ok ? 'success' : 'error');
|
|
57
|
+
},
|
|
58
|
+
{ enabled: isOpen },
|
|
59
|
+
);
|
|
74
60
|
|
|
75
61
|
// "What's new" opens the popup, which draws at a higher layer: leaving this
|
|
76
62
|
// dialog mounted would stack two modals over the same subject, and its
|
|
@@ -175,8 +161,11 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
175
161
|
harnesses={harnesses}
|
|
176
162
|
versions={versions.rows}
|
|
177
163
|
loading={harnessesLoading}
|
|
178
|
-
onUpdate={
|
|
179
|
-
updating={updating}
|
|
164
|
+
onUpdate={update.start}
|
|
165
|
+
updating={update.updating}
|
|
166
|
+
progress={update.progress}
|
|
167
|
+
log={update.job ? { harness: update.job.harness, message: update.job.message } : null}
|
|
168
|
+
onOpenLog={() => setLogOpen(true)}
|
|
180
169
|
onOpenHarness={(id) => {
|
|
181
170
|
onClose();
|
|
182
171
|
// The settings modal is the frame that owns harness pages; the
|
|
@@ -212,6 +201,10 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
212
201
|
{/* Sibling of the About backdrop, not a child: an event inside the portal
|
|
213
202
|
would otherwise bubble to that backdrop's `onClick` and close About. */}
|
|
214
203
|
{notesTarget && <NotesDialog target={notesTarget} onClose={() => setNotesTarget(null)} />}
|
|
204
|
+
{/* The log draws ABOVE About and does not replace it — the card it was
|
|
205
|
+
opened from keeps its glanceable state. It is not gated on a run being
|
|
206
|
+
in flight: a finished (or failed) record is what a reader came for. */}
|
|
207
|
+
{logOpen && update.job && <UpdateLogDialog job={update.job} onClose={() => setLogOpen(false)} />}
|
|
215
208
|
</>,
|
|
216
209
|
document.body,
|
|
217
210
|
);
|
|
@@ -32,9 +32,12 @@ import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
|
32
32
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
33
33
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
34
34
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
35
|
+
import { useChildExpansion } from '@/client/hooks/workspace/child-expansion';
|
|
35
36
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
36
37
|
import { SessionRow, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
37
38
|
import { SubagentList } from '@/client/components/common/subagent-list';
|
|
39
|
+
import { ChildSessionList } from '@/client/components/layout/session-sidebar/ChildSessionList';
|
|
40
|
+
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
38
41
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
39
42
|
import { WorkspaceOptionsMenu } from '@/client/components/common/workspace-options-menu';
|
|
40
43
|
import { NewWorktreeModal } from '@/client/components/workspace/worktree-modal/index';
|
|
@@ -86,6 +89,7 @@ export function WorkspaceSection({
|
|
|
86
89
|
const urlSubagentId = searchParams.get('subagent');
|
|
87
90
|
const urlSessionId = searchParams.get('sessionId');
|
|
88
91
|
const { expandedSessionIds, toggleSession } = useExpandedSessions();
|
|
92
|
+
const { expandedChildIds, toggleChild } = useChildExpansion();
|
|
89
93
|
const { refresh } = useSidebarData();
|
|
90
94
|
const toggleFetcher = useFetcher<{ success?: boolean }>();
|
|
91
95
|
const {
|
|
@@ -146,6 +150,7 @@ export function WorkspaceSection({
|
|
|
146
150
|
activeSessionId,
|
|
147
151
|
sessionStatus,
|
|
148
152
|
});
|
|
153
|
+
const tree = buildSessionTree(rendered);
|
|
149
154
|
|
|
150
155
|
// A session selection opens every workspace: a checkbox on a collapsed folder
|
|
151
156
|
// would let the user select rows they cannot see or unselect.
|
|
@@ -220,7 +225,7 @@ export function WorkspaceSection({
|
|
|
220
225
|
|
|
221
226
|
{listOpen && (
|
|
222
227
|
<div className="space-y-0.5">
|
|
223
|
-
{
|
|
228
|
+
{tree.roots.map((session) => {
|
|
224
229
|
const key = String(session.id);
|
|
225
230
|
const isActive = activeSessionId !== null
|
|
226
231
|
? String(activeSessionId) === key
|
|
@@ -228,8 +233,10 @@ export function WorkspaceSection({
|
|
|
228
233
|
// While one of its subagents is being viewed, the parent row dims so
|
|
229
234
|
// the highlighted roster entry reads as the active one.
|
|
230
235
|
const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
|
|
236
|
+
const hasChildren = (tree.childrenOf.get(key)?.length ?? 0) > 0;
|
|
231
237
|
const hasSubagents = Boolean(session.hasSubagents);
|
|
232
|
-
const
|
|
238
|
+
const childrenExpanded = hasChildren && expandedChildIds.has(key);
|
|
239
|
+
const rosterExpanded = hasSubagents && expandedSessionIds.has(key);
|
|
233
240
|
const pending = key.startsWith('new-');
|
|
234
241
|
|
|
235
242
|
return (
|
|
@@ -246,9 +253,12 @@ export function WorkspaceSection({
|
|
|
246
253
|
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
247
254
|
worktree={session.worktree}
|
|
248
255
|
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
256
|
+
expandable={hasChildren}
|
|
257
|
+
isExpanded={childrenExpanded}
|
|
258
|
+
onToggleExpand={() => toggleChild(key)}
|
|
249
259
|
hasSubagents={hasSubagents}
|
|
250
|
-
|
|
251
|
-
|
|
260
|
+
subagentsExpanded={rosterExpanded}
|
|
261
|
+
onToggleSubagents={() => toggleSession(key)}
|
|
252
262
|
onClick={() => onSelectSession(session.id)}
|
|
253
263
|
onArchive={() => handleArchive(session)}
|
|
254
264
|
// A pending `new-…` chat has no transcript anywhere yet, so
|
|
@@ -263,7 +273,10 @@ export function WorkspaceSection({
|
|
|
263
273
|
selected={Boolean(batch?.selected.includes(key))}
|
|
264
274
|
onToggleSelect={batch ? () => batch.toggle(key) : undefined}
|
|
265
275
|
/>
|
|
266
|
-
{
|
|
276
|
+
{childrenExpanded && (
|
|
277
|
+
<ChildSessionList parentId={key} childrenOf={tree.childrenOf} onSelect={onSelectSession} />
|
|
278
|
+
)}
|
|
279
|
+
{rosterExpanded && (
|
|
267
280
|
<SubagentList
|
|
268
281
|
sessionId={session.id}
|
|
269
282
|
isActiveSession={activeSessionId !== null && key === String(activeSessionId)}
|
|
@@ -3,9 +3,12 @@ import { FolderItemMenu } from '@/client/components/mobile/mobile-session-sideba
|
|
|
3
3
|
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
4
4
|
import { MobileSessionRow } from '@/client/components/mobile/mobile-session-sidebar/SessionRow';
|
|
5
5
|
import { SubagentList } from '@/client/components/common/subagent-list';
|
|
6
|
+
import { ChildSessionList } from '@/client/components/layout/session-sidebar/ChildSessionList';
|
|
7
|
+
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
6
8
|
import { useWorktreeDialog } from '@/client/components/mobile/mobile-session-sidebar/WorktreeDialog';
|
|
7
9
|
import { useShowMore } from '@/client/hooks/ui/show-more';
|
|
8
10
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
11
|
+
import { useChildExpansion } from '@/client/hooks/workspace/child-expansion';
|
|
9
12
|
import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-folder-actions';
|
|
10
13
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
11
14
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
@@ -62,6 +65,7 @@ export function MobileSessionCategory({
|
|
|
62
65
|
);
|
|
63
66
|
const { refresh } = useSidebarData();
|
|
64
67
|
const { expandedSessionIds, toggleSession } = useExpandedSessions();
|
|
68
|
+
const { expandedChildIds, toggleChild } = useChildExpansion();
|
|
65
69
|
// The viewed transcript, so its session row dims while a roster entry is
|
|
66
70
|
// open (desktop parity — same params, same rule).
|
|
67
71
|
const [searchParams] = useSearchParams();
|
|
@@ -112,6 +116,7 @@ export function MobileSessionCategory({
|
|
|
112
116
|
activeSessionId,
|
|
113
117
|
sessionStatus,
|
|
114
118
|
});
|
|
119
|
+
const tree = buildSessionTree(visibleSessions);
|
|
115
120
|
const listOpen = isExpanded || sessionCheckboxes;
|
|
116
121
|
|
|
117
122
|
return (
|
|
@@ -224,7 +229,7 @@ export function MobileSessionCategory({
|
|
|
224
229
|
|
|
225
230
|
{listOpen && (
|
|
226
231
|
<div className="mt-0.5 space-y-0.5">
|
|
227
|
-
{
|
|
232
|
+
{tree.roots.map((session) => {
|
|
228
233
|
const sessionKey = String(session.id);
|
|
229
234
|
const isSessionActive = String(activeSessionId) === sessionKey;
|
|
230
235
|
// While one of its subagents is being viewed, the parent session
|
|
@@ -233,9 +238,11 @@ export function MobileSessionCategory({
|
|
|
233
238
|
const isViewingSubagent = isSessionActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
|
|
234
239
|
// Same gate as desktop: the omp-side loader flag is authoritative,
|
|
235
240
|
// so a session whose roster exists on disk can be opened without a
|
|
236
|
-
// live process.
|
|
241
|
+
// live process. Children are a separate, tree-level disclosure.
|
|
237
242
|
const hasSubagents = Boolean(session.hasSubagents);
|
|
243
|
+
const hasChildren = (tree.childrenOf.get(sessionKey)?.length ?? 0) > 0;
|
|
238
244
|
const isRosterOpen = hasSubagents && expandedSessionIds.has(sessionKey);
|
|
245
|
+
const childrenOpen = hasChildren && expandedChildIds.has(sessionKey);
|
|
239
246
|
|
|
240
247
|
return (
|
|
241
248
|
<div key={session.id} className="space-y-0.5">
|
|
@@ -247,8 +254,11 @@ export function MobileSessionCategory({
|
|
|
247
254
|
awaitingInput={Boolean(session.awaitingInput)}
|
|
248
255
|
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
249
256
|
hasSubagents={hasSubagents}
|
|
250
|
-
|
|
251
|
-
|
|
257
|
+
subagentsExpanded={isRosterOpen}
|
|
258
|
+
onToggleSubagents={() => toggleSession(sessionKey)}
|
|
259
|
+
expandable={hasChildren}
|
|
260
|
+
isExpanded={childrenOpen}
|
|
261
|
+
onToggleExpand={() => toggleChild(sessionKey)}
|
|
252
262
|
onSelect={() => onSelectSession(session.id)}
|
|
253
263
|
onArchive={() => handleArchive(session)}
|
|
254
264
|
onDelete={
|
|
@@ -272,6 +282,13 @@ export function MobileSessionCategory({
|
|
|
272
282
|
selected={Boolean(batch?.selected.includes(sessionKey))}
|
|
273
283
|
onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
|
|
274
284
|
/>
|
|
285
|
+
{childrenOpen && (
|
|
286
|
+
<ChildSessionList
|
|
287
|
+
parentId={sessionKey}
|
|
288
|
+
childrenOf={tree.childrenOf}
|
|
289
|
+
onSelect={onSelectSession}
|
|
290
|
+
/>
|
|
291
|
+
)}
|
|
275
292
|
{isRosterOpen && (
|
|
276
293
|
<SubagentList sessionId={session.id} isActiveSession={isSessionActive} />
|
|
277
294
|
)}
|