Skip to content

Commit 811516c

Browse files
committed
fix(web): preserve device dismissals when reopening files
1 parent 84ac31d commit 811516c

3 files changed

Lines changed: 31 additions & 2 deletions

File tree

‎apps/web/src/rightPanelStore.test.ts‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,31 @@ describe("rightPanelStore", () => {
9191
expect(selectThreadRightPanelState(migrated.byThreadKey, refA).closedSurfaces).toEqual([]);
9292
});
9393

94+
it.each(["reopenClosed", "openFile"] as const)(
95+
"keeps a dismissed device hidden when %s opens a file tab",
96+
(action) => {
97+
const store = useRightPanelStore.getState();
98+
const device = {
99+
hostId: "nucbox",
100+
deviceId: "emulator-5580",
101+
name: "Pixel",
102+
platform: "android",
103+
} as const;
104+
store.openFile(refA, "src/app.ts");
105+
store.closeSurface(refA, "file:src/app.ts");
106+
store.openDevice(refA, device);
107+
store.closeSurface(refA, "device:nucbox:emulator-5580");
108+
109+
if (action === "reopenClosed") store.reopenClosed(refA);
110+
else store.openFile(refA, "src/app.ts");
111+
store.openDevice(refA, device, true);
112+
113+
expect(
114+
selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA).surfaces,
115+
).toEqual([expect.objectContaining({ id: "file:src/app.ts" })]);
116+
},
117+
);
118+
94119
it("gives each host/device its own tab and preserves renamed tabs", () => {
95120
const store = useRightPanelStore.getState();
96121
const android = {

‎apps/web/src/rightPanelStore.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ const upsertSurface = (
275275
surface: RightPanelSurface,
276276
activate = true,
277277
): ThreadRightPanelState => ({
278-
...(current.closedSurfaces ? { closedSurfaces: current.closedSurfaces } : {}),
278+
...current,
279279
isOpen: true,
280280
surfaces: current.surfaces.some((entry) => entry.id === surface.id)
281281
? current.surfaces
@@ -625,7 +625,7 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
625625
(existing?.revealRequestId ?? 0) + 1,
626626
);
627627
return {
628-
...(current.closedSurfaces ? { closedSurfaces: current.closedSurfaces } : {}),
628+
...current,
629629
isOpen: true,
630630
activeSurfaceId: surface.id,
631631
surfaces: existing

‎docs/user/keybindings.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ tab. When nothing remains to close, it closes the window. In a browser, `mod+w`
128128
closes the browser tab; rebind `rightPanel.close` and `terminal.close` to an available
129129
shortcut such as `alt+w`.
130130

131+
`mod+shift+t` reopens the last closed file, diff, or pull request tab in the current
132+
thread. Browsers also use this shortcut to reopen browser tabs; choose another
133+
binding in Settings if the browser takes it first.
134+
131135
Many defaults include `!terminalFocus` so they do not intercept terminal input.
132136
Keep that condition when remapping them if you want the same behavior.
133137

0 commit comments

Comments
 (0)