Add code mode and speculation toggles to the `clai2` web UI, with a read-only `PluginHost.setting`
Merged
MP
2mo ago+267+267+012345678901234567890123456789-53-53-01234567890123456789
Part 8 of the clai2 web UI stack (… → #10275 → this PR). Based on #10275. No linked issue: requested by the CLAI maintainer.
Why. Turn code mode and speculative execution on and off from the web UI, as /set and Ctrl+X Ctrl+S do in the terminal.
New public surface
PluginHost.setting(key) -> JsonValue, read-only: the effective value of a CLAI setting, such asrun.code_mode, as/set KEYshows it. It raisesKeyErrorfor an unknown key or a host without settings. It's backed by a newCommandContext.setting. Writing goes through the prompt, as the user would:send_input('/set KEY VALUE'). So there is no second way to change settings.- Web plugin:
POST /api/switch {key, on}, allowed only forrun.code_modeandrun.speculative_code_mode. Each status update carriescode_modeandspeculation.
User-visible behavior. The composer bar gets Code and Speculative toggles, lit in Lithium when on. While speculation is on, Code shows on and locked, since speculation turns code mode on for its runs. While a turn runs, the tooltip says the change applies from the next prompt, because the running turn keeps its tools.
Verification.
tests/clai2/test_host_input.py::test_settings_are_readablereads a setting, changes it through/set, and reads the new value.tests/clai2/test_web.py::test_switcheschecks the status values, both switches through/set, and refuses (422) other keys. A host without settings reportsNone.- 77 tests pass across the web, host-input and plugin suites.
- Headed Playwright against
clai2 --webflipped each switch both ways, saw Code lock while Speculative was on, and restored the saved values (verified withclai2 config get).
What changes for existing users. Nothing until they enable web. host.setting is new and opt-in.
- 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.