fix(desktop): stop history search after enough matches - #5524
Open
liuxiaocs7 wants to merge 2 commits into
Open
liuxiaocs7 wants to merge 2 commits into
liuxiaocs7 wants to merge 2 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?