@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.
Files changed (205) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +579 -510
  3. package/dist/client/static/js/index-bc9aa4mx.css +1 -0
  4. package/dist/client/static/js/{index-jcr5twtp.js → index-ga8cbpt4.js} +1072 -1174
  5. package/package.json +2 -4
  6. package/src/cli/lib/args.js +24 -1
  7. package/src/cli/lib/args.test.js +16 -0
  8. package/src/cli/lib/commands/session.js +233 -0
  9. package/src/cli/lib/commands/session.test.js +103 -0
  10. package/src/cli/main.js +1 -1
  11. package/src/client/components/common/ComposerPicker.tsx +3 -0
  12. package/src/client/components/common/code-surface/shiki.test.ts +82 -0
  13. package/src/client/components/common/code-surface/shiki.ts +28 -7
  14. package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +113 -0
  15. package/src/client/components/common/session-actions-menu/index.tsx +33 -2
  16. package/src/client/components/common/session-row/StatusSlot.tsx +4 -4
  17. package/src/client/components/common/session-row/index.tsx +27 -1
  18. package/src/client/components/layout/desktop-layout/resizer/separator-drag.ts +3 -3
  19. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +25 -12
  20. package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +66 -0
  21. package/src/client/components/layout/session-sidebar/SessionItem.tsx +28 -3
  22. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +36 -5
  23. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +94 -0
  24. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
  25. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +120 -0
  26. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +47 -0
  27. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +28 -35
  28. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +18 -5
  29. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +21 -4
  30. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +27 -5
  31. package/src/client/components/workspace/chat-timeline/ComposerDock.tsx +64 -70
  32. package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
  33. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +135 -118
  34. package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
  35. package/src/client/components/workspace/chat-timeline/MessageList.tsx +4 -0
  36. package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
  37. package/src/client/components/workspace/chat-timeline/composer-dock-frame.test.tsx +155 -0
  38. package/src/client/components/workspace/chat-timeline/index.tsx +3 -1
  39. package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
  40. package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
  41. package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
  42. package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
  43. package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
  44. package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
  45. package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
  46. package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
  47. package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
  48. package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
  49. package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
  50. package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
  51. package/src/client/data/settings/omp-schema.json +1 -1
  52. package/src/client/data/theme/terminal.test.ts +25 -0
  53. package/src/client/data/theme/terminal.ts +96 -79
  54. package/src/client/hooks/chat/composer/items.test.ts +12 -26
  55. package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -0
  56. package/src/client/hooks/chat/omp/prompt-send.test.ts +7 -7
  57. package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
  58. package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
  59. package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
  60. package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
  61. package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
  62. package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
  63. package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
  64. package/src/client/hooks/chat/timeline/send.test.ts +3 -1
  65. package/src/client/hooks/chat/timeline/send.ts +51 -50
  66. package/src/client/hooks/chat/timeline/use-fork-session.ts +49 -0
  67. package/src/client/hooks/models/use-harness-update.test.ts +193 -0
  68. package/src/client/hooks/models/use-harness-update.ts +202 -0
  69. package/src/client/hooks/workspace/child-expansion.ts +33 -0
  70. package/src/client/hooks/workspace/terminal/index.ts +17 -3
  71. package/src/client/hooks/workspace/terminal/socket.ts +9 -4
  72. package/src/client/lib/session-tree.test.ts +50 -0
  73. package/src/client/lib/session-tree.ts +59 -0
  74. package/src/client/tailwind.css +17 -11
  75. package/src/server/index.ts +2 -0
  76. package/src/server/lib/auth/guard.ts +10 -0
  77. package/src/server/lib/btw/session-copy.server.ts +6 -44
  78. package/src/server/lib/btw/session-copy.test.ts +2 -1
  79. package/src/server/lib/db/schema.ts +4 -0
  80. package/src/server/lib/db/seed-terminal.test.ts +1 -1
  81. package/src/server/lib/db/seed.test.ts +1 -1
  82. package/src/server/lib/harness/acp/background-work.test.ts +262 -0
  83. package/src/server/lib/harness/acp/background-work.ts +320 -0
  84. package/src/server/lib/harness/acp/client.ts +2 -2
  85. package/src/server/lib/harness/acp/gateway-env.test.ts +64 -0
  86. package/src/server/lib/harness/acp/gateway-env.ts +70 -0
  87. package/src/server/lib/harness/acp/prompt.test.ts +20 -0
  88. package/src/server/lib/harness/acp/prompt.ts +19 -3
  89. package/src/server/lib/harness/acp/session-background.test.ts +129 -0
  90. package/src/server/lib/harness/acp/session-exit.ts +31 -0
  91. package/src/server/lib/harness/acp/session-handshake.test.ts +108 -0
  92. package/src/server/lib/harness/acp/session-handshake.ts +27 -1
  93. package/src/server/lib/harness/acp/session-listeners.ts +31 -0
  94. package/src/server/lib/harness/acp/session-requests.ts +47 -0
  95. package/src/server/lib/harness/acp/session-turns.ts +20 -5
  96. package/src/server/lib/harness/acp/session.test-util.ts +23 -1
  97. package/src/server/lib/harness/acp/session.ts +59 -59
  98. package/src/server/lib/harness/acp/turn.test.ts +81 -0
  99. package/src/server/lib/harness/acp/turn.ts +26 -9
  100. package/src/server/lib/harness/acp/verbs.ts +12 -2
  101. package/src/server/lib/harness/launch.ts +3 -1
  102. package/src/server/lib/harness/spawn.server.ts +15 -2
  103. package/src/server/lib/harness/update-job-store.test.ts +126 -0
  104. package/src/server/lib/harness/update-job-store.ts +109 -0
  105. package/src/server/lib/harness/update-job.server.ts +203 -0
  106. package/src/server/lib/harness/update-worker.test.ts +153 -0
  107. package/src/server/lib/harness/update-worker.ts +197 -0
  108. package/src/server/lib/lifecycle/paths.ts +23 -0
  109. package/src/server/lib/omp/rpc/manager.ts +5 -5
  110. package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
  111. package/src/server/lib/omp/rpc/session-registry.ts +14 -2
  112. package/src/server/lib/omp/rpc/terminal-settle.ts +53 -5
  113. package/src/server/lib/omp/session/delete-flow.server.ts +47 -0
  114. package/src/server/lib/omp/session/delete.server.ts +5 -0
  115. package/src/server/lib/omp/session/rewind-file.ts +39 -21
  116. package/src/server/lib/omp/session/sidebar-data.server.ts +6 -6
  117. package/src/server/lib/omp/session/transcript-copy.ts +123 -0
  118. package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
  119. package/src/server/lib/sessions/agent-token.server.ts +134 -0
  120. package/src/server/lib/sessions/answers.server.test.ts +33 -0
  121. package/src/server/lib/sessions/answers.server.ts +37 -0
  122. package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
  123. package/src/server/lib/sessions/dispatch.server.ts +128 -0
  124. package/src/server/lib/sessions/fork.server.test.ts +209 -0
  125. package/src/server/lib/sessions/fork.server.ts +304 -0
  126. package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
  127. package/src/server/lib/sessions/lifecycle.server.ts +71 -0
  128. package/src/server/lib/sessions/notify.server.test.ts +112 -0
  129. package/src/server/lib/sessions/notify.server.ts +212 -0
  130. package/src/server/lib/sessions/relation-types.ts +76 -0
  131. package/src/server/lib/sessions/relations.server.test.ts +207 -0
  132. package/src/server/lib/sessions/relations.server.ts +337 -0
  133. package/src/server/lib/sessions/resolve.server.ts +106 -0
  134. package/src/server/lib/sessions/schema.server.ts +82 -0
  135. package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
  136. package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
  137. package/src/server/lib/sessions/spawn.server.test.ts +196 -0
  138. package/src/server/lib/sessions/spawn.server.ts +310 -0
  139. package/src/server/lib/terminal/attach-replay.test.ts +2 -2
  140. package/src/server/lib/terminal/output.test.ts +2 -2
  141. package/src/server/lib/terminal/output.ts +1 -1
  142. package/src/server/lib/terminal/resize.test.ts +99 -0
  143. package/src/server/lib/terminal/runtime.server.ts +26 -6
  144. package/src/server/lib/terminal/send-result.test.ts +18 -1
  145. package/src/server/lib/terminal/send-result.ts +26 -2
  146. package/src/server/lib/terminal/session.server.ts +6 -6
  147. package/src/server/lib/usage/new-api.test.ts +92 -0
  148. package/src/server/lib/usage/new-api.ts +131 -0
  149. package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
  150. package/src/server/lib/usage/provider-key.ts +33 -0
  151. package/src/server/lib/usage/providers.server.ts +10 -3
  152. package/src/server/lib/usage/vendor-balance.server.ts +4 -53
  153. package/src/server/lib/usage/vendor-http.ts +41 -0
  154. package/src/server/lib/usage/window.ts +55 -0
  155. package/src/server/routes/agent/command.ts +14 -1
  156. package/src/server/routes/agent/harness-command.ts +6 -0
  157. package/src/server/routes/agent/new.ts +15 -0
  158. package/src/server/routes/harness/add-provider.test.ts +9 -1
  159. package/src/server/routes/harness/import-action.ts +4 -0
  160. package/src/server/routes/harness/import.test.ts +1 -1
  161. package/src/server/routes/harness/index.ts +5 -1
  162. package/src/server/routes/harness/update-status.ts +26 -0
  163. package/src/server/routes/harness/update.test.ts +119 -0
  164. package/src/server/routes/harness/update.ts +59 -147
  165. package/src/server/routes/sessions/answer.ts +24 -0
  166. package/src/server/routes/sessions/batch-delete.ts +11 -5
  167. package/src/server/routes/sessions/delete.ts +4 -2
  168. package/src/server/routes/sessions/fork.ts +74 -0
  169. package/src/server/routes/sessions/index.ts +14 -0
  170. package/src/server/routes/sessions/relations.ts +85 -0
  171. package/src/server/routes/sessions/session.ts +4 -0
  172. package/src/server/routes/sessions/spawn.ts +134 -0
  173. package/src/server/routes/terminal/ws.ts +3 -3
  174. package/src/shared/lib/chat/composer/client.ts +31 -2
  175. package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
  176. package/src/shared/lib/chat/composer/delegation.ts +206 -0
  177. package/src/shared/lib/chat/notice-text.ts +1 -1
  178. package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
  179. package/src/shared/lib/code/ansi.ts +1 -1
  180. package/src/shared/lib/fonts/nerd-symbols.css +4 -3
  181. package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
  182. package/src/shared/lib/harness/provider-facts.test.ts +27 -0
  183. package/src/shared/lib/harness/providers.ts +35 -1
  184. package/src/shared/lib/harness/update-job.ts +33 -0
  185. package/src/shared/lib/harness/update-plan.test.ts +21 -6
  186. package/src/shared/lib/harness/update-plan.ts +12 -4
  187. package/src/shared/lib/omp/session/wait-idle.test.ts +11 -0
  188. package/src/shared/lib/omp/session/wait-idle.ts +12 -2
  189. package/src/shared/lib/theme/catalog.test.ts +13 -9
  190. package/src/shared/lib/theme/color.test.ts +2 -2
  191. package/src/shared/lib/theme/color.ts +4 -4
  192. package/src/shared/lib/theme/theme.test.ts +1 -1
  193. package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
  194. package/src/shared/lib/workspace/terminal/input.ts +33 -0
  195. package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
  196. package/src/shared/lib/workspace/terminal/keys.ts +7 -7
  197. package/src/shared/types/chat.ts +1 -1
  198. package/src/shared/types/harness-update.ts +65 -0
  199. package/src/shared/types/omp/agent.ts +19 -2
  200. package/src/shared/types/workspace.ts +4 -0
  201. package/src/test-support/fake-omp-fork.ts +16 -2
  202. package/src/test-support/harness-table.test-util.ts +15 -1
  203. package/dist/client/static/js/index-z3w7n85q.css +0 -1
  204. package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
  205. package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
@@ -0,0 +1,113 @@
1
+ /**
2
+ * @license
3
+ * SPDX-License-Identifier: MIT
4
+ */
5
+
6
+ /**
7
+ * "New child session" from a row's menu.
8
+ *
9
+ * The child needs a first prompt — a session with none is not a thing Kabmo can
10
+ * create — so the menu item opens this small form instead of firing a request
11
+ * blind. The harness is explicit because cross-provider delegation is the point:
12
+ * one agent asks another to review.
13
+ */
14
+
15
+ import { useState } from 'preact/hooks';
16
+ import { Modal } from '@/client/components/common/Modal';
17
+ import { HARNESS_IDS, harnessDescriptor } from '@/shared/lib/harness/catalog';
18
+
19
+ export interface NewChildSessionDialogProps {
20
+ parentSessionId: string;
21
+ onClose: () => void;
22
+ }
23
+
24
+ export function NewChildSessionDialog({ parentSessionId, onClose }: NewChildSessionDialogProps) {
25
+ const [harness, setHarness] = useState('omp-rpc');
26
+ const [prompt, setPrompt] = useState('');
27
+ const [busy, setBusy] = useState(false);
28
+ const [error, setError] = useState<string | null>(null);
29
+
30
+ const submit = async (event: Event) => {
31
+ event.preventDefault();
32
+ if (busy || !prompt.trim()) return;
33
+ setBusy(true);
34
+ setError(null);
35
+ try {
36
+ const response = await fetch('/api/sessions/spawn', {
37
+ method: 'POST',
38
+ headers: { 'content-type': 'application/json' },
39
+ body: JSON.stringify({
40
+ parentSessionId,
41
+ harness,
42
+ prompt: prompt.trim(),
43
+ }),
44
+ });
45
+ const body = (await response.json().catch(() => null)) as
46
+ | { sessionId?: string; error?: string }
47
+ | null;
48
+ if (!response.ok || !body?.sessionId) {
49
+ setError(body?.error ?? 'Could not create the child session.');
50
+ setBusy(false);
51
+ return;
52
+ }
53
+ window.location.assign(`/?sessionId=${encodeURIComponent(body.sessionId)}`);
54
+ } catch {
55
+ setError('Could not reach the server.');
56
+ setBusy(false);
57
+ }
58
+ };
59
+
60
+ return (
61
+ <Modal
62
+ header="New child session"
63
+ onClose={onClose}
64
+ form={{ onSubmit: submit, className: 'flex flex-col gap-3' }}
65
+ zClass="z-[80]"
66
+ footer={
67
+ <div className="flex justify-end gap-2 px-4 py-3 border-t border-ink/10">
68
+ <button
69
+ type="button"
70
+ onClick={onClose}
71
+ className="px-3 py-1.5 rounded-md text-xs text-ink/70 hover:bg-ink/5 cursor-pointer"
72
+ >
73
+ Cancel
74
+ </button>
75
+ <button
76
+ type="submit"
77
+ disabled={busy || !prompt.trim()}
78
+ className="px-3 py-1.5 rounded-md text-xs bg-ink text-paper disabled:opacity-40 cursor-pointer"
79
+ >
80
+ {busy ? 'Creating…' : 'Create'}
81
+ </button>
82
+ </div>
83
+ }
84
+ >
85
+ <label className="flex flex-col gap-1 px-4 pt-3 text-xs">
86
+ <span className="text-ink/60">Harness</span>
87
+ <select
88
+ value={harness}
89
+ onChange={(event) => setHarness(event.currentTarget.value)}
90
+ className="rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-xs"
91
+ >
92
+ {HARNESS_IDS.map((id) => (
93
+ <option key={id} value={id}>
94
+ {harnessDescriptor(id)?.label ?? id}
95
+ </option>
96
+ ))}
97
+ </select>
98
+ </label>
99
+ <label className="flex flex-col gap-1 px-4 text-xs">
100
+ <span className="text-ink/60">First prompt</span>
101
+ <textarea
102
+ value={prompt}
103
+ onInput={(event) => setPrompt(event.currentTarget.value)}
104
+ rows={5}
105
+ autoFocus
106
+ className="rounded-md border border-ink/20 bg-paper px-2 py-1.5 text-xs font-sans resize-y"
107
+ placeholder="What should this child do?"
108
+ />
109
+ </label>
110
+ {error && <p className="px-4 text-xs text-error">{error}</p>}
111
+ </Modal>
112
+ );
113
+ }
@@ -28,7 +28,8 @@
28
28
  import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'preact/hooks';
29
29
  import type { TargetedMouseEvent } from 'preact';
30
30
  import { createPortal } from 'preact/compat';
31
- import { Archive, ArchiveRestore, Hourglass, Pencil, Trash2, WandSparkles } from 'lucide-preact';
31
+ import { Archive, ArchiveRestore, GitBranch, Hourglass, Pencil, Trash2, WandSparkles } from 'lucide-preact';
32
+ import { NewChildSessionDialog } from '@/client/components/common/session-actions-menu/NewChildSessionDialog';
32
33
 
33
34
  /** Viewport coordinates the menu hangs off, plus which edge it aligns to. */
34
35
  export interface MenuAnchor {
@@ -82,6 +83,8 @@ export function useRowMenu(): RowMenuHandle {
82
83
 
83
84
  export interface SessionActionsMenuProps {
84
85
  anchor: MenuAnchor;
86
+ /** The row's id; enables "New child session". Absent on a synthetic row. */
87
+ sessionId?: string | number;
85
88
  isArchived?: boolean;
86
89
  /** Omitted when the row cannot be renamed (a pending `new-…` chat). */
87
90
  onRename?: () => void;
@@ -102,6 +105,7 @@ export interface SessionActionsMenuProps {
102
105
 
103
106
  export function SessionActionsMenu({
104
107
  anchor,
108
+ sessionId,
105
109
  isArchived = false,
106
110
  onRename,
107
111
  onRenameWithAi,
@@ -112,6 +116,11 @@ export function SessionActionsMenu({
112
116
  }: SessionActionsMenuProps) {
113
117
  const menuRef = useRef<HTMLDivElement>(null);
114
118
  const [pos, setPos] = useState<{ top: number; left: number } | null>(null);
119
+ const [childOpen, setChildOpen] = useState(false);
120
+ const canSpawnChild =
121
+ sessionId !== undefined &&
122
+ !String(sessionId).startsWith('new-') &&
123
+ !isArchived;
115
124
 
116
125
  useLayoutEffect(() => {
117
126
  const el = menuRef.current;
@@ -148,6 +157,7 @@ export function SessionActionsMenu({
148
157
  };
149
158
 
150
159
  return createPortal(
160
+ <>
151
161
  <div
152
162
  className="fixed inset-0 z-[70]"
153
163
  onClick={onClose}
@@ -170,6 +180,20 @@ export function SessionActionsMenu({
170
180
  className="glass-popover fixed z-[70] w-44 bg-paper border border-ink/15 rounded-lg shadow-xl py-1 text-xs text-ink font-sans"
171
181
  onClick={(e) => e.stopPropagation()}
172
182
  >
183
+ {canSpawnChild && (
184
+ <button
185
+ type="button"
186
+ role="menuitem"
187
+ onClick={(event) => {
188
+ event.stopPropagation();
189
+ setChildOpen(true);
190
+ }}
191
+ className="w-full text-left px-3 py-1.5 hover:bg-ink/5 flex items-center gap-2 transition-colors cursor-pointer"
192
+ >
193
+ <GitBranch size={12} className="text-ink/60" />
194
+ <span>New child session</span>
195
+ </button>
196
+ )}
173
197
  {onRename && (
174
198
  <button
175
199
  type="button"
@@ -235,7 +259,14 @@ export function SessionActionsMenu({
235
259
  </button>
236
260
  )}
237
261
  </div>
238
- </div>,
262
+ </div>
263
+ {childOpen && sessionId !== undefined && (
264
+ <NewChildSessionDialog
265
+ parentSessionId={String(sessionId)}
266
+ onClose={() => setChildOpen(false)}
267
+ />
268
+ )}
269
+ </>,
239
270
  document.body,
240
271
  );
241
272
  }
@@ -15,7 +15,7 @@
15
15
  * 2. blocked on a question — says it is YOUR turn, not that work is happening;
16
16
  * 3. a held prompt — the row exists only because a prompt is waiting;
17
17
  * 4. a run in flight — the spinner;
18
- * 5. the roster chevron, PINNED while the row has subagents.
18
+ * 5. the child-session chevron, PINNED while the row has children.
19
19
  *
20
20
  * A batch checkbox replaces the whole slot: in that mode the row is a choice,
21
21
  * and a run spinner beside a checkbox reads as a second, unrelated control.
@@ -31,7 +31,7 @@ export interface StatusSlotProps {
31
31
  awaitingInput?: boolean;
32
32
  renaming?: boolean;
33
33
  waitingFor?: { title: string | null };
34
- /** The row has a subagent roster, so the chevron exists. */
34
+ /** The row has child sessions, so the tree chevron exists. */
35
35
  expandable?: boolean;
36
36
  isExpanded?: boolean;
37
37
  onToggleExpand?: (event: TargetedMouseEvent<HTMLElement>) => void;
@@ -88,9 +88,9 @@ export function StatusSlot({
88
88
  event.stopPropagation();
89
89
  onToggleExpand(event);
90
90
  }}
91
- title={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
91
+ title={isExpanded ? 'Collapse child sessions' : 'Expand child sessions'}
92
92
  aria-expanded={isExpanded}
93
- aria-label={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
93
+ aria-label={isExpanded ? 'Collapse child sessions' : 'Expand child sessions'}
94
94
  className={`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${
95
95
  chevronPinned
96
96
  ? 'text-ink/55 hover:text-ink'
@@ -45,6 +45,7 @@
45
45
  */
46
46
 
47
47
  import type { TargetedMouseEvent } from 'preact';
48
+ import { Boxes } from 'lucide-preact';
48
49
  import { useInlineRename } from '@/client/hooks/ui/inline-rename';
49
50
  import { useSessionRenaming } from '@/client/hooks/workspace/renaming-sessions';
50
51
  import { SessionActionsMenu, useRowMenu } from '@/client/components/common/session-actions-menu';
@@ -71,6 +72,11 @@ export interface SessionRowProps {
71
72
  /** The row's prompt is held until another session finishes. */
72
73
  waitingFor?: { title: string | null };
73
74
  hasSubagents?: boolean;
75
+ /** Whether the subagent roster is open; a separate control from children. */
76
+ subagentsExpanded?: boolean;
77
+ onToggleSubagents?: (event: TargetedMouseEvent<HTMLElement>) => void;
78
+ /** Whether this row can expand child sessions. */
79
+ expandable?: boolean;
74
80
  isExpanded?: boolean;
75
81
  onToggleExpand?: (event: TargetedMouseEvent<HTMLElement>) => void;
76
82
  onClick?: () => void;
@@ -98,6 +104,9 @@ export function SessionRow({
98
104
  worktree,
99
105
  waitingFor,
100
106
  hasSubagents = false,
107
+ subagentsExpanded = false,
108
+ onToggleSubagents,
109
+ expandable = false,
101
110
  isExpanded = false,
102
111
  onToggleExpand,
103
112
  onClick,
@@ -176,7 +185,7 @@ export function SessionRow({
176
185
  awaitingInput={awaitingInput}
177
186
  renaming={renaming}
178
187
  waitingFor={waitingFor}
179
- expandable={hasSubagents}
188
+ expandable={expandable}
180
189
  isExpanded={isExpanded}
181
190
  onToggleExpand={onToggleExpand}
182
191
  selectable={selectable}
@@ -207,6 +216,22 @@ export function SessionRow({
207
216
  {worktree && <WorktreeBadge worktree={worktree} />}
208
217
  </span>
209
218
 
219
+ {hasSubagents && onToggleSubagents && !selectable && (
220
+ <button
221
+ type="button"
222
+ onClick={(event) => {
223
+ event.stopPropagation();
224
+ onToggleSubagents(event);
225
+ }}
226
+ title="Subagents (tool calls)"
227
+ aria-label="Subagents"
228
+ aria-expanded={subagentsExpanded}
229
+ className={`shrink-0 rounded p-1 text-ink/40 hover:bg-ink/10 hover:text-ink cursor-pointer ${touch ? 'ml-1' : 'ml-0.5'}`}
230
+ >
231
+ <Boxes size={touch ? 15 : 13} />
232
+ </button>
233
+ )}
234
+
210
235
  <TrailingSlot
211
236
  timeAgo={timeAgo}
212
237
  touch={touch}
@@ -218,6 +243,7 @@ export function SessionRow({
218
243
  {menu.anchor && (
219
244
  <SessionActionsMenu
220
245
  anchor={menu.anchor}
246
+ sessionId={sessionId}
221
247
  isArchived={isArchived}
222
248
  onRename={onRename ? startRename : undefined}
223
249
  onRenameWithAi={onRenameWithAi}
@@ -18,9 +18,9 @@ export interface SeparatorDrag {
18
18
  *
19
19
  * A ghost guide line follows the pointer, and the real width is re-applied at
20
20
  * most every `RESIZE_FOLLOW_INTERVAL_MS`. Applying it on every pointermove
21
- * re-renders both panels per frame and reflows whatever they contain — an xterm
22
- * buffer, a CodeMirror document, a browser iframe — for a width the user is
23
- * still choosing. The panel's own width transition smooths the steps that land.
21
+ * re-renders both panels per frame and reflows whatever they contain — a
22
+ * terminal buffer, a CodeMirror document, a browser iframe — for a width the
23
+ * user is still choosing. The panel's own width transition smooths the steps that land.
24
24
  *
25
25
  * Kept out of `index.tsx` so the components stay inside the repo's file-size
26
26
  * ceiling.
@@ -9,7 +9,10 @@ import { SessionDeleteModal } from '@/client/components/common/session-delete-mo
9
9
  import { SessionItem } from '@/client/components/layout/session-sidebar/SessionItem';
10
10
  import { CategoryHeader } from '@/client/components/layout/session-sidebar/CategoryHeader';
11
11
  import { SubagentList } from '@/client/components/common/subagent-list';
12
+ import { ChildSessionList } from '@/client/components/layout/session-sidebar/ChildSessionList';
13
+ import { buildSessionTree } from '@/client/lib/session-tree';
12
14
  import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
15
+ import { useChildExpansion } from '@/client/hooks/workspace/child-expansion';
13
16
  import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
14
17
  import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
15
18
  import type { BatchBinding } from '@/client/components/common/batch-selection/types';
@@ -58,6 +61,7 @@ export function Category({
58
61
  // Roster expansion is shared with the mobile drawer: one persisted set, so a
59
62
  // row expanded on the phone is expanded here too.
60
63
  const { expandedSessionIds, toggleSession } = useExpandedSessions();
64
+ const { expandedChildIds, toggleChild } = useChildExpansion();
61
65
 
62
66
  useEffect(() => {
63
67
  if (typeof folder.isExpanded === 'boolean') setIsOpen(folder.isExpanded);
@@ -100,10 +104,6 @@ export function Category({
100
104
  );
101
105
  };
102
106
 
103
- const handleToggleSessionExpand = (sessionId: string) => {
104
- toggleSession(sessionId);
105
- };
106
-
107
107
  const onPin = () => {
108
108
  handlePin();
109
109
  setShowMenu(false);
@@ -148,6 +148,7 @@ export function Category({
148
148
  activeSessionId,
149
149
  sessionStatus,
150
150
  });
151
+ const tree = buildSessionTree(renderedSessions);
151
152
  // A session selection opens every folder: a checkbox on a collapsed workspace
152
153
  // would let the user select rows they cannot see or unselect. The WORKSPACE
153
154
  // mode leaves the expansion alone — it selects folders, not rows.
@@ -192,7 +193,7 @@ export function Category({
192
193
  {/* Sessions List */}
193
194
  {listOpen && (
194
195
  <div className="space-y-0.5">
195
- {renderedSessions.map((session) => {
196
+ {tree.roots.map((session) => {
196
197
  const sessionKey = String(session.id);
197
198
  const isActive = activeSessionId !== null
198
199
  ? String(activeSessionId) === sessionKey
@@ -201,10 +202,13 @@ export function Category({
201
202
  // row dims so the highlighted roster entry reads as the active one.
202
203
  const isViewingSubagent = isActive && urlSessionId === sessionKey && Boolean(urlSubagentId);
203
204
  const canExpandActive = activeSessionId !== null && sessionKey === String(activeSessionId);
204
- // Chevron gate comes straight from the omp-side loader flag
205
- // (disk scan + transcript recovery); the client never overrides it.
205
+ // Two independent disclosures: children (the tree) and subagents
206
+ // (a tool-call roster). The chevron belongs to the first, the badge
207
+ // to the second.
208
+ const hasChildren = (tree.childrenOf.get(sessionKey)?.length ?? 0) > 0;
206
209
  const hasSubagents = Boolean(session.hasSubagents);
207
- const isExpanded = hasSubagents && expandedSessionIds.has(sessionKey);
210
+ const childrenExpanded = hasChildren && expandedChildIds.has(sessionKey);
211
+ const rosterExpanded = hasSubagents && expandedSessionIds.has(sessionKey);
208
212
 
209
213
  return (
210
214
  <div key={session.id} className="space-y-0.5">
@@ -231,10 +235,12 @@ export function Category({
231
235
  onRenameWithAi={
232
236
  String(session.id).startsWith('new-') ? undefined : () => void handleRenameWithAi(session)
233
237
  }
234
- expandable={hasSubagents}
238
+ expandable={hasChildren}
235
239
  hasSubagents={hasSubagents}
236
- isExpanded={isExpanded}
237
- onToggleExpand={() => handleToggleSessionExpand(sessionKey)}
240
+ isExpanded={childrenExpanded}
241
+ onToggleExpand={() => toggleChild(sessionKey)}
242
+ subagentsExpanded={rosterExpanded}
243
+ onToggleSubagents={() => toggleSession(sessionKey)}
238
244
  waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
239
245
  onCancelWait={
240
246
  session.waitingFor
@@ -245,7 +251,14 @@ export function Category({
245
251
  selected={Boolean(batch?.selected.includes(sessionKey))}
246
252
  onToggleSelect={batch ? () => batch.toggle(sessionKey) : undefined}
247
253
  />
248
- {hasSubagents && isExpanded && (
254
+ {childrenExpanded && (
255
+ <ChildSessionList
256
+ parentId={sessionKey}
257
+ childrenOf={tree.childrenOf}
258
+ onSelect={onSelectSession}
259
+ />
260
+ )}
261
+ {rosterExpanded && (
249
262
  <SubagentList sessionId={session.id} isActiveSession={canExpandActive} />
250
263
  )}
251
264
  </div>
@@ -0,0 +1,66 @@
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,5 +1,5 @@
1
1
  import type { TargetedMouseEvent } from 'preact';
2
- import { Check, ChevronDown, ChevronRight, CircleQuestionMark, Hourglass, Loader2, MoreHorizontal } from 'lucide-preact';
2
+ import { Boxes, Check, ChevronDown, ChevronRight, CircleQuestionMark, Hourglass, Loader2, MoreHorizontal } from 'lucide-preact';
3
3
  import { useInlineRename } from '@/client/hooks/ui/inline-rename';
4
4
  import { useSessionRenaming } from '@/client/hooks/workspace/renaming-sessions';
5
5
  import { SessionActionsMenu, useRowMenu } from '@/client/components/common/session-actions-menu';
@@ -35,6 +35,9 @@ export interface SessionItemProps {
35
35
  expandable?: boolean;
36
36
  isExpanded?: boolean;
37
37
  hasSubagents?: boolean;
38
+ /** Whether the subagent roster (a separate list) is open. */
39
+ subagentsExpanded?: boolean;
40
+ onToggleSubagents?: (e: TargetedMouseEvent<HTMLElement>) => void;
38
41
  onToggleExpand?: (e: TargetedMouseEvent<HTMLElement>) => void;
39
42
  /**
40
43
  * The row's prompt is held until another session finishes. A pending row has
@@ -73,6 +76,8 @@ export function SessionItem({
73
76
  expandable = false,
74
77
  isExpanded = false,
75
78
  hasSubagents = false,
79
+ subagentsExpanded = false,
80
+ onToggleSubagents,
76
81
  onToggleExpand,
77
82
  waitingFor,
78
83
  onCancelWait,
@@ -86,7 +91,7 @@ export function SessionItem({
86
91
  // outranks the run cue: the server refuses a rename mid-run, so the two can
87
92
  // only overlap for the instant the refusal is in flight.
88
93
  const renaming = useSessionRenaming(sessionId);
89
- const showChevron = Boolean(expandable && hasSubagents && onToggleExpand);
94
+ const showChevron = Boolean(expandable && onToggleExpand);
90
95
  // The slot shows one glyph, never two side by side. A live run signal owns
91
96
  // it at rest — the spinner, or the blocked-on-a-question cue, which says it
92
97
  // is YOUR turn. With nothing live to report the chevron is PINNED, collapsed
@@ -159,7 +164,7 @@ export function SessionItem({
159
164
  e.stopPropagation();
160
165
  onToggleExpand(e);
161
166
  }}
162
- title={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
167
+ title={isExpanded ? 'Collapse child sessions' : 'Expand child sessions'}
163
168
  aria-expanded={isExpanded}
164
169
  className={`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${
165
170
  chevronPinned
@@ -262,6 +267,25 @@ export function SessionItem({
262
267
  <span className="shrink-0 ml-2 font-mono text-[10px] text-ink/40">{timeAgo}</span>
263
268
  )}
264
269
 
270
+ {/* The roster is a tool-call list, not a tree: its trigger is a badge,
271
+ never the chevron. Keeping the two controls apart is what stops a
272
+ child session and a subagent from reading as the same thing. */}
273
+ {!isEditing && hasSubagents && onToggleSubagents && !selectable && (
274
+ <button
275
+ type="button"
276
+ onClick={(e) => {
277
+ e.stopPropagation();
278
+ onToggleSubagents(e);
279
+ }}
280
+ title="Subagents (tool calls)"
281
+ aria-label="Subagents"
282
+ aria-expanded={subagentsExpanded}
283
+ className="shrink-0 ml-1 p-1 text-ink/40 hover:text-ink hover:bg-ink/10 rounded cursor-pointer"
284
+ >
285
+ <Boxes size={13} />
286
+ </button>
287
+ )}
288
+
265
289
  {/* One trigger, whatever the row can do — the menu grows, so a row with
266
290
  more actions costs no extra width. It is always drawn, the way the
267
291
  phone's row draws it: a hover-only trigger is invisible until the
@@ -290,6 +314,7 @@ export function SessionItem({
290
314
  {menu.anchor && (
291
315
  <SessionActionsMenu
292
316
  anchor={menu.anchor}
317
+ sessionId={sessionId}
293
318
  isArchived={isArchived}
294
319
  onRename={onRename ? startRename : undefined}
295
320
  onRenameWithAi={onRenameWithAi}
@@ -31,6 +31,7 @@
31
31
  import { useState } from 'preact/hooks';
32
32
  import { Download, Loader2 } from 'lucide-preact';
33
33
  import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
34
+ import { UpdateLogLine } from '@/client/components/layout/session-sidebar/about-modal/UpdateLogLine';
34
35
  import { harnessStatus, type HarnessState } from '@/shared/lib/harness/status';
35
36
  import { harnessCategoryId } from '@/shared/lib/harness/menu';
36
37
  import type { HarnessSummary } from '@/shared/types/harness';
@@ -41,10 +42,23 @@ interface HarnessTableProps {
41
42
  versions: HarnessVersionRow[];
42
43
  loading?: boolean;
43
44
  onOpenHarness: (id: string) => void;
44
- /** Runs one npm harness's update; resolves to a refusal, or null. */
45
+ /** Starts one harness's update as a background job and follows it; resolves
46
+ * to a refusal (a busy server, an unknown harness), or null when it began. */
45
47
  onUpdate: (id: string) => Promise<string | null>;
46
- /** Which harness is mid-update. */
48
+ /** Which harness is mid-update, and the step it is on (an adapter install,
49
+ * `claude update`, …). The step comes from the background job's record. */
47
50
  updating: string | null;
51
+ progress?: string | null;
52
+ /**
53
+ * The last update record this card read, running OR finished.
54
+ *
55
+ * The run is a background worker, and its output lives in that record — so the
56
+ * row that owns it offers `View log` next to the spinner, and keeps offering it
57
+ * once the run has settled, because a failure is exactly when the output is
58
+ * worth reading.
59
+ */
60
+ log?: { harness: string; message: string | null } | null;
61
+ onOpenLog?: () => void;
48
62
  }
49
63
 
50
64
  /** The state mark. Shape carries the state, so tone is reinforcement only. */
@@ -88,7 +102,8 @@ function StateMark({ state }: { state: HarnessState }) {
88
102
  const COLUMNS = 'grid grid-cols-[minmax(0,1fr)_7rem_1.75rem] items-start gap-x-2 md:grid-cols-[minmax(0,1fr)_9.5rem_1.75rem]';
89
103
 
90
104
  export function HarnessTable({
91
- harnesses, versions, loading = false, onOpenHarness, onUpdate, updating,
105
+ harnesses, versions, loading = false, onOpenHarness, onUpdate, updating, progress = null,
106
+ log = null, onOpenLog,
92
107
  }: HarnessTableProps) {
93
108
  const [problem, setProblem] = useState<{ id: string; message: string } | null>(null);
94
109
 
@@ -151,6 +166,9 @@ export function HarnessTable({
151
166
  const status = harnessStatus(entry);
152
167
  const version = byId.get(entry.id);
153
168
  const isUpdating = updating === entry.id;
169
+ // The row that owns the record gets the log line: while its worker
170
+ // runs, and after it settles so the output is not lost with it.
171
+ const showLogLine = isUpdating || log?.harness === entry.id;
154
172
  // The number a reader calls "the version": the CLI when the harness is
155
173
  // an adapter, otherwise the agent itself. Each part carries its own
156
174
  // `latest` and its own ability to move, so the two are never compared
@@ -181,6 +199,10 @@ export function HarnessTable({
181
199
  ].filter((target): target is string => Boolean(target))
182
200
  : [];
183
201
  const updateLabel = `Update ${entry.label}${targets.length > 0 ? ` to ${targets.join(' + ')}` : ''}`;
202
+ // While the background worker runs, the button names the STEP it is
203
+ // on: one press can be an adapter install and then `claude update`,
204
+ // and "Updating…" alone would hide which half is moving.
205
+ const actionLabel = isUpdating && progress ? `Updating ${entry.label}: ${progress}` : updateLabel;
184
206
  return (
185
207
  <div key={entry.id} className={`${COLUMNS} border-b border-ink/5 py-1.5`}>
186
208
  {/* The name is the link: one target per row, and the row's other
@@ -278,8 +300,8 @@ export function HarnessTable({
278
300
  type="button"
279
301
  onClick={() => void runUpdate(entry.id)}
280
302
  disabled={isUpdating}
281
- aria-label={updateLabel}
282
- title={updateLabel}
303
+ aria-label={actionLabel}
304
+ title={actionLabel}
283
305
  className="inline-flex cursor-pointer items-center justify-center rounded border border-ink/25 p-1 text-ink transition-colors hover:border-ink/50 hover:bg-ink/5 disabled:cursor-not-allowed disabled:opacity-50"
284
306
  >
285
307
  {isUpdating
@@ -294,6 +316,15 @@ export function HarnessTable({
294
316
  {problem?.id === entry.id && (
295
317
  <span className="col-span-3 pb-1 text-[10px] text-ink/70">{problem.message}</span>
296
318
  )}
319
+
320
+ {showLogLine && (
321
+ <UpdateLogLine
322
+ running={isUpdating}
323
+ progress={progress}
324
+ message={log?.message ?? null}
325
+ onOpenLog={onOpenLog}
326
+ />
327
+ )}
297
328
  </div>
298
329
  );
299
330
  })}