History

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

Julius Marminge committed 4 months ago

Commit dc82f791 parent 335e0b52 files · +17 −9Browse files

Unified · Split

2 files
  1. apps/web/src/rightPanelStore.test.ts +6 −6
  2. apps/web/src/rightPanelStore.ts +11 −3
apps/web/src/rightPanelStore.test.ts+6−6
@@ -338,12 +338,12 @@ describe("rightPanelStore", () => { · 337 unmodified lines
338338 });
339339 });
340340
341− it("closing the final terminal pane removes its surface but keeps the panel open", () => {
341+ it("closing the final terminal pane removes its surface and closes the panel", () => {
342342 useRightPanelStore.getState().openTerminal(refA, "term-1");
343343 useRightPanelStore.getState().closeTerminal(refA, "terminal:term-1", "term-1");
344344
345345 expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
346− isOpen: true,
346+ isOpen: false,
347347 activeSurfaceId: null,
348348 surfaces: [],
349349 });
@@ -359,12 +359,12 @@ describe("rightPanelStore", () => { · 9 unmodified lines
359359 );
360360 });
361361
362− it("closing the final surface leaves the panel open and empty", () => {
362+ it("closing the final surface closes the panel", () => {
363363 useRightPanelStore.getState().openTerminal(refA, "term-1");
364364 useRightPanelStore.getState().closeSurface(refA, "terminal:term-1");
365365
366366 expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
367− isOpen: true,
367+ isOpen: false,
368368 activeSurfaceId: null,
369369 surfaces: [],
370370 });
@@ -406,14 +406,14 @@ describe("rightPanelStore", () => { · 35 unmodified lines
406406 });
407407 });
408408
409− it("closing all surfaces leaves the panel open and empty", () => {
409+ it("closing all surfaces closes the panel", () => {
410410 useRightPanelStore.getState().openBrowser(refA, "tab-a");
411411 useRightPanelStore.getState().openFile(refA, "src/index.ts");
412412
413413 useRightPanelStore.getState().closeAllSurfaces(refA);
414414
415415 expect(selectThreadRightPanelState(useRightPanelStore.getState().byThreadKey, refA)).toEqual({
416− isOpen: true,
416+ isOpen: false,
417417 activeSurfaceId: null,
418418 surfaces: [],
419419 });
apps/web/src/rightPanelStore.ts+11−3
@@ -340,6 +340,7 @@ export const useRightPanelStore = create<RightPanelStoreState>()( · 339 unmodified lines
340340 const fallback = surfaces[Math.min(index, surfaces.length - 1)] ?? null;
341341 return {
342342 ...current,
343+ isOpen: surfaces.length > 0 && current.isOpen,
343344 surfaces,
344345 activeSurfaceId:
345346 current.activeSurfaceId === surfaceId
@@ -378,9 +379,16 @@ export const useRightPanelStore = create<RightPanelStoreState>()( · 32 unmodified lines
378379 const index = current.surfaces.findIndex((surface) => surface.id === surfaceId);
379380 if (index < 0) return current;
380381 const surfaces = current.surfaces.filter((surface) => surface.id !== surfaceId);
381− if (current.activeSurfaceId !== surfaceId) return { ...current, surfaces };
382+ if (current.activeSurfaceId !== surfaceId) {
383+ return { ...current, isOpen: surfaces.length > 0 && current.isOpen, surfaces };
384+ }
382385 const fallback = surfaces[Math.min(index, surfaces.length - 1)] ?? null;
383− return { ...current, surfaces, activeSurfaceId: fallback?.id ?? null };
386+ return {
387+ ...current,
388+ isOpen: surfaces.length > 0 && current.isOpen,
389+ surfaces,
390+ activeSurfaceId: fallback?.id ?? null,
391+ };
384392 }),
385393 })),
386394 closeOtherSurfaces: (ref, surfaceId) =>
@@ -417,7 +425,7 @@ export const useRightPanelStore = create<RightPanelStoreState>()( · 30 unmodified lines
417425 byThreadKey: updateThread(state.byThreadKey, scopedThreadKey(ref), (current) =>
418426 current.surfaces.length === 0
419427 ? current
420− : { ...current, isOpen: true, surfaces: [], activeSurfaceId: null },
428+ : { ...current, isOpen: false, surfaces: [], activeSurfaceId: null },
421429 ),
422430 })),
423431 reconcileBrowserSurfaces: (ref, tabIds) =>

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t