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

-25
View File
@@ -682,31 +682,6 @@ fn active_turn_steer_race(error: &TypedRequestError) -> Option<ActiveTurnSteerRa
Some(ActiveTurnSteerRace::ExpectedTurnMismatch { actual_turn_id })
}
fn session_start_error(
action: &str,
target_session: &SessionTarget,
err: color_eyre::eyre::Report,
) -> color_eyre::eyre::Report {
if let Some(message) = archived_session_guidance(&err) {
return color_eyre::eyre::eyre!("{message}");
}
let target_label = target_session.display_label();
color_eyre::eyre::eyre!("Failed to {action} session from {target_label}: {err}")
}
fn archived_session_guidance(err: &color_eyre::eyre::Report) -> Option<String> {
let err = err.to_string();
let message = &err[err.find("session ")?..];
if !message.contains(" is archived. Run `codex unarchive ") {
return None;
}
let message = message
.split_once(" (code ")
.map_or(message, |(message, _)| message);
Some(message.to_string())
}
fn active_turn_interrupt_race(error: &TypedRequestError) -> Option<String> {
let TypedRequestError::Server { method, source } = error else {
return None;