repoburg 1.3.201 → 1.3.204
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/agent-pane/backend/dist/index.js +2714 -32395
- package/agent-pane/backend/dist/server.js +45304 -0
- package/askuser-after-step5-postgres-selected.png +0 -0
- package/askuser-after-step7-answer-sent.png +0 -0
- package/askuser-card-visible.png +0 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.d.ts +16 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js +87 -0
- package/backend/dist/src/agent-runtime/agent-runtime-event-emitter.js.map +1 -1
- package/backend/dist/src/agent-runtime/agent-runtime.types.d.ts +16 -1
- package/backend/dist/src/app.controller.d.ts +1 -0
- package/backend/dist/src/app.service.d.ts +1 -0
- package/backend/dist/src/app.service.js +4 -1
- package/backend/dist/src/app.service.js.map +1 -1
- package/backend/dist/src/interactive-chat/chat.service.d.ts +4 -0
- package/backend/dist/src/interactive-chat/chat.service.js +21 -1
- package/backend/dist/src/interactive-chat/chat.service.js.map +1 -1
- package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js +12 -1
- package/backend/dist/src/llm-orchestration/action-handlers/invoke-subagent.handler.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.d.ts +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js +1 -0
- package/backend/dist/src/llm-orchestration/llm-orchestration.interfaces.js.map +1 -1
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js +2 -0
- package/backend/dist/src/llm-orchestration/llm-turn-processor.service.js.map +1 -1
- package/backend/dist/tsconfig.build.tsbuildinfo +1 -1
- package/daemon/dist/agentPane.js +128 -0
- package/daemon/dist/agentPane.spec.js +183 -0
- package/daemon/dist/api/services.js +4 -0
- package/daemon/dist/index.js +28 -8
- package/daemon/dist/serviceManager.js +30 -11
- package/daemon/dist/serviceManager.spec.js +26 -0
- package/daemon/dist/workspace-validation.js +63 -0
- package/daemon/dist/workspace-validation.spec.js +63 -0
- package/daemon/package.json +1 -1
- package/package.json +15 -2
- package/r2-step4-apple-banana.png +0 -0
- package/r2-step5-after-rewind-apple-last.png +0 -0
- package/r2-step7-apple-cherry.png +0 -0
- package/r2-step8-cherry-menu-no-restore.png +0 -0
- package/r3-step3-live-task-card-running.png +0 -0
- package/r3-step4-after-completion.png +0 -0
- package/r3-step5-persistence-after-reload.png +0 -0
- package/r3-step6-tasks-tab-card.png +0 -0
- package/reverify-answered-state-answer-sent.png +0 -0
- package/reverify-card-visible-after-completion.png +0 -0
- package/rewind-step3-apple-banana-turns.png +0 -0
- package/rewind-step5-ui-unchanged-after-confirmed-rewind.png +0 -0
- package/rewind-step6-apple-menu-no-restore.png +0 -0
- package/rewind-step7-final-turnlist-unchanged.png +0 -0
- package/rewind-step7-negative-error-toast.png +0 -0
- package/rewind-step7-negative-error-toast2.png +0 -0
- package/subagent-r2-step5-turn-after-reload-no-card.png +0 -0
- package/subagent-r2-step6-tasks-panel-card.png +0 -0
- package/subagent-step3-tasks-tab-done-card.png +0 -0
- package/subagent-step4-turn-stuck-no-cards.png +0 -0
- package/agent-pane/.prettierignore +0 -5
- package/agent-pane/.prettierrc +0 -8
- package/agent-pane/backend/coverage/base.css +0 -224
- package/agent-pane/backend/coverage/block-navigation.js +0 -87
- package/agent-pane/backend/coverage/clover.xml +0 -887
- package/agent-pane/backend/coverage/coverage-final.json +0 -10
- package/agent-pane/backend/coverage/favicon.png +0 -0
- package/agent-pane/backend/coverage/index.html +0 -176
- package/agent-pane/backend/coverage/prettify.css +0 -1
- package/agent-pane/backend/coverage/prettify.js +0 -2
- package/agent-pane/backend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/backend/coverage/sorter.js +0 -210
- package/agent-pane/backend/coverage/src/codex/codex-provider.ts.html +0 -1402
- package/agent-pane/backend/coverage/src/codex/index.html +0 -131
- package/agent-pane/backend/coverage/src/codex/item-mapper.ts.html +0 -331
- package/agent-pane/backend/coverage/src/db/index.html +0 -131
- package/agent-pane/backend/coverage/src/db/index.ts.html +0 -436
- package/agent-pane/backend/coverage/src/db/schema.ts.html +0 -175
- package/agent-pane/backend/coverage/src/index.html +0 -116
- package/agent-pane/backend/coverage/src/index.ts.html +0 -262
- package/agent-pane/backend/coverage/src/routes/index.html +0 -146
- package/agent-pane/backend/coverage/src/routes/sessions.ts.html +0 -991
- package/agent-pane/backend/coverage/src/routes/turns.ts.html +0 -256
- package/agent-pane/backend/coverage/src/routes/workspaces.ts.html +0 -406
- package/agent-pane/backend/coverage/src/ws/index.html +0 -116
- package/agent-pane/backend/coverage/src/ws/index.ts.html +0 -238
- package/agent-pane/backend/data.db +0 -0
- package/agent-pane/backend/data.db-shm +0 -0
- package/agent-pane/backend/data.db-wal +0 -0
- package/agent-pane/backend/package-lock.json +0 -5945
- package/agent-pane/backend/package.json +0 -33
- package/agent-pane/backend/scripts/backfill-from-jsonl.ts +0 -206
- package/agent-pane/backend/scripts/import-session-from-jsonl.ts +0 -264
- package/agent-pane/backend/src/claude/claude-message-mapper.test.ts +0 -271
- package/agent-pane/backend/src/claude/claude-message-mapper.ts +0 -259
- package/agent-pane/backend/src/claude/claude-provider.test.ts +0 -455
- package/agent-pane/backend/src/claude/claude-provider.ts +0 -1319
- package/agent-pane/backend/src/claude/claude-types.ts +0 -45
- package/agent-pane/backend/src/codex/app-server-client.test.ts +0 -183
- package/agent-pane/backend/src/codex/app-server-client.ts +0 -247
- package/agent-pane/backend/src/codex/app-server-types.ts +0 -259
- package/agent-pane/backend/src/codex/codex-provider-runtime-config.test.ts +0 -56
- package/agent-pane/backend/src/codex/codex-provider.test.ts +0 -60
- package/agent-pane/backend/src/codex/codex-provider.ts +0 -619
- package/agent-pane/backend/src/codex/item-mapper.test.ts +0 -221
- package/agent-pane/backend/src/codex/item-mapper.ts +0 -86
- package/agent-pane/backend/src/codex/shared-app-server.ts +0 -25
- package/agent-pane/backend/src/db/index.test.ts +0 -125
- package/agent-pane/backend/src/db/index.ts +0 -230
- package/agent-pane/backend/src/db/schema.ts +0 -34
- package/agent-pane/backend/src/index.ts +0 -89
- package/agent-pane/backend/src/integration/__fixtures__/cancel-turn.json +0 -29
- package/agent-pane/backend/src/integration/__fixtures__/delta-streaming.json +0 -40
- package/agent-pane/backend/src/integration/__fixtures__/failed-turn.json +0 -16
- package/agent-pane/backend/src/integration/__fixtures__/mcp-tool-call.json +0 -60
- package/agent-pane/backend/src/integration/__fixtures__/missing-item-started.json +0 -34
- package/agent-pane/backend/src/integration/__fixtures__/multi-item-turn.json +0 -85
- package/agent-pane/backend/src/integration/__fixtures__/multi-turn.json +0 -48
- package/agent-pane/backend/src/integration/__fixtures__/simple-turn.json +0 -35
- package/agent-pane/backend/src/integration/delta-streaming.test.ts +0 -130
- package/agent-pane/backend/src/integration/helpers/app-server-mock.ts +0 -272
- package/agent-pane/backend/src/integration/helpers/test-app.ts +0 -110
- package/agent-pane/backend/src/integration/helpers/ws-capture.ts +0 -64
- package/agent-pane/backend/src/integration/item-lifecycle.test.ts +0 -133
- package/agent-pane/backend/src/integration/mcp-tool-call.test.ts +0 -102
- package/agent-pane/backend/src/integration/missing-item-started.test.ts +0 -91
- package/agent-pane/backend/src/integration/multi-turn.test.ts +0 -121
- package/agent-pane/backend/src/integration/session-operations.test.ts +0 -175
- package/agent-pane/backend/src/integration/threads-claude-fork.test.ts +0 -241
- package/agent-pane/backend/src/integration/threads.test.ts +0 -309
- package/agent-pane/backend/src/integration/title-generation.test.ts +0 -109
- package/agent-pane/backend/src/integration/turn-cancel.test.ts +0 -111
- package/agent-pane/backend/src/integration/turn-failure.test.ts +0 -97
- package/agent-pane/backend/src/integration/turn-lifecycle.test.ts +0 -141
- package/agent-pane/backend/src/providers/index.ts +0 -16
- package/agent-pane/backend/src/providers/registry.test.ts +0 -92
- package/agent-pane/backend/src/providers/registry.ts +0 -43
- package/agent-pane/backend/src/providers/runtime-provider.ts +0 -43
- package/agent-pane/backend/src/repoburg/action-mapping.ts +0 -216
- package/agent-pane/backend/src/repoburg/agent-runtime-client.test.ts +0 -271
- package/agent-pane/backend/src/repoburg/agent-runtime-client.ts +0 -262
- package/agent-pane/backend/src/repoburg/backend-resolver.test.ts +0 -271
- package/agent-pane/backend/src/repoburg/backend-resolver.ts +0 -246
- package/agent-pane/backend/src/repoburg/repoburg-client.test.ts +0 -159
- package/agent-pane/backend/src/repoburg/repoburg-client.ts +0 -181
- package/agent-pane/backend/src/repoburg/repoburg-provider.test.ts +0 -723
- package/agent-pane/backend/src/repoburg/repoburg-provider.ts +0 -422
- package/agent-pane/backend/src/repoburg/turn-projector.test.ts +0 -475
- package/agent-pane/backend/src/repoburg/turn-projector.ts +0 -537
- package/agent-pane/backend/src/routes/files.ts +0 -31
- package/agent-pane/backend/src/routes/mcp.ts +0 -33
- package/agent-pane/backend/src/routes/models.test.ts +0 -92
- package/agent-pane/backend/src/routes/models.ts +0 -16
- package/agent-pane/backend/src/routes/plugins.ts +0 -40
- package/agent-pane/backend/src/routes/providers.test.ts +0 -86
- package/agent-pane/backend/src/routes/providers.ts +0 -86
- package/agent-pane/backend/src/routes/sessions.test.ts +0 -558
- package/agent-pane/backend/src/routes/sessions.ts +0 -504
- package/agent-pane/backend/src/routes/skills.test.ts +0 -114
- package/agent-pane/backend/src/routes/skills.ts +0 -70
- package/agent-pane/backend/src/routes/threads.ts +0 -323
- package/agent-pane/backend/src/routes/turns.test.ts +0 -196
- package/agent-pane/backend/src/routes/turns.ts +0 -103
- package/agent-pane/backend/src/routes/workspaces.test.ts +0 -197
- package/agent-pane/backend/src/routes/workspaces.ts +0 -128
- package/agent-pane/backend/src/ws/index.test.ts +0 -107
- package/agent-pane/backend/src/ws/index.ts +0 -51
- package/agent-pane/backend/tsconfig.json +0 -25
- package/agent-pane/backend/vitest.config.ts +0 -20
- package/agent-pane/eslint.config.js +0 -33
- package/agent-pane/frontend/coverage/base.css +0 -224
- package/agent-pane/frontend/coverage/block-navigation.js +0 -87
- package/agent-pane/frontend/coverage/clover.xml +0 -2962
- package/agent-pane/frontend/coverage/coverage-final.json +0 -37
- package/agent-pane/frontend/coverage/favicon.png +0 -0
- package/agent-pane/frontend/coverage/index.html +0 -251
- package/agent-pane/frontend/coverage/prettify.css +0 -1
- package/agent-pane/frontend/coverage/prettify.js +0 -2
- package/agent-pane/frontend/coverage/sort-arrow-sprite.png +0 -0
- package/agent-pane/frontend/coverage/sorter.js +0 -210
- package/agent-pane/frontend/coverage/src/App.tsx.html +0 -217
- package/agent-pane/frontend/coverage/src/AppInitializer.tsx.html +0 -223
- package/agent-pane/frontend/coverage/src/api/client.ts.html +0 -187
- package/agent-pane/frontend/coverage/src/api/index.html +0 -161
- package/agent-pane/frontend/coverage/src/api/sessions.ts.html +0 -316
- package/agent-pane/frontend/coverage/src/api/websocket.ts.html +0 -544
- package/agent-pane/frontend/coverage/src/api/workspaces.ts.html +0 -199
- package/agent-pane/frontend/coverage/src/components/CollapsibleToolCalls.tsx.html +0 -226
- package/agent-pane/frontend/coverage/src/components/CommandInputBar.tsx.html +0 -382
- package/agent-pane/frontend/coverage/src/components/CommandPalette.tsx.html +0 -715
- package/agent-pane/frontend/coverage/src/components/IdeWorkspace.tsx.html +0 -160
- package/agent-pane/frontend/coverage/src/components/ModelSelector.tsx.html +0 -478
- package/agent-pane/frontend/coverage/src/components/NewSessionDialog.tsx.html +0 -472
- package/agent-pane/frontend/coverage/src/components/RenderArea.tsx.html +0 -574
- package/agent-pane/frontend/coverage/src/components/RightPanel.tsx.html +0 -205
- package/agent-pane/frontend/coverage/src/components/RuntimeIcon.tsx.html +0 -133
- package/agent-pane/frontend/coverage/src/components/SessionTabs.tsx.html +0 -217
- package/agent-pane/frontend/coverage/src/components/StatusBar.tsx.html +0 -271
- package/agent-pane/frontend/coverage/src/components/StatusDot.tsx.html +0 -109
- package/agent-pane/frontend/coverage/src/components/Toast.tsx.html +0 -313
- package/agent-pane/frontend/coverage/src/components/TurnContent.tsx.html +0 -1216
- package/agent-pane/frontend/coverage/src/components/WorkspaceSidebar.tsx.html +0 -1138
- package/agent-pane/frontend/coverage/src/components/index.html +0 -326
- package/agent-pane/frontend/coverage/src/components/panels/ChangesPanel.tsx.html +0 -247
- package/agent-pane/frontend/coverage/src/components/panels/LogsPanel.tsx.html +0 -160
- package/agent-pane/frontend/coverage/src/components/panels/MetricsPanel.tsx.html +0 -427
- package/agent-pane/frontend/coverage/src/components/panels/TurnsPanel.tsx.html +0 -397
- package/agent-pane/frontend/coverage/src/components/panels/index.html +0 -161
- package/agent-pane/frontend/coverage/src/constants/index.html +0 -116
- package/agent-pane/frontend/coverage/src/constants/models.ts.html +0 -406
- package/agent-pane/frontend/coverage/src/hooks/index.html +0 -146
- package/agent-pane/frontend/coverage/src/hooks/useEscapeKey.ts.html +0 -124
- package/agent-pane/frontend/coverage/src/hooks/useOutsideClick.ts.html +0 -142
- package/agent-pane/frontend/coverage/src/hooks/useSessionStatus.ts.html +0 -187
- package/agent-pane/frontend/coverage/src/index.html +0 -146
- package/agent-pane/frontend/coverage/src/main.tsx.html +0 -115
- package/agent-pane/frontend/coverage/src/store/index.html +0 -116
- package/agent-pane/frontend/coverage/src/store/store.ts.html +0 -2404
- package/agent-pane/frontend/coverage/src/test/component-helpers.ts.html +0 -190
- package/agent-pane/frontend/coverage/src/test/fixtures.ts.html +0 -367
- package/agent-pane/frontend/coverage/src/test/index.html +0 -131
- package/agent-pane/frontend/coverage/src/types/index.html +0 -116
- package/agent-pane/frontend/coverage/src/types/index.ts.html +0 -466
- package/agent-pane/frontend/coverage/src/utils/changes.ts.html +0 -202
- package/agent-pane/frontend/coverage/src/utils/duration.ts.html +0 -127
- package/agent-pane/frontend/coverage/src/utils/index.html +0 -131
- package/agent-pane/frontend/dist/assets/index-34WaZYsW.css +0 -1
- package/agent-pane/frontend/dist/assets/index-y7xlT86e.js +0 -362
- package/agent-pane/frontend/dist/index.html +0 -19
- package/agent-pane/frontend/index.html +0 -18
- package/agent-pane/frontend/package-lock.json +0 -4211
- package/agent-pane/frontend/package.json +0 -35
- package/agent-pane/frontend/src/App.test.tsx +0 -74
- package/agent-pane/frontend/src/App.tsx +0 -44
- package/agent-pane/frontend/src/AppInitializer.test.tsx +0 -142
- package/agent-pane/frontend/src/AppInitializer.tsx +0 -46
- package/agent-pane/frontend/src/__tests__/ThreadsPanel.test.tsx +0 -192
- package/agent-pane/frontend/src/api/client.test.ts +0 -126
- package/agent-pane/frontend/src/api/client.ts +0 -34
- package/agent-pane/frontend/src/api/models.ts +0 -7
- package/agent-pane/frontend/src/api/providers.ts +0 -17
- package/agent-pane/frontend/src/api/sessions.test.ts +0 -245
- package/agent-pane/frontend/src/api/sessions.ts +0 -97
- package/agent-pane/frontend/src/api/skills.ts +0 -12
- package/agent-pane/frontend/src/api/websocket.test.ts +0 -288
- package/agent-pane/frontend/src/api/websocket.ts +0 -238
- package/agent-pane/frontend/src/api/workspaces.test.ts +0 -112
- package/agent-pane/frontend/src/api/workspaces.ts +0 -38
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.test.tsx +0 -49
- package/agent-pane/frontend/src/components/CollapsibleToolCalls.tsx +0 -56
- package/agent-pane/frontend/src/components/CommandInputBar.test.tsx +0 -133
- package/agent-pane/frontend/src/components/CommandInputBar.tsx +0 -584
- package/agent-pane/frontend/src/components/CommandPalette.test.tsx +0 -226
- package/agent-pane/frontend/src/components/CommandPalette.tsx +0 -194
- package/agent-pane/frontend/src/components/CommentableText.test.tsx +0 -196
- package/agent-pane/frontend/src/components/CommentableText.tsx +0 -379
- package/agent-pane/frontend/src/components/IdeWorkspace.test.tsx +0 -39
- package/agent-pane/frontend/src/components/IdeWorkspace.tsx +0 -51
- package/agent-pane/frontend/src/components/ModelSelector.test.tsx +0 -129
- package/agent-pane/frontend/src/components/ModelSelector.tsx +0 -191
- package/agent-pane/frontend/src/components/NewSessionDialog.test.tsx +0 -95
- package/agent-pane/frontend/src/components/NewSessionDialog.tsx +0 -129
- package/agent-pane/frontend/src/components/RenderArea.test.tsx +0 -160
- package/agent-pane/frontend/src/components/RenderArea.tsx +0 -170
- package/agent-pane/frontend/src/components/ResizeHandle.tsx +0 -29
- package/agent-pane/frontend/src/components/RightPanel.test.tsx +0 -43
- package/agent-pane/frontend/src/components/RightPanel.tsx +0 -46
- package/agent-pane/frontend/src/components/RuntimeIcon.test.tsx +0 -32
- package/agent-pane/frontend/src/components/RuntimeIcon.tsx +0 -16
- package/agent-pane/frontend/src/components/SessionTabs.test.tsx +0 -72
- package/agent-pane/frontend/src/components/SessionTabs.tsx +0 -49
- package/agent-pane/frontend/src/components/StatusBar.test.tsx +0 -56
- package/agent-pane/frontend/src/components/StatusBar.tsx +0 -129
- package/agent-pane/frontend/src/components/StatusDot.test.tsx +0 -25
- package/agent-pane/frontend/src/components/StatusDot.tsx +0 -8
- package/agent-pane/frontend/src/components/Toast.test.tsx +0 -79
- package/agent-pane/frontend/src/components/Toast.tsx +0 -76
- package/agent-pane/frontend/src/components/TurnContent.test.tsx +0 -298
- package/agent-pane/frontend/src/components/TurnContent.tsx +0 -548
- package/agent-pane/frontend/src/components/WorkspaceSidebar.test.tsx +0 -297
- package/agent-pane/frontend/src/components/WorkspaceSidebar.tsx +0 -351
- package/agent-pane/frontend/src/components/input/OptionSubPopup.tsx +0 -32
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.test.tsx +0 -63
- package/agent-pane/frontend/src/components/input/SkillMentionPopup.tsx +0 -78
- package/agent-pane/frontend/src/components/input/SlashPopup.test.tsx +0 -96
- package/agent-pane/frontend/src/components/input/SlashPopup.tsx +0 -82
- package/agent-pane/frontend/src/components/panels/ChangesPanel.test.tsx +0 -61
- package/agent-pane/frontend/src/components/panels/ChangesPanel.tsx +0 -54
- package/agent-pane/frontend/src/components/panels/TasksPanel.test.tsx +0 -97
- package/agent-pane/frontend/src/components/panels/TasksPanel.tsx +0 -208
- package/agent-pane/frontend/src/components/panels/ThreadsPanel.tsx +0 -382
- package/agent-pane/frontend/src/components/panels/TurnsPanel.test.tsx +0 -83
- package/agent-pane/frontend/src/components/panels/TurnsPanel.tsx +0 -126
- package/agent-pane/frontend/src/constants/models.test.ts +0 -97
- package/agent-pane/frontend/src/constants/models.ts +0 -166
- package/agent-pane/frontend/src/hooks/useEscapeKey.test.ts +0 -42
- package/agent-pane/frontend/src/hooks/useEscapeKey.ts +0 -13
- package/agent-pane/frontend/src/hooks/useOutsideClick.test.ts +0 -92
- package/agent-pane/frontend/src/hooks/useOutsideClick.ts +0 -19
- package/agent-pane/frontend/src/hooks/useProvider.ts +0 -44
- package/agent-pane/frontend/src/hooks/useResizable.test.ts +0 -97
- package/agent-pane/frontend/src/hooks/useResizable.ts +0 -75
- package/agent-pane/frontend/src/hooks/useSessionStatus.test.ts +0 -116
- package/agent-pane/frontend/src/hooks/useSessionStatus.ts +0 -34
- package/agent-pane/frontend/src/main.test.tsx +0 -37
- package/agent-pane/frontend/src/main.tsx +0 -10
- package/agent-pane/frontend/src/store/sessionSlice.ts +0 -440
- package/agent-pane/frontend/src/store/store.test.ts +0 -1319
- package/agent-pane/frontend/src/store/store.ts +0 -37
- package/agent-pane/frontend/src/store/threadSlice.ts +0 -136
- package/agent-pane/frontend/src/store/uiSlice.ts +0 -133
- package/agent-pane/frontend/src/store/workspaceSlice.ts +0 -77
- package/agent-pane/frontend/src/store/wsSlice.ts +0 -361
- package/agent-pane/frontend/src/styles/app.css +0 -611
- package/agent-pane/frontend/src/styles/tokens.css +0 -62
- package/agent-pane/frontend/src/test/component-helpers.ts +0 -38
- package/agent-pane/frontend/src/test/fixtures.ts +0 -100
- package/agent-pane/frontend/src/test-setup.ts +0 -5
- package/agent-pane/frontend/src/types/index.test.ts +0 -128
- package/agent-pane/frontend/src/types/index.ts +0 -132
- package/agent-pane/frontend/src/utils/changes.test.ts +0 -81
- package/agent-pane/frontend/src/utils/changes.ts +0 -39
- package/agent-pane/frontend/src/utils/duration.test.ts +0 -75
- package/agent-pane/frontend/src/utils/duration.ts +0 -14
- package/agent-pane/frontend/tsconfig.json +0 -25
- package/agent-pane/frontend/vite.config.ts +0 -22
- package/agent-pane/frontend/vitest.config.ts +0 -29
- package/agent-pane/package-lock.json +0 -1527
- package/agent-pane/package.json +0 -19
- package/agent-pane/shared/provider-types.ts +0 -67
- package/agent-pane/shared/types.ts +0 -167
|
@@ -1,455 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
|
|
2
|
-
|
|
3
|
-
// Mock the SDK query function
|
|
4
|
-
vi.mock('@anthropic-ai/claude-agent-sdk', () => ({
|
|
5
|
-
query: vi.fn(),
|
|
6
|
-
}));
|
|
7
|
-
|
|
8
|
-
import { query } from '@anthropic-ai/claude-agent-sdk';
|
|
9
|
-
|
|
10
|
-
// Capture broadcasts without touching a real WebSocket server.
|
|
11
|
-
const captured: Array<{ event: string; data: unknown }> = [];
|
|
12
|
-
vi.mock('../ws/index.ts', async (importOriginal) => {
|
|
13
|
-
const actual = (await importOriginal()) as Record<string, unknown>;
|
|
14
|
-
return {
|
|
15
|
-
...actual,
|
|
16
|
-
broadcast: vi.fn((event: string, data: unknown) => {
|
|
17
|
-
captured.push({ event, data });
|
|
18
|
-
}),
|
|
19
|
-
};
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
// Import after mocks are set up
|
|
23
|
-
import { claudeProvider, clearAllThreads, handleResultMessage, handleMessage } from './claude-provider.ts';
|
|
24
|
-
import { initDb } from '../db/index.ts';
|
|
25
|
-
import type Database from 'better-sqlite3';
|
|
26
|
-
import type { ClaudeSessionEntry } from './claude-types.ts';
|
|
27
|
-
|
|
28
|
-
describe('claudeProvider', () => {
|
|
29
|
-
beforeEach(() => {
|
|
30
|
-
vi.clearAllMocks();
|
|
31
|
-
clearAllThreads();
|
|
32
|
-
captured.length = 0;
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
it('implements all RuntimeProvider methods', () => {
|
|
36
|
-
expect(claudeProvider.startTurn).toBeTypeOf('function');
|
|
37
|
-
expect(claudeProvider.interruptTurn).toBeTypeOf('function');
|
|
38
|
-
expect(claudeProvider.clearThread).toBeTypeOf('function');
|
|
39
|
-
expect(claudeProvider.clearAllThreads).toBeTypeOf('function');
|
|
40
|
-
expect(claudeProvider.getModels).toBeTypeOf('function');
|
|
41
|
-
expect(claudeProvider.shutdown).toBeTypeOf('function');
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
it('getModels returns an array', async () => {
|
|
45
|
-
const mockQuery = {
|
|
46
|
-
initializationResult: vi.fn().mockResolvedValue({ models: [] }),
|
|
47
|
-
close: vi.fn(),
|
|
48
|
-
[Symbol.asyncIterator]: async function* () {},
|
|
49
|
-
};
|
|
50
|
-
vi.mocked(query).mockReturnValue(mockQuery as never);
|
|
51
|
-
|
|
52
|
-
const models = await claudeProvider.getModels();
|
|
53
|
-
expect(Array.isArray(models)).toBe(true);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('getModels returns empty array on error', async () => {
|
|
57
|
-
vi.mocked(query).mockImplementation(() => {
|
|
58
|
-
throw new Error('SDK not available');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const models = await claudeProvider.getModels();
|
|
62
|
-
expect(models).toEqual([]);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
it('clearThread does not throw for unknown session', () => {
|
|
66
|
-
expect(() => claudeProvider.clearThread('unknown-id')).not.toThrow();
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('clearAllThreads does not throw when empty', () => {
|
|
70
|
-
expect(() => clearAllThreads()).not.toThrow();
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
it('interruptTurn returns false for unknown session', async () => {
|
|
74
|
-
const result = await claudeProvider.interruptTurn('unknown-id');
|
|
75
|
-
expect(result).toBe(false);
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
it('shutdown does not throw', async () => {
|
|
79
|
-
await expect(claudeProvider.shutdown()).resolves.not.toThrow();
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
/** Build a mock ClaudeSessionEntry whose query.getContextUsage() returns the given snapshot. */
|
|
84
|
-
function makeEntry(getContextUsage: ReturnType<typeof vi.fn>): ClaudeSessionEntry {
|
|
85
|
-
return {
|
|
86
|
-
query: {
|
|
87
|
-
getContextUsage,
|
|
88
|
-
interrupt: vi.fn(),
|
|
89
|
-
setModel: vi.fn(),
|
|
90
|
-
close: vi.fn(),
|
|
91
|
-
stopTask: vi.fn(),
|
|
92
|
-
initializationResult: vi.fn(),
|
|
93
|
-
[Symbol.asyncIterator]: async function* () {},
|
|
94
|
-
} as never,
|
|
95
|
-
sessionId: 'cs_test',
|
|
96
|
-
turnId: null,
|
|
97
|
-
cwd: '/test',
|
|
98
|
-
promptQueue: { push: vi.fn(), close: vi.fn() } as never,
|
|
99
|
-
messageLoop: null,
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/** Build a result/success SDK message with the given (accumulated) token usage. */
|
|
104
|
-
function makeResultMessage(usage: {
|
|
105
|
-
input_tokens: number;
|
|
106
|
-
cache_read_input_tokens: number;
|
|
107
|
-
cache_creation_input_tokens: number;
|
|
108
|
-
output_tokens: number;
|
|
109
|
-
}): unknown {
|
|
110
|
-
return {
|
|
111
|
-
type: 'result',
|
|
112
|
-
subtype: 'success',
|
|
113
|
-
usage,
|
|
114
|
-
modelUsage: {},
|
|
115
|
-
result: 'done',
|
|
116
|
-
is_error: false,
|
|
117
|
-
num_turns: 1,
|
|
118
|
-
stop_reason: 'end_turn',
|
|
119
|
-
duration_ms: 100,
|
|
120
|
-
duration_api_ms: 100,
|
|
121
|
-
total_cost_usd: 0,
|
|
122
|
-
permission_denials: [],
|
|
123
|
-
uuid: 'u1',
|
|
124
|
-
session_id: 'cs_test',
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
describe('handleResultMessage — context-window usage', () => {
|
|
129
|
-
let db: Database.Database;
|
|
130
|
-
|
|
131
|
-
beforeEach(() => {
|
|
132
|
-
db = initDb(':memory:');
|
|
133
|
-
// Session with a non-null title so syncThreadTitle short-circuits (no title query).
|
|
134
|
-
db.prepare(
|
|
135
|
-
`INSERT INTO sessions (id, title, runtime_type, status, is_running, lifecycle, created_at, updated_at)
|
|
136
|
-
VALUES ('s1', 'Test', 'claude', 'running', 1, 'working', ?, ?)`,
|
|
137
|
-
).run(new Date().toISOString(), new Date().toISOString());
|
|
138
|
-
db.prepare(
|
|
139
|
-
`INSERT INTO turns (id, session_id, user_prompt, status, created_at, updated_at)
|
|
140
|
-
VALUES ('t1', 's1', 'hi', 'running', ?, ?)`,
|
|
141
|
-
).run(new Date().toISOString(), new Date().toISOString());
|
|
142
|
-
captured.length = 0;
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
afterEach(() => {
|
|
146
|
-
db.close();
|
|
147
|
-
});
|
|
148
|
-
|
|
149
|
-
it('uses SDK getContextUsage() real fill, NOT the accumulated result.usage sum', async () => {
|
|
150
|
-
// Old buggy behavior: result.usage sums to 800K (accumulated). getContextUsage reports the real 130K.
|
|
151
|
-
const getContextUsage = vi.fn().mockResolvedValue({
|
|
152
|
-
totalTokens: 130000,
|
|
153
|
-
maxTokens: 1000000,
|
|
154
|
-
rawMaxTokens: 1000000,
|
|
155
|
-
percentage: 13,
|
|
156
|
-
categories: [],
|
|
157
|
-
gridRows: [],
|
|
158
|
-
model: 'claude-sonnet',
|
|
159
|
-
memoryFiles: [],
|
|
160
|
-
mcpTools: [],
|
|
161
|
-
});
|
|
162
|
-
const entry = makeEntry(getContextUsage);
|
|
163
|
-
|
|
164
|
-
await handleResultMessage(
|
|
165
|
-
makeResultMessage({
|
|
166
|
-
input_tokens: 300000,
|
|
167
|
-
cache_read_input_tokens: 400000,
|
|
168
|
-
cache_creation_input_tokens: 100000, // sum = 800K (the wrong accumulated value)
|
|
169
|
-
output_tokens: 500,
|
|
170
|
-
}) as never,
|
|
171
|
-
's1',
|
|
172
|
-
't1',
|
|
173
|
-
entry,
|
|
174
|
-
db,
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
// turn:contextUsage must carry the SDK's real fill (130K), not the 800K sum.
|
|
178
|
-
const ctx = captured.find((b) => b.event === 'turn:contextUsage');
|
|
179
|
-
expect(ctx).toBeDefined();
|
|
180
|
-
expect((ctx!.data as { totalTokens: number }).totalTokens).toBe(130000);
|
|
181
|
-
expect((ctx!.data as { contextWindow: number }).contextWindow).toBe(1000000);
|
|
182
|
-
expect((ctx!.data as { percentage: number }).percentage).toBe(13);
|
|
183
|
-
|
|
184
|
-
// Persisted to the session row so the counter survives reload.
|
|
185
|
-
const row = db.prepare('SELECT context_usage FROM sessions WHERE id = ?').get('s1') as
|
|
186
|
-
| { context_usage: string | null }
|
|
187
|
-
| undefined;
|
|
188
|
-
expect(row?.context_usage).toBeTruthy();
|
|
189
|
-
expect(JSON.parse(row!.context_usage!).totalTokens).toBe(130000);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('does not broadcast a bad value when getContextUsage() rejects', async () => {
|
|
193
|
-
const getContextUsage = vi.fn().mockRejectedValue(new Error('not available'));
|
|
194
|
-
const entry = makeEntry(getContextUsage);
|
|
195
|
-
|
|
196
|
-
await handleResultMessage(
|
|
197
|
-
makeResultMessage({
|
|
198
|
-
input_tokens: 100,
|
|
199
|
-
cache_read_input_tokens: 0,
|
|
200
|
-
cache_creation_input_tokens: 0,
|
|
201
|
-
output_tokens: 10,
|
|
202
|
-
}) as never,
|
|
203
|
-
's1',
|
|
204
|
-
't1',
|
|
205
|
-
entry,
|
|
206
|
-
db,
|
|
207
|
-
);
|
|
208
|
-
|
|
209
|
-
expect(captured.find((b) => b.event === 'turn:contextUsage')).toBeUndefined();
|
|
210
|
-
// The turn still completes normally.
|
|
211
|
-
expect(captured.find((b) => b.event === 'turn:completed')).toBeDefined();
|
|
212
|
-
});
|
|
213
|
-
});
|
|
214
|
-
|
|
215
|
-
describe('handleMessage — system/init must not corrupt main session for thread entries', () => {
|
|
216
|
-
let db: Database.Database;
|
|
217
|
-
|
|
218
|
-
beforeEach(() => {
|
|
219
|
-
db = initDb(':memory:');
|
|
220
|
-
// Main session whose Claude session id is 'main-session-1'.
|
|
221
|
-
db.prepare(
|
|
222
|
-
`INSERT INTO sessions (id, title, runtime_type, status, is_running, lifecycle, external_thread_id, created_at, updated_at)
|
|
223
|
-
VALUES ('s1', 'Test', 'claude', 'active', 0, 'working', 'main-session-1', ?, ?)`,
|
|
224
|
-
).run(new Date().toISOString(), new Date().toISOString());
|
|
225
|
-
captured.length = 0;
|
|
226
|
-
});
|
|
227
|
-
|
|
228
|
-
afterEach(() => {
|
|
229
|
-
db.close();
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
/** Build a minimal entry for init-handler tests (getContextUsage unused). */
|
|
233
|
-
function makeInitEntry(): ClaudeSessionEntry {
|
|
234
|
-
return makeEntry(vi.fn());
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
/** Build a system/init SDK message with the given Claude session id. */
|
|
238
|
-
function makeInitMessage(claudeSessionId: string): unknown {
|
|
239
|
-
return { type: 'system', subtype: 'init', session_id: claudeSessionId };
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
it('thread entry: sets entry.sessionId but does NOT overwrite the main session external_thread_id', async () => {
|
|
243
|
-
// Regression: the system/init handler previously wrote the forked session's
|
|
244
|
-
// id into the MAIN session's external_thread_id for ALL entries, because
|
|
245
|
-
// handleMessage is always called with the main session id and entry.threadId
|
|
246
|
-
// was never populated. After a restart/rewind the main session would resume
|
|
247
|
-
// the fork and "remember" the thread's discussion.
|
|
248
|
-
const entry = makeInitEntry();
|
|
249
|
-
entry.threadId = 'thread-1';
|
|
250
|
-
|
|
251
|
-
await handleMessage(
|
|
252
|
-
makeInitMessage('fork-session-9') as never,
|
|
253
|
-
's1', // main session id — passed to handleMessage for ALL entries
|
|
254
|
-
't1',
|
|
255
|
-
entry,
|
|
256
|
-
db,
|
|
257
|
-
);
|
|
258
|
-
|
|
259
|
-
// entry.sessionId is captured (needed for Monitor output-path construction).
|
|
260
|
-
expect(entry.sessionId).toBe('fork-session-9');
|
|
261
|
-
// The main session's resume id is NOT corrupted with the fork's id.
|
|
262
|
-
const row = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as
|
|
263
|
-
| { external_thread_id: string | null }
|
|
264
|
-
| undefined;
|
|
265
|
-
expect(row?.external_thread_id).toBe('main-session-1');
|
|
266
|
-
});
|
|
267
|
-
|
|
268
|
-
it('main entry: still persists external_thread_id (preserves existing behavior)', async () => {
|
|
269
|
-
const entry = makeInitEntry();
|
|
270
|
-
entry.threadId = null; // main session entry (not a thread/fork)
|
|
271
|
-
|
|
272
|
-
await handleMessage(
|
|
273
|
-
makeInitMessage('fork-session-9') as never,
|
|
274
|
-
's1',
|
|
275
|
-
't1',
|
|
276
|
-
entry,
|
|
277
|
-
db,
|
|
278
|
-
);
|
|
279
|
-
|
|
280
|
-
expect(entry.sessionId).toBe('fork-session-9');
|
|
281
|
-
const row = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as
|
|
282
|
-
| { external_thread_id: string | null }
|
|
283
|
-
| undefined;
|
|
284
|
-
expect(row?.external_thread_id).toBe('fork-session-9');
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
// ---------------------------------------------------------------------------
|
|
289
|
-
// startTurn — thread fork isolation (BUG 1 + BUG 2 regression tests)
|
|
290
|
-
// ---------------------------------------------------------------------------
|
|
291
|
-
|
|
292
|
-
/** Build a mock `Query` whose async iterator yields the given SDK messages in
|
|
293
|
-
* order, then ends. getContextUsage resolves an empty snapshot (0/0) so the
|
|
294
|
-
* result/success handler completes the turn without emitting contextUsage. */
|
|
295
|
-
function createClaudeQueryMock(messages: unknown[]): unknown {
|
|
296
|
-
return {
|
|
297
|
-
getContextUsage: vi.fn().mockResolvedValue({
|
|
298
|
-
totalTokens: 0, maxTokens: 0, rawMaxTokens: 0, percentage: 0,
|
|
299
|
-
categories: [], gridRows: [], model: '', memoryFiles: [], mcpTools: [],
|
|
300
|
-
}),
|
|
301
|
-
interrupt: vi.fn(),
|
|
302
|
-
setModel: vi.fn(),
|
|
303
|
-
close: vi.fn(),
|
|
304
|
-
stopTask: vi.fn(),
|
|
305
|
-
initializationResult: vi.fn(),
|
|
306
|
-
[Symbol.asyncIterator]: async function* () {
|
|
307
|
-
for (const m of messages) yield m;
|
|
308
|
-
},
|
|
309
|
-
};
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/** A `system/init` SDK message carrying the given Claude session id. */
|
|
313
|
-
function initMsg(claudeSessionId: string): unknown {
|
|
314
|
-
return { type: 'system', subtype: 'init', session_id: claudeSessionId };
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/** A `result/success` SDK message that completes a turn. */
|
|
318
|
-
function resultSuccessMsg(claudeSessionId: string): unknown {
|
|
319
|
-
return {
|
|
320
|
-
type: 'result', subtype: 'success',
|
|
321
|
-
usage: { input_tokens: 10, cache_read_input_tokens: 0, cache_creation_input_tokens: 0, output_tokens: 5 },
|
|
322
|
-
modelUsage: {}, result: 'done', is_error: false, num_turns: 1,
|
|
323
|
-
stop_reason: 'end_turn', duration_ms: 1, duration_api_ms: 1, total_cost_usd: 0,
|
|
324
|
-
permission_denials: [], uuid: 'u1', session_id: claudeSessionId,
|
|
325
|
-
};
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
/** Poll the DB until the given turn reaches the expected status. */
|
|
329
|
-
async function waitForTurnStatus(db: Database.Database, turnId: string, status: string, timeoutMs = 2000): Promise<void> {
|
|
330
|
-
const start = Date.now();
|
|
331
|
-
while (Date.now() - start < timeoutMs) {
|
|
332
|
-
const row = db.prepare('SELECT status FROM turns WHERE id = ?').get(turnId) as { status: string } | undefined;
|
|
333
|
-
if (row?.status === status) return;
|
|
334
|
-
await new Promise((r) => setTimeout(r, 10));
|
|
335
|
-
}
|
|
336
|
-
throw new Error(`turn ${turnId} did not reach status '${status}' within ${timeoutMs}ms`);
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
describe('startTurn — thread fork isolation', () => {
|
|
340
|
-
let db: Database.Database;
|
|
341
|
-
|
|
342
|
-
beforeEach(() => {
|
|
343
|
-
vi.clearAllMocks();
|
|
344
|
-
clearAllThreads();
|
|
345
|
-
captured.length = 0;
|
|
346
|
-
db = initDb(':memory:');
|
|
347
|
-
// Main Claude session with a known resume id. Title set so syncThreadTitle
|
|
348
|
-
// short-circuits (no title-generation query).
|
|
349
|
-
db.prepare(
|
|
350
|
-
`INSERT INTO sessions (id, title, runtime_type, status, is_running, lifecycle, external_thread_id, created_at, updated_at)
|
|
351
|
-
VALUES ('s1', 'Test', 'claude', 'active', 0, 'working', 'main-1', ?, ?)`,
|
|
352
|
-
).run(new Date().toISOString(), new Date().toISOString());
|
|
353
|
-
});
|
|
354
|
-
|
|
355
|
-
afterEach(() => {
|
|
356
|
-
clearAllThreads();
|
|
357
|
-
db.close();
|
|
358
|
-
});
|
|
359
|
-
|
|
360
|
-
it('main session resumes from its own persisted external_thread_id', async () => {
|
|
361
|
-
// Seed a MAIN turn (no thread_id).
|
|
362
|
-
const now = new Date().toISOString();
|
|
363
|
-
db.prepare(
|
|
364
|
-
`INSERT INTO turns (id, session_id, user_prompt, status, created_at, updated_at)
|
|
365
|
-
VALUES ('t1', 's1', 'hi', 'pending', ?, ?)`,
|
|
366
|
-
).run(now, now);
|
|
367
|
-
|
|
368
|
-
vi.mocked(query).mockReturnValue(createClaudeQueryMock([initMsg('main-1'), resultSuccessMsg('main-1')]) as never);
|
|
369
|
-
|
|
370
|
-
const session = db.prepare('SELECT * FROM sessions WHERE id = ?').get('s1') as never;
|
|
371
|
-
const turn = db.prepare('SELECT * FROM turns WHERE id = ?').get('t1') as never;
|
|
372
|
-
await claudeProvider.startTurn(session, turn);
|
|
373
|
-
|
|
374
|
-
await waitForTurnStatus(db, 't1', 'completed');
|
|
375
|
-
|
|
376
|
-
// The main session's query was started with resume = its persisted external_thread_id.
|
|
377
|
-
const opts = (vi.mocked(query).mock.calls[0][0] as { options: { resume?: string } }).options;
|
|
378
|
-
expect(opts.resume).toBe('main-1');
|
|
379
|
-
});
|
|
380
|
-
|
|
381
|
-
it('thread turn resumes from its OWN fork id and does NOT corrupt the main session (BUG 1 + BUG 2)', async () => {
|
|
382
|
-
const now = new Date().toISOString();
|
|
383
|
-
// Anchor turn + a discussion thread forked to 'fork-9'.
|
|
384
|
-
db.prepare(
|
|
385
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, status, created_at, updated_at)
|
|
386
|
-
VALUES ('t1', 's1', 'hi', 'resp', 'completed', ?, ?)`,
|
|
387
|
-
).run(now, now);
|
|
388
|
-
db.prepare(
|
|
389
|
-
`INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, external_thread_id, status, created_at, updated_at)
|
|
390
|
-
VALUES ('th1', 's1', 'i1', 't1', 0, 4, 'resp', 'fork-9', 'open', ?, ?)`,
|
|
391
|
-
).run(now, now);
|
|
392
|
-
// Thread turn.
|
|
393
|
-
db.prepare(
|
|
394
|
-
`INSERT INTO turns (id, session_id, user_prompt, status, thread_id, created_at, updated_at)
|
|
395
|
-
VALUES ('tt1', 's1', 'discuss this', 'pending', 'th1', ?, ?)`,
|
|
396
|
-
).run(now, now);
|
|
397
|
-
|
|
398
|
-
// The forked query emits init with the FORK's session id, then completes.
|
|
399
|
-
vi.mocked(query).mockReturnValue(createClaudeQueryMock([initMsg('fork-9'), resultSuccessMsg('fork-9')]) as never);
|
|
400
|
-
|
|
401
|
-
const session = db.prepare('SELECT * FROM sessions WHERE id = ?').get('s1') as never;
|
|
402
|
-
const turn = db.prepare('SELECT * FROM turns WHERE id = ?').get('tt1') as never;
|
|
403
|
-
await claudeProvider.startTurn(session, turn);
|
|
404
|
-
|
|
405
|
-
await waitForTurnStatus(db, 'tt1', 'completed');
|
|
406
|
-
|
|
407
|
-
// BUG 2: the thread resumed its OWN fork ('fork-9'), not the main session.
|
|
408
|
-
const opts = (vi.mocked(query).mock.calls[0][0] as { options: { resume?: string } }).options;
|
|
409
|
-
expect(opts.resume).toBe('fork-9');
|
|
410
|
-
|
|
411
|
-
// BUG 1: the main session's external_thread_id was NOT overwritten with the
|
|
412
|
-
// fork's id (the system/init handler skipped the DB write for thread entries).
|
|
413
|
-
const row = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as
|
|
414
|
-
| { external_thread_id: string | null }
|
|
415
|
-
| undefined;
|
|
416
|
-
expect(row?.external_thread_id).toBe('main-1');
|
|
417
|
-
});
|
|
418
|
-
|
|
419
|
-
it('thread turn with a FAILED fork starts a fresh isolated session (resume undefined), never the main session (BUG 2)', async () => {
|
|
420
|
-
const now = new Date().toISOString();
|
|
421
|
-
db.prepare(
|
|
422
|
-
`INSERT INTO turns (id, session_id, user_prompt, agent_response, status, created_at, updated_at)
|
|
423
|
-
VALUES ('t1', 's1', 'hi', 'resp', 'completed', ?, ?)`,
|
|
424
|
-
).run(now, now);
|
|
425
|
-
// Thread with NO external_thread_id (fork failed / not created).
|
|
426
|
-
db.prepare(
|
|
427
|
-
`INSERT INTO discussion_threads (id, session_id, item_id, turn_id, start_offset, end_offset, selected_text, status, created_at, updated_at)
|
|
428
|
-
VALUES ('th1', 's1', 'i1', 't1', 0, 4, 'resp', 'open', ?, ?)`,
|
|
429
|
-
).run(now, now);
|
|
430
|
-
db.prepare(
|
|
431
|
-
`INSERT INTO turns (id, session_id, user_prompt, status, thread_id, created_at, updated_at)
|
|
432
|
-
VALUES ('tt1', 's1', 'discuss this', 'pending', 'th1', ?, ?)`,
|
|
433
|
-
).run(now, now);
|
|
434
|
-
|
|
435
|
-
// Fresh session emits its own init id, then completes.
|
|
436
|
-
vi.mocked(query).mockReturnValue(createClaudeQueryMock([initMsg('fresh-1'), resultSuccessMsg('fresh-1')]) as never);
|
|
437
|
-
|
|
438
|
-
const session = db.prepare('SELECT * FROM sessions WHERE id = ?').get('s1') as never;
|
|
439
|
-
const turn = db.prepare('SELECT * FROM turns WHERE id = ?').get('tt1') as never;
|
|
440
|
-
await claudeProvider.startTurn(session, turn);
|
|
441
|
-
|
|
442
|
-
await waitForTurnStatus(db, 'tt1', 'completed');
|
|
443
|
-
|
|
444
|
-
// The thread started a FRESH session: no `resume` option (must NOT fall back
|
|
445
|
-
// to the main session's 'main-1').
|
|
446
|
-
const opts = (vi.mocked(query).mock.calls[0][0] as { options: { resume?: string } }).options;
|
|
447
|
-
expect(opts.resume).toBeUndefined();
|
|
448
|
-
|
|
449
|
-
// The main session is untouched.
|
|
450
|
-
const row = db.prepare('SELECT external_thread_id FROM sessions WHERE id = ?').get('s1') as
|
|
451
|
-
| { external_thread_id: string | null }
|
|
452
|
-
| undefined;
|
|
453
|
-
expect(row?.external_thread_id).toBe('main-1');
|
|
454
|
-
});
|
|
455
|
-
});
|