Skip to content

fix(app): ⌘W closes the side panel when nothing in it is left to close - #59002

Open
kitlangton wants to merge 3 commits into
betafrom
cmdw-panel
Open

kitlangton wants to merge 3 commits into
betafrom
cmdw-panel

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

What it does

Opening the side panel with ⇧⌘R shows a New tab. ⌘W closes that New tab, but the next ⌘W did nothing: the panel stayed open and empty, and only ⇧⌘R closed it. Now, with focus in the side panel, ⌘W closes the panel itself once nothing in it is left to close, the way an editor closes the focused pane before the window.

How it works

With focus in the side panel, ⌘W now closes, in order:

  1. the New tab view it shows,
  2. else the selected tab, unless it's pinned,
  3. else the side panel itself, through the same toggle as ⇧⌘R, so focus goes back where it was.

With focus outside the side panel, ⌘W still closes the session tab. The existing guard still swallows one extra ⌘W after the panel closes, so a quick double press never closes the session. The bottom panel (⌘J) is unchanged.

Risk

Desktop and web app keyboard handling only. A panel whose only tab is pinned now closes on ⌘W instead of ignoring it.

Proof

  • bunx playwright test e2e/regression/tabs.spec.ts -g "⌘W|side-panel tabs": 4 passed. The new test fails without the fix (the panel stays open after the second ⌘W).
  • New test: ⇧⌘R → ⌘W closes the New tab → ⌘W closes the panel and keeps the session → with no panel open, ⌘W from the composer closes the session tab.
  • bun typecheck in packages/app: clean. bun script/lint-changed.ts origin/beta: 0 problems.

Base is beta: the side panel's New tab view and the ⌘W guard this builds on only exist there.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is sound. I put the new e2e test into a copy of the base branch, where it fails: the panel stays open after the second ⌘W. With this PR it passes, along with the three existing ⌘W and side-panel tests in tabs.spec.ts. tsc -b in packages/app is clean.

The new fallback can't open the panel: onSelect returns early when the side panel is closed. It closes through the same region.toggle() as ⇧⌘R, and the existing guard still catches an extra ⌘W.

Public API: unchanged (app keyboard handling only).

No blocking concerns.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit is sound. It keeps focus in the side panel when ⌘W removes a focused New tab, so the next ⌘W closes the panel and gives focus back to the composer. The updated e2e test fails without the new code, and passes with it along with the other ⌘W and side-panel tests. tsc -b in packages/app is clean.

Public API: unchanged.

No new concerns.

@opencode-agent opencode-agent Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new commit only merges beta; the PR's own diff is unchanged since my last review. At the new head, the ⌘W and side-panel e2e tests in tabs.spec.ts pass (4/4) and tsc -b in packages/app is clean.

Public API: unchanged.

No new concerns.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant