[codex] Close right panel when its last tab closes (#3221)

Co-authored-by: Julius Marminge <[email protected]>
This commit is contained in:
Julius MarmingeandJulius Marminge authored and GitHub committed 2026-06-19 23:48:41 -07:00
1 parent 335e0b59ea
commit dc82f792c3
2 files changed
+17 -9

No files matched your search

+6 -6
View File
@@ -338,12 +338,12 @@ describe("rightPanelStore", () => {
});
});
it("closing the final terminal pane removes its surface but keeps the panel open", () => {
it("closing the final terminal pane removes its surface and closes the panel", () => {
useRightPanelStore.getState().openTerminal(refA, "term-1");
useRightPanelStore.getState().closeTerminal(refA, "terminal:term-1", "term-1");
expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
isOpen: true,
isOpen: false,
activeSurfaceId: null,
surfaces: [],
});
@@ -359,12 +359,12 @@ describe("rightPanelStore", () => {
);
});
it("closing the final surface leaves the panel open and empty", () => {
it("closing the final surface closes the panel", () => {
useRightPanelStore.getState().openTerminal(refA, "term-1");
useRightPanelStore.getState().closeSurface(refA, "terminal:term-1");
expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
isOpen: true,
isOpen: false,
activeSurfaceId: null,
surfaces: [],
});
@@ -406,14 +406,14 @@ describe("rightPanelStore", () => {
});
});
it("closing all surfaces leaves the panel open and empty", () => {
it("closing all surfaces closes the panel", () => {
useRightPanelStore.getState().openBrowser(refA, "tab-a");
useRightPanelStore.getState().openFile(refA, "src/index.ts");
useRightPanelStore.getState().closeAllSurfaces(refA);
expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
isOpen: true,
isOpen: false,
activeSurfaceId: null,
surfaces: [],
});
+11 -3
View File
@@ -340,6 +340,7 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
const fallback = surfaces[Math.min(index, surfaces.length - 1)] ?? null;
return {
...current,
isOpen: surfaces.length > 0 && current.isOpen,
surfaces,
activeSurfaceId:
current.activeSurfaceId === surfaceId
@@ -378,9 +379,16 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
const index = current.surfaces.findIndex((surface) => surface.id === surfaceId);
if (index < 0) return current;
const surfaces = current.surfaces.filter((surface) => surface.id !== surfaceId);
if (current.activeSurfaceId !== surfaceId) return { ...current, surfaces };
if (current.activeSurfaceId !== surfaceId) {
return { ...current, isOpen: surfaces.length > 0 && current.isOpen, surfaces };
}
const fallback = surfaces[Math.min(index, surfaces.length - 1)] ?? null;
return { ...current, surfaces, activeSurfaceId: fallback?.id ?? null };
return {
...current,
isOpen: surfaces.length > 0 && current.isOpen,
surfaces,
activeSurfaceId: fallback?.id ?? null,
};
}),
})),
closeOtherSurfaces: (ref, surfaceId) =>
@@ -417,7 +425,7 @@ export const useRightPanelStore = create<RightPanelStoreState>()(
byThreadKey: updateThread(state.byThreadKey, scopedThreadKey(ref), (current) =>
current.surfaces.length === 0
? current
: { ...current, isOpen: true, surfaces: [], activeSurfaceId: null },
: { ...current, isOpen: false, surfaces: [], activeSurfaceId: null },
),
})),
reconcileBrowserSurfaces: (ref, tabIds) =>