@kabmo-labs/kabmo 0.24.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.
- package/dist/client/index.html +1 -1
- package/dist/client/index.js +585 -512
- package/dist/client/static/js/{index-jcr5twtp.js → index-95b3n20k.js} +1105 -1207
- package/dist/client/static/js/index-p2yw9ywf.css +1 -0
- package/package.json +2 -4
- package/src/cli/lib/args.js +24 -1
- package/src/cli/lib/args.test.js +16 -0
- package/src/cli/lib/commands/session.js +233 -0
- package/src/cli/lib/commands/session.test.js +103 -0
- package/src/cli/main.js +1 -1
- package/src/client/components/common/ComposerPicker.tsx +3 -0
- package/src/client/components/common/code-surface/shiki.test.ts +82 -0
- package/src/client/components/common/code-surface/shiki.ts +28 -7
- package/src/client/components/common/session-actions-menu/index.tsx +59 -2
- 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 +17 -5
- package/src/client/components/common/session-row/index.tsx +28 -3
- 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/resizer/separator-drag.ts +3 -3
- package/src/client/components/layout/session-sidebar/CategoryItem.tsx +70 -61
- 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 +35 -7
- package/src/client/components/layout/session-sidebar/about-modal/HarnessRow.tsx +261 -0
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTable.tsx +39 -198
- package/src/client/components/layout/session-sidebar/about-modal/HarnessTableLog.test.tsx +114 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.test.tsx +130 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogDialog.tsx +128 -0
- package/src/client/components/layout/session-sidebar/about-modal/UpdateLogLine.tsx +56 -0
- package/src/client/components/layout/session-sidebar/about-modal/index.tsx +44 -36
- package/src/client/components/layout/session-sidebar/modern/WorkspaceSection.tsx +62 -47
- package/src/client/components/mobile/mobile-session-sidebar/Item.tsx +63 -50
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.test.ts +5 -0
- package/src/client/components/mobile/mobile-session-sidebar/SessionRow.tsx +37 -12
- 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/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/ComposerDock.tsx +64 -70
- package/src/client/components/workspace/chat-timeline/ComposerDockFrame.tsx +35 -0
- package/src/client/components/workspace/chat-timeline/EmptyWorkspacePrompt.tsx +128 -122
- package/src/client/components/workspace/chat-timeline/MessageItem.tsx +22 -1
- package/src/client/components/workspace/chat-timeline/MessageList.tsx +11 -5
- package/src/client/components/workspace/chat-timeline/PendingChatView.tsx +10 -0
- package/src/client/components/workspace/chat-timeline/RunFooter.tsx +12 -3
- package/src/client/components/workspace/chat-timeline/TimelineBody.tsx +3 -0
- 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/composer-dock-frame.test.tsx +155 -0
- package/src/client/components/workspace/chat-timeline/index.tsx +11 -20
- package/src/client/components/workspace/chat-timeline/target-picker/DraftTargetRow.tsx +115 -0
- package/src/client/components/workspace/chat-timeline/target-picker/ParentSessionPicker.tsx +173 -0
- package/src/client/components/workspace/chat-timeline/target-picker/parent-session-options.test.ts +49 -0
- package/src/client/components/workspace/terminal-panel/KeyBar.tsx +10 -8
- package/src/client/components/workspace/terminal-panel/{RealtimeXtermView.tsx → RealtimeTerminalView.tsx} +51 -58
- package/src/client/components/workspace/terminal-panel/fit.test.ts +37 -0
- package/src/client/components/workspace/terminal-panel/fit.ts +64 -0
- package/src/client/components/workspace/terminal-panel/fonts.test.ts +161 -0
- package/src/client/components/workspace/terminal-panel/fonts.ts +164 -0
- package/src/client/components/workspace/terminal-panel/grid.test.ts +52 -0
- package/src/client/components/workspace/terminal-panel/grid.ts +118 -0
- package/src/client/components/workspace/terminal-panel/index.tsx +25 -21
- package/src/client/components/workspace/terminal-panel/mount.ts +247 -223
- package/src/client/components/workspace/terminal-panel/navigation.test.ts +54 -0
- package/src/client/components/workspace/terminal-panel/navigation.ts +47 -0
- package/src/client/data/settings/omp-schema.json +1 -1
- package/src/client/data/theme/terminal.test.ts +25 -0
- package/src/client/data/theme/terminal.ts +96 -79
- package/src/client/hooks/chat/composer/items.test.ts +31 -26
- package/src/client/hooks/chat/composer/pick-mapping.test.ts +42 -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/prompt-send.test.ts +7 -7
- package/src/client/hooks/chat/omp/prompt-send.ts +26 -14
- package/src/client/hooks/chat/omp/run-switch.ts +1 -1
- package/src/client/hooks/chat/omp/session-list.tsx +4 -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-request.test.ts +54 -0
- package/src/client/hooks/chat/timeline/fork-request.ts +43 -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 +205 -0
- package/src/client/hooks/chat/timeline/pending-dispatch.ts +253 -0
- package/src/client/hooks/chat/timeline/prompt-text.test.ts +34 -1
- package/src/client/hooks/chat/timeline/prompt-text.ts +47 -20
- package/src/client/hooks/chat/timeline/send-execute.test.ts +39 -0
- package/src/client/hooks/chat/timeline/send-helpers.ts +30 -1
- package/src/client/hooks/chat/timeline/send-steer.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.test-util.ts +7 -1
- package/src/client/hooks/chat/timeline/send.test.ts +3 -1
- package/src/client/hooks/chat/timeline/send.ts +48 -133
- 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 +58 -0
- package/src/client/hooks/models/use-harness-update.test.ts +286 -0
- package/src/client/hooks/models/use-harness-update.ts +250 -0
- 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/expanded-sessions.ts +36 -7
- package/src/client/hooks/workspace/terminal/index.ts +17 -3
- package/src/client/hooks/workspace/terminal/socket.ts +9 -4
- 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/session-tree.test.ts +50 -0
- package/src/client/lib/session-tree.ts +59 -0
- package/src/client/lib/signals.ts +5 -1
- package/src/client/main.tsx +6 -0
- package/src/client/tailwind.css +17 -11
- package/src/server/index.ts +2 -0
- package/src/server/lib/auth/guard.ts +10 -0
- package/src/server/lib/btw/session-copy.server.ts +6 -44
- package/src/server/lib/btw/session-copy.test.ts +2 -1
- package/src/server/lib/db/schema.ts +5 -0
- package/src/server/lib/db/seed-terminal.test.ts +1 -1
- package/src/server/lib/db/seed.test.ts +1 -1
- package/src/server/lib/harness/acp/background-work.test.ts +262 -0
- package/src/server/lib/harness/acp/background-work.ts +320 -0
- package/src/server/lib/harness/acp/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 +33 -23
- 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/gateway-env.test.ts +64 -0
- package/src/server/lib/harness/acp/gateway-env.ts +70 -0
- 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/prompt.test.ts +20 -0
- package/src/server/lib/harness/acp/prompt.ts +19 -3
- package/src/server/lib/harness/acp/protocol.ts +41 -2
- package/src/server/lib/harness/acp/session-background.test.ts +129 -0
- package/src/server/lib/harness/acp/session-exit.ts +31 -0
- package/src/server/lib/harness/acp/session-facts.ts +1 -1
- package/src/server/lib/harness/acp/session-handshake.test.ts +197 -0
- package/src/server/lib/harness/acp/session-handshake.ts +110 -7
- package/src/server/lib/harness/acp/session-idle.ts +7 -6
- package/src/server/lib/harness/acp/session-listeners.ts +31 -0
- 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 +89 -0
- package/src/server/lib/harness/acp/session-turns.ts +28 -8
- 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 +42 -2
- package/src/server/lib/harness/acp/session.ts +115 -115
- package/src/server/lib/harness/acp/tool-calls.ts +223 -0
- package/src/server/lib/harness/acp/turn.test.ts +183 -0
- package/src/server/lib/harness/acp/turn.ts +102 -10
- 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 +58 -8
- package/src/server/lib/harness/launch.test.ts +25 -0
- package/src/server/lib/harness/launch.ts +24 -10
- package/src/server/lib/harness/session.ts +3 -0
- package/src/server/lib/harness/spawn.server.ts +15 -2
- package/src/server/lib/harness/update-job-store.test.ts +151 -0
- package/src/server/lib/harness/update-job-store.ts +115 -0
- package/src/server/lib/harness/update-job.server.ts +94 -0
- 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.test.ts +153 -0
- package/src/server/lib/harness/update-worker.ts +202 -0
- package/src/server/lib/lifecycle/after-listen.ts +9 -0
- package/src/server/lib/lifecycle/paths.ts +28 -0
- package/src/server/lib/omp/rpc/manager.ts +5 -5
- package/src/server/lib/omp/rpc/prewarm-pool.ts +12 -3
- package/src/server/lib/omp/rpc/run-settle.server.ts +10 -1
- package/src/server/lib/omp/rpc/session-registry.ts +14 -2
- package/src/server/lib/omp/rpc/subagent-liveness.ts +5 -5
- package/src/server/lib/omp/rpc/terminal-settle.ts +58 -6
- package/src/server/lib/omp/session/delete-flow.server.ts +48 -0
- package/src/server/lib/omp/session/delete.server.ts +5 -0
- package/src/server/lib/omp/session/rewind-file.ts +39 -21
- package/src/server/lib/omp/session/sidebar-data.server.ts +16 -18
- package/src/server/lib/omp/session/transcript-copy.ts +123 -0
- package/src/server/lib/sessions/agent-token.server.test.ts +64 -0
- package/src/server/lib/sessions/agent-token.server.ts +134 -0
- package/src/server/lib/sessions/answers.server.test.ts +33 -0
- package/src/server/lib/sessions/answers.server.ts +37 -0
- package/src/server/lib/sessions/dispatch.server.test.ts +143 -0
- package/src/server/lib/sessions/dispatch.server.ts +128 -0
- package/src/server/lib/sessions/fork.server.test.ts +277 -0
- package/src/server/lib/sessions/fork.server.ts +329 -0
- package/src/server/lib/sessions/lifecycle.server.test.ts +75 -0
- package/src/server/lib/sessions/lifecycle.server.ts +71 -0
- package/src/server/lib/sessions/notify.server.test.ts +112 -0
- package/src/server/lib/sessions/notify.server.ts +212 -0
- package/src/server/lib/sessions/relation-types.ts +76 -0
- package/src/server/lib/sessions/relations.server.test.ts +207 -0
- package/src/server/lib/sessions/relations.server.ts +337 -0
- package/src/server/lib/sessions/resolve.server.ts +106 -0
- package/src/server/lib/sessions/schema.server.ts +82 -0
- package/src/server/lib/sessions/sidebar-relations.server.test.ts +61 -0
- package/src/server/lib/sessions/sidebar-relations.server.ts +47 -0
- package/src/server/lib/sessions/spawn.server.test.ts +237 -0
- package/src/server/lib/sessions/spawn.server.ts +335 -0
- package/src/server/lib/terminal/attach-replay.test.ts +2 -2
- package/src/server/lib/terminal/output.test.ts +2 -2
- package/src/server/lib/terminal/output.ts +1 -1
- package/src/server/lib/terminal/resize.test.ts +99 -0
- package/src/server/lib/terminal/runtime.server.ts +26 -6
- package/src/server/lib/terminal/send-result.test.ts +18 -1
- package/src/server/lib/terminal/send-result.ts +26 -2
- package/src/server/lib/terminal/session.server.ts +6 -6
- package/src/server/lib/usage/new-api.test.ts +92 -0
- package/src/server/lib/usage/new-api.ts +131 -0
- package/src/server/lib/usage/provider-endpoint.test.ts +106 -0
- package/src/server/lib/usage/provider-key.ts +33 -0
- package/src/server/lib/usage/providers.server.ts +10 -3
- package/src/server/lib/usage/vendor-balance.server.ts +4 -53
- package/src/server/lib/usage/vendor-http.ts +41 -0
- package/src/server/lib/usage/window.ts +55 -0
- package/src/server/routes/agent/command.ts +14 -1
- package/src/server/routes/agent/harness-command.ts +12 -5
- package/src/server/routes/agent/new.ts +15 -0
- package/src/server/routes/chat/stream.ts +7 -2
- package/src/server/routes/harness/add-provider.test.ts +9 -1
- package/src/server/routes/harness/import-action.ts +4 -0
- package/src/server/routes/harness/import.test.ts +1 -1
- package/src/server/routes/harness/index.ts +5 -1
- package/src/server/routes/harness/update-status.ts +32 -0
- package/src/server/routes/harness/update.test.ts +156 -0
- package/src/server/routes/harness/update.ts +64 -147
- package/src/server/routes/sessions/answer.ts +24 -0
- package/src/server/routes/sessions/batch-delete.ts +11 -5
- package/src/server/routes/sessions/body-readers.ts +43 -0
- package/src/server/routes/sessions/delete.ts +4 -2
- package/src/server/routes/sessions/fork.ts +89 -0
- package/src/server/routes/sessions/index.ts +14 -0
- package/src/server/routes/sessions/relations.ts +85 -0
- package/src/server/routes/sessions/routes.test.ts +1 -2
- package/src/server/routes/sessions/session.ts +23 -0
- package/src/server/routes/sessions/spawn.ts +137 -0
- package/src/server/routes/terminal/ws.ts +3 -3
- package/src/shared/lib/chat/composer/client.ts +31 -2
- package/src/shared/lib/chat/composer/delegation.test.ts +93 -0
- package/src/shared/lib/chat/composer/delegation.ts +206 -0
- package/src/shared/lib/chat/notice-text.ts +1 -1
- package/src/shared/lib/chat/omp/agent-events.ts +11 -0
- package/src/shared/lib/chat/omp/session-modes-signal.test.ts +41 -0
- package/src/shared/lib/chat/tool/summary-wait.test.ts +11 -0
- package/src/shared/lib/code/ansi.ts +1 -1
- package/src/shared/lib/fonts/nerd-symbols.css +4 -3
- package/src/shared/lib/fonts/nerd-symbols.test.ts +9 -9
- package/src/shared/lib/harness/mode-signal.ts +20 -0
- package/src/shared/lib/harness/provider-facts.test.ts +27 -0
- package/src/shared/lib/harness/providers.ts +35 -1
- package/src/shared/lib/harness/session-modes.ts +24 -0
- package/src/shared/lib/harness/update-job.ts +80 -0
- package/src/shared/lib/harness/update-plan.test.ts +21 -6
- package/src/shared/lib/harness/update-plan.ts +12 -4
- package/src/shared/lib/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/omp/session/wait-idle.test.ts +11 -0
- package/src/shared/lib/omp/session/wait-idle.ts +12 -2
- package/src/shared/lib/settings/defaults.ts +3 -0
- package/src/shared/lib/theme/catalog.test.ts +13 -9
- package/src/shared/lib/theme/color.test.ts +2 -2
- package/src/shared/lib/theme/color.ts +4 -4
- package/src/shared/lib/theme/theme.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/input.test.ts +27 -0
- package/src/shared/lib/workspace/terminal/input.ts +33 -0
- package/src/shared/lib/workspace/terminal/keys.test.ts +1 -1
- package/src/shared/lib/workspace/terminal/keys.ts +7 -7
- package/src/shared/types/chat.ts +1 -1
- package/src/shared/types/harness-update.ts +89 -0
- package/src/shared/types/omp/agent.ts +19 -2
- package/src/shared/types/realtime.ts +2 -0
- package/src/shared/types/settings/state.ts +10 -0
- package/src/shared/types/workspace.ts +8 -0
- package/src/test-support/fake-omp-fork.ts +16 -2
- package/src/test-support/harness-table.test-util.ts +31 -1
- package/dist/client/static/js/index-z3w7n85q.css +0 -1
- package/src/client/components/common/subagent-list/index.tsx +0 -165
- package/src/client/components/workspace/terminal-panel/webgl.test.ts +0 -75
- package/src/client/components/workspace/terminal-panel/webgl.ts +0 -108
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The panel a reader opens when a harness update is running (or just failed).
|
|
8
|
+
*
|
|
9
|
+
* The complaint it answers was concrete: press Update on `claude`, and the card
|
|
10
|
+
* showed a spinner with no way to see what the install was printing — so a
|
|
11
|
+
* failure said "update failed" with the reason already gone. These cases pin the
|
|
12
|
+
* three things the panel must state: every step and its command, the streamed
|
|
13
|
+
* output, and the finished run's own sentence.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
17
|
+
import { Window } from 'happy-dom';
|
|
18
|
+
import { render } from 'preact';
|
|
19
|
+
import { act } from 'preact/test-utils';
|
|
20
|
+
import { UpdateLogDialog } from '@/client/components/layout/session-sidebar/about-modal/UpdateLogDialog';
|
|
21
|
+
import { installDomGlobals, restoreDomGlobals } from '@/test-support/pristine-globals';
|
|
22
|
+
import type { HarnessUpdateJob } from '@/shared/types/harness-update';
|
|
23
|
+
|
|
24
|
+
beforeAll(() => {
|
|
25
|
+
installDomGlobals(new Window({ url: 'http://localhost' }));
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
afterAll(() => {
|
|
29
|
+
restoreDomGlobals();
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
let container: HTMLElement | null = null;
|
|
33
|
+
|
|
34
|
+
afterEach(() => {
|
|
35
|
+
if (container) act(() => render(null, container!));
|
|
36
|
+
container?.remove();
|
|
37
|
+
container = null;
|
|
38
|
+
for (const node of Array.from(document.body.children)) node.remove();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function job(overrides: Partial<HarnessUpdateJob> = {}): HarnessUpdateJob {
|
|
42
|
+
return {
|
|
43
|
+
harness: 'claude',
|
|
44
|
+
label: 'claude',
|
|
45
|
+
startedAt: Date.now(),
|
|
46
|
+
finishedAt: null,
|
|
47
|
+
pid: 4242,
|
|
48
|
+
steps: [
|
|
49
|
+
{
|
|
50
|
+
part: 'adapter',
|
|
51
|
+
command: 'npm install -g @agentclientprotocol/claude-agent-acp@0.102.0',
|
|
52
|
+
argv: ['npm', 'install', '-g', '@agentclientprotocol/claude-agent-acp@0.102.0'],
|
|
53
|
+
state: 'running',
|
|
54
|
+
code: null,
|
|
55
|
+
},
|
|
56
|
+
],
|
|
57
|
+
output: '',
|
|
58
|
+
ok: null,
|
|
59
|
+
message: null,
|
|
60
|
+
applied: false,
|
|
61
|
+
repointed: null,
|
|
62
|
+
...overrides,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Mount the panel and hand back its dialog element. */
|
|
67
|
+
function mountPanel(record: HarnessUpdateJob, onClose: () => void = () => {}): HTMLElement {
|
|
68
|
+
container = document.createElement('div');
|
|
69
|
+
document.body.appendChild(container);
|
|
70
|
+
act(() => render(<UpdateLogDialog job={record} onClose={onClose} />, container!));
|
|
71
|
+
const panel = document.querySelector('[role="dialog"]');
|
|
72
|
+
if (!panel) throw new Error('the log panel did not mount');
|
|
73
|
+
return panel as HTMLElement;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
describe('UpdateLogDialog', () => {
|
|
77
|
+
test('a running step shows its command and says it is waiting for output', () => {
|
|
78
|
+
const panel = mountPanel(job());
|
|
79
|
+
expect(panel.textContent).toContain('Updating claude');
|
|
80
|
+
expect(panel.textContent).toContain('Installing…');
|
|
81
|
+
expect(panel.textContent).toContain('adapter');
|
|
82
|
+
// The command is the reader's way to repeat a step by hand after a failure.
|
|
83
|
+
expect(panel.textContent).toContain('npm install -g @agentclientprotocol/claude-agent-acp@0.102.0');
|
|
84
|
+
expect(panel.textContent).toContain('Waiting for output…');
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
test('the streamed output is rendered verbatim', () => {
|
|
88
|
+
const panel = mountPanel(job({ output: 'added 1 package in 3s\nnpm warn deprecated x' }));
|
|
89
|
+
expect(panel.querySelector('pre')?.textContent).toContain('added 1 package in 3s');
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
test('a failed step names its exit code, and the run its sentence', () => {
|
|
93
|
+
const panel = mountPanel(job({
|
|
94
|
+
finishedAt: Date.now(),
|
|
95
|
+
pid: null,
|
|
96
|
+
ok: false,
|
|
97
|
+
applied: true,
|
|
98
|
+
message: 'claude update failed (exit 3)',
|
|
99
|
+
output: 'boom',
|
|
100
|
+
steps: [{
|
|
101
|
+
part: 'Claude Code',
|
|
102
|
+
command: 'claude update',
|
|
103
|
+
argv: ['claude', 'update'],
|
|
104
|
+
state: 'failed',
|
|
105
|
+
code: 3,
|
|
106
|
+
}],
|
|
107
|
+
}));
|
|
108
|
+
expect(panel.textContent).toContain('Failed');
|
|
109
|
+
expect(panel.textContent).toContain('claude update');
|
|
110
|
+
expect(panel.textContent).toContain('exit 3');
|
|
111
|
+
expect(panel.textContent).toContain('claude update failed (exit 3)');
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
test('a finished run with no output says so instead of showing an empty box', () => {
|
|
115
|
+
const panel = mountPanel(job({ finishedAt: Date.now(), pid: null, ok: true, message: 'claude updated (adapter)' }));
|
|
116
|
+
expect(panel.textContent).toContain('The commands printed nothing.');
|
|
117
|
+
expect(panel.textContent).toContain('claude updated (adapter)');
|
|
118
|
+
expect(panel.textContent).toContain('Finished');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
test('the close control asks to close', () => {
|
|
122
|
+
let closed = 0;
|
|
123
|
+
const panel = mountPanel(job(), () => { closed += 1; });
|
|
124
|
+
const close = panel.querySelector<HTMLButtonElement>('button[aria-label="Close"]')
|
|
125
|
+
?? panel.querySelector<HTMLButtonElement>('button');
|
|
126
|
+
expect(close).not.toBeNull();
|
|
127
|
+
act(() => close!.click());
|
|
128
|
+
expect(closed).toBe(1);
|
|
129
|
+
});
|
|
130
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The install's own console, opened from the row that is updating.
|
|
8
|
+
*
|
|
9
|
+
* A harness update is a background job now, so the dialog's spinner says that
|
|
10
|
+
* *something* is running and nothing about what it is doing — and when a press
|
|
11
|
+
* fails, "claude update failed" without the command's output is not actionable.
|
|
12
|
+
* The worker already streams every step's stdout/stderr into the job record
|
|
13
|
+
* (throttled to 400 ms), so this panel is only a view of that: the steps, and
|
|
14
|
+
* the output, pinned to the newest line.
|
|
15
|
+
*
|
|
16
|
+
* It stays open after the run settles — the failure case is exactly when the log
|
|
17
|
+
* matters — and the record it renders is the last one the card polled, so a
|
|
18
|
+
* finished run keeps its output until another update replaces it.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { useEffect, useRef } from 'preact/hooks';
|
|
22
|
+
import { createPortal } from 'preact/compat';
|
|
23
|
+
import { Ban, CheckCircle2, CircleDashed, Loader2 } from 'lucide-preact';
|
|
24
|
+
import { Modal } from '@/client/components/common/Modal';
|
|
25
|
+
import { jobQueued, jobRunning } from '@/shared/lib/harness/update-job';
|
|
26
|
+
import type { HarnessUpdateJob, HarnessUpdateJobStep } from '@/shared/types/harness-update';
|
|
27
|
+
|
|
28
|
+
export interface UpdateLogDialogProps {
|
|
29
|
+
job: HarnessUpdateJob;
|
|
30
|
+
onClose: () => void;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The mark for one step's state. */
|
|
34
|
+
function StepMark({ state }: { state: HarnessUpdateJobStep['state'] }) {
|
|
35
|
+
if (state === 'ok') return <CheckCircle2 size={12} className="shrink-0 text-ink/55" />;
|
|
36
|
+
if (state === 'failed') return <Ban size={12} className="shrink-0 text-error" />;
|
|
37
|
+
if (state === 'running') return <Loader2 size={12} className="shrink-0 animate-spin text-ink motion-reduce:animate-none" />;
|
|
38
|
+
return <CircleDashed size={12} className="shrink-0 text-ink/25" />;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** How the panel describes the run, in the same words the toast uses. */
|
|
42
|
+
function phaseLabel(job: HarnessUpdateJob): string {
|
|
43
|
+
if (jobQueued(job)) return 'Queued — starts when the install running now finishes';
|
|
44
|
+
if (job.finishedAt === null) return 'Installing…';
|
|
45
|
+
return job.ok ? 'Finished' : 'Failed';
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export function UpdateLogDialog({ job, onClose }: UpdateLogDialogProps) {
|
|
49
|
+
const output = useRef<HTMLPreElement | null>(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;
|
|
54
|
+
|
|
55
|
+
// Pin to the newest line while the worker streams. Without it the panel shows
|
|
56
|
+
// the top of npm's output and the reason for a failure is always below the
|
|
57
|
+
// fold.
|
|
58
|
+
useEffect(() => {
|
|
59
|
+
const node = output.current;
|
|
60
|
+
if (node) node.scrollTop = node.scrollHeight;
|
|
61
|
+
}, [job.output]);
|
|
62
|
+
|
|
63
|
+
return createPortal(
|
|
64
|
+
<Modal
|
|
65
|
+
onClose={onClose}
|
|
66
|
+
// Above About (`z-50`) — the log is opened FROM that card, not instead of it.
|
|
67
|
+
zClass="z-[65]"
|
|
68
|
+
maxWidthClass="max-w-3xl"
|
|
69
|
+
ariaLabel={`Update log for ${job.label}`}
|
|
70
|
+
header={
|
|
71
|
+
<div className="flex min-w-0 items-center gap-3">
|
|
72
|
+
{running
|
|
73
|
+
? <Loader2 size={15} className="shrink-0 animate-spin text-ink/70 motion-reduce:animate-none" />
|
|
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'} />}
|
|
78
|
+
<div className="min-w-0">
|
|
79
|
+
<h2 className="truncate text-sm font-semibold text-ink">Updating {job.label}</h2>
|
|
80
|
+
<p className="truncate font-mono text-[11px] text-ink/50">
|
|
81
|
+
{phaseLabel(job)}
|
|
82
|
+
{job.steps.length > 0 ? ` · ${job.steps.filter((step) => step.state === 'ok').length}/${job.steps.length} steps` : ''}
|
|
83
|
+
</p>
|
|
84
|
+
</div>
|
|
85
|
+
</div>
|
|
86
|
+
}
|
|
87
|
+
footer={
|
|
88
|
+
job.message ? (
|
|
89
|
+
<div className="border-t border-ink/10 px-5 py-2.5">
|
|
90
|
+
<p className="text-[11px] leading-4 text-ink/65">{job.message}</p>
|
|
91
|
+
</div>
|
|
92
|
+
) : undefined
|
|
93
|
+
}
|
|
94
|
+
>
|
|
95
|
+
<div className="flex min-h-0 flex-col gap-3 px-5 py-4">
|
|
96
|
+
{/* What the run will do, and what it is doing: the commands are the
|
|
97
|
+
reader's way to repeat a step by hand after a failure. */}
|
|
98
|
+
<ul className="space-y-1">
|
|
99
|
+
{job.steps.map((step, index) => (
|
|
100
|
+
<li key={`${step.part}-${index}`} className="flex items-start gap-2">
|
|
101
|
+
<span className="mt-0.5 flex h-3.5 items-center"><StepMark state={step.state} /></span>
|
|
102
|
+
<span className="min-w-0 flex-1">
|
|
103
|
+
<span className="block text-[11px] leading-4 text-ink">{step.part}</span>
|
|
104
|
+
<span className="block break-all font-mono text-[10px] leading-[15px] text-ink/45">
|
|
105
|
+
{step.command}
|
|
106
|
+
{step.state === 'failed' && step.code !== null ? ` — exit ${step.code}` : ''}
|
|
107
|
+
</span>
|
|
108
|
+
</span>
|
|
109
|
+
{/* One line per STATE, because a press can run two installs: the
|
|
110
|
+
reader has to see which half is done. */}
|
|
111
|
+
<span className="shrink-0 text-[10px] leading-4 text-ink/40">{step.state}</span>
|
|
112
|
+
</li>
|
|
113
|
+
))}
|
|
114
|
+
</ul>
|
|
115
|
+
|
|
116
|
+
{/* The output box scrolls on its own — the modal body must not, or the
|
|
117
|
+
step list would scroll away from the log it explains. */}
|
|
118
|
+
<pre
|
|
119
|
+
ref={output}
|
|
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"
|
|
121
|
+
>
|
|
122
|
+
{job.output || (unfinished ? 'Waiting for output…' : 'The commands printed nothing.')}
|
|
123
|
+
</pre>
|
|
124
|
+
</div>
|
|
125
|
+
</Modal>,
|
|
126
|
+
document.body,
|
|
127
|
+
);
|
|
128
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The in-flow line an updating harness row carries: what the background worker
|
|
8
|
+
* is doing — or that it is still waiting its turn — and the way into its log.
|
|
9
|
+
*
|
|
10
|
+
* It is a LINE under the row rather than a second icon in the action cell,
|
|
11
|
+
* because that cell is a fixed `1.75rem` track measured for one 24px button —
|
|
12
|
+
* two of them overflow it, which is the same defect the earlier `7rem` track
|
|
13
|
+
* caused in the other direction. In flow it can also carry the step's name,
|
|
14
|
+
* which a bare icon cannot.
|
|
15
|
+
*
|
|
16
|
+
* **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
|
+
*
|
|
21
|
+
* After the run settles the line stays, showing what happened and keeping
|
|
22
|
+
* `View log` available: the failure case is exactly when the output matters, and
|
|
23
|
+
* the record it lives in survives until that harness is updated again.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
export interface UpdateLogLineProps {
|
|
27
|
+
/** Is the worker still installing? */
|
|
28
|
+
running: boolean;
|
|
29
|
+
/** Is this run waiting for the install ahead of it? */
|
|
30
|
+
queued?: boolean;
|
|
31
|
+
/** The step it is on (`adapter`, `Claude Code`, …), when the record says. */
|
|
32
|
+
progress: string | null;
|
|
33
|
+
/** The finished run's sentence, once it has one. */
|
|
34
|
+
message: string | null;
|
|
35
|
+
onOpenLog?: () => void;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function UpdateLogLine({ running, queued = false, progress, message, onOpenLog }: UpdateLogLineProps) {
|
|
39
|
+
return (
|
|
40
|
+
<span className="col-span-3 flex items-center gap-2 pb-1 text-[10px] text-ink/60">
|
|
41
|
+
{running
|
|
42
|
+
? <span>{progress ? `Installing ${progress}…` : 'Updating…'}</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>}
|
|
46
|
+
<button
|
|
47
|
+
type="button"
|
|
48
|
+
data-update-log
|
|
49
|
+
onClick={() => onOpenLog?.()}
|
|
50
|
+
className="shrink-0 cursor-pointer font-medium text-ink underline decoration-ink/30 underline-offset-2 transition-colors hover:decoration-ink"
|
|
51
|
+
>
|
|
52
|
+
View log
|
|
53
|
+
</button>
|
|
54
|
+
</span>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
@@ -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';
|
|
@@ -12,6 +12,8 @@ import { useKabmoEvent } from '@/client/hooks/ui/window-event';
|
|
|
12
12
|
import { useHarnesses } from '@/client/hooks/models/use-harnesses';
|
|
13
13
|
import { HarnessTable, harnessCategoryFor } from '@/client/components/layout/session-sidebar/about-modal/HarnessTable';
|
|
14
14
|
import { useHarnessVersions } from '@/client/hooks/models/use-harness-versions';
|
|
15
|
+
import { useHarnessUpdate } from '@/client/hooks/models/use-harness-update';
|
|
16
|
+
import { UpdateLogDialog } from '@/client/components/layout/session-sidebar/about-modal/UpdateLogDialog';
|
|
15
17
|
import { useDialogBehaviour } from '@/client/hooks/ui/dialog-behaviour';
|
|
16
18
|
import { UPDATE_POPUP_OPEN_EVENT } from '@/shared/lib/updates/popup-state';
|
|
17
19
|
import type { UpdateTarget } from '@/shared/types/updates';
|
|
@@ -29,6 +31,7 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
29
31
|
// Which product's "what am I running" notes are open. The dialog draws above
|
|
30
32
|
// this panel instead of replacing it, so closing it returns here.
|
|
31
33
|
const [notesTarget, setNotesTarget] = useState<UpdateTarget | null>(null);
|
|
34
|
+
// The update log panel, opened for a harness id.
|
|
32
35
|
// The About sheet is a dialog to assistive tech and to the keyboard. It had
|
|
33
36
|
// neither: measured in the running console it carried no `role`, no
|
|
34
37
|
// `aria-modal`, and Escape did nothing while focus sat inside it.
|
|
@@ -38,39 +41,33 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
38
41
|
// made in either appears here without a reload.
|
|
39
42
|
const { harnesses, isLoading: harnessesLoading } = useHarnesses();
|
|
40
43
|
const versions = useHarnessVersions();
|
|
41
|
-
//
|
|
42
|
-
//
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
//
|
|
60
|
-
//
|
|
61
|
-
//
|
|
62
|
-
//
|
|
63
|
-
//
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
} catch (cause) {
|
|
69
|
-
return cause instanceof Error ? cause.message : 'Update failed';
|
|
70
|
-
} finally {
|
|
71
|
-
setUpdating(null);
|
|
72
|
-
}
|
|
73
|
-
};
|
|
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.
|
|
60
|
+
const update = useHarnessUpdate(
|
|
61
|
+
(message, ok) => {
|
|
62
|
+
// The hook re-reads the version rows itself once a run settles (the update
|
|
63
|
+
// forgot the cached probe), so what is left here is telling the user what
|
|
64
|
+
// happened. The row will still read the OLD number until the agent is
|
|
65
|
+
// probed again, and saying otherwise would be a claim Kabmo cannot stand
|
|
66
|
+
// behind.
|
|
67
|
+
onToast?.(message, ok ? 'success' : 'error');
|
|
68
|
+
},
|
|
69
|
+
{ enabled: isOpen },
|
|
70
|
+
);
|
|
74
71
|
|
|
75
72
|
// "What's new" opens the popup, which draws at a higher layer: leaving this
|
|
76
73
|
// dialog mounted would stack two modals over the same subject, and its
|
|
@@ -81,6 +78,10 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
81
78
|
|
|
82
79
|
if (!isOpen) return null;
|
|
83
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
|
+
|
|
84
85
|
// Rendered through a portal, for the reason the update popup is: this dialog
|
|
85
86
|
// is mounted inside whichever sidebar is on screen, and that sidebar is not
|
|
86
87
|
// always laid out — the phone's drawer hides its whole screen with
|
|
@@ -175,8 +176,9 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
175
176
|
harnesses={harnesses}
|
|
176
177
|
versions={versions.rows}
|
|
177
178
|
loading={harnessesLoading}
|
|
178
|
-
onUpdate={
|
|
179
|
-
|
|
179
|
+
onUpdate={update.start}
|
|
180
|
+
jobs={update.jobs}
|
|
181
|
+
onOpenLog={setLogHarness}
|
|
180
182
|
onOpenHarness={(id) => {
|
|
181
183
|
onClose();
|
|
182
184
|
// The settings modal is the frame that owns harness pages; the
|
|
@@ -212,6 +214,12 @@ export function AboutModal({ isOpen, onClose, updates, onToast }: AboutModalProp
|
|
|
212
214
|
{/* Sibling of the About backdrop, not a child: an event inside the portal
|
|
213
215
|
would otherwise bubble to that backdrop's `onClick` and close About. */}
|
|
214
216
|
{notesTarget && <NotesDialog target={notesTarget} onClose={() => setNotesTarget(null)} />}
|
|
217
|
+
{/* The log draws ABOVE About and does not replace it — the card it was
|
|
218
|
+
opened from keeps its glanceable state. It is not gated on a run being
|
|
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)} />}
|
|
215
223
|
</>,
|
|
216
224
|
document.body,
|
|
217
225
|
);
|
|
@@ -33,17 +33,20 @@ import { useWorkspaceFolderActions } from '@/client/hooks/workspace/workspace-fo
|
|
|
33
33
|
import { useSessionDelete } from '@/client/hooks/workspace/session-delete';
|
|
34
34
|
import { useExpandedSessions } from '@/client/hooks/workspace/expanded-sessions';
|
|
35
35
|
import { useSidebarData } from '@/client/hooks/chat/omp/session-list';
|
|
36
|
-
import { SessionRow, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
37
|
-
import {
|
|
36
|
+
import { SessionRow, sessionRowBranchStyle, type SessionRowDensity } from '@/client/components/common/session-row';
|
|
37
|
+
import { SessionBranch, branchControlFor } from '@/client/components/common/session-branch';
|
|
38
|
+
import type { BranchControl } from '@/client/components/common/session-branch';
|
|
39
|
+
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
38
40
|
import { SessionDeleteModal } from '@/client/components/common/session-delete-modal';
|
|
39
41
|
import { WorkspaceOptionsMenu } from '@/client/components/common/workspace-options-menu';
|
|
40
42
|
import { NewWorktreeModal } from '@/client/components/workspace/worktree-modal/index';
|
|
41
43
|
import { WorkspaceHeader } from '@/client/components/layout/session-sidebar/modern/WorkspaceHeader';
|
|
42
44
|
import { folderBatchState } from '@/client/components/common/batch-selection/folder-state';
|
|
43
45
|
import { relativeTimeAgo } from '@/shared/lib/workspace/relative-time';
|
|
46
|
+
import { isPendingSessionId } from '@/shared/lib/omp/session/default-title';
|
|
44
47
|
import type { BatchBinding } from '@/client/components/common/batch-selection/types';
|
|
45
48
|
import type { SessionStatusMap } from '@/client/components/layout/session-sidebar/variant-props';
|
|
46
|
-
import type { WorkspaceFolderData } from '@/shared/types';
|
|
49
|
+
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
47
50
|
|
|
48
51
|
export interface WorkspaceSectionProps {
|
|
49
52
|
folder: WorkspaceFolderData;
|
|
@@ -146,10 +149,53 @@ export function WorkspaceSection({
|
|
|
146
149
|
activeSessionId,
|
|
147
150
|
sessionStatus,
|
|
148
151
|
});
|
|
152
|
+
const tree = buildSessionTree(rendered);
|
|
149
153
|
|
|
150
154
|
// A session selection opens every workspace: a checkbox on a collapsed folder
|
|
151
155
|
// would let the user select rows they cannot see or unselect.
|
|
152
156
|
const listOpen = forceExpanded || isOpen || sessionCheckboxes;
|
|
157
|
+
|
|
158
|
+
// Roots and descendants share this renderer: a child session is the same row as a root.
|
|
159
|
+
const renderSessionRow = (session: SessionItemData, control: BranchControl) => {
|
|
160
|
+
const key = String(session.id);
|
|
161
|
+
const isActive = activeSessionId === null ? session.is_active === 1 : String(activeSessionId) === key;
|
|
162
|
+
// While one of its subagents is viewed, the row dims so the leaf reads as the active one.
|
|
163
|
+
const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
|
|
164
|
+
const pending = isPendingSessionId(key);
|
|
165
|
+
return (
|
|
166
|
+
<SessionRow
|
|
167
|
+
sessionId={session.id}
|
|
168
|
+
title={session.title}
|
|
169
|
+
harness={session.harness}
|
|
170
|
+
folderId={session.folder_id}
|
|
171
|
+
density={density}
|
|
172
|
+
isActive={isActive && !viewingSubagent}
|
|
173
|
+
isArchived={session.is_archived === 1}
|
|
174
|
+
status={sessionStatus[key]}
|
|
175
|
+
awaitingInput={Boolean(session.awaitingInput)}
|
|
176
|
+
timeAgo={relativeTimeAgo(session.updated_at ?? session.created_at)}
|
|
177
|
+
worktree={session.worktree}
|
|
178
|
+
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
179
|
+
expandable={control.expandable} isChild={control.isChild}
|
|
180
|
+
isExpanded={control.isExpanded}
|
|
181
|
+
onToggleExpand={control.onToggleExpand}
|
|
182
|
+
onClick={() => onSelectSession(session.id)}
|
|
183
|
+
onArchive={() => handleArchive(session)}
|
|
184
|
+
// A pending `new-…` chat has no transcript anywhere yet, so there is
|
|
185
|
+
// nothing to delete and nothing to rename from.
|
|
186
|
+
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
187
|
+
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
188
|
+
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
189
|
+
onCancelWait={session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined}
|
|
190
|
+
selectable={sessionCheckboxes}
|
|
191
|
+
selected={Boolean(batch?.selected.includes(key))}
|
|
192
|
+
onToggleSelect={batch ? () => batch.toggle(key) : undefined}
|
|
193
|
+
/>
|
|
194
|
+
);
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
const controlFor = (session: SessionItemData): BranchControl =>
|
|
198
|
+
branchControlFor(session, tree.childrenOf, expandedSessionIds, toggleSession);
|
|
153
199
|
const canCreateWorktree = Boolean(onNewWorktreeSession && folder.project_path);
|
|
154
200
|
|
|
155
201
|
return (
|
|
@@ -220,53 +266,22 @@ export function WorkspaceSection({
|
|
|
220
266
|
|
|
221
267
|
{listOpen && (
|
|
222
268
|
<div className="space-y-0.5">
|
|
223
|
-
{
|
|
269
|
+
{tree.roots.map((session) => {
|
|
224
270
|
const key = String(session.id);
|
|
225
|
-
const
|
|
226
|
-
? String(activeSessionId) === key
|
|
227
|
-
: session.is_active === 1;
|
|
228
|
-
// While one of its subagents is being viewed, the parent row dims so
|
|
229
|
-
// the highlighted roster entry reads as the active one.
|
|
230
|
-
const viewingSubagent = isActive && urlSessionId === key && Boolean(urlSubagentId);
|
|
231
|
-
const hasSubagents = Boolean(session.hasSubagents);
|
|
232
|
-
const isExpanded = hasSubagents && expandedSessionIds.has(key);
|
|
233
|
-
const pending = key.startsWith('new-');
|
|
234
|
-
|
|
271
|
+
const control = controlFor(session);
|
|
235
272
|
return (
|
|
236
273
|
<div key={session.id} className="space-y-0.5">
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
waitingFor={session.waitingFor ? { title: session.waitingFor.title } : undefined}
|
|
249
|
-
hasSubagents={hasSubagents}
|
|
250
|
-
isExpanded={isExpanded}
|
|
251
|
-
onToggleExpand={() => toggleSession(key)}
|
|
252
|
-
onClick={() => onSelectSession(session.id)}
|
|
253
|
-
onArchive={() => handleArchive(session)}
|
|
254
|
-
// A pending `new-…` chat has no transcript anywhere yet, so
|
|
255
|
-
// there is nothing to delete and nothing to rename from.
|
|
256
|
-
onDelete={pending ? undefined : () => sessionDelete.requestDelete(session)}
|
|
257
|
-
onRename={pending ? undefined : (name) => void handleRename(session, name)}
|
|
258
|
-
onRenameWithAi={pending ? undefined : () => void handleRenameWithAi(session)}
|
|
259
|
-
onCancelWait={
|
|
260
|
-
session.waitingFor ? () => onCancelWait?.(session.waitingFor!.waitId) : undefined
|
|
261
|
-
}
|
|
262
|
-
selectable={sessionCheckboxes}
|
|
263
|
-
selected={Boolean(batch?.selected.includes(key))}
|
|
264
|
-
onToggleSelect={batch ? () => batch.toggle(key) : undefined}
|
|
265
|
-
/>
|
|
266
|
-
{hasSubagents && isExpanded && (
|
|
267
|
-
<SubagentList
|
|
268
|
-
sessionId={session.id}
|
|
269
|
-
isActiveSession={activeSessionId !== null && key === String(activeSessionId)}
|
|
274
|
+
{renderSessionRow(session, control)}
|
|
275
|
+
{control.isExpanded && (
|
|
276
|
+
<SessionBranch
|
|
277
|
+
parentId={key}
|
|
278
|
+
hasSubagents={Boolean(session.hasSubagents)}
|
|
279
|
+
childrenOf={tree.childrenOf}
|
|
280
|
+
expandedIds={expandedSessionIds}
|
|
281
|
+
onToggle={toggleSession}
|
|
282
|
+
activeSessionId={activeSessionId === null ? null : String(activeSessionId)}
|
|
283
|
+
renderSession={renderSessionRow}
|
|
284
|
+
style={sessionRowBranchStyle(density === 'touch')}
|
|
270
285
|
/>
|
|
271
286
|
)}
|
|
272
287
|
</div>
|