@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
|
@@ -6923,7 +6923,7 @@
|
|
|
6923
6923
|
"tab": "files",
|
|
6924
6924
|
"group": "LSP",
|
|
6925
6925
|
"label": "LSP",
|
|
6926
|
-
"description": "
|
|
6926
|
+
"description": "Language-server integration: the lsp tool, diagnostics on write/edit, and format on write (--no-lsp disables for the run)"
|
|
6927
6927
|
}
|
|
6928
6928
|
},
|
|
6929
6929
|
"lsp.lazy": {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { describe, expect, test } from 'bun:test';
|
|
7
|
+
import {
|
|
8
|
+
TERMINAL_SCROLLBACK_BYTES,
|
|
9
|
+
TERMINAL_SCROLLBACK_LINES,
|
|
10
|
+
scrollbackBytesForLines,
|
|
11
|
+
} from '@/client/data/theme/terminal';
|
|
12
|
+
|
|
13
|
+
describe('terminal scrollback budget', () => {
|
|
14
|
+
test('is a byte budget, not xterm’s line count', () => {
|
|
15
|
+
// Ghostty charges roughly one 16-byte cell per retained column.
|
|
16
|
+
expect(scrollbackBytesForLines(10_000, 100)).toBe(16_000_000);
|
|
17
|
+
expect(TERMINAL_SCROLLBACK_BYTES).toBe(scrollbackBytesForLines(TERMINAL_SCROLLBACK_LINES, 100));
|
|
18
|
+
// Passing xterm's `10000` through as the option would be ~1000× too small.
|
|
19
|
+
expect(TERMINAL_SCROLLBACK_BYTES).toBeGreaterThan(10_000);
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('never returns a zero budget', () => {
|
|
23
|
+
expect(scrollbackBytesForLines(0, 0)).toBe(16);
|
|
24
|
+
});
|
|
25
|
+
});
|
|
@@ -5,12 +5,11 @@ import { resolveTheme } from '@/shared/lib/theme/catalog';
|
|
|
5
5
|
* The terminal palette for a theme, derived from the same eight colors the rest
|
|
6
6
|
* of the app paints with.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* scrollback instead of leaving the previous palette on screen.
|
|
8
|
+
* The palette is applied when the WASM terminal is created: ANSI cells carry
|
|
9
|
+
* RGB resolved at parse time, so a running terminal cannot simply be recolored
|
|
10
|
+
* (see the theme rebuild in `terminal-panel/mount.ts`). Every blend is computed
|
|
11
|
+
* here in hex — the canvas renderer understands literal colors, not
|
|
12
|
+
* `color-mix()`.
|
|
14
13
|
*
|
|
15
14
|
* ANSI slots map onto the semantic colors the palette does carry (red=error,
|
|
16
15
|
* green=success, yellow=warning, blue=info, magenta=accent); `cyan` has no
|
|
@@ -19,18 +18,48 @@ import { resolveTheme } from '@/shared/lib/theme/catalog';
|
|
|
19
18
|
* the foreground, which is lighter on a dark theme and darker on a light one —
|
|
20
19
|
* the direction that increases contrast on both.
|
|
21
20
|
*/
|
|
22
|
-
export function
|
|
21
|
+
export function getTerminalTheme(themeId: string) {
|
|
23
22
|
const palette = resolveTheme(themeId);
|
|
24
|
-
const { canvas, ink } = palette;
|
|
23
|
+
const { canvas, ink, paper } = palette;
|
|
25
24
|
|
|
26
25
|
const towardInk = (color: string) => mixHex(color, ink, 0.2);
|
|
27
26
|
const grayscale = (ratio: number) => mixHex(canvas, ink, ratio);
|
|
28
27
|
|
|
28
|
+
// Two slots the canvas renderer paints OPAQUELY, so their values are
|
|
29
|
+
// deliberate departures from xterm's:
|
|
30
|
+
// - `selectionBackground` is a 28% ink-over-canvas gray rather than a
|
|
31
|
+
// translucent wash. The renderer's selection branch does
|
|
32
|
+
// `fillRect(...)` with the raw color — no alpha is applied and an
|
|
33
|
+
// `rgba()` value is NOT parsed (see the renderer's selection branch,
|
|
34
|
+
// which reads `this.theme.selectionBackground` directly) — so a
|
|
35
|
+
// translucent value would paint as the literal CSS color, and a light
|
|
36
|
+
// wash would vanish against the canvas. Opaque + mixed keeps the
|
|
37
|
+
// selection visible on every theme.
|
|
38
|
+
// - `cursor: palette.meta` is the theme's own accent rather than xterm's
|
|
39
|
+
// `cursor: ink`. The block cursor is a filled rect in the meta color
|
|
40
|
+
// with `cursorAccent` drawn through the glyph, so the blink reads on
|
|
41
|
+
// both light and dark palettes without a second constant.
|
|
42
|
+
//
|
|
43
|
+
// `background` is TRANSPARENT: the terminal has no surface of its own.
|
|
44
|
+
//
|
|
45
|
+
// It used to be `canvas`, a slightly darker rectangle that also stopped a cell
|
|
46
|
+
// short of the panel on the right (the fit addon reserves 15 px for its
|
|
47
|
+
// in-canvas scrollbar) — measured as a terminal that was not full width.
|
|
48
|
+
// Painting the panel's `paper` fixed the colour mismatch but still drew a
|
|
49
|
+
// surface over the panel's material, which under `[data-surface="glass"]` is
|
|
50
|
+
// the frosted chrome (`glass.css` makes the view ROOT transparent for exactly
|
|
51
|
+
// this reason). Transparent lets that chrome — and the aura behind it — show
|
|
52
|
+
// through the canvas; the classic look is unchanged because the chrome's own
|
|
53
|
+
// fill is `--theme-paper` there. `renderLine` clears each row before filling,
|
|
54
|
+
// so a transparent ground leaves the previous frame erased, not smeared.
|
|
55
|
+
//
|
|
56
|
+
// `cursorAccent` stays `paper`: it is the glyph drawn INSIDE the dark cursor
|
|
57
|
+
// block, so it needs a real colour, not the surface.
|
|
29
58
|
return {
|
|
30
|
-
background:
|
|
59
|
+
background: 'transparent',
|
|
31
60
|
foreground: ink,
|
|
32
61
|
cursor: palette.meta,
|
|
33
|
-
cursorAccent:
|
|
62
|
+
cursorAccent: paper,
|
|
34
63
|
selectionBackground: grayscale(0.28),
|
|
35
64
|
selectionForeground: ink,
|
|
36
65
|
black: grayscale(0.2),
|
|
@@ -52,6 +81,9 @@ export function getXtermTheme(themeId: string) {
|
|
|
52
81
|
};
|
|
53
82
|
}
|
|
54
83
|
|
|
84
|
+
/** The text face the renderer measures its cell width from. */
|
|
85
|
+
export const TERMINAL_TEXT_FAMILY = 'Fira Code';
|
|
86
|
+
|
|
55
87
|
/**
|
|
56
88
|
* Font stack for the terminal canvas.
|
|
57
89
|
*
|
|
@@ -71,22 +103,20 @@ export function getXtermTheme(themeId: string) {
|
|
|
71
103
|
* (`src/shared/lib/fonts/nerd-symbols.css`), and it is deliberately LAST: a
|
|
72
104
|
* machine that already has a Nerd Font renders from it and never fetches these
|
|
73
105
|
* bytes, while a phone — which has none — falls through to it instead of
|
|
74
|
-
* painting tofu.
|
|
75
|
-
* ahead of it, laying out a PUA glyph issued zero font requests; with no local
|
|
76
|
-
* family present, the face is fetched and all of the prompt's codepoints
|
|
77
|
-
* render.
|
|
106
|
+
* painting tofu.
|
|
78
107
|
*
|
|
79
108
|
* Only glyphs the text face lacks reach these entries, so Latin metrics are
|
|
80
|
-
* untouched
|
|
109
|
+
* untouched.
|
|
81
110
|
*/
|
|
82
|
-
export const
|
|
111
|
+
export const TERMINAL_GLYPH_FALLBACKS =
|
|
83
112
|
"'FiraCode Nerd Font Mono', 'FiraCode Nerd Font', 'JetBrainsMono Nerd Font', " +
|
|
84
113
|
"'JetBrainsMono NF', 'JetBrains Mono Nerd Font', 'Hack Nerd Font', 'MesloLGS NF', " +
|
|
85
114
|
"'MesloLGM Nerd Font', 'CaskaydiaCove Nerd Font', 'SauceCodePro Nerd Font', " +
|
|
86
115
|
"'Symbols Nerd Font Mono', 'Symbols Nerd Font', 'PowerlineSymbols'";
|
|
87
116
|
|
|
88
117
|
/**
|
|
89
|
-
* The bundled symbols face, kept separate so `mount.ts` can await it by
|
|
118
|
+
* The bundled symbols face, kept separate so `mount.ts` can await/watch it by
|
|
119
|
+
* name.
|
|
90
120
|
*
|
|
91
121
|
* It must stay last in the stack (see above) and its family name must match the
|
|
92
122
|
* `@font-face` in `nerd-symbols.css` — the two are one contract, which is why
|
|
@@ -94,70 +124,57 @@ export const XTERM_GLYPH_FALLBACKS =
|
|
|
94
124
|
*/
|
|
95
125
|
export const NERD_SYMBOLS_FAMILY = 'Kabmo Nerd Symbols';
|
|
96
126
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
/** xterm's private render service, read only to size-check before fitting. */
|
|
101
|
-
export interface XtermCore {
|
|
102
|
-
_core?: { _renderService?: { dimensions?: { css?: { cell?: { width?: number; height?: number } } } } };
|
|
103
|
-
}
|
|
127
|
+
/** The faces whose late arrival changes what the canvas should rasterize. */
|
|
128
|
+
export const TERMINAL_FACES = [TERMINAL_TEXT_FAMILY, NERD_SYMBOLS_FAMILY] as const;
|
|
104
129
|
|
|
105
|
-
/**
|
|
106
|
-
*
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
130
|
+
/**
|
|
131
|
+
* The canvas renderer composes its font string as `[italic ][bold ]SIZE FAMILY`
|
|
132
|
+
* when a cell is bold, and the shorthand grammar allows ONE weight before the
|
|
133
|
+
* size — not one per family — so the stack cannot ask for a real 700 per
|
|
134
|
+
* face (`'Fira Code';700` is not a valid family token and the whole
|
|
135
|
+
* declaration is dropped, leaving the renderer's `monospace` default). Bold
|
|
136
|
+
* therefore goes through the CSS font-matching rules: the first family that
|
|
137
|
+
* SHIPS a 700 wins, and `@fontsource/fira-code` does — `fira-code-fonts.css`
|
|
138
|
+
* bundles 400/500/600/700 — so bold cells rasterize from the real 700 and
|
|
139
|
+
* match xterm. Verified in Chromium: `bold 12px 'Fira Code', …` with the 700
|
|
140
|
+
* face unloaded reports `12px "Fira Code"` (the 400 face) and downloads
|
|
141
|
+
* `fira-code-latin-700-normal.woff2` the moment a bold cell is laid out.
|
|
142
|
+
*/
|
|
143
|
+
export const TERMINAL_FONT_FAMILY =
|
|
144
|
+
`'${TERMINAL_TEXT_FAMILY}', ${TERMINAL_GLYPH_FALLBACKS}, '${NERD_SYMBOLS_FAMILY}', Menlo, Monaco, 'Courier New', monospace`;
|
|
112
145
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
if (!dims?.css?.cell?.width || !dims?.css?.cell?.height) return undefined;
|
|
125
|
-
return origPropose?.call(this);
|
|
126
|
-
} catch {
|
|
127
|
-
return undefined;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
} catch {}
|
|
132
|
-
}
|
|
146
|
+
/**
|
|
147
|
+
* The cell font size in CSS px.
|
|
148
|
+
*
|
|
149
|
+
* 12px is a measured choice: the right panel is ~350 px wide at its default
|
|
150
|
+
* width, and 12px keeps a normal prompt unwrapped. The renderer has no
|
|
151
|
+
* `lineHeight` option, so the cell box is measured instead — `measureTerminalCell`
|
|
152
|
+
* in `terminal-panel/fonts.ts` pads the glyph ink (`Mg`) by 2.5 px above and 1 px
|
|
153
|
+
* below: 15 px per cell, which is what a painted background block needs to read
|
|
154
|
+
* as a rectangle rather than a band.
|
|
155
|
+
*/
|
|
156
|
+
export const TERMINAL_FONT_SIZE = 12;
|
|
133
157
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
158
|
+
/**
|
|
159
|
+
* Ghostty's `max_scrollback` is a BYTE budget, not a line count.
|
|
160
|
+
*
|
|
161
|
+
* The wrapper types it as lines and passes xterm's `scrollback: 10000` through
|
|
162
|
+
* unchanged, which retains roughly 600 rows at a 98-column panel (measured).
|
|
163
|
+
* Kabmo wants xterm's old 10,000-line depth, so the budget is stated in the
|
|
164
|
+
* renderer's own unit.
|
|
165
|
+
*
|
|
166
|
+
* Ghostty charges roughly one 16-byte cell per retained column, so
|
|
167
|
+
* `lines × cols × 16` is the deliberate over-estimate: at 100 columns it is
|
|
168
|
+
* 16 MB for 10,000 lines, and the byte cap trims earlier only if the estimate
|
|
169
|
+
* is too small. The server's replay history is capped separately at 512 KiB
|
|
170
|
+
* (`lib/terminal/history.ts`), so a reconnect is bounded regardless.
|
|
171
|
+
*/
|
|
172
|
+
export const TERMINAL_SCROLLBACK_CELL_BYTES = 16;
|
|
173
|
+
export const TERMINAL_SCROLLBACK_LINES = 10_000;
|
|
138
174
|
|
|
139
|
-
export function
|
|
140
|
-
|
|
141
|
-
const core = term?._core;
|
|
142
|
-
if (core?._renderService) {
|
|
143
|
-
const proto = Object.getPrototypeOf(core._renderService);
|
|
144
|
-
const desc = Object.getOwnPropertyDescriptor(proto, 'dimensions');
|
|
145
|
-
if (desc?.get && !proto.__safePatched) {
|
|
146
|
-
proto.__safePatched = true;
|
|
147
|
-
const origGet = desc.get;
|
|
148
|
-
Object.defineProperty(proto, 'dimensions', {
|
|
149
|
-
get() {
|
|
150
|
-
try {
|
|
151
|
-
if (!this._renderer?.value) return DEFAULT_DIMENSIONS;
|
|
152
|
-
return origGet.call(this);
|
|
153
|
-
} catch {
|
|
154
|
-
return DEFAULT_DIMENSIONS;
|
|
155
|
-
}
|
|
156
|
-
},
|
|
157
|
-
configurable: true,
|
|
158
|
-
enumerable: true
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
} catch {}
|
|
175
|
+
export function scrollbackBytesForLines(lines: number, cols: number): number {
|
|
176
|
+
return Math.max(1, lines) * Math.max(1, cols) * TERMINAL_SCROLLBACK_CELL_BYTES;
|
|
163
177
|
}
|
|
178
|
+
|
|
179
|
+
/** The default budget: 10,000 lines at the panel's usual 100 columns. */
|
|
180
|
+
export const TERMINAL_SCROLLBACK_BYTES = scrollbackBytesForLines(TERMINAL_SCROLLBACK_LINES, 100);
|
|
@@ -32,8 +32,6 @@ import { registerListSlot, resetListSlots } from '@/client/lib/plugins/list-slot
|
|
|
32
32
|
import {
|
|
33
33
|
invalidateComposerCache,
|
|
34
34
|
loadComposerItems,
|
|
35
|
-
toAgentPickItems,
|
|
36
|
-
toFilePickItems,
|
|
37
35
|
} from '@/shared/lib/chat/composer/client';
|
|
38
36
|
|
|
39
37
|
const DOM_GLOBALS = ['window', 'document', 'navigator', 'HTMLElement', 'Element', 'Node', 'Event', 'CustomEvent'] as const;
|
|
@@ -144,7 +142,10 @@ describe('useComposerItems', () => {
|
|
|
144
142
|
|
|
145
143
|
await mount('mention', '/repo');
|
|
146
144
|
await settle(6);
|
|
147
|
-
|
|
145
|
+
const tokens = state.items.map((item) => item.token);
|
|
146
|
+
expect(tokens[0]).toBe('@sonic');
|
|
147
|
+
expect(tokens.at(-1)).toBe('@file:src/a.ts');
|
|
148
|
+
expect(tokens).toContain('@harness:claude');
|
|
148
149
|
expect(state.error).toBeNull();
|
|
149
150
|
});
|
|
150
151
|
|
|
@@ -240,7 +241,8 @@ describe('plugin commands in the popup', () => {
|
|
|
240
241
|
await mount('mention', '/repo');
|
|
241
242
|
await settle(6);
|
|
242
243
|
|
|
243
|
-
expect(state.items).
|
|
244
|
+
expect(state.items.every((item) => item.source === 'harness')).toBe(true);
|
|
245
|
+
expect(state.items.length).toBeGreaterThan(0);
|
|
244
246
|
});
|
|
245
247
|
|
|
246
248
|
test('a closed menu offers nothing, not even a plugin row', async () => {
|
|
@@ -252,26 +254,6 @@ describe('plugin commands in the popup', () => {
|
|
|
252
254
|
});
|
|
253
255
|
});
|
|
254
256
|
|
|
255
|
-
describe('pick item mapping', () => {
|
|
256
|
-
test('an agent becomes a bare @name token', () => {
|
|
257
|
-
const [item] = toAgentPickItems([
|
|
258
|
-
{ id: 'a1', name: 'sonic', description: 'fast', scope: 'user', systemPrompt: '' },
|
|
259
|
-
]);
|
|
260
|
-
expect(item).toMatchObject({ id: 'agent-sonic', name: 'sonic', kind: 'agent', source: 'agent', token: '@sonic' });
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
test('a file is namespaced under file:, so a root-level name cannot shadow an agent', () => {
|
|
264
|
-
const [item] = toFilePickItems([{ name: 'sonic', path: 'sonic' }]);
|
|
265
|
-
expect(item.token).toBe('@file:sonic');
|
|
266
|
-
expect(item.path).toBe('sonic');
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
test('a path with whitespace is quoted, so the token cannot end early', () => {
|
|
270
|
-
const [item] = toFilePickItems([{ name: 'my notes.md', path: 'docs/my notes.md' }]);
|
|
271
|
-
expect(item.token).toBe('@"file:docs/my notes.md"');
|
|
272
|
-
});
|
|
273
|
-
});
|
|
274
|
-
|
|
275
257
|
describe('loadComposerItems', () => {
|
|
276
258
|
test('mention merges agents first, then workspace files', async () => {
|
|
277
259
|
answer = (url) => url.includes('/api/settings/agents')
|
|
@@ -279,7 +261,9 @@ describe('loadComposerItems', () => {
|
|
|
279
261
|
: { body: { files: [{ name: 'a.ts', path: 'src/a.ts' }] } };
|
|
280
262
|
|
|
281
263
|
const items = await loadComposerItems('mention', '/repo');
|
|
282
|
-
expect(items.
|
|
264
|
+
expect(items[0].source).toBe('agent');
|
|
265
|
+
expect(items.at(-1)?.source).toBe('file');
|
|
266
|
+
expect(items.some((item) => item.source === 'harness')).toBe(true);
|
|
283
267
|
expect(requested).toContain('/api/fs/list?root=%2Frepo');
|
|
284
268
|
});
|
|
285
269
|
|
|
@@ -289,7 +273,9 @@ describe('loadComposerItems', () => {
|
|
|
289
273
|
: { body: { files: [{ name: 'a.ts', path: 'src/a.ts' }] } };
|
|
290
274
|
|
|
291
275
|
const items = await loadComposerItems('mention', '/repo', 's1', { includeAgents: false });
|
|
292
|
-
expect(items.
|
|
276
|
+
expect(items.at(-1)?.source).toBe('file');
|
|
277
|
+
expect(items.some((item) => item.source === 'harness')).toBe(true);
|
|
278
|
+
expect(items.some((item) => item.source === 'agent')).toBe(false);
|
|
293
279
|
// The agents request is skipped entirely, not fetched and filtered.
|
|
294
280
|
expect(requested.some((url) => url.includes('/api/settings/agents'))).toBe(false);
|
|
295
281
|
});
|
|
@@ -315,6 +301,25 @@ describe('loadComposerItems', () => {
|
|
|
315
301
|
expect(requested.length).toBe(6);
|
|
316
302
|
});
|
|
317
303
|
|
|
304
|
+
test('commands are scoped to the live session, with one cache entry per session', async () => {
|
|
305
|
+
answer = (url) => (url.includes('sessionId=s1')
|
|
306
|
+
? { body: { commands: [{ id: 'c1', name: 'test', description: 'Run tests', scope: 'system', template: '' }], skills: [] } }
|
|
307
|
+
: { body: { commands: [], skills: [] } });
|
|
308
|
+
|
|
309
|
+
const forS1 = await loadComposerItems('command', '/repo', 's1');
|
|
310
|
+
expect(requested).toContain('/api/settings/commands?root=%2Frepo&sessionId=s1');
|
|
311
|
+
expect(forS1.some((item) => item.name === 'test')).toBe(true);
|
|
312
|
+
|
|
313
|
+
// Another chat must not be served s1's vocabulary from the cache.
|
|
314
|
+
const forS2 = await loadComposerItems('command', '/repo', 's2');
|
|
315
|
+
expect(requested.some((url) => url.includes('sessionId=s2'))).toBe(true);
|
|
316
|
+
expect(forS2.some((item) => item.name === 'test')).toBe(false);
|
|
317
|
+
|
|
318
|
+
const before = requested.length;
|
|
319
|
+
await loadComposerItems('command', '/repo', 's1');
|
|
320
|
+
expect(requested.length).toBe(before);
|
|
321
|
+
});
|
|
322
|
+
|
|
318
323
|
test('a command entry is a /name token and a skill is prefixed', async () => {
|
|
319
324
|
answer = (url) => url.includes('/commands')
|
|
320
325
|
? { body: { commands: [{ id: 'c', name: 'fix', description: 'fix it', scope: 'user', template: '/fix' }] } }
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { describe, expect, test } from 'bun:test';
|
|
2
|
+
import {
|
|
3
|
+
toAgentPickItems,
|
|
4
|
+
toFilePickItems,
|
|
5
|
+
toHarnessPickItems,
|
|
6
|
+
} from '@/shared/lib/chat/composer/client';
|
|
7
|
+
|
|
8
|
+
describe('pick item mapping', () => {
|
|
9
|
+
test('an agent becomes a bare @name token', () => {
|
|
10
|
+
const [item] = toAgentPickItems([
|
|
11
|
+
{ id: 'a1', name: 'sonic', description: 'fast', scope: 'user', systemPrompt: '' },
|
|
12
|
+
]);
|
|
13
|
+
expect(item).toMatchObject({
|
|
14
|
+
id: 'agent-sonic',
|
|
15
|
+
name: 'sonic',
|
|
16
|
+
kind: 'agent',
|
|
17
|
+
source: 'agent',
|
|
18
|
+
token: '@sonic',
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
test('a harness becomes a namespaced default-model token', () => {
|
|
23
|
+
const [item] = toHarnessPickItems().filter((entry) => entry.token === '@harness:claude');
|
|
24
|
+
expect(item).toMatchObject({
|
|
25
|
+
id: 'harness-claude',
|
|
26
|
+
kind: 'harness',
|
|
27
|
+
source: 'harness',
|
|
28
|
+
token: '@harness:claude',
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
test('a file is namespaced under file:, so a root-level name cannot shadow an agent', () => {
|
|
33
|
+
const [item] = toFilePickItems([{ name: 'sonic', path: 'sonic' }]);
|
|
34
|
+
expect(item.token).toBe('@file:sonic');
|
|
35
|
+
expect(item.path).toBe('sonic');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
test('a path with whitespace is quoted, so the token cannot end early', () => {
|
|
39
|
+
const [item] = toFilePickItems([{ name: 'my notes.md', path: 'docs/my notes.md' }]);
|
|
40
|
+
expect(item.token).toBe('@"file:docs/my notes.md"');
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
*/
|
|
26
26
|
|
|
27
27
|
import { useEffect, useMemo, useRef } from 'preact/hooks';
|
|
28
|
-
import type { PendingSessionEntry } from '@/client/hooks/chat/omp/pending-
|
|
28
|
+
import type { PendingSessionEntry } from '@/client/hooks/chat/omp/pending-entry';
|
|
29
29
|
import { pendingHostFolderIds } from '@/client/hooks/chat/omp/pending-rows';
|
|
30
30
|
import { setFolderExpanded } from '@/client/hooks/workspace/folder-expansion';
|
|
31
31
|
import type { WorkspaceFolderData } from '@/shared/types';
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The pending → real id switch a spawn performs, and who may claim it.
|
|
8
|
+
*
|
|
9
|
+
* Split from the store (`pending-sessions.ts`) because the two readers ask
|
|
10
|
+
* different questions of the same record: the session-state provider claims it
|
|
11
|
+
* once to carry a draft across, while the agent hook only peeks to know the
|
|
12
|
+
* conversation did not change. Neither may treat a plain session switch as an
|
|
13
|
+
* adoption — that mistake copied one chat's draft into another and cleared the
|
|
14
|
+
* run's tool map mid-turn.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** `toId → fromId` for a spawn adoption, written where the spawn answers. */
|
|
18
|
+
const adoptions = new Map<string, string>();
|
|
19
|
+
|
|
20
|
+
/** Record a spawn adoption; bounded by the store, which drops the source. */
|
|
21
|
+
export function recordAdoption(fromId: string, toId: string): void {
|
|
22
|
+
adoptions.set(toId, fromId);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Whether `toId` is the id a spawn answered with for `fromId` — consuming the
|
|
27
|
+
* record so one adoption is claimed once.
|
|
28
|
+
*
|
|
29
|
+
* Only a real spawn may carry the transient slot's UI state across: clicking a
|
|
30
|
+
* different session from a pending chat is the same URL transition, and was
|
|
31
|
+
* measured copying `chat.draft` into the other session.
|
|
32
|
+
*/
|
|
33
|
+
export function consumeAdoption(fromId: string | null | undefined, toId: string): boolean {
|
|
34
|
+
if (!fromId || adoptions.get(toId) !== fromId) return false;
|
|
35
|
+
adoptions.delete(toId);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Whether `toId` is the id a spawn answered with for `fromId`, WITHOUT claiming
|
|
41
|
+
* the record.
|
|
42
|
+
*
|
|
43
|
+
* The agent hook's question is "is this the SAME conversation under a new id",
|
|
44
|
+
* not "may I carry this UI state across": treating an adoption as a session
|
|
45
|
+
* switch threw away `toolResultsRef`/`lastToolMessageRef` mid-turn, so every
|
|
46
|
+
* later progress frame lost its card. The provider still owns the single claim,
|
|
47
|
+
* so peeking here cannot steal it.
|
|
48
|
+
*/
|
|
49
|
+
export function isSpawnAdoption(fromId: string | null | undefined, toId: string): boolean {
|
|
50
|
+
return Boolean(fromId) && adoptions.get(toId) === fromId;
|
|
51
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The pending row a "New child session" click creates.
|
|
8
|
+
*
|
|
9
|
+
* A child is a pending chat like any other — same store, same lifetime — but it
|
|
10
|
+
* must land INSIDE its parent's branch and keep its branch slot, harness and
|
|
11
|
+
* "New Child" title across the id switch a spawn performs. Both facts are
|
|
12
|
+
* asserted here rather than in the store suite, because they are the ones the
|
|
13
|
+
* tree depends on.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import { beforeEach, describe, expect, test } from 'bun:test';
|
|
17
|
+
|
|
18
|
+
import {
|
|
19
|
+
adoptPendingSession,
|
|
20
|
+
listPendingSessions,
|
|
21
|
+
releasePendingSession,
|
|
22
|
+
startPendingSession,
|
|
23
|
+
} from '@/client/hooks/chat/omp/pending-sessions';
|
|
24
|
+
import { withPendingRows } from '@/client/hooks/chat/omp/pending-rows';
|
|
25
|
+
import { buildSessionTree } from '@/client/lib/session-tree';
|
|
26
|
+
import { formatNewSessionTitle } from '@/shared/lib/omp/session/default-title';
|
|
27
|
+
import type { WorkspaceFolderData } from '@/shared/types';
|
|
28
|
+
|
|
29
|
+
function folders(...ids: string[]): WorkspaceFolderData[] {
|
|
30
|
+
return [{
|
|
31
|
+
id: 1,
|
|
32
|
+
name: 'ws',
|
|
33
|
+
isExpanded: false,
|
|
34
|
+
hasMore: false,
|
|
35
|
+
totalSessions: ids.length,
|
|
36
|
+
sessions: ids.map((id) => ({ id, folder_id: 1, title: id.toUpperCase() })),
|
|
37
|
+
}];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function clear(): void {
|
|
41
|
+
for (const entry of listPendingSessions()) releasePendingSession(entry.id);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
beforeEach(clear);
|
|
45
|
+
|
|
46
|
+
describe('pending child rows', () => {
|
|
47
|
+
test('a pending CHILD nests under its parent, with its harness and title', () => {
|
|
48
|
+
const title = formatNewSessionTitle(new Date(), 'New Child');
|
|
49
|
+
const id = startPendingSession(1, { parentSessionId: 'real-1', harness: 'claude', title });
|
|
50
|
+
|
|
51
|
+
const out = withPendingRows(folders('real-1'), listPendingSessions(), { activeId: 'real-1' });
|
|
52
|
+
const tree = buildSessionTree(out[0]?.sessions ?? []);
|
|
53
|
+
const child = tree.childrenOf.get('real-1')?.[0];
|
|
54
|
+
expect(tree.roots.map((session) => session.id)).toEqual(['real-1']);
|
|
55
|
+
expect(child?.id).toBe(id);
|
|
56
|
+
expect(child?.parentSessionId).toBe('real-1');
|
|
57
|
+
expect(child?.harness).toBe('claude');
|
|
58
|
+
expect(child?.title).toBe(title);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
test('adoption keeps a child in its branch after the id switch', () => {
|
|
62
|
+
const title = formatNewSessionTitle(new Date(), 'New Child');
|
|
63
|
+
const id = startPendingSession(1, { parentSessionId: 'real-1', harness: 'claude', title });
|
|
64
|
+
|
|
65
|
+
adoptPendingSession(id, 'omp-child', 1);
|
|
66
|
+
const adopted = listPendingSessions().find((entry) => entry.id === 'omp-child');
|
|
67
|
+
expect(adopted?.parentSessionId).toBe('real-1');
|
|
68
|
+
expect(adopted?.harness).toBe('claude');
|
|
69
|
+
expect(adopted?.title).toBe(title);
|
|
70
|
+
// The old pending id is gone: one row, not two.
|
|
71
|
+
expect(listPendingSessions().some((entry) => entry.id === id)).toBe(false);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* SPDX-License-Identifier: MIT
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* One row the client draws before omp's transcript scan can see the session.
|
|
8
|
+
*
|
|
9
|
+
* Split from the store that owns its lifetime (`pending-sessions.ts`): the
|
|
10
|
+
* type is what three modules share, and keeping it here is what lets the store
|
|
11
|
+
* stay inside the file-size ceiling without a second shape.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export interface PendingSessionEntry {
|
|
15
|
+
/** Client-side `new-<epoch>` id, or the omp UUID a spawn adopted. */
|
|
16
|
+
id: string;
|
|
17
|
+
/** The folder the row belongs to; null resolves from the active session. */
|
|
18
|
+
folderId: number | string | null;
|
|
19
|
+
/** Epoch ms the chat was started — stable across adoption and reloads, so
|
|
20
|
+
* neither the title nor the ordering can churn on a revalidate. */
|
|
21
|
+
createdAt: number;
|
|
22
|
+
/** Epoch ms a prompt was dispatched for this chat, or null while it is a
|
|
23
|
+
* draft the user has not sent in. */
|
|
24
|
+
sentAt: number | null;
|
|
25
|
+
/**
|
|
26
|
+
* Set while this chat's prompt is HELD for another session to finish.
|
|
27
|
+
*
|
|
28
|
+
* The row is drawn exactly as it was before the send — same id, same folder —
|
|
29
|
+
* because the session does not exist yet: what the user asked for is that the
|
|
30
|
+
* row stays put and says what it is waiting on. `waitId` is the server row
|
|
31
|
+
* that owns the wait, so cancelling from the row reaches it.
|
|
32
|
+
*/
|
|
33
|
+
waiting?: {
|
|
34
|
+
waitId: string;
|
|
35
|
+
dependsOn: string;
|
|
36
|
+
dependsOnTitle: string | null;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* The session this pending chat is a CHILD of, when it was started from that
|
|
40
|
+
* row's "New child session" menu. Absent for a top-level New Session.
|
|
41
|
+
*
|
|
42
|
+
* Carried onto the sidebar row so `buildSessionTree` can nest the row under
|
|
43
|
+
* its parent from the first frame — the child exists client-side before omp's
|
|
44
|
+
* transcript scan can see it, exactly like any pending chat.
|
|
45
|
+
*/
|
|
46
|
+
parentSessionId?: string;
|
|
47
|
+
/** Harness picked for a pending child, so its mark is drawn before spawn. */
|
|
48
|
+
harness?: string;
|
|
49
|
+
/** Row title override: a pending child names itself "New Child - …". */
|
|
50
|
+
title?: string;
|
|
51
|
+
/**
|
|
52
|
+
* The session this pending chat BRANCHES from, when the Fork button started
|
|
53
|
+
* it. A fork is not a child: it records a source edge, not a parent, so this
|
|
54
|
+
* is kept apart from `parentSessionId`.
|
|
55
|
+
*/
|
|
56
|
+
forkSourceSessionId?: string;
|
|
57
|
+
/** The transcript entry the fork cuts at; absent means the source's tip. */
|
|
58
|
+
forkAnchorEntryId?: string;
|
|
59
|
+
}
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
|
|
16
16
|
import type { SessionItemData, WorkspaceFolderData } from '@/shared/types';
|
|
17
17
|
import { pendingSessionTitle } from '@/shared/lib/omp/session/default-title';
|
|
18
|
-
import type { PendingSessionEntry } from '@/client/hooks/chat/omp/pending-
|
|
18
|
+
import type { PendingSessionEntry } from '@/client/hooks/chat/omp/pending-entry';
|
|
19
19
|
|
|
20
20
|
export interface PendingRowOptions {
|
|
21
21
|
/** The session the URL has open; its folder is the fallback host. */
|
|
@@ -58,12 +58,16 @@ export function withPendingRows(
|
|
|
58
58
|
const row: SessionItemData = {
|
|
59
59
|
id: entry.id,
|
|
60
60
|
folder_id: target.id,
|
|
61
|
-
title: options.titleFor?.(String(entry.id)) ?? pendingSessionTitle(entry.id),
|
|
61
|
+
title: entry.title ?? options.titleFor?.(String(entry.id)) ?? pendingSessionTitle(entry.id),
|
|
62
62
|
// The id's own clock, never `Date.now()`: the row is ranked by
|
|
63
63
|
// `updated_at`, and a re-stamp on every revalidate kept it perpetually
|
|
64
64
|
// newest and reshuffled LATEST_SESSION ordering mid-run.
|
|
65
65
|
created_at: stamp,
|
|
66
66
|
updated_at: stamp,
|
|
67
|
+
// A pending CHILD nests under its parent from the first frame; the tree
|
|
68
|
+
// builder does the rest, so no second placement rule exists.
|
|
69
|
+
...(entry.parentSessionId ? { parentSessionId: entry.parentSessionId } : {}),
|
|
70
|
+
...(entry.harness ? { harness: entry.harness } : {}),
|
|
67
71
|
// The row's own reason for existing past the click: its prompt is held.
|
|
68
72
|
...(entry.waiting
|
|
69
73
|
? { waitingFor: { waitId: entry.waiting.waitId, sessionId: entry.waiting.dependsOn, title: entry.waiting.dependsOnTitle } }
|
|
@@ -20,8 +20,6 @@ import { beforeEach, describe, expect, test } from 'bun:test';
|
|
|
20
20
|
|
|
21
21
|
import {
|
|
22
22
|
adoptPendingSession,
|
|
23
|
-
consumeAdoption,
|
|
24
|
-
isSpawnAdoption,
|
|
25
23
|
hydratePendingSession,
|
|
26
24
|
listPendingSessions,
|
|
27
25
|
markPendingSessionSent,
|
|
@@ -31,6 +29,7 @@ import {
|
|
|
31
29
|
releasePendingSession,
|
|
32
30
|
startPendingSession,
|
|
33
31
|
} from '@/client/hooks/chat/omp/pending-sessions';
|
|
32
|
+
import { consumeAdoption, isSpawnAdoption } from '@/client/hooks/chat/omp/pending-adoption';
|
|
34
33
|
import { pendingHostFolderIds, withPendingRows } from '@/client/hooks/chat/omp/pending-rows';
|
|
35
34
|
import { formatNewSessionTitle } from '@/shared/lib/omp/session/default-title';
|
|
36
35
|
import { forgetSession, getSessionValue, setSessionKey } from '@/shared/lib/workspace/session-state/store';
|