Skip to content

ui: focus the chat form when typing with nothing focused - #32570

Merged
allozaur merged 1 commit into
ggml-org:masterfrom
allozaur:allozaur/feat/chat-form-type-to-focus
Nov 20, 2026
Merged

allozaur merged 1 commit into
ggml-org:masterfrom
allozaur:allozaur/feat/chat-form-type-to-focus

Conversation

@allozaur

Copy link
Copy Markdown
Contributor

Overview

On the chat screen, you can start typing without clicking into the chat form first: if nothing else has focus, the form takes it and the text appears there.

Additional information

What changed
  • ChatScreenForm listens for keydown on the window and focuses the chat form when shouldTypeToFocus (new, utils/type-to-focus.ts) says so. Focus moves during keydown, so the key's character, the first one included, goes into the editor.
  • shouldTypeToFocus takes a single printable character with no Ctrl/Cmd/Alt, outside IME composition, not already handled (defaultPrevented), and only when focus is not in an input, textarea, select or contenteditable, or inside a dialog, alert dialog, menu or listbox (they take typed letters themselves or trap focus).
  • Space and named keys (Enter, Escape, arrows, Tab, F-keys) are left alone, so scrolling, pressing a focused button and shortcuts work as before.
  • Like the existing auto-focus, it does nothing on mobile or while the form is disabled.
Testing
  • tests/client/type-to-focus.svelte.test.ts covers the cases above in the browser test project.
  • In the dev server against llama-server: with focus on the page body, typing "Hello there" put the full text in the chat form.
  • npm run check passes.

Requirements

A printable key pressed on the chat screen while no field, editor,
dialog or menu has focus now moves focus to the chat form, and the
character lands there.

Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur marked this pull request as ready for review November 18, 2026 23:05
@allozaur
allozaur requested a review from a team as a code owner November 18, 2026 23:05
@allozaur
allozaur merged commit 28de970 into ggml-org:master Nov 20, 2026
8 checks passed
Kidplayer666 pushed a commit to Kidplayer666/llama.cpp that referenced this pull request Nov 20, 2026
…2570)

A printable key pressed on the chat screen while no field, editor,
dialog or menu has focus now moves focus to the chat form, and the
character lands there.

Assisted-by: Claude (Opus 5.5 Medium)
Annieren pushed a commit to Annieren/llama.cpp-upstream that referenced this pull request Nov 23, 2026
…2570)

A printable key pressed on the chat screen while no field, editor,
dialog or menu has focus now moves focus to the chat form, and the
character lands there.

Assisted-by: Claude (Opus 5.5 Medium)
Nindaleth pushed a commit to Nindaleth/llama.cpp that referenced this pull request Nov 26, 2026
…2570)

A printable key pressed on the chat screen while no field, editor,
dialog or menu has focus now moves focus to the chat form, and the
character lands there.

Assisted-by: Claude (Opus 5.5 Medium)
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.

2 participants