GeezerVison is showing github.com — fix(web): closing the last Browser tab hides the right panel again (#… · pingdotgg/t3code@d0b81ce
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: apps/web/src/components/preview/agentOpenedPreviews.test.ts +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -258,7 +258,7 @@ describe("followPreviewSessions", () => { | 258 | 258 | useRightPanelStore | 259 | 259 | .getState() | 260 | 260 | .byThreadKey[threadKey]?.surfaces.filter((surface) => surface.kind === "preview") | 261 | | - .map((surface) => surface.id); | | 261 | + .map((surface) => surface.id) ?? []; | 262 | 262 |
| 263 | 263 | it("adds visible sessions as tabs and drops tabs whose session ended", () => { | 264 | 264 | setup(); | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/hooks/useRightPanelSurfaceClose.ts +3-1Lines changed: 3 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -88,8 +88,10 @@ export function useRightPanelSurfaceClose(input: { | 88 | 88 | (left, right) => Number(left.id === activeId) - Number(right.id === activeId), | 89 | 89 | ); | 90 | 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. | 92 | 93 | store.closeSurface(threadRef, surface.id); | | 94 | + releaseSurfaceResources(threadRef, surface); | 93 | 95 | } | 94 | 96 | const nextActiveSurface = selectActiveRightPanelSurface( | 95 | 97 | useRightPanelStore.getState().byThreadKey, | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/rightPanelStore.test.ts +18Lines changed: 18 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1181,6 +1181,24 @@ describe("rightPanelStore", () => { | 1181 | 1181 | }); | 1182 | 1182 | }); | 1183 | 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 | + | 1184 | 1202 | it("moves a surface to a new index and keeps it there through browser reconciliation", () => { | 1185 | 1203 | const store = useRightPanelStore.getState(); | 1186 | 1204 | store.openTerminal(refA, "term-1"); | |
Collapse file Copy file name to clipboardExpand all lines: apps/web/src/rightPanelStore.ts +6Lines changed: 6 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -972,8 +972,14 @@ export const useRightPanelStore = create<RightPanelStoreState>()( | 972 | 972 | (surface) => surface.id === current.activeSurfaceId, | 973 | 973 | ); | 974 | 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); | 975 | 980 | return { | 976 | 981 | ...current, | | 982 | + isOpen: closedLastSessionTab ? false : current.isOpen, | 977 | 983 | surfaces, | 978 | 984 | activeSurfaceId: activeStillExists | 979 | 985 | ? current.activeSurfaceId | |
|