Skip to content

Commit a22d003

Browse files
authored
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
1 parent 4fe60c8 commit a22d003

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

src/vs/sessions/contrib/providers/agentHost/browser/baseAgentHostSessionsProvider.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3144,6 +3144,39 @@ export abstract class BaseAgentHostSessionsProvider extends Disposable implement
31443144
this._seedRunningConfigFromState(sessionId, state);
31453145
this._applySessionMetaFromState(sessionId, state);
31463146
this._applyChatCatalogFromState(sessionId, state);
3147+
3148+
if (!previous) {
3149+
// This is the first time we've seen this session and the initial
3150+
// list of changesets are included in the state, so we use that to
3151+
// initialize the changeset catalogue.v Subsequent updates will be
3152+
// handled by handling the ActionType.SessionChangesetsChanged
3153+
// action.
3154+
this._applyChangesetsFromState(sessionId, state);
3155+
}
3156+
}
3157+
3158+
/**
3159+
* Seed the cached adapter's changeset catalogue from an AHP
3160+
* {@link SessionState}. The catalogue otherwise only flows in via the live
3161+
* `SessionChangesetsChanged` action, which the host emits only when entries
3162+
* are added or removed. On restore (e.g. after a reload) nothing mutates, so
3163+
* that action never fires and the catalogue would stay empty. The restored
3164+
* `SessionState` snapshot carries the persisted `changesets`, so apply it
3165+
* here to surface the catalogue immediately.
3166+
*/
3167+
private _applyChangesetsFromState(sessionId: string, state: SessionState): void {
3168+
if (state.changesets === undefined) {
3169+
return;
3170+
}
3171+
const rawId = this._rawIdFromChatId(sessionId);
3172+
if (!rawId) {
3173+
return;
3174+
}
3175+
const cached = this._sessionCache.get(rawId);
3176+
if (!cached) {
3177+
return;
3178+
}
3179+
cached.updateChangesets(state.changesets);
31473180
}
31483181

31493182
/**

0 commit comments

Comments
 (0)