1551
*/
1552
private async _buildProvisionalChat(session: URI, chat: URI, entry: ClaudeSessionEntry): Promise<ClaudeAgentSession> {
1554
>
if (!info) {
1555
throw new Error(`[Claude] no backing chat for chat ${chat.toString()}`);
1556
}
1557
>
const parentSession = await this._resolveParentSession(session, AgentSession.id(session));
claudeAgent.ts
1558
>
let overlay: IClaudeSessionOverlay = {};
1559
>
try {
1560
>
overlay = await this._metadataStore.read(chat);
1561
>
} catch (err) {
1562
this._logService.warn(`[Claude] chat overlay read failed for ${chat.toString()}; continuing with defaults`, err);
1563
}
1564
>
const permissionMode = readClaudePermissionMode(this._configurationService, chat) ?? overlay.permissionMode ?? parentSession.permissionMode;
claudeAgent.ts
1565
>
// Overlay takes precedence over the backing: `changeModel` always writes
1566
>
// the overlay first (via `setModel` or `_metadataStore.write`) and then
1567
>
// the backing. If the backing update is lost, the overlay already holds
1568
>
// the newest model; preferring it here ensures a model change is never
1569
>
// silently reverted after a restart.
1570
>
const model = overlay.model ?? info.model;
1571
>
const chatSession = ClaudeAgentSession.createProvisional(
1572
>
info.sdkSessionId,
1573
>
session,
1574
>
chat,
1575
>
parentSession.workingDirectory,
1576
>
parentSession.project,
1577
>
model,
1578
>
overlay.agent ?? parentSession.agent,
1579
>
undefined,
1580
>
new PendingRequestRegistry<CallToolResult>(),
1581
>
permissionMode,
1582
>
this._metadataStore,
1583
>
this._instantiationService,
1584
>
);
1585
>
entry.registerPeerChat(chat.toString(), this._wireEntry(chatSession));
1586
>
return chatSession;
1587
>
}
1588
1589
/**