Prompt to unarchive sessions before resuming or forking (#39640)

## Why

Starting an archived session with `codex resume` or `codex fork` stopped with
guidance to run a separate `codex unarchive` command first.

## What changed

- Detect archived-session startup failures and offer to unarchive and retry the
  requested operation.
- Allow the user to cancel without modifying the archived session.
- Render the confirmation in the alternate screen when available and preserve
  inline terminal context when `--no-alt-screen` is set.
- Preserve `--no-alt-screen` whether it appears before or after the `resume` or
  `fork` subcommand.

## Testing

- Cover confirmation, cancellation, retry behavior, and unrelated startup
  failures for both resume and fork.
- Add prompt interaction and terminal rendering coverage, including narrow and
  inline viewports.

GitOrigin-RevId: 382cdbd15b5d12c091e554d6d3a2f9b3589654f4
This commit is contained in:
Jeremy Rose authored and copyberry committed 2026-08-20 07:25:40 +00:00
1 parent fdc23b93b8
commit d944ce83a2
11 files changed
+736 -57

No files matched your search

-27
View File
@@ -6272,33 +6272,6 @@ fn active_turn_not_steerable_turn_error_extracts_structured_server_error() {
);
}
#[test]
fn session_start_error_surfaces_archived_guidance_without_rollout_path() {
let thread_id =
ThreadId::from_string("019e72f4-e09a-70f2-b2c2-a153a57b8cc0").expect("thread id");
let target_session = SessionTarget {
path: Some(std::path::PathBuf::from(
"/Users/me/.codex/archived_sessions/rollout.jsonl",
)),
thread_id,
history_mode: None,
};
let expected = format!(
"session {thread_id} is archived. Run `codex unarchive {thread_id}` to unarchive it first."
);
for action in ["resume", "fork"] {
let err = color_eyre::eyre::eyre!(
"thread/{action} failed during TUI bootstrap: thread/{action} failed: {expected} (code -32600)"
);
assert_eq!(
session_start_error(action, &target_session, err).to_string(),
expected
);
}
}
#[test]
fn active_turn_steer_race_detects_missing_active_turn() {
let error = TypedRequestError::Server {