fix(desktop): stop history search after enough matches - #5524
liuxiaocs7 wants to merge 3 commits into
Conversation
Read transcript pages in search order and stop once the result budget is met, retaining cancellation, truncation and read-failure behavior. Fixes apache#5523 Refs apache#2913, apache#4677 Generated-by: Codex
Keep the implementation and regression tests in the pull request. Generated-by: Codex
Keep the Host Recall search replacement introduced by apache#5531 and remove the obsolete local-scan implementation and its pagination regression tests. The resolved tree matches origin/main at 1c18700. Preserve both branches' commit history. Generated-by: Codex
|
Closing this PR as superseded by #5531. #5531 replaced Desktop's local transcript scan with Host-side Recall and removed the implementation that this PR optimized. After merging the latest main and resolving those deletions in favor of the new architecture, this branch has no file differences from main; merging it would add no code changes. The original commits remain in the branch history. This does not mean that the early-stop optimization in this PR was merged, or that all equivalent performance concerns are resolved. We will separately investigate whether the new Recall path still loads complete candidate transcripts before applying the result limit. This closure is not evidence that #5523 is fixed. Posted by Codex on behalf of @liuxiaocs7. |
Summary
Desktop history search currently waits for
loadTranscript()to decode an entire conversation before checking any content. A 20,000-message transcript with a match in the oldest message still costs 20,000 decodes and 78 additional page requests even withlimit=1.Consume oldest-first message pages at the opening watermark and stop as soon as the global result or snippet budget is met. Reuse a complete small bootstrap, preserve source sequence identities, and close the search-owned handle on completion or cancellation. Preserve title priority, filtering and redaction, truncation at page boundaries, and rollback of a session's content hits on ordinary read failure. The existing Host protocol and shared page decoder are reused.
Fixes #5523
Refs #2913, #4677
Verification
The real IPC → matcher → subscription → Host pager/decoder regression in
apps/desktop/src/main/__tests__/thread-search-pagination.test.tsfailed before the fix (20000 !== 256) and now passes. It uses synthetic storage/transport; the counts below do not measure production wall-clock latency:npm run lint,npm run build,npm run typecheck, both Desktop/UI Knip checks, and commit hooks. Formatting passes for all Git-tracked files; the broadnpm run format:checkencounters 16 unrelated, pre-existing untracked investigation files in the local workspace.npm testcompleted but was not green. Shell PATH, executor cancellation and peer-invitation failures passed isolated reruns. Storage's child-readiness check passed withNODE_NO_WARNINGS=1; Eval passed on Python 3.12 (87 tests, 12 skipped) after the default Python 3.9 failed. Runtime Host'sproduction Host publishes and retires an implementation child patchstill fails in isolation withHosted real-model Turn did not become terminal; that test does not exercise the modified search path. This PR does not claim a clean full-suite run.No-match and insufficient-match queries still require a full scan. Retaining the tail bootstrap before the forward scan makes the 20,000-message full-scan fixture use 79 extra requests instead of 78, about 16 KiB more raw data. The 256-message early-hit result is specific to the small-message fixture; completing a fragmented message may need continuation requests. Host-local search remains separate work under #2913.
AI use
Tool(s) and scope: Codex diagnosed and implemented the change, wrote regression tests, ran verification, and prepared/submitted this contribution on behalf of @liuxiaocs7. The commits contain
Generated-by: Codex; retain it in the squash commit.Checklist
Does this PR entail a change in behavior?