Skip to content

feat(chat): focus the composer when the ⌘M chat view opens - #1163

Open
probertson wants to merge 1 commit into
eneskirca:mainfrom
probertson:feat/md-view-focus-composer
Open

probertson wants to merge 1 commit into
eneskirca:mainfrom
probertson:feat/md-view-focus-composer

Conversation

@probertson

@probertson probertson commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Opening the ⌘M chat view now puts the keyboard in its composer, so you can start typing straight away. Before, entering the view blurred the terminal and left focus nowhere, and you had to click the composer first.

When it takes focus: only if focus was nowhere, already inside this node, or in a terminal. A text field elsewhere (a rename box, the sessions filter, another node's composer) keeps it. Opening the output view (agents without a chat view) changes nothing.

Timing: ChatPanel is code-split. On the first open the composer mounts after the view's entry has already run, so the entry leaves a request that the composer takes when it mounts. If a dialog keeps the composer disabled (e.g. Claude's folder-trust prompt), it takes the request when it becomes enabled. Leaving the view cancels the request. Exit still returns focus to the terminal under the existing rule.

The kanban card modal uses the same hook (useMdModeFocus), so it gets the same behavior.

How it was checked

  • New unit tests in useMdModeFocus.test.tsx: composer already mounted, composer mounted later, request taken once, request cancelled on exit, a second mount of the same session elsewhere ignored, a text field elsewhere left alone, no focus when the view is already open at mount, disabled then enabled, terminal restored on exit.
  • npm run typecheck and the terminal/nodes/kanban suites (1587 tests) pass.
  • In an isolated dev build over CDP, with a Claude node: the cached-chunk path and the first-open path after a reload both landed focus in the composer; toggling back returned it to the terminal; the trust dialog kept the composer disabled and unfocused.
  • Manually on macOS, including the ⌘M chord itself: works as expected.

Not checked: the ⌘K palette entry and the kanban card modal specifically.

🤖 Generated with Claude Code

Entering the view blurred the xterm and left focus nowhere, so the user had to click the
composer before typing. The composer now takes focus on entry — when focus was nowhere, inside
this node, or in a terminal; a text field elsewhere keeps it. The ChatPanel is code-split, so
on a first open (and while a dialog keeps the composer disabled) the request waits for the
composer to mount/enable; leaving the view cancels it. Exit still restores the terminal under
the existing rule.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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