Show a loading spinner while the `clai2` web UI opens a session

Merged
MP
2mo ago
+180-84

Part 12 of the clai2 web UI stack (… → #10282 → this PR). Based on #10282. No linked issue: requested by the CLAI maintainer.

Why. Clicking a session in the sidebar showed nothing until it opened: first the transcript loads, then the shell runs /resume and the new state arrives over the WebSocket. Whenever that took a moment, the app looked frozen.

What changes (web UI only, no Python changes)

  • While a session opens: the clicked sidebar row shows a spinner, and the main pane shows "Opening title…" over the old conversation. Both fade in only after 120 ms, so a quick switch never flashes them.
  • When the wait ends: when the shell switches to that session, when a read-only preview arrives, on an error (shown in the toast), or after 15 s if the shell never switches.
  • Rapid clicks: only the last session clicked opens; earlier transcript requests that resolve late are ignored.
  • "Continue here" on a preview uses the same path, so it shows the spinner too and reports a failure instead of an unhandled rejection.

Verification.

  • tsc --noEmit and npm run build are clean. The bundle is rebuilt.
  • Headed Playwright against clai2 --web, with transcript requests delayed by 1.5 s in the page:
    • the overlay ("Opening FizzBuzzWuzz in Go…") and the row spinner showed, then both went away once the session opened;
    • clicking two sessions 300 ms apart opened the second;
    • without the delay, the overlay was never visible during an open (polled every 5 ms).
    • No page errors.
  • Timing without the delay: opening a session takes 0.1–0.3 s and previewing one (up to a 1 MB transcript) under 0.25 s, with both the test model and a real one.

What changes for existing users. Only the web UI, as above.

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