The best way to control Claude Code, Codex and more from any computer or phone
fix(web): closing the last Browser tab hides the right panel again (#26058)
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Julius Marminge committed
Oct 27, 2026 at 11:03 UTC
d0b81ceb6e225a7386203d590ec84def4abed281
4 files changed
+28
-2
apps/web/src/components/preview/agentOpenedPreviews.test.ts
+1
-1
@@ -258,7 +258,7 @@ describe("followPreviewSessions", () => {
258
useRightPanelStore
259
.getState()
260
.byThreadKey[threadKey]?.surfaces.filter((surface) => surface.kind === "preview")
261
- .map((surface) => surface.id);
261
+ .map((surface) => surface.id) ?? [];
262
263
it("adds visible sessions as tabs and drops tabs whose session ended", () => {
264
setup();
apps/web/src/hooks/useRightPanelSurfaceClose.ts
+3
-1
@@ -88,8 +88,10 @@ export function useRightPanelSurfaceClose(input: {
88
(left, right) => Number(left.id === activeId) - Number(right.id === activeId),
89
);
90
for (const surface of ordered) {
91
- releaseSurfaceResources(threadRef, surface);
91
+ // Releasing a browser drops its session, which prunes the tab automatically; close it
92
+ // first so the close stays a user action that hides the panel after the last tab.
93
store.closeSurface(threadRef, surface.id);
94
+ releaseSurfaceResources(threadRef, surface);
95
}
96
const nextActiveSurface = selectActiveRightPanelSurface(
97
useRightPanelStore.getState().byThreadKey,
apps/web/src/rightPanelStore.test.ts
+18
@@ -1181,6 +1181,24 @@ describe("rightPanelStore", () => {
1181
});
1182
});
1183
1184
+ it("hides the panel when browser reconciliation removes its last session tab", () => {
1185
+ const store = useRightPanelStore.getState();
1186
+ store.openBrowser(refA, "tab-a");
1187
+ store.reconcileBrowserSurfaces(refA, []);
1188
+ expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
1189
+ isOpen: false,
1190
+ activeSurfaceId: null,
1191
+ surfaces: [],
1192
+ });
1193
+
1194
+ store.openBrowser(refA, "tab-b");
1195
+ store.open(refA, "diff");
1196
+ store.reconcileBrowserSurfaces(refA, []);
1197
+ expect(
1198
+ selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA),
1199
+ ).toMatchObject({ isOpen: true, activeSurfaceId: "diff" });
1200
+ });
1201
+
1202
it("moves a surface to a new index and keeps it there through browser reconciliation", () => {
1203
const store = useRightPanelStore.getState();
1204
store.openTerminal(refA, "term-1");
apps/web/src/rightPanelStore.ts
+6
@@ -972,8 +972,14 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
972
(surface) => surface.id === current.activeSurfaceId,
973
);
974
const fallbackBrowser = surfaces.find((surface) => surface.kind === "preview");
975
+ // A closed session tab was the last surface: hide the panel rather than leave it on
976
+ // the empty picker, as a user close would. A dropped `browser:new` placeholder does not count.
977
+ const closedLastSessionTab =
978
+ surfaces.length === 0 &&
979
+ current.surfaces.some((surface) => surface.kind === "preview" && surface.resourceId);
980
return {
981
...current,
982
+ isOpen: closedLastSessionTab ? false : current.isOpen,
983
surfaces,
984
activeSurfaceId: activeStillExists
985
? current.activeSurfaceId