fix: restore Changes focus on task return (#2091)
This commit is contained in:
@@ -179,6 +179,7 @@ describe("applyChangesPanelAutoFocusState fallback session keys", () => {
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: false,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated";
|
||||
@@ -207,6 +208,7 @@ describe("applyChangesPanelAutoFocusState fallback session keys", () => {
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: false,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated";
|
||||
@@ -223,8 +225,8 @@ describe("applyChangesPanelAutoFocusState fallback session keys", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyChangesPanelAutoFocusState saved layouts", () => {
|
||||
it("keeps a returning environment's saved active panel over pending changes", () => {
|
||||
describe("applyChangesPanelAutoFocusState returning environments", () => {
|
||||
it("activates pending changes when returning from another environment", () => {
|
||||
const previousMarkers = {
|
||||
envB: { count: 1, fingerprint: "b1" },
|
||||
};
|
||||
@@ -240,17 +242,75 @@ describe("applyChangesPanelAutoFocusState saved layouts", () => {
|
||||
environmentIdBySessionId: {},
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
hasSavedLayout: true,
|
||||
isRestoringLayout: false,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated";
|
||||
},
|
||||
});
|
||||
|
||||
expect(activateCalls).toBe(0);
|
||||
expect(activateCalls).toBe(1);
|
||||
expect(pendingEnvKeys.size).toBe(0);
|
||||
});
|
||||
|
||||
it("keeps pending changes while maximized and activates them after exit", () => {
|
||||
const previousMarkers = {
|
||||
envB: { count: 1, fingerprint: "b1" },
|
||||
};
|
||||
const pendingEnvKeys = new Set(["envB"]);
|
||||
let activateCalls = 0;
|
||||
const baseArgs = {
|
||||
signalsByEnv: {
|
||||
envB: signal(1, "b1"),
|
||||
},
|
||||
activeEnvKey: "envB",
|
||||
previousActiveEnvKey: "envA",
|
||||
environmentIdBySessionId: {},
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: false,
|
||||
};
|
||||
|
||||
applyChangesPanelAutoFocusState({
|
||||
...baseArgs,
|
||||
isMaximized: true,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "no-panel" as const;
|
||||
},
|
||||
});
|
||||
const whileMaximized = {
|
||||
activateCalls,
|
||||
pendingEnvKeys: [...pendingEnvKeys],
|
||||
};
|
||||
|
||||
applyChangesPanelAutoFocusState({
|
||||
...baseArgs,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated" as const;
|
||||
},
|
||||
});
|
||||
|
||||
expect({
|
||||
whileMaximized,
|
||||
afterExit: {
|
||||
activateCalls,
|
||||
pendingEnvKeys: [...pendingEnvKeys],
|
||||
},
|
||||
}).toEqual({
|
||||
whileMaximized: {
|
||||
activateCalls: 1,
|
||||
pendingEnvKeys: ["envB"],
|
||||
},
|
||||
afterExit: {
|
||||
activateCalls: 2,
|
||||
pendingEnvKeys: [],
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("applyChangesPanelAutoFocusState", () => {
|
||||
@@ -270,6 +330,7 @@ describe("applyChangesPanelAutoFocusState", () => {
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: false,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated";
|
||||
@@ -288,6 +349,7 @@ describe("applyChangesPanelAutoFocusState", () => {
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: false,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated";
|
||||
@@ -309,6 +371,7 @@ describe("applyChangesPanelAutoFocusState", () => {
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: true,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated";
|
||||
@@ -328,6 +391,7 @@ describe("applyChangesPanelAutoFocusState", () => {
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: false,
|
||||
isMaximized: false,
|
||||
activate: () => {
|
||||
activateCalls += 1;
|
||||
return "activated";
|
||||
@@ -480,6 +544,7 @@ describe("applyChangesPanelAutoFocusState restore races", () => {
|
||||
previousMarkers,
|
||||
pendingEnvKeys,
|
||||
isRestoringLayout: false,
|
||||
isMaximized: false,
|
||||
getIsRestoringLayout: () => restoring,
|
||||
activate: () => {
|
||||
restoring = true;
|
||||
|
||||
Reference in New Issue
Block a user