@kabmo-labs/kabmo 0.25.0 → 0.27.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 +448 -444
- package/dist/client/static/js/index-32rpkj6b.css +1 -0
- package/dist/client/static/js/{index-ga8cbpt4.js → index-e3qh2yps.js} +950 -950
- package/package.json +1 -1
- package/src/client/components/common/Toast.test.tsx +28 -2
- package/src/client/components/common/Toast.tsx +21 -9
- package/src/client/components/common/session-actions-menu/index.tsx +38 -12
- package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
- package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
- package/src/client/components/common/session-branch/index.tsx +169 -0
- package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
- package/src/client/components/common/session-branch/style.ts +29 -0
- package/src/client/components/common/session-row/StatusSlot.tsx +15 -3
- package/src/client/components/common/session-row/index.tsx +24 -25
- package/src/client/components/common/session-row/session-row.test.tsx +11 -0
- package/src/client/components/common/session-state-provider/index.tsx +1 -1
- package/src/client/components/layout/desktop-layout/LeftColumn.tsx +2 -1
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +66 -69
- package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
- package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
- package/src/client/components/layout/session-sidebar/SessionItem.tsx +33 -30
- package/src/client/components/layout/session-sidebar/SessionList.tsx +2 -1
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +35 -225
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +36 -16
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +11 -3
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +13 -4
- package/src/client/components/layout/session-sidebar/about-modal/UpdateSection.tsx +3 -2
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +30 -14
- package/src/client/components/layout/session-sidebar/modern/RevealRow.tsx +56 -0
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +69 -85
- package/src/client/components/layout/session-sidebar/modern/reveal-row.test.tsx +104 -0
- package/src/client/components/layout/session-sidebar/scheduler-modal/index.tsx +2 -1
- package/src/client/components/layout/session-sidebar/variant-props.ts +2 -1
- package/src/client/components/mobile/SessionSidebar.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/ClassicDrawer.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +59 -62
- package/src/client/components/mobile/mobile-session-sidebar/List.tsx +2 -1
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +33 -30
- package/src/client/components/settings/Modal.tsx +1 -1
- package/src/client/components/settings/Sidebar.tsx +1 -1
- package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
- package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
- package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
- package/src/client/components/settings/categories/project-settings/WorktreeSettings.tsx +2 -1
- package/src/client/components/settings/categories/usage-settings/LimitsSection.tsx +39 -19
- package/src/client/components/settings/categories/usage-settings/ProviderDetail.tsx +1 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.test.ts +94 -0
- package/src/client/components/settings/categories/usage-settings/limit-groups.ts +118 -0
- package/src/client/components/settings/categories/usage-settings/limits-section.test.tsx +118 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
- package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +86 -93
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +7 -5
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +21 -1
- package/src/client/components/workspace/chat-timeline/PendingTranscript.tsx +130 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
- package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
- package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
- package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
- package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
- package/src/client/components/workspace/chat-timeline/fork-preview.test.tsx +141 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +16 -22
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +116 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
- package/src/client/components/workspace/chat-timeline/target-picker/WorktreePicker.tsx +5 -4
- package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
- package/src/client/components/workspace/git-panel/index.tsx +2 -2
- package/src/client/components/workspace/terminal-panel/RealtimeTerminalView.tsx +8 -5
- package/src/client/components/workspace/terminal-panel/index.tsx +3 -0
- package/src/client/hooks/chat/composer/items.test.ts +19 -0
- package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
- package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
- package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
- package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
- package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
- package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
- package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
- package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
- package/src/client/hooks/chat/omp/run-switch.ts +1 -1
- package/src/client/hooks/chat/omp/session-list.tsx +9 -0
- package/src/client/hooks/chat/omp/sidebar-reload.test.ts +85 -0
- package/src/client/hooks/chat/omp/sidebar-reload.ts +30 -0
- package/src/client/hooks/chat/subagents/roster.ts +122 -0
- package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
- package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
- package/src/client/hooks/chat/timeline/fork-preview.test.ts +148 -0
- package/src/client/hooks/chat/timeline/fork-preview.ts +104 -0
- package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
- package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
- package/src/client/hooks/chat/timeline/fork-send.test.ts +139 -0
- package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
- package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
- package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
- package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
- package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
- package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
- package/src/client/hooks/chat/timeline/modes.ts +42 -29
- package/src/client/hooks/chat/timeline/pending-branch.ts +214 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +302 -0
- package/src/client/hooks/chat/timeline/send.ts +17 -103
- package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
- package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
- package/src/client/hooks/chat/timeline/use-fork-session.ts +40 -31
- package/src/client/hooks/chat/waiting/cancel.ts +2 -1
- package/src/client/hooks/chat/waiting/dispatch.ts +5 -4
- package/src/client/hooks/chat/waiting/held.ts +2 -1
- package/src/client/hooks/models/use-harness-update.test.ts +137 -44
- package/src/client/hooks/models/use-harness-update.ts +133 -85
- package/src/client/hooks/settings/providers/actions.ts +3 -2
- package/src/client/hooks/settings/providers/messages.ts +9 -7
- package/src/client/hooks/settings/providers/model-actions.ts +2 -1
- package/src/client/hooks/ui/editor-error-toast.ts +2 -1
- package/src/client/hooks/ui/input-required-alert.ts +12 -5
- package/src/client/hooks/ui/notifications.ts +45 -0
- package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
- package/src/client/hooks/workspace/batch-archive.test.ts +2 -2
- package/src/client/hooks/workspace/batch-archive.ts +4 -2
- package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
- package/src/client/hooks/workspace/git-action-outcome.ts +4 -3
- package/src/client/hooks/workspace/navbar-session-actions.ts +2 -1
- package/src/client/hooks/workspace/session-actions.test.ts +2 -1
- package/src/client/hooks/workspace/session-actions.ts +2 -1
- package/src/client/hooks/workspace/terminal/connection.test.ts +63 -0
- package/src/client/hooks/workspace/terminal/connection.ts +47 -0
- package/src/client/hooks/workspace/terminal/index.ts +35 -4
- package/src/client/hooks/workspace/workspace-folder-actions.ts +2 -1
- package/src/client/lib/native/open-session.ts +33 -0
- package/src/client/lib/notifications/os.test.ts +125 -0
- package/src/client/lib/notifications/os.ts +130 -0
- package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
- package/src/client/lib/router/open-session.test.ts +75 -0
- package/src/client/lib/router/open-session.ts +34 -0
- package/src/client/lib/signals.ts +5 -1
- package/src/client/main.tsx +6 -0
- package/src/server/lib/db/schema.ts +1 -0
- package/src/server/lib/harness/acp/calls.ts +15 -1
- package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
- package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
- package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
- package/src/server/lib/harness/acp/client-fs.ts +131 -0
- package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
- package/src/server/lib/harness/acp/client-initialize.ts +84 -0
- package/src/server/lib/harness/acp/client.ts +31 -21
- package/src/server/lib/harness/acp/commands.test.ts +5 -5
- package/src/server/lib/harness/acp/commands.ts +14 -2
- package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
- package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
- package/src/server/lib/harness/acp/frames.ts +71 -158
- package/src/server/lib/harness/acp/mapper.test.ts +40 -0
- package/src/server/lib/harness/acp/mapper.ts +12 -0
- package/src/server/lib/harness/acp/permissions.ts +6 -0
- package/src/server/lib/harness/acp/protocol.ts +41 -2
- package/src/server/lib/harness/acp/session-facts.ts +1 -1
- package/src/server/lib/harness/acp/session-handshake.test.ts +90 -1
- package/src/server/lib/harness/acp/session-handshake.ts +83 -6
- package/src/server/lib/harness/acp/session-idle.ts +7 -6
- package/src/server/lib/harness/acp/session-notifications.ts +41 -2
- package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
- package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
- package/src/server/lib/harness/acp/session-permissions.ts +36 -0
- package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
- package/src/server/lib/harness/acp/session-requests.ts +48 -6
- package/src/server/lib/harness/acp/session-turns.ts +8 -3
- package/src/server/lib/harness/acp/session-usage.ts +4 -0
- package/src/server/lib/harness/acp/session-web-state.ts +30 -2
- package/src/server/lib/harness/acp/session.test-util.ts +19 -1
- package/src/server/lib/harness/acp/session.ts +60 -60
- package/src/server/lib/harness/acp/tool-calls.ts +223 -0
- package/src/server/lib/harness/acp/turn.test.ts +102 -0
- package/src/server/lib/harness/acp/turn.ts +81 -6
- package/src/server/lib/harness/acp/v2.test.ts +144 -0
- package/src/server/lib/harness/acp/v2.ts +220 -0
- package/src/server/lib/harness/acp/verbs.ts +46 -6
- package/src/server/lib/harness/launch.test.ts +25 -0
- package/src/server/lib/harness/launch.ts +21 -9
- package/src/server/lib/harness/session.ts +3 -0
- package/src/server/lib/harness/update-job-store.test.ts +37 -12
- package/src/server/lib/harness/update-job-store.ts +22 -16
- package/src/server/lib/harness/update-job.server.ts +66 -175
- package/src/server/lib/harness/update-queue.server.ts +292 -0
- package/src/server/lib/harness/update-queue.test.ts +265 -0
- package/src/server/lib/harness/update-spawn.server.ts +96 -0
- package/src/server/lib/harness/update-worker.ts +8 -3
- package/src/server/lib/lifecycle/after-listen.ts +9 -0
- package/src/server/lib/lifecycle/paths.ts +14 -9
- package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
- package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
- package/src/server/lib/omp/rpc/terminal-settle.ts +5 -1
- package/src/server/lib/omp/session/delete-flow.server.ts +1 -0
- package/src/server/lib/omp/session/sidebar-data.server.ts +10 -12
- package/src/server/lib/sessions/fork.server.test.ts +68 -0
- package/src/server/lib/sessions/fork.server.ts +31 -6
- package/src/server/lib/sessions/spawn.server.test.ts +41 -0
- package/src/server/lib/sessions/spawn.server.ts +27 -2
- package/src/server/lib/usage/report.server.ts +57 -0
- package/src/server/routes/agent/harness-command.ts +6 -5
- package/src/server/routes/chat/stream.ts +7 -2
- package/src/server/routes/harness/update-status.ts +18 -12
- package/src/server/routes/harness/update.test.ts +53 -16
- package/src/server/routes/harness/update.ts +13 -8
- package/src/server/routes/sessions/body-readers.ts +43 -0
- package/src/server/routes/sessions/fork.ts +19 -4
- package/src/server/routes/sessions/routes.test.ts +1 -2
- package/src/server/routes/sessions/session.ts +19 -0
- package/src/server/routes/sessions/spawn.ts +16 -13
- package/src/shared/lib/chat/omp/agent-events.ts +11 -0
- package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
- package/src/shared/lib/chat/timeline/fork-preview.test.ts +62 -0
- package/src/shared/lib/chat/timeline/fork-preview.ts +36 -0
- package/src/shared/lib/harness/mode-signal.ts +20 -0
- package/src/shared/lib/harness/session-modes.ts +24 -0
- package/src/shared/lib/harness/update-job.ts +53 -6
- package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
- package/src/shared/lib/notifications/outcomes.test.ts +96 -0
- package/src/shared/lib/notifications/outcomes.ts +64 -0
- package/src/shared/lib/notifications/settings.test.ts +49 -0
- package/src/shared/lib/notifications/settings.ts +34 -0
- package/src/shared/lib/omp/session/default-title.ts +5 -4
- package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
- package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
- package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
- package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
- package/src/shared/lib/settings/defaults.ts +3 -0
- package/src/shared/lib/ui/toast-duration.test.ts +25 -1
- package/src/shared/lib/ui/toast-duration.ts +22 -4
- package/src/shared/lib/workspace/session-state/store.ts +4 -0
- package/src/shared/types/harness-update.ts +24 -0
- package/src/shared/types/realtime.ts +2 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/src/shared/types/workspace.ts +4 -0
- package/src/test-support/harness-table.test-util.ts +25 -9
- package/dist/client/static/js/index-bc9aa4mx.css +0 -1
- package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +0 -113
- package/src/client/components/common/subagent-list/index.tsx +0 -165
- package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +0 -66
- package/src/client/hooks/workspace/child-expansion.ts +0 -33
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { useEffect, useState } from 'preact/hooks';
|
|
2
|
-
import { Square } from 'lucide-preact';
|
|
3
|
-
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
4
|
-
import { SubagentStatusIcon } from '@/client/components/common/SubagentStatusIcon';
|
|
5
|
-
import { isRecord } from '@/shared/lib/util/guards';
|
|
6
|
-
import { fetchSubagentHistory, historyEntryToSubagentInfo } from '@/shared/lib/omp/subagent/history/client';
|
|
7
|
-
import { subagentRowLabel } from '@/shared/lib/omp/subagent/label';
|
|
8
|
-
import { mergeSubagentRoster, parseSubagentLifecycle, parseSubagentRosterResponse, readSubagentProgressFrame } from '@/shared/lib/omp/subagent/parse';
|
|
9
|
-
import { subscribeSubagentFrame, type SubagentFrame } from '@/shared/lib/chat/omp/subagent-frames';
|
|
10
|
-
import { cancelSubagent } from '@/shared/lib/omp/subagent/control';
|
|
11
|
-
import type { SubagentInfo, SubagentProgress } from '@/shared/types';
|
|
12
|
-
|
|
13
|
-
type SubagentListProps = {
|
|
14
|
-
sessionId: string | number;
|
|
15
|
-
isActiveSession: boolean;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const PROGRESS_STATUS: Record<NonNullable<SubagentProgress['status']>, SubagentInfo['status']> = {
|
|
19
|
-
pending: 'started', running: 'started', completed: 'completed', failed: 'failed', aborted: 'aborted',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
/** Fold one progress frame into the roster entry it names (id, else index). */
|
|
23
|
-
function applyProgress(roster: SubagentInfo[], progress: SubagentProgress): SubagentInfo[] {
|
|
24
|
-
return roster.map((entry) => {
|
|
25
|
-
if (progress.id !== undefined) {
|
|
26
|
-
if (entry.id !== progress.id) return entry;
|
|
27
|
-
} else if (progress.index === undefined || progress.index < 0 || entry.index !== progress.index) {
|
|
28
|
-
return entry;
|
|
29
|
-
}
|
|
30
|
-
const status = progress.status && entry.status === 'started'
|
|
31
|
-
? PROGRESS_STATUS[progress.status] ?? entry.status
|
|
32
|
-
: entry.status;
|
|
33
|
-
return { ...entry, status, progress: { ...entry.progress, ...progress }, lastUpdate: Date.now() };
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Subagent roster nested under a session row: renders clean, readable subagent
|
|
39
|
-
* items matching the minimalist sidebar layout while preserving interactive inspection.
|
|
40
|
-
* Shared by the desktop sidebar's `CategoryItem` and the mobile drawer's
|
|
41
|
-
* `MobileSessionCategory`, so both list the same roster.
|
|
42
|
-
*/
|
|
43
|
-
export function SubagentList({ sessionId, isActiveSession }: SubagentListProps) {
|
|
44
|
-
const [searchParams] = useSearchParams();
|
|
45
|
-
const viewedSubagentId = searchParams.get('subagent');
|
|
46
|
-
const [subagents, setSubagents] = useState<SubagentInfo[]>([]);
|
|
47
|
-
const [isLoading, setIsLoading] = useState(false);
|
|
48
|
-
|
|
49
|
-
// History pass: the roster floor for every session.
|
|
50
|
-
useEffect(() => {
|
|
51
|
-
let cancelled = false;
|
|
52
|
-
const sid = String(sessionId);
|
|
53
|
-
setSubagents([]);
|
|
54
|
-
setIsLoading(true);
|
|
55
|
-
void fetchSubagentHistory(sid)
|
|
56
|
-
.then((entries) => {
|
|
57
|
-
if (cancelled || !entries) return;
|
|
58
|
-
const roster = entries.map(historyEntryToSubagentInfo);
|
|
59
|
-
setSubagents((prev) => mergeSubagentRoster(prev, roster));
|
|
60
|
-
})
|
|
61
|
-
.finally(() => { if (!cancelled) setIsLoading(false); });
|
|
62
|
-
return () => { cancelled = true; };
|
|
63
|
-
}, [sessionId]);
|
|
64
|
-
|
|
65
|
-
// Live pass: active session only.
|
|
66
|
-
useEffect(() => {
|
|
67
|
-
if (!isActiveSession) return;
|
|
68
|
-
let cancelled = false;
|
|
69
|
-
const sid = String(sessionId);
|
|
70
|
-
const requestedAt = Date.now();
|
|
71
|
-
const forThisSession = (frame: SubagentFrame) =>
|
|
72
|
-
frame.sessionId === sid ? frame.payload : null;
|
|
73
|
-
|
|
74
|
-
const unsubLifecycle = subscribeSubagentFrame('subagent_lifecycle', (frame) => {
|
|
75
|
-
const entry = parseSubagentLifecycle(forThisSession(frame));
|
|
76
|
-
if (entry) {
|
|
77
|
-
setSubagents((prev) => mergeSubagentRoster(prev, [entry]));
|
|
78
|
-
}
|
|
79
|
-
});
|
|
80
|
-
const unsubProgress = subscribeSubagentFrame('subagent_progress', (frame) => {
|
|
81
|
-
const progress = readSubagentProgressFrame(forThisSession(frame));
|
|
82
|
-
if (progress) setSubagents((prev) => applyProgress(prev, progress));
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
// Snapshot the LIVE registry. This POST is the spawn path, so the server
|
|
86
|
-
// refuses it (409) for a session it does not manage — an observer read must
|
|
87
|
-
// never boot an omp child. The history pass above already covers a finished
|
|
88
|
-
// session from disk, so nothing is missing when this comes back empty.
|
|
89
|
-
fetch(`/api/agent/${encodeURIComponent(sid)}`, {
|
|
90
|
-
method: 'POST',
|
|
91
|
-
headers: { 'Content-Type': 'application/json' },
|
|
92
|
-
body: JSON.stringify({ type: 'get_subagents' }),
|
|
93
|
-
})
|
|
94
|
-
.then((res) => (res.ok ? res.json() : null))
|
|
95
|
-
.then((body: unknown) => {
|
|
96
|
-
if (cancelled || !isRecord(body)) return;
|
|
97
|
-
const payload = 'data' in body ? body.data : body;
|
|
98
|
-
setSubagents((prev) => mergeSubagentRoster(prev, parseSubagentRosterResponse(payload), requestedAt));
|
|
99
|
-
})
|
|
100
|
-
.catch(() => {});
|
|
101
|
-
|
|
102
|
-
return () => {
|
|
103
|
-
cancelled = true;
|
|
104
|
-
unsubLifecycle();
|
|
105
|
-
unsubProgress();
|
|
106
|
-
};
|
|
107
|
-
}, [isActiveSession, sessionId]);
|
|
108
|
-
|
|
109
|
-
const hint = isLoading ? 'Loading subagents…' : subagents.length === 0 ? 'No subagent activity' : null;
|
|
110
|
-
|
|
111
|
-
return (
|
|
112
|
-
<div className="pl-6 pr-0 space-y-0.5 py-0.5">
|
|
113
|
-
{hint ? (
|
|
114
|
-
<div className="px-2 py-1 text-xs italic text-ink/40 flex items-center">
|
|
115
|
-
<span className="w-4 h-4 shrink-0" />
|
|
116
|
-
<span className="w-2 shrink-0" />
|
|
117
|
-
<span className="flex-1 min-w-0 truncate">{hint}</span>
|
|
118
|
-
</div>
|
|
119
|
-
) : (
|
|
120
|
-
subagents.map((subagent) => {
|
|
121
|
-
const label = subagentRowLabel(subagent);
|
|
122
|
-
const brief = subagent.task ?? subagent.assignment ?? subagent.description ?? label;
|
|
123
|
-
const isViewed = subagent.id === viewedSubagentId;
|
|
124
|
-
// A running subagent can be stopped from the roster. The row itself is
|
|
125
|
-
// a button (it opens the transcript), so the control is a SIBLING —
|
|
126
|
-
// nesting one button in another is invalid and swallows the inner
|
|
127
|
-
// click.
|
|
128
|
-
const running = isActiveSession && subagent.status === 'started';
|
|
129
|
-
return (
|
|
130
|
-
<div key={subagent.id} className="flex items-center group/subagent-row">
|
|
131
|
-
<button
|
|
132
|
-
type="button"
|
|
133
|
-
title={brief}
|
|
134
|
-
onClick={() => window.dispatchEvent(new CustomEvent('omp:view-subagent', { detail: { sessionId: String(sessionId), subagent } }))}
|
|
135
|
-
className={`flex-1 min-w-0 flex items-center text-left text-xs rounded-md px-2 py-1 cursor-pointer transition-colors select-none group/subagent ${isViewed ? 'bg-ink/10 font-medium text-ink' : 'text-ink/70 hover:text-ink hover:bg-ink/5'}`}
|
|
136
|
-
>
|
|
137
|
-
{/* Subagent status icon slot - aligned straight with session item text */}
|
|
138
|
-
<span className="w-4 h-4 flex items-center justify-center shrink-0">
|
|
139
|
-
<SubagentStatusIcon status={subagent.status} live={running} size={11} />
|
|
140
|
-
</span>
|
|
141
|
-
|
|
142
|
-
{/* Gap between subagent icon and task text */}
|
|
143
|
-
<span className="w-2 shrink-0" />
|
|
144
|
-
|
|
145
|
-
{/* Subagent label: `id (agent): target` */}
|
|
146
|
-
<span className="flex-1 min-w-0 truncate leading-snug">{label}</span>
|
|
147
|
-
</button>
|
|
148
|
-
{running && (
|
|
149
|
-
<button
|
|
150
|
-
type="button"
|
|
151
|
-
title="Stop this subagent"
|
|
152
|
-
aria-label="Stop this subagent"
|
|
153
|
-
onClick={() => void cancelSubagent(String(sessionId), subagent.id)}
|
|
154
|
-
className="touch-visible shrink-0 mr-1 w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/5 opacity-0 group-hover/subagent-row:opacity-100 transition-opacity cursor-pointer"
|
|
155
|
-
>
|
|
156
|
-
<Square size={10} />
|
|
157
|
-
</button>
|
|
158
|
-
)}
|
|
159
|
-
</div>
|
|
160
|
-
);
|
|
161
|
-
})
|
|
162
|
-
)}
|
|
163
|
-
</div>
|
|
164
|
-
);
|
|
165
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* SPDX-License-Identifier: MIT
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The rows under an expanded session: real sessions, drawn compactly.
|
|
8
|
-
*
|
|
9
|
-
* These are NOT subagents. A subagent row is a tool call with a task name and
|
|
10
|
-
* no session behind it; a child row opens `/sessions/:id`, carries the harness
|
|
11
|
-
* mark in its usual leading position, and may itself have children. Keeping the
|
|
12
|
-
* two lists separate is what stops one chevron from meaning two things.
|
|
13
|
-
*
|
|
14
|
-
* Indentation, not a second row style: the harness glyph stays where every
|
|
15
|
-
* session row puts it, and the depth is the only visual difference.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
|
|
19
|
-
import { descendantsOf } from '@/client/lib/session-tree';
|
|
20
|
-
import type { SessionItemData } from '@/shared/types';
|
|
21
|
-
|
|
22
|
-
export interface ChildSessionListProps {
|
|
23
|
-
parentId: string;
|
|
24
|
-
childrenOf: Map<string, SessionItemData[]>;
|
|
25
|
-
onSelect: (sessionId: string | number) => void;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
function statusDot(session: SessionItemData): string {
|
|
29
|
-
if (session.awaitingInput) return 'bg-amber-500';
|
|
30
|
-
if (session.streamStatus === 'stream') return 'bg-emerald-500 animate-pulse';
|
|
31
|
-
if (session.is_archived === 1) return 'bg-ink/20';
|
|
32
|
-
return 'bg-ink/25';
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function ChildSessionList({ parentId, childrenOf, onSelect }: ChildSessionListProps) {
|
|
36
|
-
const rows = descendantsOf(parentId, childrenOf);
|
|
37
|
-
if (rows.length === 0) return null;
|
|
38
|
-
|
|
39
|
-
return (
|
|
40
|
-
<div data-testid="child-session-list" className="space-y-0.5">
|
|
41
|
-
{rows.map(({ session, depth }) => {
|
|
42
|
-
const title = session.title.charAt(0).toUpperCase() + session.title.slice(1);
|
|
43
|
-
return (
|
|
44
|
-
<button
|
|
45
|
-
key={session.id}
|
|
46
|
-
type="button"
|
|
47
|
-
data-testid="child-session-row"
|
|
48
|
-
data-session-id={String(session.id)}
|
|
49
|
-
onClick={() => onSelect(session.id)}
|
|
50
|
-
title={session.title}
|
|
51
|
-
className="group/child flex w-full items-center rounded-lg py-1 pr-2 text-left text-xs text-ink/70 transition-colors cursor-pointer hover:bg-ink/5 hover:text-ink"
|
|
52
|
-
style={{ paddingLeft: `${8 + depth * 12}px` }}
|
|
53
|
-
>
|
|
54
|
-
<span className={`mr-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${statusDot(session)}`} aria-hidden="true" />
|
|
55
|
-
{session.harness && (
|
|
56
|
-
<span className="mr-1.5 flex shrink-0 items-center">
|
|
57
|
-
<HarnessGlyph harness={session.harness} size={HARNESS_GLYPH_SIZE.compact} />
|
|
58
|
-
</span>
|
|
59
|
-
)}
|
|
60
|
-
<span className="min-w-0 flex-1 truncate">{title}</span>
|
|
61
|
-
</button>
|
|
62
|
-
);
|
|
63
|
-
})}
|
|
64
|
-
</div>
|
|
65
|
-
);
|
|
66
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
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
|
-
}
|