sessions: cover reconciliation queued before layout restore

Exercise the restore guard inside the sequencer callback by queueing a stale Changes replacement before a gated restore begins. Verify that replacement remains pending until the restore-end reconciliation.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Alex Dima
2026-08-22 20:27:19 +02:00
co-authored by Copilot
parent 3ada3563aa
commit c17604a764
@@ -2955,6 +2955,53 @@ suite('LayoutController (desktop)', () => {
});
});
test('[managed tabs / session switch] stops queued Changes replacement when working-set restore starts', async () => {
const controller = createSinglePaneController({ activateAux: true });
await settle();
const sessionA = makeSession(URI.parse('session:a'));
const sessionB = makeSession(URI.parse('session:b'));
harness.activeSessionObs.set(sessionA, undefined);
await settle();
harness.activeSessionObs.set(sessionB, undefined);
await settle();
const sessionBChanges = harness.activeGroupEditors.find(editor => !(editor instanceof EmptyFileEditorInput))!;
const sessionAChangesResource = harness.sessionChangesService.getChangesEditorResource(sessionA.resource);
const staleSessionAChanges = store.add(new TestStubEditorInput(sessionAChangesResource));
harness.activeGroupEditors.splice(harness.activeGroupEditors.indexOf(sessionBChanges), 1, staleSessionAChanges);
let replacements = 0;
harness.onReplaceEditors = () => {
replacements++;
};
harness.onDidRevealSidePane.fire();
let releaseRestore!: () => void;
const restoreGate = new Promise<void>(resolve => releaseRestore = resolve);
controller.runWithRestore(() => restoreGate);
await settle();
const replacementsDuringRestore = replacements;
const changesDuringRestore = harness.activeGroupEditors.find(editor => !(editor instanceof EmptyFileEditorInput))?.resource;
releaseRestore();
await settle();
const changesAfterRestore = harness.activeGroupEditors.find(editor => !(editor instanceof EmptyFileEditorInput))?.resource;
assert.deepStrictEqual({
replacementsDuringRestore,
changesDuringRestore: changesDuringRestore?.toString(),
replacementsAfterRestore: replacements,
changesAfterRestore: changesAfterRestore?.toString(),
}, {
replacementsDuringRestore: 0,
changesDuringRestore: sessionAChangesResource.toString(),
replacementsAfterRestore: 1,
changesAfterRestore: harness.sessionChangesService.getChangesEditorResource(sessionB.resource).toString(),
});
});
test('[managed tabs / session switch] does not publish workspace from a superseded reconcile', async () => {
createSinglePaneController({ activateAux: true });
await settle();