Add code mode and speculation toggles to the `clai2` web UI, with a read-only `PluginHost.setting`

Merged
MP
2mo ago
+267-53

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 as run.code_mode, as /set KEY shows it. It raises KeyError for an unknown key or a host without settings. It's backed by a new CommandContext.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 for run.code_mode and run.speculative_code_mode. Each status update carries code_mode and speculation.

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_readable reads a setting, changes it through /set, and reads the new value.
  • tests/clai2/test_web.py::test_switches checks the status values, both switches through /set, and refuses (422) other keys. A host without settings reports None.
  • 77 tests pass across the web, host-input and plugin suites.
  • Headed Playwright against clai2 --web flipped each switch both ways, saw Code lock while Speculative was on, and restored the saved values (verified with clai2 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.