Sessions: account a restored Session to its Workspace

Ensure() only registered a Workspace when the Session was new, so Sessions restored from disk never entered the Workspace record and stayed invisible in the panel. Always create (idempotent) and attach an unaccounted Session; warn on attach failure. Tests gain a shared Workspace fixture.
This commit is contained in:
2026-11-02 04:28:26 +08:00
parent 3bee231da6
commit d527ad8045
4 changed files with 40 additions and 7 deletions
+2 -1
View File
@@ -13,6 +13,7 @@ import { promptParts } from '../src/app/prompts.ts'
import { RESOURCES } from '../src/app/resources.ts'
import { TICKET_STATES } from '../src/app/cards.ts'
import { Runtime } from '../src/app/runtime.ts'
import { workspaceRegistry } from './fixtures/host.ts'
import { workerSessionId } from '../src/executor/dsh.ts'
import { Store } from '../src/app/store.ts'
import { Commands } from '../src/infra/commands.ts'
@@ -131,7 +132,7 @@ async function start() {
const ctx = new Context()
const history = { read: async () => ({ events: [] }), [Symbol.asyncDispose]: async () => {} }
const services = { agents, llm: { resolveCallConfig: async (value: unknown) => value },
workspaceRegistry: { create: async (cwd: string) => ({ id: cwd }) },
workspaceRegistry: workspaceRegistry().service,
sessionController: { create, resolveAgent, selectModel: async () => {}, rename: async () => {}, inspect: async () => ({ events: [] }) },
sessionPersistence: { flush: async () => {}, open: async () => history }, permissionPresets: { set: () => {} }, subprocess,
webServer: { host: '127.0.0.1', port: 3082, register: () => () => {} } }