Focus the `clai2` web UI composer after switching sessions

Merged
MP
1mo ago
+101-47

Fixes #11283

Why we make these changes

After you click a session in the web UI sidebar, focus stays on the sidebar row, so whatever you type goes nowhere. The composer only focused itself on mount, and switching sessions keeps it mounted. Now, once the picked session shows, App focuses the co... [truncated]

New public surface

none

User-visible behavior

Before: click session B in the sidebar, wait, type: nothing is entered.
After: the keystrokes go into session B's prompt box.

Verification

  • New Playwright case test_switching_sessions_focuses_the_composer in tests/clai2/browser/test_web_browser.py. It checks that the composer is focused after a switch and that typing lands in it. It also holds the /open request, moves focus to the sess... [truncated]
  • app.js rebuilt from source with npm run build (Node v24.22.1) after each rebase onto main; tests/clai2/test_web_assets.py passes.
  • tests/clai2/test_web*.py (64 passed), ruff, pyright and pre-commit pass on the changed files.
  • Browser tests could not run reliably on this machine. In the WSL headless Chromium shell, requestAnimationFrame never fires, so Playwright clicks time out. Before the rebase, one run of the browser suite passed (4 passed), but later runs were flaky... [truncated]

What changes for existing users

Picking a session from the sidebar now puts the cursor in its prompt box.

Checklist

  • No breaking changes in accordance with the version policy.
  • Any permitted compatibility impact has a label, warning, migration and release note, and an exact API-check waiver if the gate reports it.
  • PR title is fit for the release changelog.