From a22d00300655c17490ce63dffc28bcdcedcd82c4 Mon Sep 17 00:00:00 2001 From: Ladislau Szomoru <3372902+lszomoru@users.noreply.github.com> Date: Tue, 30 Jun 2026 11:53:00 +0000 Subject: [PATCH] AgentHost - restore changesets when reloading the window (#323512) AgentHost - restore changesets when reloading the window (#323494) * AgentHost - restore changesets when reloading the window * Tweak the fix so that we only use the state information to initialize the changesets --- .../browser/baseAgentHostSessionsProvider.ts | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts b/src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts index 59311f524ec..00781d7a1bc 100644 --- a/src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts +++ b/src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts @@ -3144,6 +3144,39 @@ export abstract class BaseAgentHostSessionsProvider extends Disposable implement this._seedRunningConfigFromState(sessionId, state); this._applySessionMetaFromState(sessionId, state); this._applyChatCatalogFromState(sessionId, state); + + if (!previous) { + // This is the first time we've seen this session and the initial + // list of changesets are included in the state, so we use that to + // initialize the changeset catalogue.v Subsequent updates will be + // handled by handling the ActionType.SessionChangesetsChanged + // action. + this._applyChangesetsFromState(sessionId, state); + } + } + + /** + * Seed the cached adapter's changeset catalogue from an AHP + * {@link SessionState}. The catalogue otherwise only flows in via the live + * `SessionChangesetsChanged` action, which the host emits only when entries + * are added or removed. On restore (e.g. after a reload) nothing mutates, so + * that action never fires and the catalogue would stay empty. The restored + * `SessionState` snapshot carries the persisted `changesets`, so apply it + * here to surface the catalogue immediately. + */ + private _applyChangesetsFromState(sessionId: string, state: SessionState): void { + if (state.changesets === undefined) { + return; + } + const rawId = this._rawIdFromChatId(sessionId); + if (!rawId) { + return; + } + const cached = this._sessionCache.get(rawId); + if (!cached) { + return; + } + cached.updateChangesets(state.changesets); } /**