Make `/theme` work in the `clai2` web UI
Merged
MP
2mo ago+359+359+012345678901234567890123456789-66-66-01234567890123456789
Part 9 of the clai2 web UI stack (… → #10276 → this PR). Based on #10276. No linked issue: requested by the CLAI maintainer.
Why. Make /theme work in the web UI, so the browser follows the palette the terminal uses.
What changes
- The web plugin sends the
/themechoice in its snapshot, plus aThemeChangedmessage when a command changes it: the name, the available names, and the termflow palette (bg,fg, 16 ANSI slots). It reads the choice withhost.setting('display.theme')from #10276. - The browser paints a palette with the same slot for each role as the terminal (
ui/rendering/theme.py): accent from slot 12, errors 1, thinking 5, success 14, warnings 3. Diff lines blend green and red into the background at 28%, asdiff_themedoes. The page's mode follows the palette's brightness, as_is_lightdecides. defaultkeeps Pydantic's colours and the light/dark toggle. A palette hides the toggle, since it fixes the mode.- The sidebar footer has a theme picker that sends
/theme NAME. A bare/themetyped in the browser still opens the terminal's picker, so the footer is the browser's way to pick.
New public surface. None (web plugin wire fields only).
Verification.
tests/clai2/test_web.py::test_themechecks the default theme and the list of names, then/theme tokyo_nightarriving as aThemeChangedwith its palette. It also checks that a command which doesn't change the theme sends nothing.- A host without settings reports
default. - 65 tests pass across the web, built-in plugin and startup-import suites.
- Headed Playwright against
clai2 --webpickedtokyo_night,github_lightandcatppuccin_latte, then typed/theme rose_pine_dawn. The page's computed background, text, sidebar and send button matched each palette, and the saved theme was restored. No page errors.
What changes for existing users. Nothing until they enable web.
- 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.