# 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. ## Deployment (2026-10-25, user: "do it now") - Backup: `~/.local/share/pipelines/backups/modes-20261025-151900/` (bin, lib, manifest, SQLite `.backup`, integrity ok, 133 operator chats). - `./install --web-port 8083` succeeded (existing DB/auth/ntfy kept). No runs were executing; one chat had just answered a permission, and the user had accepted interrupting in-flight turns. Managed server restarted 15:34:59; ping reports commit f57c8023 (dirty: untracked `.claude/` plus uncommitted formatter-only files). Live `chat_sessions` rows carry mode/mode_name for codex, opencode and claude; `chat_modes` returns the five Claude modes. - Public web root `app/build/web` swapped to the installed bundle (updates/ kept); rollback `app/build/web-before-modes-*`. 8443/8096 serve the new main.dart.js. - APK **0.1.29882413** (SHA256 `22080fcbf5f09b2110ba27a93b61add235fb701fddea779cf7330cacc44f4888`) published to the installer feed and to `app/build/updates` + `app/build/web/updates` (rollback `*-before-modes-29882413`); authenticated downloads verified on 8443 and 8096. No live mode switch was exercised and no device was used.