Skip to content

fix(webui): don't auto-focus program input on session switch (mobile keyboard)#617

Merged
edwin-zvs merged 1 commit into
mainfrom
fix-webui-program-mobile-keyboard
Jun 29, 2026
Merged

fix(webui): don't auto-focus program input on session switch (mobile keyboard)#617
edwin-zvs merged 1 commit into
mainfrom
fix-webui-program-mobile-keyboard

Conversation

@edwin-zvs

Copy link
Copy Markdown
Contributor

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 program contenteditable by 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 already program. This is a programmatic restore, not an edit intent, but it still called enterProgramMode(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 the selectSession path, using the existing opts.focus mechanism. 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.

One-line behavioral change (plus an explanatory comment).

Testing

  • cargo build — compiles clean (index.html is include_str!'d into the daemon; warnings are pre-existing and unrelated).
  • The fix is in crates/daemon/assets/index.html → relevant binary is construct (the daemon serves the embedded asset).

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.
@edwin-zvs
edwin-zvs merged commit 6a82877 into main Jun 29, 2026
1 check passed
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