@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,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tree lines in front of one row.
|
|
3
|
+
*
|
|
4
|
+
* One level is as wide as the distance from a row's leading-slot centre to its
|
|
5
|
+
* harness mark centre, so the child row's indicator slot lands exactly under
|
|
6
|
+
* the parent's harness icon. The line itself stays on the parent's chevron
|
|
7
|
+
* column; what separates the two is VERTICAL — the first row of a branch starts
|
|
8
|
+
* its stem `STEM_GAP` below the row (below the chevron ink) instead of running
|
|
9
|
+
* up into the glyph.
|
|
10
|
+
*
|
|
11
|
+
* The strokes are 2px, the chevron's own ink weight, and each segment ABUTS the
|
|
12
|
+
* next instead of overlapping it: a translucent `bg-ink/40` painted twice by
|
|
13
|
+
* overlapping stems read as alternating dark bands ("belang") down a two-child
|
|
14
|
+
* branch. The list's 2px row gap is covered by the segment above (bottom:-2px),
|
|
15
|
+
* and the next row starts at its own top edge, so the line is continuous and
|
|
16
|
+
* one-ply everywhere.
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import type { BranchRowStyle } from '@/client/components/common/session-branch/style';
|
|
20
|
+
|
|
21
|
+
export interface BranchGuidesProps {
|
|
22
|
+
/** For each ancestor level, whether THAT ancestor was the last sibling. */
|
|
23
|
+
ancestors: readonly boolean[];
|
|
24
|
+
/** Whether this row is the last sibling at its own level. */
|
|
25
|
+
isLast: boolean;
|
|
26
|
+
/** The first row of the branch: the stem starts below the parent chevron. */
|
|
27
|
+
first: boolean;
|
|
28
|
+
style: BranchRowStyle;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The list's space-y gap, bridged by the segment above. */
|
|
32
|
+
const GAP = 2;
|
|
33
|
+
/** Vertical breathing room between the parent chevron and the stem. */
|
|
34
|
+
const STEM_GAP = 6;
|
|
35
|
+
|
|
36
|
+
export function BranchGuides({ ancestors, isLast, first, style }: BranchGuidesProps) {
|
|
37
|
+
// Where the row's leading slot sits inside its box, and the pitch to its
|
|
38
|
+
// harness mark: the next level's indicator targets that mark's centre.
|
|
39
|
+
const slotCenter = style.insetPx + style.slotWidth / 2;
|
|
40
|
+
const pitch = style.slotWidth / 2 + style.markGap + style.glyph / 2;
|
|
41
|
+
// From the line to the child slot's left edge: the arm crosses the row inset.
|
|
42
|
+
const arm = pitch + style.insetPx - slotCenter;
|
|
43
|
+
// 2px matches the chevron's ink weight; offset by half its width to sit on
|
|
44
|
+
// the icon's exact integer centre.
|
|
45
|
+
const STROKE = 2;
|
|
46
|
+
const line = slotCenter - STROKE / 2;
|
|
47
|
+
|
|
48
|
+
const stem = first
|
|
49
|
+
? isLast
|
|
50
|
+
// From below the chevron to THIS row's centre.
|
|
51
|
+
? { left: line, top: -STEM_GAP, height: `calc(50% + ${STEM_GAP}px)` }
|
|
52
|
+
: { left: line, top: -STEM_GAP, bottom: -GAP }
|
|
53
|
+
: isLast
|
|
54
|
+
? { left: line, top: 0, height: '50%' }
|
|
55
|
+
: { left: line, top: 0, bottom: -GAP };
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<>
|
|
59
|
+
{ancestors.map((ancestorIsLast, level) => (
|
|
60
|
+
<span
|
|
61
|
+
key={level}
|
|
62
|
+
data-guide="ancestor"
|
|
63
|
+
data-continues={ancestorIsLast ? undefined : 'true'}
|
|
64
|
+
aria-hidden="true"
|
|
65
|
+
className="relative shrink-0"
|
|
66
|
+
style={{ width: pitch }}
|
|
67
|
+
>
|
|
68
|
+
{!ancestorIsLast && (
|
|
69
|
+
<span
|
|
70
|
+
className="absolute z-10 bg-ink/40"
|
|
71
|
+
style={{ left: line, top: 0, bottom: -GAP, width: STROKE }}
|
|
72
|
+
/>
|
|
73
|
+
)}
|
|
74
|
+
</span>
|
|
75
|
+
))}
|
|
76
|
+
<span
|
|
77
|
+
data-guide="connector"
|
|
78
|
+
data-last={isLast ? 'true' : undefined}
|
|
79
|
+
data-first={first ? 'true' : undefined}
|
|
80
|
+
aria-hidden="true"
|
|
81
|
+
className="relative shrink-0"
|
|
82
|
+
style={{ width: pitch }}
|
|
83
|
+
>
|
|
84
|
+
<span className="absolute z-10 bg-ink/40" style={{ width: STROKE, ...stem }} />
|
|
85
|
+
{/* Above the row's background: the arm crosses its inset padding. */}
|
|
86
|
+
<span
|
|
87
|
+
className="absolute z-10 bg-ink/40"
|
|
88
|
+
style={{ left: line, top: 'calc(50% - 1px)', width: arm + 1, height: STROKE }}
|
|
89
|
+
/>
|
|
90
|
+
</span>
|
|
91
|
+
</>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One subagent in a session's branch.
|
|
8
|
+
*
|
|
9
|
+
* A subagent is a leaf: it is a tool call, not a session, and it opens the
|
|
10
|
+
* subagent transcript rather than `/sessions/:id`. The robot mark replaces the
|
|
11
|
+
* harness mark in the same column every session row puts it, and the leading
|
|
12
|
+
* 16px slot is the SHARED slot rule — one glyph there, and for a leaf that
|
|
13
|
+
* glyph is the run state, exactly as a parent row shows a status when it has
|
|
14
|
+
* no branch to disclose.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { Bot, Square } from 'lucide-preact';
|
|
18
|
+
import { useSearchParams } from '@/client/lib/router/search-params';
|
|
19
|
+
import { SubagentStatusIcon } from '@/client/components/common/SubagentStatusIcon';
|
|
20
|
+
import type { BranchRowStyle } from '@/client/components/common/session-branch/style';
|
|
21
|
+
import { subagentRowLabel } from '@/shared/lib/omp/subagent/label';
|
|
22
|
+
import { cancelSubagent } from '@/shared/lib/omp/subagent/control';
|
|
23
|
+
import type { SubagentInfo } from '@/shared/types';
|
|
24
|
+
|
|
25
|
+
export interface SubagentRowProps {
|
|
26
|
+
subagent: SubagentInfo;
|
|
27
|
+
/** The session that owns the roster; the view event and cancel address it. */
|
|
28
|
+
sessionId: string;
|
|
29
|
+
style: BranchRowStyle;
|
|
30
|
+
/** A live run this process can stop (and show as pulsing). */
|
|
31
|
+
running: boolean;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function SubagentRow({ subagent, sessionId, style, running }: SubagentRowProps) {
|
|
35
|
+
const [searchParams] = useSearchParams();
|
|
36
|
+
const viewed = subagent.id === searchParams.get('subagent');
|
|
37
|
+
const label = subagentRowLabel(subagent);
|
|
38
|
+
const brief = subagent.task ?? subagent.assignment ?? subagent.description ?? label;
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className="group/subagent-row flex items-center">
|
|
42
|
+
<button
|
|
43
|
+
type="button"
|
|
44
|
+
title={brief}
|
|
45
|
+
onClick={() => window.dispatchEvent(
|
|
46
|
+
new CustomEvent('omp:view-subagent', { detail: { sessionId, subagent } }),
|
|
47
|
+
)}
|
|
48
|
+
className={`flex-1 min-w-0 flex items-center text-left text-xs rounded-md ${style.inset} ${style.padding} cursor-pointer transition-colors select-none ${
|
|
49
|
+
viewed ? 'bg-ink/10 font-medium text-ink' : 'text-ink/70 hover:text-ink hover:bg-ink/5'
|
|
50
|
+
}`}
|
|
51
|
+
>
|
|
52
|
+
<span
|
|
53
|
+
data-testid="subagent-status-slot"
|
|
54
|
+
className="w-4 h-4 flex items-center justify-center shrink-0"
|
|
55
|
+
>
|
|
56
|
+
<SubagentStatusIcon status={subagent.status} live={running} size={11} />
|
|
57
|
+
</span>
|
|
58
|
+
<span className="w-2 shrink-0" />
|
|
59
|
+
<span data-testid="subagent-mark" className="mr-1.5 flex shrink-0 items-center text-ink/55">
|
|
60
|
+
<Bot size={style.glyph} aria-hidden="true" />
|
|
61
|
+
</span>
|
|
62
|
+
<span className="flex-1 min-w-0 truncate leading-snug">{label}</span>
|
|
63
|
+
</button>
|
|
64
|
+
{running && (
|
|
65
|
+
<button
|
|
66
|
+
type="button"
|
|
67
|
+
title="Stop this subagent"
|
|
68
|
+
aria-label="Stop this subagent"
|
|
69
|
+
onClick={() => void cancelSubagent(sessionId, subagent.id)}
|
|
70
|
+
className="touch-visible shrink-0 mr-1 w-5 h-5 flex items-center justify-center rounded text-ink/40 hover:text-error hover:bg-error/5 opacity-0 group-hover/subagent-row:opacity-100 transition-opacity cursor-pointer"
|
|
71
|
+
>
|
|
72
|
+
<Square size={10} />
|
|
73
|
+
</button>
|
|
74
|
+
)}
|
|
75
|
+
</div>
|
|
76
|
+
);
|
|
77
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The branch under ONE session row: its child sessions first, then its
|
|
8
|
+
* subagents, drawn as one tree.
|
|
9
|
+
*
|
|
10
|
+
* A session has exactly one disclosure. Before this, children and the subagent
|
|
11
|
+
* roster were two lists behind two controls (a chevron and a `Boxes` badge),
|
|
12
|
+
* which is why a row could be open in one sense and closed in the other. Now
|
|
13
|
+
* the chevron opens this branch, and the branch is the union of the two.
|
|
14
|
+
*
|
|
15
|
+
* Ordering is the order the lists already had: child sessions (the sidebar's
|
|
16
|
+
* own sort), then the roster (its own batch/index order). A child session can
|
|
17
|
+
* itself have a branch, so the renderer recurses one level per child — the
|
|
18
|
+
* guide cells carry the depth, not a second row style.
|
|
19
|
+
*
|
|
20
|
+
* The chrome owns the row component (classic, modern, mobile), so it supplies
|
|
21
|
+
* `renderSession`; everything below that is shared, including the subagent
|
|
22
|
+
* rows and the tree lines.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { Fragment } from 'preact';
|
|
26
|
+
import type { ComponentChild } from 'preact';
|
|
27
|
+
import { BranchGuides } from '@/client/components/common/session-branch/BranchGuides';
|
|
28
|
+
import { SubagentRow } from '@/client/components/common/session-branch/SubagentRow';
|
|
29
|
+
import type { BranchRowStyle } from '@/client/components/common/session-branch/style';
|
|
30
|
+
import { useSubagentRoster } from '@/client/hooks/chat/subagents/roster';
|
|
31
|
+
import type { SessionItemData } from '@/shared/types';
|
|
32
|
+
|
|
33
|
+
/** What the chrome's row needs to know about its branch. */
|
|
34
|
+
export interface BranchControl {
|
|
35
|
+
/** The row has child sessions, subagents, or both. */
|
|
36
|
+
expandable: boolean;
|
|
37
|
+
isExpanded: boolean;
|
|
38
|
+
onToggleExpand: () => void;
|
|
39
|
+
/**
|
|
40
|
+
* This row is a CHILD session (it is drawn inside a branch). A leaf child
|
|
41
|
+
* has no chevron and no run cue, so its leading slot is otherwise empty; the
|
|
42
|
+
* row draws a child mark there instead of leaving a hole.
|
|
43
|
+
*/
|
|
44
|
+
isChild: boolean;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* The control a session row gets from its own subtree and the one expansion
|
|
49
|
+
* set. Shared by all three chromes: a row that is expandable in one layout and
|
|
50
|
+
* not in another is the same defect as two different branch lists.
|
|
51
|
+
*/
|
|
52
|
+
export function branchControlFor(
|
|
53
|
+
session: SessionItemData,
|
|
54
|
+
childrenOf: Map<string, SessionItemData[]>,
|
|
55
|
+
expandedIds: ReadonlySet<string>,
|
|
56
|
+
onToggle: (sessionId: string) => void,
|
|
57
|
+
isChild = false,
|
|
58
|
+
): BranchControl {
|
|
59
|
+
const key = String(session.id);
|
|
60
|
+
return {
|
|
61
|
+
expandable: (childrenOf.get(key)?.length ?? 0) > 0 || Boolean(session.hasSubagents),
|
|
62
|
+
isExpanded: expandedIds.has(key),
|
|
63
|
+
onToggleExpand: () => onToggle(key),
|
|
64
|
+
isChild,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface SessionBranchProps {
|
|
69
|
+
/** The session whose branch this is. */
|
|
70
|
+
parentId: string;
|
|
71
|
+
/** That session's own `hasSubagents` flag; false skips the roster read. */
|
|
72
|
+
hasSubagents: boolean;
|
|
73
|
+
childrenOf: Map<string, SessionItemData[]>;
|
|
74
|
+
/** One set for both halves of the branch. */
|
|
75
|
+
expandedIds: ReadonlySet<string>;
|
|
76
|
+
onToggle: (sessionId: string) => void;
|
|
77
|
+
/** The session the URL has open, so its roster can take live frames. */
|
|
78
|
+
activeSessionId: string | null;
|
|
79
|
+
renderSession: (session: SessionItemData, control: BranchControl) => ComponentChild;
|
|
80
|
+
style: BranchRowStyle;
|
|
81
|
+
/** `isLast` of each ancestor row, outermost first. */
|
|
82
|
+
ancestors?: readonly boolean[];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function SessionBranch({
|
|
86
|
+
parentId,
|
|
87
|
+
hasSubagents,
|
|
88
|
+
childrenOf,
|
|
89
|
+
expandedIds,
|
|
90
|
+
onToggle,
|
|
91
|
+
activeSessionId,
|
|
92
|
+
renderSession,
|
|
93
|
+
style,
|
|
94
|
+
ancestors = [],
|
|
95
|
+
}: SessionBranchProps) {
|
|
96
|
+
const children = childrenOf.get(parentId) ?? [];
|
|
97
|
+
const { subagents, isLoading } = useSubagentRoster(parentId, activeSessionId === parentId, hasSubagents);
|
|
98
|
+
const rows = [
|
|
99
|
+
...children.map((session) => ({ kind: 'session' as const, session })),
|
|
100
|
+
...subagents.map((subagent) => ({ kind: 'subagent' as const, subagent })),
|
|
101
|
+
];
|
|
102
|
+
|
|
103
|
+
if (rows.length === 0) {
|
|
104
|
+
if (!isLoading) return null;
|
|
105
|
+
return (
|
|
106
|
+
<div data-testid="session-branch" className="space-y-0.5">
|
|
107
|
+
<div className="flex items-stretch">
|
|
108
|
+
<BranchGuides ancestors={ancestors} isLast first style={style} />
|
|
109
|
+
<div className={`flex min-w-0 flex-1 items-center text-xs italic text-ink/40 ${style.inset} ${style.padding}`}>
|
|
110
|
+
Loading subagents…
|
|
111
|
+
</div>
|
|
112
|
+
</div>
|
|
113
|
+
</div>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div data-testid="session-branch" className="space-y-0.5">
|
|
119
|
+
{rows.map((row, index) => {
|
|
120
|
+
const isLast = index === rows.length - 1;
|
|
121
|
+
if (row.kind === 'subagent') {
|
|
122
|
+
return (
|
|
123
|
+
<div key={`subagent:${row.subagent.id}`} className="flex items-stretch">
|
|
124
|
+
<BranchGuides ancestors={ancestors} isLast={isLast} first={index === 0} style={style} />
|
|
125
|
+
<div className="min-w-0 flex-1">
|
|
126
|
+
<SubagentRow
|
|
127
|
+
subagent={row.subagent}
|
|
128
|
+
sessionId={parentId}
|
|
129
|
+
style={style}
|
|
130
|
+
running={activeSessionId === parentId && row.subagent.status === 'started'}
|
|
131
|
+
/>
|
|
132
|
+
</div>
|
|
133
|
+
</div>
|
|
134
|
+
);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const key = String(row.session.id);
|
|
138
|
+
const childCount = childrenOf.get(key)?.length ?? 0;
|
|
139
|
+
const control: BranchControl = {
|
|
140
|
+
expandable: childCount > 0 || Boolean(row.session.hasSubagents),
|
|
141
|
+
isExpanded: expandedIds.has(key),
|
|
142
|
+
onToggleExpand: () => onToggle(key),
|
|
143
|
+
isChild: true,
|
|
144
|
+
};
|
|
145
|
+
return (
|
|
146
|
+
<Fragment key={key}>
|
|
147
|
+
<div className="flex items-stretch">
|
|
148
|
+
<BranchGuides ancestors={ancestors} isLast={isLast} first={index === 0} style={style} />
|
|
149
|
+
<div className="min-w-0 flex-1">{renderSession(row.session, control)}</div>
|
|
150
|
+
</div>
|
|
151
|
+
{control.isExpanded && (
|
|
152
|
+
<SessionBranch
|
|
153
|
+
parentId={key}
|
|
154
|
+
hasSubagents={Boolean(row.session.hasSubagents)}
|
|
155
|
+
childrenOf={childrenOf}
|
|
156
|
+
expandedIds={expandedIds}
|
|
157
|
+
onToggle={onToggle}
|
|
158
|
+
activeSessionId={activeSessionId}
|
|
159
|
+
renderSession={renderSession}
|
|
160
|
+
style={style}
|
|
161
|
+
ancestors={[...ancestors, isLast]}
|
|
162
|
+
/>
|
|
163
|
+
)}
|
|
164
|
+
</Fragment>
|
|
165
|
+
);
|
|
166
|
+
})}
|
|
167
|
+
</div>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The shared branch: one disclosure, one tree, one slot rule.
|
|
8
|
+
*
|
|
9
|
+
* The suite pins the three facts the design rests on after the two lists were
|
|
10
|
+
* merged: a child session is rendered by the CHROME's own row component, a
|
|
11
|
+
* deeper branch recurses with the guide flags of every ancestor, and a subagent
|
|
12
|
+
* is a leaf whose leading 16px slot carries its state while the robot takes the
|
|
13
|
+
* harness column.
|
|
14
|
+
*
|
|
15
|
+
* Rendered with `h()` (no JSX) against happy-dom, following `SessionItem.test.ts`.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { afterAll, afterEach, beforeAll, describe, expect, test } from 'bun:test';
|
|
19
|
+
import { Window } from 'happy-dom';
|
|
20
|
+
import { h, render } from 'preact';
|
|
21
|
+
import { act } from 'preact/test-utils';
|
|
22
|
+
|
|
23
|
+
import { SessionBranch } from '@/client/components/common/session-branch';
|
|
24
|
+
import type { BranchControl, SessionBranchProps } from '@/client/components/common/session-branch';
|
|
25
|
+
import { SubagentRow } from '@/client/components/common/session-branch/SubagentRow';
|
|
26
|
+
import type { SessionItemData, SubagentInfo } from '@/shared/types';
|
|
27
|
+
|
|
28
|
+
const DOM_GLOBALS = ['window', 'document', 'navigator', 'Node', 'Element', 'HTMLElement', 'HTMLInputElement', 'Event', 'MouseEvent', 'KeyboardEvent', 'CustomEvent'] as const;
|
|
29
|
+
const nativeGlobals: Partial<Record<(typeof DOM_GLOBALS)[number], unknown>> = {};
|
|
30
|
+
|
|
31
|
+
let container: HTMLElement;
|
|
32
|
+
|
|
33
|
+
beforeAll(() => {
|
|
34
|
+
const win = new Window({ url: 'http://localhost' });
|
|
35
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
36
|
+
for (const key of DOM_GLOBALS) {
|
|
37
|
+
if (!(key in nativeGlobals)) nativeGlobals[key] = target[key];
|
|
38
|
+
target[key] = (win as unknown as Record<string, unknown>)[key];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
afterAll(() => {
|
|
43
|
+
const target = globalThis as unknown as Record<string, unknown>;
|
|
44
|
+
for (const key of DOM_GLOBALS) {
|
|
45
|
+
if (nativeGlobals[key] === undefined) delete target[key];
|
|
46
|
+
else target[key] = nativeGlobals[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
afterEach(() => {
|
|
51
|
+
if (container) render(null, container);
|
|
52
|
+
container?.remove();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
async function mount(node: preact.ComponentChild) {
|
|
56
|
+
container = document.createElement('div');
|
|
57
|
+
document.body.appendChild(container);
|
|
58
|
+
await act(async () => {
|
|
59
|
+
render(node, container);
|
|
60
|
+
});
|
|
61
|
+
return container;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** A row stand-in that exposes the control the chrome would have received. */
|
|
65
|
+
const row = (session: SessionItemData, control: BranchControl) =>
|
|
66
|
+
h(
|
|
67
|
+
'button',
|
|
68
|
+
{
|
|
69
|
+
'data-testid': 'branch-row',
|
|
70
|
+
'data-id': String(session.id),
|
|
71
|
+
'data-expandable': String(control.expandable),
|
|
72
|
+
'data-expanded': String(control.isExpanded),
|
|
73
|
+
},
|
|
74
|
+
session.title,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
function branch(overrides: Partial<SessionBranchProps> = {}) {
|
|
78
|
+
const childrenOf = new Map<string, SessionItemData[]>([
|
|
79
|
+
['root', [
|
|
80
|
+
{ id: 'child-a', folder_id: 1, title: 'Child A' },
|
|
81
|
+
{ id: 'child-b', folder_id: 1, title: 'Child B' },
|
|
82
|
+
]],
|
|
83
|
+
['child-a', [
|
|
84
|
+
{ id: 'grandchild', folder_id: 1, title: 'Grandchild' },
|
|
85
|
+
]],
|
|
86
|
+
]);
|
|
87
|
+
return h(SessionBranch, {
|
|
88
|
+
parentId: 'root',
|
|
89
|
+
hasSubagents: false,
|
|
90
|
+
childrenOf,
|
|
91
|
+
expandedIds: new Set<string>(),
|
|
92
|
+
onToggle: () => {},
|
|
93
|
+
activeSessionId: null,
|
|
94
|
+
renderSession: row,
|
|
95
|
+
style: { inset: 'px-2', insetPx: 8, slotWidth: 16, markGap: 8, padding: 'py-1', glyph: 12 },
|
|
96
|
+
...overrides,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
describe('SessionBranch', () => {
|
|
101
|
+
test('renders the chrome row for each child, with the branch control', async () => {
|
|
102
|
+
const el = await mount(branch());
|
|
103
|
+
const rows = [...el.querySelectorAll<HTMLElement>('[data-testid="branch-row"]')];
|
|
104
|
+
expect(rows.map((r) => r.dataset.id)).toEqual(['child-a', 'child-b']);
|
|
105
|
+
// Child A has a child of its own, so its chevron exists; B has nothing.
|
|
106
|
+
expect(rows[0]?.dataset.expandable).toBe('true');
|
|
107
|
+
expect(rows[1]?.dataset.expandable).toBe('false');
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
test('a branch with only subagents keeps the session expandable', async () => {
|
|
111
|
+
const childrenOf = new Map([
|
|
112
|
+
['root', [{ id: 'child-a', folder_id: 1, title: 'Child A', hasSubagents: true }]],
|
|
113
|
+
]);
|
|
114
|
+
const el = await mount(branch({ childrenOf }));
|
|
115
|
+
expect(el.querySelector<HTMLElement>('[data-testid="branch-row"]')?.dataset.expandable).toBe('true');
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
test('guides mark the last sibling and continue the ancestors that have one', async () => {
|
|
119
|
+
const el = await mount(branch({
|
|
120
|
+
expandedIds: new Set(['child-a']),
|
|
121
|
+
renderSession: (session, control) => h('div', null, row(session, control)),
|
|
122
|
+
}));
|
|
123
|
+
const connectors = [...el.querySelectorAll<HTMLElement>('[data-guide="connector"]')];
|
|
124
|
+
expect(connectors).toHaveLength(3);
|
|
125
|
+
// Child A is not last at its level, the grandchild is its only child, and
|
|
126
|
+
// Child B is the last row of the branch.
|
|
127
|
+
expect(connectors[0]?.dataset.last).toBeUndefined();
|
|
128
|
+
expect(connectors[1]?.dataset.last).toBe('true');
|
|
129
|
+
expect(connectors[2]?.dataset.last).toBe('true');
|
|
130
|
+
// The grandchild inherits one ancestor line, and that ancestor (Child A)
|
|
131
|
+
// has a following sibling, so the line continues past the grandchild.
|
|
132
|
+
const inherited = [...el.querySelectorAll<HTMLElement>('[data-guide="ancestor"]')];
|
|
133
|
+
expect(inherited).toHaveLength(1);
|
|
134
|
+
expect(inherited[0]?.dataset.continues).toBe('true');
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
test('the guide stays on the chevron column and its arm reaches the child indicator', async () => {
|
|
138
|
+
const el = await mount(branch());
|
|
139
|
+
const connector = el.querySelector<HTMLElement>('[data-guide="connector"]');
|
|
140
|
+
const vertical = connector?.children[0] as HTMLElement;
|
|
141
|
+
const horizontal = connector?.children[1] as HTMLElement;
|
|
142
|
+
// Classic: one level is the 22px pitch (slot half + mark gap + glyph half),
|
|
143
|
+
// so the child's indicator slot centre lands on the parent's harness centre.
|
|
144
|
+
expect(connector?.style.width).toBe('22px');
|
|
145
|
+
// The line stays on the parent chevron's centre; spacing is vertical only.
|
|
146
|
+
expect(vertical.style.left).toBe('15px');
|
|
147
|
+
expect(horizontal.style.left).toBe('15px');
|
|
148
|
+
// The arm runs from the chevron column to the child slot's left edge.
|
|
149
|
+
expect(horizontal.style.width).toBe('15px');
|
|
150
|
+
expect(vertical.style.width).toBe('2px');
|
|
151
|
+
expect(horizontal.style.height).toBe('2px');
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
test('the first row starts its stem below the chevron', async () => {
|
|
155
|
+
const el = await mount(branch());
|
|
156
|
+
const firstVertical = el.querySelector<HTMLElement>('[data-guide="connector"]')?.children[0] as HTMLElement;
|
|
157
|
+
// Siblings after it continue from the row above, so only the first row
|
|
158
|
+
// carries the vertical gap.
|
|
159
|
+
expect(firstVertical.style.top).toBe('-6px');
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
test('the last sibling reaches its own centre, not just its top edge', async () => {
|
|
163
|
+
const el = await mount(branch());
|
|
164
|
+
const connectors = [...el.querySelectorAll<HTMLElement>('[data-guide="connector"]')];
|
|
165
|
+
const lastVertical = connectors[1]?.children[0] as HTMLElement;
|
|
166
|
+
expect(lastVertical.style.top).toBe('0px');
|
|
167
|
+
// From its own top edge to its centre: no overlap with the sibling above, so
|
|
168
|
+
// the translucent stroke cannot darken into a band.
|
|
169
|
+
expect(lastVertical.style.height).toBe('50%');
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test('a first-and-only child stops at its centre', async () => {
|
|
173
|
+
const childrenOf = new Map<string, SessionItemData[]>([
|
|
174
|
+
['root', [{ id: 'only', folder_id: 1, title: 'Only' }]],
|
|
175
|
+
]);
|
|
176
|
+
const el = await mount(branch({ childrenOf }));
|
|
177
|
+
const vertical = el.querySelector<HTMLElement>('[data-guide="connector"]')?.children[0] as HTMLElement;
|
|
178
|
+
expect(vertical.style.top).toBe('-6px');
|
|
179
|
+
expect(vertical.style.height).toBe('calc(50% + 6px)');
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
test('an ancestor line sits on the same guide column as the connector', async () => {
|
|
183
|
+
const el = await mount(branch({ expandedIds: new Set(['child-a']) }));
|
|
184
|
+
const ancestorLine = el.querySelector<HTMLElement>('[data-guide="ancestor"] > span');
|
|
185
|
+
expect(ancestorLine?.style.left).toBe('15px');
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
test('does not recurse into a child that is collapsed', async () => {
|
|
189
|
+
const el = await mount(branch());
|
|
190
|
+
expect(el.querySelector('[data-id="grandchild"]')).toBeNull();
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
test('an expanded row with nothing under it draws nothing', async () => {
|
|
194
|
+
const el = await mount(branch({
|
|
195
|
+
childrenOf: new Map([['root', []]]),
|
|
196
|
+
hasSubagents: false,
|
|
197
|
+
}));
|
|
198
|
+
expect(el.querySelector('[data-testid="session-branch"]')).toBeNull();
|
|
199
|
+
});
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
describe('SubagentRow', () => {
|
|
203
|
+
const subagent: SubagentInfo = {
|
|
204
|
+
id: 'Sleeper',
|
|
205
|
+
agent: 'scout',
|
|
206
|
+
status: 'started',
|
|
207
|
+
index: 0,
|
|
208
|
+
lastUpdate: Date.now(),
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
test('the shared slot carries the state and the robot takes the harness column', async () => {
|
|
212
|
+
const el = await mount(h(SubagentRow, {
|
|
213
|
+
subagent,
|
|
214
|
+
sessionId: 'root',
|
|
215
|
+
style: { inset: 'px-2', insetPx: 8, slotWidth: 16, markGap: 8, padding: 'py-1', glyph: 12 },
|
|
216
|
+
running: true,
|
|
217
|
+
}));
|
|
218
|
+
const slot = el.querySelector('[data-testid="subagent-status-slot"]');
|
|
219
|
+
expect(slot).not.toBeNull();
|
|
220
|
+
// A live run is the pulsing dot, not an icon.
|
|
221
|
+
expect(slot?.querySelector('svg')).toBeNull();
|
|
222
|
+
expect(slot?.firstElementChild).not.toBeNull();
|
|
223
|
+
const mark = el.querySelector('[data-testid="subagent-mark"]');
|
|
224
|
+
expect(mark?.querySelector('svg')).not.toBeNull();
|
|
225
|
+
// It is a robot, not a harness: no harness glyph rides the row.
|
|
226
|
+
expect(el.querySelector('[data-harness]')).toBeNull();
|
|
227
|
+
expect(el.querySelector('button')?.textContent).toContain('Sleeper');
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
test('a settled subagent draws the terminal glyph instead of a spinner', async () => {
|
|
231
|
+
const el = await mount(h(SubagentRow, {
|
|
232
|
+
subagent: { ...subagent, status: 'completed' },
|
|
233
|
+
sessionId: 'root',
|
|
234
|
+
style: { inset: '', insetPx: 0, slotWidth: 16, markGap: 8, padding: 'py-2', glyph: 13 },
|
|
235
|
+
running: false,
|
|
236
|
+
}));
|
|
237
|
+
expect(el.querySelector('[data-testid="subagent-status-slot"] svg')).not.toBeNull();
|
|
238
|
+
expect(el.querySelector('[role="status"]')).toBeNull();
|
|
239
|
+
});
|
|
240
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The measurements a branch row borrows from the chrome's session row.
|
|
8
|
+
*
|
|
9
|
+
* A subagent row is a leaf of the same tree, so it has to keep the session
|
|
10
|
+
* row's inset, vertical rhythm and mark size — otherwise the robot sits a few
|
|
11
|
+
* pixels off the harness beside it. The tree lines need one more number: where
|
|
12
|
+
* the row's leading slot CENTRE sits, because that is the column a guide line
|
|
13
|
+
* must run under. The chrome that owns the row component exports its own
|
|
14
|
+
* instance of this.
|
|
15
|
+
*/
|
|
16
|
+
export interface BranchRowStyle {
|
|
17
|
+
/** Horizontal padding of the chrome's session row (`px-2`, `pl-1 pr-1`, …). */
|
|
18
|
+
inset: string;
|
|
19
|
+
/** The same padding in px, for the guide geometry. */
|
|
20
|
+
insetPx: number;
|
|
21
|
+
/** Width of the row's leading slot: 16px, 18px on the modern touch row. */
|
|
22
|
+
slotWidth: number;
|
|
23
|
+
/** Gap between the leading slot and the harness/robot mark (the row's `w-2`). */
|
|
24
|
+
markGap: number;
|
|
25
|
+
/** Vertical padding of the chrome's session row, so heights match. */
|
|
26
|
+
padding: string;
|
|
27
|
+
/** Harness/robot mark width, in px. */
|
|
28
|
+
glyph: number;
|
|
29
|
+
}
|
|
@@ -15,14 +15,14 @@
|
|
|
15
15
|
* 2. blocked on a question — says it is YOUR turn, not that work is happening;
|
|
16
16
|
* 3. a held prompt — the row exists only because a prompt is waiting;
|
|
17
17
|
* 4. a run in flight — the spinner;
|
|
18
|
-
* 5. the
|
|
18
|
+
* 5. the child-session chevron, PINNED while the row has children.
|
|
19
19
|
*
|
|
20
20
|
* A batch checkbox replaces the whole slot: in that mode the row is a choice,
|
|
21
21
|
* and a run spinner beside a checkbox reads as a second, unrelated control.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
24
|
import type { TargetedMouseEvent } from 'preact';
|
|
25
|
-
import { Check, ChevronDown, ChevronRight, CircleQuestionMark, Hourglass, Loader2 } from 'lucide-preact';
|
|
25
|
+
import { Check, ChevronDown, ChevronRight, CircleQuestionMark, GitBranch, Hourglass, Loader2 } from 'lucide-preact';
|
|
26
26
|
import { SelectionCheckbox } from '@/client/components/common/batch-selection/SelectionCheckbox';
|
|
27
27
|
|
|
28
28
|
export interface StatusSlotProps {
|
|
@@ -31,10 +31,12 @@ export interface StatusSlotProps {
|
|
|
31
31
|
awaitingInput?: boolean;
|
|
32
32
|
renaming?: boolean;
|
|
33
33
|
waitingFor?: { title: string | null };
|
|
34
|
-
/** The row has
|
|
34
|
+
/** The row has child sessions, so the tree chevron exists. */
|
|
35
35
|
expandable?: boolean;
|
|
36
36
|
isExpanded?: boolean;
|
|
37
37
|
onToggleExpand?: (event: TargetedMouseEvent<HTMLElement>) => void;
|
|
38
|
+
/** Drawn inside a parent's branch; a leaf child gets a child mark in its slot. */
|
|
39
|
+
child?: boolean;
|
|
38
40
|
selectable?: boolean;
|
|
39
41
|
selected?: boolean;
|
|
40
42
|
onToggleSelect?: () => void;
|
|
@@ -51,6 +53,7 @@ export function StatusSlot({
|
|
|
51
53
|
expandable = false,
|
|
52
54
|
isExpanded = false,
|
|
53
55
|
onToggleExpand,
|
|
56
|
+
child = false,
|
|
54
57
|
selectable = false,
|
|
55
58
|
selected = false,
|
|
56
59
|
onToggleSelect,
|
|
@@ -88,9 +91,9 @@ export function StatusSlot({
|
|
|
88
91
|
event.stopPropagation();
|
|
89
92
|
onToggleExpand(event);
|
|
90
93
|
}}
|
|
91
|
-
title={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
|
|
94
|
+
title={isExpanded ? 'Collapse sessions and subagents' : 'Expand sessions and subagents'}
|
|
92
95
|
aria-expanded={isExpanded}
|
|
93
|
-
aria-label={isExpanded ? 'Collapse subagents' : 'Expand subagents'}
|
|
96
|
+
aria-label={isExpanded ? 'Collapse sessions and subagents' : 'Expand sessions and subagents'}
|
|
94
97
|
className={`peer absolute inset-0 flex items-center justify-center rounded cursor-pointer transition-opacity ${
|
|
95
98
|
chevronPinned
|
|
96
99
|
? 'text-ink/55 hover:text-ink'
|
|
@@ -126,6 +129,15 @@ export function StatusSlot({
|
|
|
126
129
|
)}
|
|
127
130
|
</span>
|
|
128
131
|
)}
|
|
132
|
+
{child && !(expandable && onToggleExpand) && !showStatus && (
|
|
133
|
+
<span
|
|
134
|
+
data-testid="child-indicator"
|
|
135
|
+
aria-hidden="true"
|
|
136
|
+
className="pointer-events-none absolute inset-0 flex items-center justify-center text-ink/35"
|
|
137
|
+
>
|
|
138
|
+
<GitBranch size={size - 1} aria-hidden="true" />
|
|
139
|
+
</span>
|
|
140
|
+
)}
|
|
129
141
|
</span>
|
|
130
142
|
<span className="w-2 shrink-0" />
|
|
131
143
|
</>
|