1929
agentSession = this._createAgentSession(launchPlan, customizationDirectory, activeClient);
1930
await agentSession.initializeSession();
1931
>
this._registerInitializedSession(sessionId, agentSession);
copilotAgent.ts
1932
} catch (error) {
1933
agentSession?.dispose();
1934
throw error;
1935
}
1937
const project = await projectFromCopilotContext({ cwd: workingDirectory?.fsPath }, this._gitService);
1939
>
this._provisionalSessions.delete(sessionId);
1940
>
await this._storeSessionMetadata(sessionUri, provisional.model, workingDirectory, customizationDirectory, project, true);
1941
>
if (agent !== undefined) {
1942
await this._storeSessionAgentMetadata(sessionUri, agent);
1943
}
1945
>
// Capture the per-session baseline (turn/0) git checkpoint so
1946
>
// per-turn diffs computed on `ChatTurnComplete` can reflect the
1947
>
// full working-tree delta — including terminal-tool edits that are
1948
>
// invisible to the FileEditTracker pipeline. Best-effort: a
1949
>
// non-git folder or capture failure leaves the session running
1950
>
// with the legacy `file_edits`-based per-turn diff path.
1951
>
this._checkpointService.captureBaseline(sessionUri, workingDirectory).catch(err => {
1952
this._logService.warn(`[Copilot:${sessionId}] Baseline checkpoint capture failed: ${err instanceof Error ? err.message : String(err)}`);
1954
>
1955
>
this._logService.info(`[Copilot] Session materialized: ${sessionUri.toString()}`);
1956
>
this._onDidMaterializeSession.fire({ session: sessionUri, workingDirectory, project });
1957
>
return agentSession;
1958
}
1959