Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,21 @@ describe("MissionControlService", () => {
expect(service.getState().active).toBe(false);
});

it("refreshes immediately when the app regains focus", () => {
const { state, impl } = fakeSampler([MISSION_CONTROL_BACKING]);
sampler.create.mockReturnValue(impl);
const service = new MissionControlService();

service.arm();
vi.advanceTimersByTime(250);
expect(service.getState().active).toBe(true);

state.windows = [];
service.refresh();

expect(service.getState().active).toBe(false);
});

it("never touches the window list while the setting is off", () => {
settings.enabled = false;
const { state, impl } = fakeSampler([MISSION_CONTROL_BACKING]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ export class MissionControlService extends TypedEventEmitter<MissionControlServi
this.timer = setInterval(() => this.poll(), POLL_INTERVAL_MS);
}

refresh(): void {
if (!this.enabled || !this.resolveSampler()) return;
this.poll();
}

disarm(): void {
this.clearTimer();
this.setActive(false);
Expand Down
1 change: 1 addition & 0 deletions products/desktop/apps/code/src/main/window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ export function createWindow(): void {
);
mainWindow.on("show", () => missionControl.arm());
mainWindow.on("restore", () => missionControl.arm());
mainWindow.on("focus", () => missionControl.refresh());
mainWindow.on("hide", () => missionControl.disarm());
mainWindow.on("minimize", () => missionControl.disarm());
mainWindow.on("closed", () => missionControl.disarm());
Expand Down
Loading