Batch persistent history reads during reverse search (#33905)

## Why

Reverse search fetched persistent history one entry at a time, making a deep or unsuccessful search require a lookup for every older entry.

## What changed

- Keep the newest-entry probe lightweight, then scan older persistent history in bounded batches.
- Cache batch results by absolute offset and preserve continuation cursors across repeated searches.
- Ignore stale responses, retry failed batch reads a bounded number of times, and restore the draft without reporting a false “no match” state when history is unavailable.

## Testing

- Cover batch continuation, caching after query changes or cancellation, stale metadata, retry exhaustion, and thread routing.
- Verify that scanning 1,024 entries uses one single-entry lookup and eight batch lookups.

GitOrigin-RevId: efc791fcbd5290050af703dd31c5c21b33240e23
This commit is contained in:
Charlie Marsh authored and copyberry committed 2026-07-17 21:16:07 +00:00
1 parent 025db22058
commit 7ed19a9758
13 files changed
+965 -107

No files matched your search

@@ -182,7 +182,7 @@ async fn replayed_user_messages_seed_composer_history() {
};
offset
};
let response = |offset, entry: &str| HistoryLookupResponse {
let response = |offset, entry: &str| HistoryLookupResponse::Entry {
offset,
log_id: 1,
entry: Some(entry.to_string()),