@kabmo-labs/kabmo 0.25.0 → 0.26.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 (188) hide show
  1. package/dist/client/index.html +1 -1
  2. package/dist/client/index.js +440 -436
  3. package/dist/client/static/js/{index-ga8cbpt4.js → index-95b3n20k.js} +945 -945
  4. package/dist/client/static/js/index-p2yw9ywf.css +1 -0
  5. package/package.json +1 -1
  6. package/src/client/components/common/session-actions-menu/index.tsx +38 -12
  7. package/src/client/components/common/session-branch/BranchGuides.tsx +93 -0
  8. package/src/client/components/common/session-branch/SubagentRow.tsx +77 -0
  9. package/src/client/components/common/session-branch/index.tsx +169 -0
  10. package/src/client/components/common/session-branch/session-branch.test.tsx +240 -0
  11. package/src/client/components/common/session-branch/style.ts +29 -0
  12. package/src/client/components/common/session-row/StatusSlot.tsx +15 -3
  13. package/src/client/components/common/session-row/index.tsx +24 -25
  14. package/src/client/components/common/session-row/session-row.test.tsx +11 -0
  15. package/src/client/components/common/session-state-provider/index.tsx +1 -1
  16. package/src/client/components/layout/session-sidebar/CategoryItem.tsx +64 -68
  17. package/src/client/components/layout/session-sidebar/SessionItem.batch.test.ts +3 -3
  18. package/src/client/components/layout/session-sidebar/SessionItem.test.ts +25 -2
  19. package/src/client/components/layout/session-sidebar/SessionItem.tsx +33 -30
  20. package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
  21. package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +35 -225
  22. package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +36 -16
  23. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +11 -3
  24. package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +13 -4
  25. package/src/client/components/layout/session-sidebar/about-modal/index.tsx +28 -13
  26. package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +59 -57
  27. package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +57 -61
  28. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
  29. package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +33 -30
  30. package/src/client/components/settings/Sidebar.tsx +1 -1
  31. package/src/client/components/settings/categories/NotificationSettings.test.tsx +92 -0
  32. package/src/client/components/settings/categories/NotificationSettings.tsx +112 -2
  33. package/src/client/components/settings/categories/harness-settings/HarnessCard.tsx +1 -1
  34. package/src/client/components/workspace/chat-timeline/AiMessageFooter.fork.test.ts +94 -0
  35. package/src/client/components/workspace/chat-timeline/AiMessageFooter.tsx +31 -5
  36. package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +28 -39
  37. package/src/client/components/workspace/chat-timeline/MessageList.tsx +7 -5
  38. package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
  39. package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
  40. package/src/client/components/workspace/chat-timeline/chat-input/AttachmentToolbar.tsx +2 -0
  41. package/src/client/components/workspace/chat-timeline/chat-input/ModeToggles.tsx +15 -1
  42. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.test.tsx +85 -0
  43. package/src/client/components/workspace/chat-timeline/chat-input/SessionModeDropdown.tsx +84 -0
  44. package/src/client/components/workspace/chat-timeline/chat-input/Toolbar.tsx +2 -0
  45. package/src/client/components/workspace/chat-timeline/chat-input/modes-props.ts +5 -0
  46. package/src/client/components/workspace/chat-timeline/index.tsx +10 -21
  47. package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
  48. package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
  49. package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
  50. package/src/client/hooks/chat/composer/items.test.ts +19 -0
  51. package/src/client/hooks/chat/omp/folder-auto-expand.ts +1 -1
  52. package/src/client/hooks/chat/omp/pending-adoption.ts +51 -0
  53. package/src/client/hooks/chat/omp/pending-child.test.ts +73 -0
  54. package/src/client/hooks/chat/omp/pending-entry.ts +59 -0
  55. package/src/client/hooks/chat/omp/pending-rows.ts +6 -2
  56. package/src/client/hooks/chat/omp/pending-sessions.test.ts +1 -2
  57. package/src/client/hooks/chat/omp/pending-sessions.ts +45 -69
  58. package/src/client/hooks/chat/omp/pending-waiting.ts +1 -1
  59. package/src/client/hooks/chat/omp/run-switch.ts +1 -1
  60. package/src/client/hooks/chat/omp/session-list.tsx +4 -0
  61. package/src/client/hooks/chat/subagents/roster.ts +122 -0
  62. package/src/client/hooks/chat/timeline/child-spawn.test.ts +55 -0
  63. package/src/client/hooks/chat/timeline/child-spawn.ts +45 -0
  64. package/src/client/hooks/chat/timeline/fork-request.test.ts +54 -0
  65. package/src/client/hooks/chat/timeline/fork-request.ts +43 -0
  66. package/src/client/hooks/chat/timeline/mode-availability.test.ts +1 -1
  67. package/src/client/hooks/chat/timeline/mode-availability.ts +33 -0
  68. package/src/client/hooks/chat/timeline/mode-markers.ts +7 -1
  69. package/src/client/hooks/chat/timeline/mode-post.ts +15 -3
  70. package/src/client/hooks/chat/timeline/modes-contract.ts +9 -4
  71. package/src/client/hooks/chat/timeline/modes.test.ts +56 -18
  72. package/src/client/hooks/chat/timeline/modes.ts +42 -29
  73. package/src/client/hooks/chat/timeline/pending-branch.ts +205 -0
  74. package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
  75. package/src/client/hooks/chat/timeline/send.ts +17 -103
  76. package/src/client/hooks/chat/timeline/session-harness.ts +6 -0
  77. package/src/client/hooks/chat/timeline/stop-with-queue.ts +42 -0
  78. package/src/client/hooks/chat/timeline/use-fork-session.ts +40 -31
  79. package/src/client/hooks/models/use-harness-update.test.ts +137 -44
  80. package/src/client/hooks/models/use-harness-update.ts +133 -85
  81. package/src/client/hooks/ui/input-required-alert.ts +12 -5
  82. package/src/client/hooks/ui/notifications.ts +45 -0
  83. package/src/client/hooks/ui/run-outcome-alert.ts +48 -0
  84. package/src/client/hooks/workspace/expanded-sessions.ts +36 -7
  85. package/src/client/lib/native/open-session.ts +33 -0
  86. package/src/client/lib/notifications/os.test.ts +125 -0
  87. package/src/client/lib/notifications/os.ts +130 -0
  88. package/src/client/lib/plugins/sidebar-bridge.ts +2 -20
  89. package/src/client/lib/router/open-session.test.ts +75 -0
  90. package/src/client/lib/router/open-session.ts +34 -0
  91. package/src/client/lib/signals.ts +5 -1
  92. package/src/client/main.tsx +6 -0
  93. package/src/server/lib/db/schema.ts +1 -0
  94. package/src/server/lib/harness/acp/calls.ts +15 -1
  95. package/src/server/lib/harness/acp/client-capabilities.test.ts +55 -0
  96. package/src/server/lib/harness/acp/client-capabilities.ts +61 -0
  97. package/src/server/lib/harness/acp/client-fs.test.ts +135 -0
  98. package/src/server/lib/harness/acp/client-fs.ts +131 -0
  99. package/src/server/lib/harness/acp/client-initialize.test.ts +70 -0
  100. package/src/server/lib/harness/acp/client-initialize.ts +84 -0
  101. package/src/server/lib/harness/acp/client.ts +31 -21
  102. package/src/server/lib/harness/acp/commands.test.ts +5 -5
  103. package/src/server/lib/harness/acp/commands.ts +14 -2
  104. package/src/server/lib/harness/acp/frames-timing.test.ts +68 -0
  105. package/src/server/lib/harness/acp/frames-v2.test.ts +85 -0
  106. package/src/server/lib/harness/acp/frames.ts +71 -158
  107. package/src/server/lib/harness/acp/mapper.test.ts +40 -0
  108. package/src/server/lib/harness/acp/mapper.ts +12 -0
  109. package/src/server/lib/harness/acp/permissions.ts +6 -0
  110. package/src/server/lib/harness/acp/protocol.ts +41 -2
  111. package/src/server/lib/harness/acp/session-facts.ts +1 -1
  112. package/src/server/lib/harness/acp/session-handshake.test.ts +90 -1
  113. package/src/server/lib/harness/acp/session-handshake.ts +83 -6
  114. package/src/server/lib/harness/acp/session-idle.ts +7 -6
  115. package/src/server/lib/harness/acp/session-notifications.ts +41 -2
  116. package/src/server/lib/harness/acp/session-observers.test.ts +63 -0
  117. package/src/server/lib/harness/acp/session-permissions.test.ts +29 -0
  118. package/src/server/lib/harness/acp/session-permissions.ts +36 -0
  119. package/src/server/lib/harness/acp/session-requests.test.ts +92 -0
  120. package/src/server/lib/harness/acp/session-requests.ts +48 -6
  121. package/src/server/lib/harness/acp/session-turns.ts +8 -3
  122. package/src/server/lib/harness/acp/session-usage.ts +4 -0
  123. package/src/server/lib/harness/acp/session-web-state.ts +30 -2
  124. package/src/server/lib/harness/acp/session.test-util.ts +19 -1
  125. package/src/server/lib/harness/acp/session.ts +60 -60
  126. package/src/server/lib/harness/acp/tool-calls.ts +223 -0
  127. package/src/server/lib/harness/acp/turn.test.ts +102 -0
  128. package/src/server/lib/harness/acp/turn.ts +81 -6
  129. package/src/server/lib/harness/acp/v2.test.ts +144 -0
  130. package/src/server/lib/harness/acp/v2.ts +220 -0
  131. package/src/server/lib/harness/acp/verbs.ts +46 -6
  132. package/src/server/lib/harness/launch.test.ts +25 -0
  133. package/src/server/lib/harness/launch.ts +21 -9
  134. package/src/server/lib/harness/session.ts +3 -0
  135. package/src/server/lib/harness/update-job-store.test.ts +37 -12
  136. package/src/server/lib/harness/update-job-store.ts +22 -16
  137. package/src/server/lib/harness/update-job.server.ts +66 -175
  138. package/src/server/lib/harness/update-queue.server.ts +292 -0
  139. package/src/server/lib/harness/update-queue.test.ts +265 -0
  140. package/src/server/lib/harness/update-spawn.server.ts +96 -0
  141. package/src/server/lib/harness/update-worker.ts +8 -3
  142. package/src/server/lib/lifecycle/after-listen.ts +9 -0
  143. package/src/server/lib/lifecycle/paths.ts +14 -9
  144. package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
  145. package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
  146. package/src/server/lib/omp/rpc/terminal-settle.ts +5 -1
  147. package/src/server/lib/omp/session/delete-flow.server.ts +1 -0
  148. package/src/server/lib/omp/session/sidebar-data.server.ts +10 -12
  149. package/src/server/lib/sessions/fork.server.test.ts +68 -0
  150. package/src/server/lib/sessions/fork.server.ts +31 -6
  151. package/src/server/lib/sessions/spawn.server.test.ts +41 -0
  152. package/src/server/lib/sessions/spawn.server.ts +27 -2
  153. package/src/server/routes/agent/harness-command.ts +6 -5
  154. package/src/server/routes/chat/stream.ts +7 -2
  155. package/src/server/routes/harness/update-status.ts +18 -12
  156. package/src/server/routes/harness/update.test.ts +53 -16
  157. package/src/server/routes/harness/update.ts +13 -8
  158. package/src/server/routes/sessions/body-readers.ts +43 -0
  159. package/src/server/routes/sessions/fork.ts +19 -4
  160. package/src/server/routes/sessions/routes.test.ts +1 -2
  161. package/src/server/routes/sessions/session.ts +19 -0
  162. package/src/server/routes/sessions/spawn.ts +16 -13
  163. package/src/shared/lib/chat/omp/agent-events.ts +11 -0
  164. package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
  165. package/src/shared/lib/harness/mode-signal.ts +20 -0
  166. package/src/shared/lib/harness/session-modes.ts +24 -0
  167. package/src/shared/lib/harness/update-job.ts +53 -6
  168. package/src/shared/lib/icons/tint-hues.generated.ts +34 -34
  169. package/src/shared/lib/notifications/outcomes.test.ts +96 -0
  170. package/src/shared/lib/notifications/outcomes.ts +64 -0
  171. package/src/shared/lib/notifications/settings.test.ts +49 -0
  172. package/src/shared/lib/notifications/settings.ts +34 -0
  173. package/src/shared/lib/omp/session/default-title.ts +5 -4
  174. package/src/shared/lib/omp/session/prewarm-misc.test.ts +3 -2
  175. package/src/shared/lib/omp/session/schema-migrations.ts +4 -0
  176. package/src/shared/lib/omp/session/stream-state.server.test.ts +19 -0
  177. package/src/shared/lib/omp/session/stream-state.server.ts +24 -4
  178. package/src/shared/lib/settings/defaults.ts +3 -0
  179. package/src/shared/types/harness-update.ts +24 -0
  180. package/src/shared/types/realtime.ts +2 -0
  181. package/src/shared/types/settings/state.ts +10 -0
  182. package/src/shared/types/workspace.ts +4 -0
  183. package/src/test-support/harness-table.test-util.ts +25 -9
  184. package/dist/client/static/js/index-bc9aa4mx.css +0 -1
  185. package/src/client/components/common/session-actions-menu/NewChildSessionDialog.tsx +0 -113
  186. package/src/client/components/common/subagent-list/index.tsx +0 -165
  187. package/src/client/components/layout/session-sidebar/ChildSessionList.tsx +0 -66
  188. package/src/client/hooks/workspace/child-expansion.ts +0 -33
@@ -26,15 +26,18 @@
26
26
  * A row is a LINK first: clicking it opens that harness's settings page. Editing
27
27
  * lives there; About is where you learn which page to open and whether anything
28
28
  * needs doing first.
29
+ *
30
+ * The mark*up* of one row lives in `HarnessRow.tsx`; this file owns the heading,
31
+ * the tally, and the list. It also owns the one handler a press goes through, so
32
+ * a refusal is shown under the row it belongs to and never under a neighbour.
29
33
  */
30
34
 
31
35
  import { useState } from 'preact/hooks';
32
- import { Download, Loader2 } from 'lucide-preact';
33
- import { HarnessGlyph, HARNESS_GLYPH_SIZE } from '@/client/components/common/harness-glyph';
34
- import { UpdateLogLine } from '@/client/components/layout/session-sidebar/about-modal/UpdateLogLine';
35
- import { harnessStatus, type HarnessState } from '@/shared/lib/harness/status';
36
+ import { HarnessRow } from '@/client/components/layout/session-sidebar/about-modal/HarnessRow';
37
+ import { harnessStatus } from '@/shared/lib/harness/status';
36
38
  import { harnessCategoryId } from '@/shared/lib/harness/menu';
37
39
  import type { HarnessSummary } from '@/shared/types/harness';
40
+ import type { HarnessUpdateJob } from '@/shared/types/harness-update';
38
41
  import type { HarnessVersionRow } from '@/shared/types/harness-version';
39
42
 
40
43
  interface HarnessTableProps {
@@ -43,71 +46,33 @@ interface HarnessTableProps {
43
46
  loading?: boolean;
44
47
  onOpenHarness: (id: string) => void;
45
48
  /** 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. */
49
+ * to a refusal (a busy server, an unknown harness), or null when it began —
50
+ * immediately, or queued behind the install already running. */
47
51
  onUpdate: (id: string) => Promise<string | null>;
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. */
50
- updating: string | null;
51
- progress?: string | null;
52
52
  /**
53
- * The last update record this card read, running OR finished.
53
+ * The last known update record PER HARNESS: waiting its turn, installing, or
54
+ * the run that settled.
54
55
  *
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.
56
+ * Per harness, not one: two presses are two records, and a row may only ever
57
+ * show its own run (`jobQueued`, `jobRunning`, `runningStepOf`).
59
58
  */
60
- log?: { harness: string; message: string | null } | null;
61
- onOpenLog?: () => void;
62
- }
63
-
64
- /** The state mark. Shape carries the state, so tone is reinforcement only. */
65
- function StateMark({ state }: { state: HarnessState }) {
66
- if (state === 'ready') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-success" />;
67
- if (state === 'not-installed') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full border border-ink/35" />;
68
- if (state === 'needs-setup') return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-ink/45" />;
69
- return <span aria-hidden="true" className="h-1.5 w-1.5 rounded-full bg-ink/15" />;
59
+ jobs?: HarnessUpdateJob[];
60
+ /**
61
+ * Opens the log of ONE harness's record. It takes the id because there can be
62
+ * a waiting run and an installing one at the same time; the row names its own.
63
+ */
64
+ onOpenLog?: (harness: string) => void;
70
65
  }
71
66
 
72
- /**
73
- * The three-column grid every data row uses.
74
- *
75
- * The widths are the point, and every earlier guess was wrong:
76
- *
77
- * - the ACTION column held `7rem` for a single icon, stealing space from the
78
- * version cell — so `0.100.0 → 0.101.0` truncated while the action cell sat
79
- * mostly empty. It is `1.75rem` now: one 24px button and nothing else.
80
- * - the VERSION column held `7.5rem` (120px), which clipped the widest thing
81
- * it ever holds — an adapter's `adapter 0.100.0 → 0.101.0` line, measured at
82
- * 151px in this face. It is `9.5rem` (152px), the content's own width.
83
- * - on a PHONE it is `7rem`: the About card is 512px at most, and the 152px
84
- * track left the agent's own name ~130px, so `command-code` and
85
- * `deepseek-harness` were the cells that truncated while the name is the one
86
- * thing a reader is scanning for. The version line ellipsizes instead, and
87
- * carries its full text in `title`.
88
- *
89
- * It stays a FIXED track rather than `auto`: every row is its own grid, so an
90
- * `auto` track is measured per row and the version numbers stop lining up in a
91
- * column (measured: a name cell of 352px on one row and 208px on the next).
92
- *
93
- * The name takes the slack and ellipsizes. The card's own width is FIXED
94
- * (`md:w-[880px]`), so the name track cannot collapse the dialog — that only
95
- * happened while the card was `w-auto`.
96
- *
97
- * `items-start`, not `items-center`: each cell holds two lines whose heights
98
- * differ from row to row (a version cell is 16px alone and 31px with an
99
- * `adapter …` line under it), and centering measured the number 7.5px BELOW the
100
- * name it belongs to. Top-aligned, line one of every cell shares one baseline.
101
- */
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]';
103
-
104
67
  export function HarnessTable({
105
- harnesses, versions, loading = false, onOpenHarness, onUpdate, updating, progress = null,
106
- log = null, onOpenLog,
68
+ harnesses, versions, loading = false, onOpenHarness, onUpdate, jobs = [],
69
+ onOpenLog,
107
70
  }: HarnessTableProps) {
108
71
  const [problem, setProblem] = useState<{ id: string; message: string } | null>(null);
109
72
 
110
73
  const byId = new Map(versions.map((row) => [row.id, row]));
74
+ // ONE record per harness: the row renders its own run, never a neighbour's.
75
+ const jobById = new Map(jobs.map((job) => [job.harness, job]));
111
76
  // The built-in transport is the default every discovered session runs on, with
112
77
  // nothing to install, probe or update; listing it would inflate the count with
113
78
  // the one entry nobody has to decide about.
@@ -162,175 +127,20 @@ export function HarnessTable({
162
127
  // scrollers, and the inner one had no reason to exist. The About panel's
163
128
  // own body is the single scroller now, so the list simply grows.
164
129
  <div data-harness-rows="" className="grid grid-cols-1 gap-x-6 md:grid-cols-2">
165
- {entries.map((entry) => {
166
- const status = harnessStatus(entry);
167
- const version = byId.get(entry.id);
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;
172
- // The number a reader calls "the version": the CLI when the harness is
173
- // an adapter, otherwise the agent itself. Each part carries its own
174
- // `latest` and its own ability to move, so the two are never compared
175
- // across each other.
176
- //
177
- // A CLI part EXISTS for every adapter even when its `--version` could
178
- // not be read (the binary is absent, or its launcher is broken). Taking
179
- // that empty part as the lead painted `—` over a known adapter number:
180
- // measured on `zcode` (adapter 0.82.3 probed, no `zcode` runtime) and
181
- // `claude` (`claude --version` fails while the adapter answers). The
182
- // part that HAS a number leads.
183
- const cli = version?.cli ?? null;
184
- const agent = version?.agent ?? null;
185
- const lead = cli?.version ? cli : agent;
186
- const showAdapterLine = Boolean(
187
- cli?.version && agent?.version && agent.version !== cli.version,
188
- );
189
- // What the press would install, named: an adapter and a CLI are two
190
- // different products, so the accessible name says which is moving.
191
- const targets = version
192
- ? [
193
- version.agent.updateAvailable && version.agent.latest
194
- ? version.cli ? `adapter ${version.agent.latest}` : version.agent.latest
195
- : null,
196
- version.cli?.updateAvailable && version.cli.latest
197
- ? `${version.cli.name} ${version.cli.latest}`
198
- : null,
199
- ].filter((target): target is string => Boolean(target))
200
- : [];
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;
206
- return (
207
- <div key={entry.id} className={`${COLUMNS} border-b border-ink/5 py-1.5`}>
208
- {/* The name is the link: one target per row, and the row's other
209
- cells stay selectable text.
210
- TWO lines per cell, and the same two line boxes on both
211
- sides: the name and its version share row one (16px), the
212
- state label and the adapter line share row two (15px). Every
213
- cell is a flex COLUMN of those two rows, which is what makes
214
- `ready` sit exactly under `2.1.318` and beside
215
- `adapter 0.100.0 →` (measured 8px apart when the cells were
216
- centered independently). */}
217
- <button
218
- type="button"
219
- onClick={() => onOpenHarness(entry.id)}
220
- title={status.detail ?? undefined}
221
- aria-label={`${entry.label} — ${status.label}. Open its settings.`}
222
- className="flex min-w-0 cursor-pointer items-start gap-1.5 text-left"
223
- >
224
- {/* The glyph rides the FIRST row, not the middle of the pair:
225
- centered on both rows it landed between the name and the
226
- state label. */}
227
- <span className="flex h-4 shrink-0 items-center">
228
- <HarnessGlyph harness={entry.id} size={HARNESS_GLYPH_SIZE.compact} />
229
- </span>
230
- {/* The state mark sits in the label's TOP-RIGHT CORNER, not in
231
- the flow: as a trailing child it took a column of its own and
232
- every agent name lost ~14px to a 6px dot. Positioned, the
233
- label keeps its width and the mark still reads as a status
234
- light on that name. */}
235
- <span className="flex min-w-0 flex-1 flex-col">
236
- {/* The mark sits at the top-right of the NAME ITSELF, so the
237
- wrapper must HUG the text — a `flex-1` wrapper anchored the
238
- dot to the column's edge instead, which read as a marker on
239
- the version beside it. `max-w-full` keeps it on the name and
240
- still allows the truncation. */}
241
- <span className="flex max-w-full items-center gap-1.5">
242
- <span className={`truncate text-[11px] leading-4 ${status.state === 'ready' ? 'font-medium text-ink' : 'text-ink/70'}`}>
243
- {entry.label}
244
- </span>
245
- <StateMark state={status.state} />
246
- </span>
247
- <span className="block truncate text-[10px] leading-[15px] text-ink/40">{status.label}</span>
248
- </span>
249
- </button>
250
-
251
- {/* TWO number lines, each with its OWN arrow.
252
- A harness can be an adapter over a CLI, and the two move
253
- independently: the row leads with the CLI's `2.1.318` and states
254
- `adapter 0.101.0` underneath, so `→` may only ever join the two
255
- numbers on ITS line. Joining `2.1.318` with the adapter's latest
256
- would compare two different products — the fiction this cell
257
- exists to prevent. */}
258
- <span
259
- className="flex min-w-0 flex-col items-end text-right font-mono text-[11px] leading-4 text-ink/70"
260
- title={version?.note ?? undefined}
261
- >
262
- <span className="block max-w-full truncate">
263
- {/* The CLI's version leads when the harness is an ADAPTER: it
264
- is the number a user recognises (`claude --version` →
265
- 2.1.318). */}
266
- {lead?.version ?? <span className="text-ink/30">—</span>}
267
- {lead?.updateAvailable && lead.latest && (
268
- <>
269
- <span aria-hidden="true" className="ml-1 text-ink/35">→</span>
270
- <span className="ml-1 text-ink">{lead.latest}</span>
271
- </>
272
- )}
273
- </span>
274
- {/* The adapter's own number and its own move. It lives INSIDE
275
- the version cell — as a fourth grid child it shifted every
276
- row one track and moved the action button onto its own line. */}
277
- {showAdapterLine && version && (
278
- <span
279
- className="block max-w-full truncate text-[10px] leading-[15px] text-ink/35"
280
- title={`${version.cli?.name ?? 'CLI'} ${version.cli?.version ?? 'unknown'} · adapter ${version.agent.version}`}
281
- >
282
- adapter {version.agent.version}
283
- {version.agent.updateAvailable && version.agent.latest
284
- ? ` → ${version.agent.latest}`
285
- : ''}
286
- </span>
287
- )}
288
- </span>
289
-
290
- <div className="flex min-w-0 justify-end">
291
- {/* ICON ONLY, and only when there is something to move to.
292
- A row with no newer version shows nothing: a permanent action
293
- button claims work that does not exist. The label lives in
294
- `title` + `aria-label`, so the meaning is not lost — it is just
295
- not spent on every row. The icon is a DOWNLOAD arrow because
296
- that is what the press does; it used to be `ArrowUpRight`, which
297
- reads as "open this elsewhere". */}
298
- {version?.updateAvailable ? (
299
- <button
300
- type="button"
301
- onClick={() => void runUpdate(entry.id)}
302
- disabled={isUpdating}
303
- aria-label={actionLabel}
304
- title={actionLabel}
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"
306
- >
307
- {isUpdating
308
- ? <Loader2 size={11} className="animate-spin motion-reduce:animate-none" />
309
- : <Download size={11} />}
310
- </button>
311
- ) : (
312
- <span className="text-[10px] text-ink/25">—</span>
313
- )}
314
- </div>
315
-
316
- {problem?.id === entry.id && (
317
- <span className="col-span-3 pb-1 text-[10px] text-ink/70">{problem.message}</span>
318
- )}
319
-
320
- {showLogLine && (
321
- <UpdateLogLine
322
- running={isUpdating}
323
- progress={progress}
324
- message={log?.message ?? null}
325
- onOpenLog={onOpenLog}
326
- />
327
- )}
328
- </div>
329
- );
330
- })}
130
+ {entries.map((entry) => (
131
+ <HarnessRow
132
+ key={entry.id}
133
+ entry={entry}
134
+ version={byId.get(entry.id) ?? null}
135
+ job={jobById.get(entry.id) ?? null}
136
+ problem={problem?.id === entry.id ? problem.message : null}
137
+ onOpenHarness={() => onOpenHarness(entry.id)}
138
+ onUpdate={() => void runUpdate(entry.id)}
139
+ onOpenLog={onOpenLog ? () => onOpenLog(entry.id) : undefined}
140
+ />
141
+ ))}
331
142
  </div>
332
143
  )}
333
-
334
144
  </section>
335
145
  );
336
146
  }
@@ -4,15 +4,15 @@
4
4
  */
5
5
 
6
6
  /**
7
- * The row's link to its update log.
7
+ * The row's link to its update log, in the three states a record can be in.
8
8
  *
9
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.
10
+ * something is installing — never what it printed. That output lives in the job
11
+ * record, and these cases pin the row's half of the deal: while the worker runs
12
+ * the row names the step and offers `View log`; a run WAITING behind another one
13
+ * says so instead of claiming to install; once a run settles the row keeps
14
+ * offering the log with the run's own sentence; and a record never leaks onto a
15
+ * row that does not own it.
16
16
  */
17
17
 
18
18
  import { afterAll, afterEach, beforeAll, beforeEach, describe, expect, test } from 'bun:test';
@@ -25,6 +25,7 @@ import {
25
25
  mountHarnessTable,
26
26
  restoreHarnessTableDom,
27
27
  summary,
28
+ updateJob,
28
29
  version,
29
30
  } from '@/test-support/harness-table.test-util';
30
31
 
@@ -48,7 +49,7 @@ afterAll(() => {
48
49
  restoreHarnessTableDom();
49
50
  });
50
51
 
51
- /** The claude row, with an update record attached. */
52
+ /** The claude row, with update records attached. */
52
53
  function mountClaude(state: Parameters<typeof mountHarnessTable>[5]): HTMLElement {
53
54
  return mountHarnessTable(
54
55
  container,
@@ -62,24 +63,43 @@ function mountClaude(state: Parameters<typeof mountHarnessTable>[5]): HTMLElemen
62
63
 
63
64
  describe('harness row update log', () => {
64
65
  test('while the worker runs, the row names the step and offers the log', () => {
65
- let opened = 0;
66
+ const opened: string[] = [];
66
67
  const el = mountClaude({
67
- updating: 'claude',
68
- progress: 'adapter',
69
- log: { harness: 'claude', message: null },
70
- onOpenLog: () => { opened += 1; },
68
+ jobs: [updateJob()],
69
+ onOpenLog: (harness) => { opened.push(harness); },
71
70
  });
72
71
  const row = harnessRows(el)[0];
73
72
  expect(row.textContent).toContain('Installing adapter…');
74
73
  const log = row.querySelector<HTMLButtonElement>('[data-update-log]');
75
74
  expect(log?.textContent).toBe('View log');
76
75
  act(() => log!.click());
77
- expect(opened).toBe(1);
76
+ // The opener names the harness: two records can be on screen at once.
77
+ expect(opened).toEqual(['claude']);
78
+ });
79
+
80
+ test('a run waiting behind another one says it is queued, and does not spin', () => {
81
+ const el = mountClaude({
82
+ jobs: [updateJob({ pid: null, queuedAt: Date.now() })],
83
+ onOpenLog: () => {},
84
+ });
85
+ const row = harnessRows(el)[0];
86
+ expect(row.textContent).toContain('Queued — starts when the install running now finishes');
87
+ expect(row.textContent).not.toContain('Installing');
88
+ const button = row.querySelector<HTMLButtonElement>('button[aria-label^="Queued:"]');
89
+ expect(button).not.toBeNull();
90
+ expect(button?.disabled).toBe(true);
78
91
  });
79
92
 
80
93
  test('after the run settles the log stays, with the run’s sentence', () => {
81
94
  const el = mountClaude({
82
- log: { harness: 'claude', message: 'claude update failed (exit 3)' },
95
+ jobs: [updateJob({
96
+ pid: null,
97
+ finishedAt: Date.now(),
98
+ ok: false,
99
+ applied: true,
100
+ message: 'claude update failed (exit 3)',
101
+ steps: [{ part: 'adapter', command: 'npm install -g x', argv: ['npm'], state: 'failed', code: 3 }],
102
+ })],
83
103
  onOpenLog: () => {},
84
104
  });
85
105
  const row = harnessRows(el)[0];
@@ -88,7 +108,7 @@ describe('harness row update log', () => {
88
108
  });
89
109
 
90
110
  test('a record for another harness does not appear on this row', () => {
91
- const el = mountClaude({ log: { harness: 'codex', message: 'codex updated' } });
111
+ const el = mountClaude({ jobs: [updateJob({ harness: 'codex', label: 'codex', message: 'codex updated' })] });
92
112
  expect(harnessRows(el)[0].querySelector('[data-update-log]')).toBeNull();
93
113
  });
94
114
  });
@@ -22,6 +22,7 @@ import { useEffect, useRef } from 'preact/hooks';
22
22
  import { createPortal } from 'preact/compat';
23
23
  import { Ban, CheckCircle2, CircleDashed, Loader2 } from 'lucide-preact';
24
24
  import { Modal } from '@/client/components/common/Modal';
25
+ import { jobQueued, jobRunning } from '@/shared/lib/harness/update-job';
25
26
  import type { HarnessUpdateJob, HarnessUpdateJobStep } from '@/shared/types/harness-update';
26
27
 
27
28
  export interface UpdateLogDialogProps {
@@ -39,13 +40,17 @@ function StepMark({ state }: { state: HarnessUpdateJobStep['state'] }) {
39
40
 
40
41
  /** How the panel describes the run, in the same words the toast uses. */
41
42
  function phaseLabel(job: HarnessUpdateJob): string {
43
+ if (jobQueued(job)) return 'Queued — starts when the install running now finishes';
42
44
  if (job.finishedAt === null) return 'Installing…';
43
45
  return job.ok ? 'Finished' : 'Failed';
44
46
  }
45
47
 
46
48
  export function UpdateLogDialog({ job, onClose }: UpdateLogDialogProps) {
47
49
  const output = useRef<HTMLPreElement | null>(null);
48
- const running = job.finishedAt === null;
50
+ // A QUEUED record has no worker yet: it must not spin, because nothing is
51
+ // happening to it until the run ahead of it settles.
52
+ const running = jobRunning(job);
53
+ const unfinished = job.finishedAt === null;
49
54
 
50
55
  // Pin to the newest line while the worker streams. Without it the panel shows
51
56
  // the top of npm's output and the reason for a failure is always below the
@@ -66,7 +71,10 @@ export function UpdateLogDialog({ job, onClose }: UpdateLogDialogProps) {
66
71
  <div className="flex min-w-0 items-center gap-3">
67
72
  {running
68
73
  ? <Loader2 size={15} className="shrink-0 animate-spin text-ink/70 motion-reduce:animate-none" />
69
- : <StepMark state={job.ok ? 'ok' : 'failed'} />}
74
+ // A waiting run is neither a success nor a failure: `ok` is null, and
75
+ // reading that as `failed` painted a red ban over a run that had not
76
+ // started.
77
+ : <StepMark state={job.finishedAt === null ? 'pending' : job.ok ? 'ok' : 'failed'} />}
70
78
  <div className="min-w-0">
71
79
  <h2 className="truncate text-sm font-semibold text-ink">Updating {job.label}</h2>
72
80
  <p className="truncate font-mono text-[11px] text-ink/50">
@@ -111,7 +119,7 @@ export function UpdateLogDialog({ job, onClose }: UpdateLogDialogProps) {
111
119
  ref={output}
112
120
  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
121
  >
114
- {job.output || (running ? 'Waiting for output…' : 'The commands printed nothing.')}
122
+ {job.output || (unfinished ? 'Waiting for output…' : 'The commands printed nothing.')}
115
123
  </pre>
116
124
  </div>
117
125
  </Modal>,
@@ -5,7 +5,7 @@
5
5
 
6
6
  /**
7
7
  * The in-flow line an updating harness row carries: what the background worker
8
- * is doing, and the way into its log.
8
+ * is doing — or that it is still waiting its turn — and the way into its log.
9
9
  *
10
10
  * It is a LINE under the row rather than a second icon in the action cell,
11
11
  * because that cell is a fixed `1.75rem` track measured for one 24px button —
@@ -13,14 +13,21 @@
13
13
  * caused in the other direction. In flow it can also carry the step's name,
14
14
  * which a bare icon cannot.
15
15
  *
16
+ * **Waiting is a state of its own.** Two presses are one install at a time: the
17
+ * second harness's record carries `queuedAt`, and a line that said "Updating…"
18
+ * there would claim an install that has not started. It says what it is waiting
19
+ * for, because the queue is invisible otherwise.
20
+ *
16
21
  * After the run settles the line stays, showing what happened and keeping
17
22
  * `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.
23
+ * the record it lives in survives until that harness is updated again.
19
24
  */
20
25
 
21
26
  export interface UpdateLogLineProps {
22
27
  /** Is the worker still installing? */
23
28
  running: boolean;
29
+ /** Is this run waiting for the install ahead of it? */
30
+ queued?: boolean;
24
31
  /** The step it is on (`adapter`, `Claude Code`, …), when the record says. */
25
32
  progress: string | null;
26
33
  /** The finished run's sentence, once it has one. */
@@ -28,12 +35,14 @@ export interface UpdateLogLineProps {
28
35
  onOpenLog?: () => void;
29
36
  }
30
37
 
31
- export function UpdateLogLine({ running, progress, message, onOpenLog }: UpdateLogLineProps) {
38
+ export function UpdateLogLine({ running, queued = false, progress, message, onOpenLog }: UpdateLogLineProps) {
32
39
  return (
33
40
  <span className="col-span-3 flex items-center gap-2 pb-1 text-[10px] text-ink/60">
34
41
  {running
35
42
  ? <span>{progress ? `Installing ${progress}…` : 'Updating…'}</span>
36
- : <span className="min-w-0 truncate">{message ?? 'Update finished'}</span>}
43
+ : queued
44
+ ? <span>Queued — starts when the install running now finishes</span>
45
+ : <span className="min-w-0 truncate">{message ?? 'Update finished'}</span>}
37
46
  <button
38
47
  type="button"
39
48
  data-update-log
@@ -1,4 +1,4 @@
1
- import { useRef, useState } from 'preact/hooks';
1
+ import { useEffect, useRef, useState } from 'preact/hooks';
2
2
  import { createPortal } from 'preact/compat';
3
3
  import { Heart, X } from 'lucide-preact';
4
4
  import packageJson from '@/../package.json';
@@ -31,9 +31,7 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
31
31
  // Which product's "what am I running" notes are open. The dialog draws above
32
32
  // this panel instead of replacing it, so closing it returns here.
33
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);
34
+ // The update log panel, opened for a harness id.
37
35
  // The About sheet is a dialog to assistive tech and to the keyboard. It had
38
36
  // neither: measured in the running console it carried no `role`, no
39
37
  // `aria-modal`, and Escape did nothing while focus sat inside it.
@@ -43,9 +41,22 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
43
41
  // made in either appears here without a reload.
44
42
  const { harnesses, isLoading: harnessesLoading } = useHarnesses();
45
43
  const versions = useHarnessVersions();
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.
44
+ // The rows name what is on disk NOW. A run that settled while the card was
45
+ // closed — or a probe that answered after the last read — leaves the shared
46
+ // store holding the number the update replaced, and its `loaded` flag makes a
47
+ // remount skip the read. Re-reading on OPEN is what makes "updated" and the
48
+ // version beside it agree; it does not force the registry, so the cheap path.
49
+ const refreshVersions = versions.refresh;
50
+ useEffect(() => {
51
+ if (isOpen) refreshVersions();
52
+ }, [isOpen, refreshVersions]);
53
+ // Which harness's log is open. The run is a background worker and there can be
54
+ // MORE THAN ONE record (one installing, one waiting its turn), so the panel is
55
+ // opened for a harness id and renders THAT harness's record.
56
+ const [logHarness, setLogHarness] = useState<string | null>(null);
57
+ // Which harnesses have a record — installing, waiting, or settled. The run is a
58
+ // BACKGROUND worker, so this hook also ADOPTS runs that are still going when
59
+ // the card opens — a reload no longer loses an update's state.
49
60
  const update = useHarnessUpdate(
50
61
  (message, ok) => {
51
62
  // The hook re-reads the version rows itself once a run settles (the update
@@ -67,6 +78,10 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
67
78
 
68
79
  if (!isOpen) return null;
69
80
 
81
+ // The record the open log panel renders. Looked up per harness, so a settled
82
+ // row keeps its log while another harness installs.
83
+ const logJob = logHarness ? update.jobs.find((job) => job.harness === logHarness) ?? null : null;
84
+
70
85
  // Rendered through a portal, for the reason the update popup is: this dialog
71
86
  // is mounted inside whichever sidebar is on screen, and that sidebar is not
72
87
  // always laid out — the phone's drawer hides its whole screen with
@@ -162,10 +177,8 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
162
177
  versions={versions.rows}
163
178
  loading={harnessesLoading}
164
179
  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
+ jobs={update.jobs}
181
+ onOpenLog={setLogHarness}
169
182
  onOpenHarness={(id) => {
170
183
  onClose();
171
184
  // The settings modal is the frame that owns harness pages; the
@@ -203,8 +216,10 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
203
216
  {notesTarget && <NotesDialog target={notesTarget} onClose={() => setNotesTarget(null)} />}
204
217
  {/* The log draws ABOVE About and does not replace it — the card it was
205
218
  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)} />}
219
+ in flight: a finished (or failed) record is what a reader came for, and
220
+ a WAITING one is what says where the queue is. It renders the record of
221
+ the harness whose line was clicked — two runs can exist at once. */}
222
+ {logJob && <UpdateLogDialog job={logJob} onClose={() => setLogHarness(null)} />}
208
223
  </>,
209
224
  document.body,
210
225
  );