Skip to content

Persist session mode overrides across server restarts#176

Open
zerone0x wants to merge 1 commit intozed-industries:mainfrom
zerone0x:persist-session-mode-overrides
Open

Persist session mode overrides across server restarts#176
zerone0x wants to merge 1 commit intozed-industries:mainfrom
zerone0x:persist-session-mode-overrides

Conversation

@zerone0x
Copy link
Contributor

@zerone0x zerone0x commented Mar 5, 2026

Why

Fixes #172

session/set_mode currently applies the chosen mode only to in-memory thread state. After an ACP server restart or session reload the mode resets to its default, requiring every client to re-apply the mode on reconnect. This creates confusing mode drift in persistent orchestration flows.

What this PR does

Introduces src/mode_overrides.rs — a lightweight, non-fatal store that reads and writes $CODEX_HOME/acp/session-mode-overrides.v1.json.

On session/set_mode (and session/set_config_option with config_id=="mode")
→ the chosen mode ID is persisted, keyed by the session's project CWD.

On new_session and load_session (after thread init / history replay)
→ any stored override for that CWD is replayed via Thread::set_mode, so the thread starts with the client's last explicit choice.

Storage file format:

{
  "/home/user/myproject": "auto",
  "/home/user/other":     "full-access"
}

Error handling: parse/write errors emit a warn! log and are otherwise non-fatal; the session continues with the default mode.

Changes

  • src/mode_overrides.rs (new) — ModeOverrideStore struct with get(cwd) / set(cwd, mode_id)
  • src/codex_agent.rs — wire up persistence in set_session_mode / set_session_config_option, replay in new_session / load_session
  • src/lib.rs — declare new module

🤖 Generated with Claude Code

When a client calls session/set_mode or session/set_config_option with
config_id="mode", the chosen mode ID is now written to
$CODEX_HOME/acp/session-mode-overrides.v1.json (keyed by project CWD).

On new_session and load_session the stored override is replayed after the
thread is initialised, so the client's last explicit mode choice survives
ACP server restarts without requiring the client to re-apply the mode on
every reconnect.

Storage is non-fatal: parse/write errors are logged as warnings and the
session continues with the default mode.

Fixes zed-industries#172

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Persist session mode across reconnect/load

1 participant