2269
2270
async disposeSession(session: URI): Promise<void> {
2272
>
await this._sessionSequencer.queue(sessionId, async () => {
2273
>
// Resolve the workspace-less scratch dir (if any) before deleting, so we
2274
>
// can reap it afterwards. A provisional workspace-less chat carries its state
2275
>
// in memory; a materialized/restored one persists `workspaceless` metadata.
2276
>
const provisional = this._provisionalSessions.get(sessionId);
2277
>
const isWorkspaceless = provisional
2278
? provisional.workspaceless === true
2279
: (await this._readSessionMetadata(session).catch(() => undefined))?.workspaceless === true;
2280
>
// Remove the session from the SDK's on-disk store first so it doesn't reappear in `listSessions()` after a
copilotAgent.ts
2281
>
// restart, and so that any final persist triggered by in-memory teardown can't recreate it. Provisional
2282
>
// sessions were never persisted, so there is nothing to delete on the SDK side.
2283
>
if (!this._provisionalSessions.has(sessionId)) {
2284
const client = await this._ensureClient();
2285
await client.deleteSession(sessionId);