fix(webui): don't auto-focus program input on session switch (mobile keyboard)#617
Merged
Merged
Conversation
Switching to a session whose view mode is Program called
enterProgramMode(id) without options, which focuses the program
contenteditable by default. On mobile browsers, programmatic .focus()
on a contenteditable pops the native keyboard, so every switch to a
Program-view session brought up the keyboard even though the user
never tapped to edit.
Pass { focus: false } from selectSession so the programmatic restore
no longer auto-focuses. Focus still happens on explicit user gestures:
tapping the view-mode toggle (switchCurrentViewMode keeps focusing) or
tapping the program input directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
On the mobile web UI, switching to a session whose view mode is Program brought up the native on-screen keyboard on every switch — even though the user never tapped to edit anything. Expected: switching to a Program-view session should show the program, but the keyboard should only appear when the user explicitly taps the program input to start editing.
Root cause
enterProgramMode(id, opts)focuses the programcontenteditableby default (opts.focus !== false → programInputEl.focus()). It's called from two places:switchCurrentViewMode("program")— fired by the user tapping the view-mode toggle button. This is a genuine user gesture, so focusing is intended.selectSession(id)— fired when switching to a different session whose mode is alreadyprogram. This is a programmatic restore, not an edit intent, but it still calledenterProgramMode(id)with no opts, so it auto-focused.On mobile browsers, a programmatic
.focus()on a contenteditable pops the native keyboard. So the session-switch path popped the keyboard every time.Fix
Pass
{ focus: false }from theselectSessionpath, using the existingopts.focusmechanism. The programmatic restore no longer auto-focuses; focus still happens on explicit user gestures:switchCurrentViewModekeeps focusing), orOne-line behavioral change (plus an explanatory comment).
Testing
cargo build— compiles clean (index.htmlisinclude_str!'d into the daemon; warnings are pre-existing and unrelated).crates/daemon/assets/index.html→ relevant binary isconstruct(the daemon serves the embedded asset).