feat(chat): per-chat permission modes for Claude, Codex and OpenCode

This commit is contained in:
2026-10-24 18:16:10 +01:00
parent ef575898f2
commit 6d430948a6
29 changed files with 1512 additions and 3 deletions
+42
View File
@@ -0,0 +1,42 @@
# Chat permission modes
User request (2026-10-24): change a chat to auto mode instead of plan/ask, for
Claude, Codex and OpenCode. Server and app change (user authorized the server).
## Server
- Protocol: `chat_modes` (ChatQuery → `chat_modes` list + current `chat_mode`)
and `chat_mode` ({session_id, mode} → echoed stored mode). `ChatSession` rows
carry `mode` and `mode_name` (the harness default, listed first, when none was
chosen).
- Stored in `operator_sessions.chat_mode` (additive migration); re-applied to the
harness before every turn, so a server restart keeps the choice.
- Claude: default (ask), acceptEdits, plan, auto, bypassPermissions. A new CLI
starts with `--permission-mode`; a running one switches in place with the
`set_permission_mode` control request (verified present in CLI 2.1.310).
`dontAsk` is omitted on purpose.
- Codex: ask (on-request + workspaceWrite), auto (never + workspaceWrite), full
(never + dangerFullAccess), sent as turn/start `approvalPolicy`/`sandboxPolicy`
(checked against codex 0.163.0's app-server schema).
- OpenCode: build / plan agents, sent as the prompt's `agent` (v2 body and the v1
native translation).
## App
`ChatModeControl` in the chat bar shows the row's `mode_name` without a request
(client requests are serialized, so an eager read would delay history), and reads
`chat_modes` only when tapped. Native sheet / action sheet with descriptions; a
refusal stays in the picker. Accepted switches update the opened row.
## Evidence
- Go: new tests for storage, Claude (spawn flag, live switch, default omits the
flag), Codex turn overrides, OpenCode agent on v1/v2 prompts, server
store/apply/restart. Full `go test ./...` passes except two tests that already fail
on main in this environment (umask 077 file-permission checks, and
`TestHumanRunAttentionNotification` picking up the host's real web URL).
- App: `chat_mode_control_test.dart`; analyze clean; full suite 1,867 pass.
- Browser: `tool/chat_mode_probe.mjs` (fixture gained chat_modes/chat_mode),
Material and Cupertino at 1280: `build/chat-mode-probe/`.
- Not verified against live Claude/Codex/OpenCode processes. The server isn't
deployed yet and no device was used.