Avoid paginated resume requests for verified legacy rollouts (#38604)

## Why

Resuming a known legacy rollout with `excludeTurns` first requires the TUI to
retry after the app server rejects paginated history loading.

## What changed

- Carry the history mode reported by the session picker into the resume flow.
- For embedded app-server sessions, resume a legacy rollout with its turns when
  the rollout is still legacy and background migration cannot race the check.
- Keep requesting paginated history when the picker metadata may be stale,
  migration is enabled or active, or the app server is remote.

## Testing

Added coverage for picker server replacement, background migration, maintenance
lock contention, stale history metadata, and paginated resume requests.

GitOrigin-RevId: 2300d1ad93a817eeeeb8f8ed60b073400ddf7106
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-08-14 16:33:28 +00:00
1 parent 588ee89324
commit 1bb6384c19
13 files changed
+455 -90

No files matched your search

@@ -1011,6 +1011,9 @@ impl App {
self.chat_widget.thread_name(),
self.chat_widget.rollout_path().as_deref(),
);
if let Some(history_mode) = target_session.history_mode {
app_server.remember_thread_history_mode(target_session.thread_id, history_mode);
}
match app_server
.resume_thread(
resume_config.clone(),
+7
View File
@@ -5820,6 +5820,7 @@ fn session_start_error_surfaces_archived_guidance_without_rollout_path() {
"/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."
@@ -6123,6 +6124,7 @@ async fn remote_resume_current_cwd_rejection_snapshot() -> Result<()> {
crate::resume_picker::SessionTarget {
path: None,
thread_id: ThreadId::new(),
history_mode: None,
},
)
.await?;
@@ -6165,6 +6167,7 @@ async fn remote_exec_resume_current_cwd_is_rejected() -> Result<()> {
crate::resume_picker::SessionTarget {
path: None,
thread_id: ThreadId::new(),
history_mode: None,
},
)
.await?;
@@ -6202,6 +6205,7 @@ async fn in_app_resume_session_cwd_without_metadata_is_non_fatal() -> Result<()>
crate::resume_picker::SessionTarget {
path: None,
thread_id: ThreadId::new(),
history_mode: None,
},
)
.await?;
@@ -6264,6 +6268,7 @@ async fn remote_resume_keeps_server_only_cwd_out_of_local_config() -> Result<()>
crate::resume_picker::SessionTarget {
path: Some(rollout_path),
thread_id: ThreadId::from_string(&thread_id)?,
history_mode: None,
},
)
.await?;
@@ -6382,6 +6387,7 @@ async fn in_app_resume_uses_configured_or_explicit_cwd() -> Result<()> {
crate::resume_picker::SessionTarget {
path: Some(rollout_path),
thread_id,
history_mode: None,
},
)
.await?;
@@ -6494,6 +6500,7 @@ async fn remembered_current_cwd_stays_at_launch_across_in_app_resumes() -> Resul
targets.push(crate::resume_picker::SessionTarget {
path: Some(rollout_path),
thread_id: ThreadId::from_string(&thread_id)?,
history_mode: None,
});
}
let state_db =
@@ -1064,6 +1064,7 @@ async fn paginated_workflows_never_request_full_thread_history() -> Result<()> {
)
.await?;
app_server.remember_thread_history_mode(paginated_thread_id, ThreadHistoryMode::Legacy);
let resumed = app_server
.resume_thread(
app.config.clone(),
@@ -1072,6 +1073,10 @@ async fn paginated_workflows_never_request_full_thread_history() -> Result<()> {
)
.await?;
assert_eq!(resumed.session.thread_id, paginated_thread_id);
assert!(recorded_params(&requests, "thread/read").is_empty());
let resume_requests = recorded_params(&requests, "thread/resume");
assert_eq!(resume_requests.len(), 1);
assert_eq!(resume_requests[0]["excludeTurns"], true);
let cells = crate::thread_transcript::load_session_transcript(
&mut app_server,
paginated_thread_id,
@@ -1542,6 +1547,7 @@ fn session_lifecycle_avoids_redundant_subagent_metadata_reads() -> Result<()> {
crate::resume_picker::SessionTarget {
path: Some(root_rollout_path),
thread_id: root_thread_id,
history_mode: None,
},
)
.await?;
+8
View File
@@ -19,6 +19,7 @@ fn startup_waiting_gate_is_only_for_fresh_or_exit_session_selection() {
crate::resume_picker::SessionTarget {
path: Some(PathBuf::from("/tmp/restore")),
thread_id: ThreadId::new(),
history_mode: None,
}
)),
false
@@ -28,6 +29,7 @@ fn startup_waiting_gate_is_only_for_fresh_or_exit_session_selection() {
crate::resume_picker::SessionTarget {
path: Some(PathBuf::from("/tmp/fork")),
thread_id: ThreadId::new(),
history_mode: None,
}
)),
false
@@ -39,10 +41,12 @@ fn startup_paused_goal_prompt_gate_is_only_for_quiet_resume() {
let resume = SessionSelection::Resume(crate::resume_picker::SessionTarget {
path: Some(PathBuf::from("/tmp/restore")),
thread_id: ThreadId::new(),
history_mode: None,
});
let fork = SessionSelection::Fork(crate::resume_picker::SessionTarget {
path: Some(PathBuf::from("/tmp/fork")),
thread_id: ThreadId::new(),
history_mode: None,
});
let no_images: Vec<PathBuf> = Vec::new();
let initial_images = vec![PathBuf::from("/tmp/image.png")];
@@ -111,6 +115,7 @@ fn startup_waiting_gate_not_applied_for_resume_or_fork_session_selection() {
crate::resume_picker::SessionTarget {
path: Some(PathBuf::from("/tmp/restore")),
thread_id: ThreadId::new(),
history_mode: None,
},
));
assert_eq!(
@@ -124,6 +129,7 @@ fn startup_waiting_gate_not_applied_for_resume_or_fork_session_selection() {
crate::resume_picker::SessionTarget {
path: Some(PathBuf::from("/tmp/fork")),
thread_id: ThreadId::new(),
history_mode: None,
},
));
assert_eq!(
@@ -268,6 +274,7 @@ async fn ignore_same_thread_resume_reports_noop_for_current_thread() {
let ignored = app.ignore_same_thread_resume(&crate::resume_picker::SessionTarget {
path: Some(test_path_buf("/tmp/project")),
thread_id,
history_mode: None,
});
assert!(ignored);
@@ -292,6 +299,7 @@ async fn ignore_same_thread_resume_allows_reattaching_displayed_inactive_thread(
let ignored = app.ignore_same_thread_resume(&crate::resume_picker::SessionTarget {
path: Some(test_path_buf("/tmp/project")),
thread_id,
history_mode: None,
});
assert!(!ignored);