Skip to content

fix(ui): auto-focus chat input on Hub mount#8007

Merged
DOsinga merged 2 commits intoaaif-goose:mainfrom
jeffa-block:jeffa/autofocus-chat-input
Mar 20, 2026
Merged

fix(ui): auto-focus chat input on Hub mount#8007
DOsinga merged 2 commits intoaaif-goose:mainfrom
jeffa-block:jeffa/autofocus-chat-input

Conversation

@jeffa-block
Copy link
Copy Markdown
Contributor

@jeffa-block jeffa-block commented Mar 19, 2026

Problem

Opening a new Goose window requires ~12 Tab presses to reach the chat input. The textarea has autoFocus but it's unreliable across the async render chain:

renderer.tsx (lazy App) → Suspense → OnboardingGuard (async provider check) → AppLayout → Hub → ChatInput → textarea

By the time the textarea mounts and autoFocus fires, focus can be lost to re-renders or stolen by earlier elements in the tab order (7 nav buttons + session insight cards).

Related: #5039 — the original input-disabled bug was fixed, but the render chain change that fixed it introduced this focus regression. Different root cause (focus timing vs disabled state), same UX priority: the input must be ready to type on window open.

Fix

Pass an inputRef from Hub to ChatInput and imperatively focus it via useEffect + requestAnimationFrame after mount. This fires after the DOM has fully painted, making it reliable regardless of the async render chain.

1 file changed, +15 −1 lines.

Testing

  • Open a new Goose window → cursor is in the chat input, ready to type
  • Navigate away and back to Hub → input re-focuses
  • Typecheck: tsc --noEmit
  • Lint: eslint src/components/Hub.tsx

The textarea has autoFocus but it's unreliable across the async render
chain (lazy App → Suspense → OnboardingGuard). Users had to press Tab
~12 times through nav buttons and session cards to reach the input.

Add a useEffect with requestAnimationFrame that imperatively focuses
the textarea after the Hub component mounts, so typing works
immediately on launch.
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

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

Clean fix — mirrors the existing pattern in BaseChat. Collapsed the comment to one line.

@DOsinga DOsinga added this pull request to the merge queue Mar 20, 2026
Signed-off-by: Douwe Osinga <douwe@squareup.com>
@DOsinga DOsinga enabled auto-merge March 20, 2026 13:33
@DOsinga DOsinga added this pull request to the merge queue Mar 20, 2026
Merged via the queue into aaif-goose:main with commit d767611 Mar 20, 2026
21 checks passed
elijahsgh pushed a commit to elijahsgh/goose that referenced this pull request Mar 21, 2026
Signed-off-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
Signed-off-by: esnyder <elijah.snyder1@gmail.com>
elijahsgh pushed a commit to elijahsgh/goose that referenced this pull request Mar 21, 2026
Signed-off-by: Douwe Osinga <douwe@squareup.com>
Co-authored-by: Douwe Osinga <douwe@squareup.com>
Signed-off-by: esnyder <elijah.snyder1@gmail.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.

2 participants