Persist session mode overrides across server restarts#176
Open
zerone0x wants to merge 1 commit intozed-industries:mainfrom
Open
Persist session mode overrides across server restarts#176zerone0x wants to merge 1 commit intozed-industries:mainfrom
zerone0x wants to merge 1 commit intozed-industries:mainfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Fixes #172
session/set_modecurrently 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(andsession/set_config_optionwithconfig_id=="mode")→ the chosen mode ID is persisted, keyed by the session's project CWD.
On
new_sessionandload_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) —ModeOverrideStorestruct withget(cwd)/set(cwd, mode_id)src/codex_agent.rs— wire up persistence inset_session_mode/set_session_config_option, replay innew_session/load_sessionsrc/lib.rs— declare new module🤖 Generated with Claude Code