Skip to content

Persist and replay desired mode across load fallback#46

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

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
Contributor

@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
Contributor 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.

@frankekn frankekn self-assigned this Mar 9, 2026
@vincentkoc
Copy link
Member

Superseded by #70, which merged desired-mode replay across load fallback into main on 2026-03-09.

@vincentkoc vincentkoc closed this Mar 9, 2026
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

3 participants