Open-source Grok Bot alternative for named AI teammates. Local-first desktop, web, and mobile clients with per-bot tools, instructions, and memory. Independent fork of T3 Code.
[codex] Close right panel when its last tab closes (#3221)
Julius Marmingedc82f792c3fc
diff --git a/apps/web/src/rightPanelStore.test.ts b/apps/web/src/rightPanelStore.test.tsindex fb6d56f98..b48f6e7eb 100644--- a/apps/web/src/rightPanelStore.test.ts+++ b/apps/web/src/rightPanelStore.test.ts@@ -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: [],});diff --git a/apps/web/src/rightPanelStore.ts b/apps/web/src/rightPanelStore.tsindex 26dfe8c51..70d163306 100644--- a/apps/web/src/rightPanelStore.ts+++ b/apps/web/src/rightPanelStore.ts@@ -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) =>