Skip to content

Make a split pane active when keyboard focus enters it - #7971

Merged
ymichael merged 1 commit into
mainfrom
bb/split-pane-focus-follows-keyboard
Nov 21, 2026
Merged

ymichael merged 1 commit into
mainfrom
bb/split-pane-focus-follows-keyboard

Conversation

@ymichael

Copy link
Copy Markdown
Collaborator

Human comments

What was wrong

Main-area split panes became active only on pointerdown (SplitThreadArea's pane wrapper). When the caret reached another pane's composer without a click (Tab across panes, or a plugin calling composer.focus() on a useComposers() handle there), the active pane stayed behind. #7960's active-composer rule only accepts a caret composer on the focused surface, so ⇧⌘M opened the other pane's model picker and ⇧⌘C pulled the caret over to the other pane. Before #7960 both shortcuts did nothing in that state. The side-panel split (SidebarSplitContainer) already follows focus with onFocusCapture.

What changed

  • SplitThreadArea.tsx: the pane wrapper also becomes active on focus capture, through a new onFocusWithinPane that calls focusPane only. The pointer handler still also clears a pending keyboard focus request. Focus capture must not clear it, because pane.focus.* focuses the pane root while its composer is not ready. A pane hidden behind a maximized pane doesn't take focus this way.
  • ComposerBox.tsx: a composer that mounts in an unfocused split pane gets autoFocus: false. Every composer autofocuses on mount (PromptBoxInternal defaults autoFocus to true), so on reload whichever pane's editor was ready last took the caret. On main that left the caret in an inactive pane. With focus following, it would also have switched the active pane and the URL. The check uses the pane state at mount, so making a pane active later doesn't pull the caret into its composer.

How you verified

  • New SplitThreadArea.test.tsx case: focusing a textarea in the other pane makes that pane active and moves the URL, and focus inside a pane hidden by maximize changes nothing. It fails without the onFocusCapture handler.
  • New PromptBoxInternal.test.tsx case: a composer mounted in an unfocused split pane doesn't take the caret, even after its pane becomes focused. It fails without the ComposerBox change.
  • The existing "handles a late composer and cancels pending focus on pointer activity" case caught a first version that reused the pointer handler. It passes now.
  • pnpm exec turbo run typecheck lint test --filter=@bb/app: 700 test files, 7336 tests passed.
  • Live on pnpm start:worktree, with a thread split beside New thread:
    • Click the right composer, then move the caret into the left composer without a click. The left pane becomes active and ⇧⌘M opens the left picker. Before this change, the right picker opened.
    • 5 reloads with the left pane active and 5 with the right pane active: the active pane, URL and caret stayed put every time. A first version without the ComposerBox change flipped to the New thread pane on reload.
    • Clicking into either composer and pressing ⇧⌘M opens that pane's picker.
    • Dragging New thread into a split still makes the new pane active and puts the caret there.

AGENT GENERATED

🤖 Generated with Claude Code

Main split panes became active only on pointerdown. When the caret
reached another pane's composer without a click (Tab, or a plugin
calling composer.focus()), the active pane stayed behind, so the
active-composer rule from #7960 sent composer.focus and the model picker
chords to the other pane's composer. The pane wrapper now also becomes
active on focus capture, except while hidden behind a maximized pane,
without cancelling a pending keyboard focus request.

That exposed a mount race: every composer autofocuses on mount, so on
reload whichever split pane's editor was ready last took the caret and,
now, the active pane and URL. ComposerBox suppresses autofocus for a
composer that mounts in an unfocused split pane.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ymichael
ymichael merged commit 35a03bb into main Nov 21, 2026
32 checks passed
@ymichael
ymichael deleted the bb/split-pane-focus-follows-keyboard branch November 21, 2026 04:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant