Repository navigation
fix(cli): preserve session state across reopen - #1315
Merged
XuPeng-SH merged 2 commits intoNov 17, 2026
Merged
Conversation
Contributor
|
This pull request is merged. |
Recover all terminal facts in one pass instead of inferring session lifetime from the first successful canonical commit. Reopening a failed-only session must not reuse its allocated turn.
7 tasks
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.
Capability assessment: Unchanged: CLI continuation already owns terminal-state recovery; this corrects its existing local journal semantics without adding capabilities or changing runtime profiles.
Summary
Reopening a CLI session discarded terminal facts before the latest session-start marker. A committed conversation at turn 5 could then reject the next response as turn 1. A failed-only session also reset from turn 1 to 0 and reused the failed turn's number.
Recover all successful and failed terminal facts for the same session ID in one pass. Turn allocation, display history, usage, recent tools and the last terminal event now share that recovery scope. Start/end markers describe attachments; a genuinely new session uses a new ID.
Related issue
Closes #1314
Change type
User and compatibility impact
Reopening after success or a first-turn failure preserves local recovery facts and permits the next response to commit. Untyped historical journals also retain earlier facts across reopen markers; allocation stays above their highest recorded turn even if an older process restarted its counter. No journal rewrite, format migration, configuration or API change is required.
Display history remains separate from canonical model messages. Existing canonical validation, account/privacy boundaries and independent local/Server clocks still apply.
Architecture and complexity delta
session_runtime::restored_journal_state_from_append_order_events.Verification
make format-check CARGO_NET_OFFLINE=true make lint git diff --check env -u NO_COLOR cargo nextest run --locked --offline -p astra-cli --lib --profile ci \ -E 'test(cli::session::) | test(cli::slash::slash_session::resume_tests::) | test(cli::turn::turn_entry::) | test(cli::turn::turn_commit::) | test(cli::turn::turn_success::) | test(tests::resume_tests::)'All static checks passed, including workspace Clippy with warnings denied. The offline selection passed 331/331 tests. Three updated recovery/admission regressions first failed on the previous implementation and then passed with this change.
Final checklist