Skip to content

Persist and replay desired mode across load fallback#46

Open
z-x-yang wants to merge 1 commit intoopenclaw:mainfrom
z-x-yang:codex/persist-mode-across-fallback
Open

Persist and replay desired mode across load fallback#46
z-x-yang wants to merge 1 commit intoopenclaw:mainfrom
z-x-yang:codex/persist-mode-across-fallback

Conversation

@z-x-yang
Copy link

@z-x-yang z-x-yang commented Mar 4, 2026

Summary

Fix mode loss across reconnect when session/load falls back to session/new.

This persists the user's desired mode at the ACPX session-record layer and replays it on fresh ACP sessions created during fallback.

Changes

  • Added SessionAcpxState.desired_mode_id persistence support.
  • Added src/session-mode-preference.ts helpers to normalize/read/write desired mode.
  • Persist desired mode after successful:
    • set-mode <mode>
    • set mode <value>
      including queue-owner control paths.
  • In connectAndLoadSession, when fallback creates a fresh ACP session, replay desired_mode_id via session/set_mode.
  • Added verbose diagnostics for replay success/failure.

Tests

Added/updated tests:

  • test/cli.test.ts
    • set-mode persists across load fallback and replays on fresh ACP sessions
  • test/session-conversation-model.test.ts
    • clone preserves desired_mode_id
  • test/session-persistence.test.ts
    • persisted records preserve desired_mode_id
  • test/mock-agent.ts
    • added minimal setSessionMode / setSessionConfigOption support for mode/config replay scenarios

Validation run locally:

  • npm run format:check
  • npm run build:test
  • node --test dist-test/test/session-conversation-model.test.js
  • node --test dist-test/test/session-persistence.test.js
  • node --test --test-name-pattern='set-mode persists across load fallback and replays on fresh ACP sessions' dist-test/test/cli.test.js

Fixes #45.

@z-x-yang
Copy link
Author

z-x-yang commented Mar 4, 2026

Related upstream Codex ACP work for full plan-mode interoperability:

This ACPX fix is still independently useful because ACPX is where reconnect fallback (load -> new) is handled and where session continuity is scoped.

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.

Session mode is lost when loadSession falls back to new session

1 participant