Fix SidebarSearch debounce reset and stale-response race - #97
Merged
Conversation
Found via /code-review while working on an unrelated docs PR (it scanned the whole repo since that branch had no code diff of its own) — both issues checked out as real against the actual merged code, independent of the review's wrong line numbers. - getPage's identity changes on every commit anywhere in the workspace (WorkspaceContext replaces the `pages` array on each updatePageBlocks/updatePageTitle), not just when search-relevant state changes. It was in the debounce effect's deps, so typing in the main editor while a search was pending kept resetting or double-firing the debounce — burning calls against the budgeted search endpoint for no new input. Fixed by reading it through a ref (the standard "latest ref" pattern) instead, so the effect only depends on `query`. - searchNotes results had no staleness guard, unlike the sibling RelatedPagesSection's `cancelled` flag. A slower in-flight request for an old query could resolve after a newer, faster one and silently overwrite its correct results. Added the same guard. Both regression tests fail against the pre-fix code (verified via git stash) and pass against the fix. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
PR guideAuto-generated from changed paths. Fill in Summary and How to verify in the PR description above. Touches: app shell / routes, tests Diff: 2 files changed, 159 insertions(+), 2 deletions(-) Suggested verify
Checklist (applies to this PR)
Reviewer focus
Commits
Files by area
CIPrimary check: CI runs lint, Prettier format check, Vitest coverage, and build for every PR. Coverage tables are posted separately. Template: |
|
Unit tests (Vitest)
Minimum allowed coverage is Generated by 🐒 cobertura-action against dcc3575 |
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
Found via `/code-review` while working on the docs PR (#96) — it scanned the whole repo since that branch had no code diff of its own, and surfaced two real issues in already-merged `SidebarSearch.tsx` (from #94), independent of the review's incorrect line-number citations. Verified both against the actual file before fixing.
Both new regression tests fail against the pre-fix code (verified via `git stash`) and pass against the fix — not just asserting the code does what it does.
Test plan
🤖 Generated with Claude Code