diff --git a/packages/app/e2e/regression/review.spec.ts b/packages/app/e2e/regression/review.spec.ts index b6ff69701bf..f81ef80f0d2 100644 --- a/packages/app/e2e/regression/review.spec.ts +++ b/packages/app/e2e/regression/review.spec.ts @@ -731,9 +731,22 @@ test("restores review state and the side-panel tab per session", async ({ page } await selectedFile("gamma.ts") await review.press("End") await selectedTab("README.md") + + // A hidden side-panel tab does not claim Close Tab while the side region is collapsed. + await toggle.click() + await expect(panel).toBeHidden() + await page.keyboard.press("Control+w") + await expect(page.locator("[data-titlebar-tab-slot]", { hasText: "Alpha review state" })).toHaveCount(0) + await expectSessionTitle(page, "Beta review state") + await page.keyboard.press("Control+Shift+T") + await expectSessionTitle(page, "Alpha review state") + await toggle.click() + await selectedTab("README.md") + await page.keyboard.press("Control+w") await expect(panel.getByRole("tab", { name: "README.md", exact: true })).toHaveCount(0) await expect(review).toHaveAttribute("aria-selected", "true") + await expectSessionTitle(page, "Alpha review state") }) test("shows and restores last turn changes from the session diff", async ({ page }) => { diff --git a/packages/app/src/session/commands/use-session-commands.tsx b/packages/app/src/session/commands/use-session-commands.tsx index e0157d20957..72967c36b75 100644 --- a/packages/app/src/session/commands/use-session-commands.tsx +++ b/packages/app/src/session/commands/use-session-commands.tsx @@ -71,8 +71,10 @@ export const useSessionCommands = (actions: SessionCommandContext) => { // The file the selected side tab shows; other tabs have no line selection. const activeFile = () => actions.region.selected()?.tab.file - // Pinned tabs stay open. + // Pinned tabs stay open, and hidden side-panel tabs do not claim Close Tab while the region is collapsed. const closableTab = () => { + if (!actions.session.layout.view().side.opened()) return + const entry = actions.region.selected() return entry && !entry.tab.pinned ? entry.key : undefined