Bound legacy resume preview scans (#39033)

## Why

Building a resume-picker preview for a legacy session should not require loading its full thread history.

## What changed

- Read up to six preview lines by scanning at most 1 MiB from the end of a local legacy rollout.
- Fall back to the existing history hydration path when the local file is unavailable, the bounded scan is incomplete, or the tail contains a rollback.
- Keep the initial `thread/read` request turn-free while loading the preview.

## Testing

Added coverage for compaction, rollbacks, oversized records, exhausted scan budgets, and app-server request parameters.

GitOrigin-RevId: a8950f03d8b56323f268fd3355c6a38a16cb9833
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-08-17 17:14:46 +00:00
1 parent dc473903ab
commit a8525b139c
3 files changed
+369 -15

No files matched your search

@@ -1123,6 +1123,21 @@ async fn paginated_workflows_never_request_full_thread_history() -> Result<()> {
assert!(!recorded_params(&requests, "thread/items/list").is_empty());
let previous_read_count = paginated_reads.len();
let preview = crate::resume_picker::load_transcript_preview(
&mut app_server,
legacy_thread_id,
Some(&app.config),
)
.await?;
assert!(!preview.is_empty());
let preview_reads = recorded_params(&requests, "thread/read");
let preview_include_turns = preview_reads[previous_read_count..]
.iter()
.map(|params| params["includeTurns"].as_bool().unwrap_or(false))
.collect::<Vec<_>>();
assert_eq!(preview_include_turns, vec![false]);
let previous_read_count = preview_reads.len();
crate::thread_transcript::load_session_transcript(
&mut app_server,
legacy_thread_id,