Skip to content

fix(app): give focus back when ⌘W closes the side panel's last New tab - #60435

Merged
kitlangton merged 1 commit into
devfrom
fix-cmdw-panel
Oct 30, 2026
Merged

kitlangton merged 1 commit into
devfrom
fix-cmdw-panel

Conversation

@kitlangton

Copy link
Copy Markdown
Contributor

Fixes dev-red e2e tabs.spec.ts "⌘W in the side panel closes its New tab, then the panel, and only then the session tab" (Linux and Windows, app-2) after #59002.

What broke: the first ⌘W in a side panel holding only a New tab closed the panel too, but the test expected it to stay open.

Cause: #60126 landed after #59002's CI base and made closing a strip's last New tab close the side region, on purpose and covered by its own e2e. #59002 assumed the panel stayed open after that press, and afterwards refocused the panel even though it was now closed.

Fix:

  • When emptying the region closes it, focus goes back to where the panel was opened from, the same as the toggle's close.
  • ⌘W keeps focus in the panel only while the panel is still open.
  • The e2e now expects fix(app): list side launchers only in a New tab and close the region with its last tab #60126's behaviour: the first ⌘W closes the New tab and the panel, focus returns to the composer, the next press closes nothing, and only then does ⌘W close the session tab.

Read: tabs.spec.ts and side-panels.spec.ts on mini: the target test passes. 5 tests in tabs.spec.ts that don't touch the side panel also failed there (tab-cycling and paste shortcuts, which behave differently on macOS); CI's Linux and Windows runs are the real check. bun typecheck and lint:changed are clean.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The fix is sound and works. On the base, the target e2e fails at the first ⌘W because the panel closes. I also ran this PR's version of the test against the base's source, and it fails because the composer doesn't get focus back, so the panels.tsx change is what makes it pass. With the PR, all of tabs.spec.ts and side-panels.spec.ts pass locally on headless Chromium (46 tests), and tsc -b is clean.

One behaviour change to be aware of: emptied() now also gives focus back when ⌘W closes the panel's last real tab, so focus returns to where the panel was opened from (e.g. the composer) rather than to the toggle. That matches closing with the toggle, and the existing tests still pass.

Public API: unchanged.

#60126 made closing a strip's last New tab close the side region, as closing
its last tab does. #59002 assumed the panel stayed open after that press and
then refocused the closed panel, so its e2e failed on dev.

The region now gives focus back to where it was opened from whenever emptying
it closes it, and ⌘W only keeps focus in the panel while it is still open. The
e2e expectation is updated to #60126's intended behaviour: the first ⌘W closes
the New tab with the panel, the next press closes nothing, and only then does
⌘W close the session tab.

@opencodejr opencodejr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The new commits only rebase this onto the current dev. The change itself is the same as before; the only difference is the base's new empty() check around the emptied() call in panels.tsx. I re-checked it on the new base: the target e2e still fails at the first ⌘W. With this PR, all of tabs.spec.ts and side-panels.spec.ts pass locally on headless Chromium (46 tests), and tsc -b is clean.

Public API: unchanged.

@kitlangton
kitlangton merged commit 1a5cd8b into dev Oct 30, 2026
20 checks passed
@kitlangton
kitlangton deleted the fix-cmdw-panel branch October 30, 2026 03:53
@amrkmn amrkmn mentioned this pull request Oct 30, 2026
1 task
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