fix(documents): recount facets against the current selection, and capture five search-filter findings - #1526
Conversation
…nd work PR #1523 shipped the band changes; these are what it deliberately left out, plus two defects found while tracing the filter pipeline. All five existed only in a chat session until now. - #169 phone filter controls render inline in a scrolling rail; the repo already has the right primitive in ui/sheet.tsx, so this is adoption - #170 documents mode has four overlapping filtering surfaces, and two of them are the same job — the source-type control duplicates the Document type facet group, and "Tables" appears in both it and the scope chips - #171 Sources sits in the results bar but is navigation, not a filter; it is also documents-mode only, so it can never be a fixture of a shared band - #172 facet counts come from `matches` while format counts come from `visibleMatches`, so half the filter panel goes stale on first selection and points at combinations that return nothing - #173 facets AND within a group, so two values from one group almost always return zero; flagged as a product decision rather than changed Numbered #169-#173 after main took #165-#168 while these were being written — the read-modify-write allocation race #156 already records. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Akwz3Sdms8uJ5AkDt3CduY
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in:34 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThe PR adds selection-aware smart-tag facet projection, uses it in document search results, adds fixture-driven tests, and updates the outstanding-issues ledger. ChangesSelection-aware facet projection
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Facet counts were built once against the whole match set and never revised. Selections AND together, so the moment one was applied every other facet was still reporting a number for a set the reader was no longer looking at — and some of those numbers pointed at combinations that return nothing, which reads as a live option and behaves as a dead end. `projectSmartTagFacetGroups` re-counts an already-built index against the live selection. Each count now answers the question the row actually poses: how many documents you would have if you ticked this as well. A facet that is already selected reports the current result count, because that is what it is giving you. Membership and order are deliberately preserved rather than re-sorted by the new counts: re-sorting would make rows jump under the pointer while selecting, and re-slicing to the top N could drop a facet already ticked. A facet whose count falls to zero stays in place at zero so the caller can disable it — removing it makes the list jump and hides the reason it went away. The projection is a no-op returning the same array identity when nothing is selected, so the unfiltered path is unchanged. Tests: six cases covering the stale count, the selected-facet count, the dead-end combination driven to zero, agreement between each count and the filter it describes, and stability of membership and order. Verified by mutation — neutering the projection fails three of them. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Akwz3Sdms8uJ5AkDt3CduY
BigSimmo
commented
Jul 31, 2026
@cursoragent resolve merge conflict and fix any issues and run bugbot |
Merge conflict on PR #1526 is resolved and the branch is Conflict: only Follow-up fix: zero-count unselected tag facets are now Bugbot: no Tip: |
BigSimmo
commented
Jul 31, 2026
Note for whoever resolves this — the conflict is a single file and it is one with a documented resolution protocol that a generic merge will get wrong. Branch is behind by 1. No code file conflicts — Why this file is special. It deliberately has no merge driver — How it must be resolved (this is
Prior evidence that this is not theoretical: a GitHub Update branch auto-merge on PR #1451 produced two rows numbered I have not pushed a resolution, to avoid two agents writing the same branch ( Generated by Claude Code |
projectSmartTagFacetGroups leaves dead-end facets visible at count 0 so the rail does not jump; the rail now disables those buttons so they cannot be selected. Selected facets stay clickable so filters can be cleared. Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/components/clinical-dashboard/document-search-results.tsx`:
- Around line 925-932: Update the facet-button configuration passed to
DocumentTagFacetRail so unselected facets with a projected count of zero are
disabled, using tagFacetGroups from projectSmartTagFacetGroups. Keep selected
facets enabled regardless of count so users can remove them, and preserve
existing behavior for nonzero or selected facets.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7317fd19-86d8-4db5-82e8-e5c093b529de
📒 Files selected for processing (4)
docs/outstanding-issues.mdsrc/components/clinical-dashboard/document-search-results.tsxsrc/lib/document-tags.tstests/document-tags.test.ts
Uh oh!
There was an error while loading. Please reload this page.
BigSimmo
commented
Jul 31, 2026
@cursoragent Work this open PR (confirm number + GitHub head first). Start from Goal: review + Bugbot the tip, fix actionable issues with smallest changes, clear merge/required-CI/thread blockers, push fixes, post one PR summary. Stay light — no full local If the PR is already MERGED or CLOSED: confirm head + merge commit, note required-CI outcome, post one summary, and stop.
Stop when merge-tree clean, no actionable threads left, and required checks are green or clearly in progress on the current tip. |
PR #1526 · tip Done
CIRequired checks re-running on Residual
|
Sync PR policy body was overwriting this PR's description with leftover Sentry/RAG template text from main (#1478). Point the template at the actual facet-recount work so CI can sync an accurate body. Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
PR #1526 review+bugbot+fixTip: Fixed
Dispositioned / no action
Required CI (on |
🔒 Upgrade RequiredPrivate repository analysis requires Pro or Enterprise. Upgrade: https://ecc.tools/pricing?plan=pro ECC Tools keeps the core app open, and puts private repos, team features, and enterprise controls behind paid tiers. |
Uh oh!
There was an error while loading. Please reload this page.


Summary
Two product commits plus a
mainmerge that renumbered the ledger, and a small follow-up that disables dead-end facets.cf5d7cdf— fix the stale facet counts (archived as#173).buildSmartDocumentTagFacetIndexcounted every facet once against the whole match set and never revised it. Selections AND together (filterDocumentsBySmartTagFacetIndex), so the moment one facet was applied every other one still reported a number for a set the reader was no longer looking at — and some pointed at combinations returning nothing.projectSmartTagFacetGroups(index, selectedTagKeys)re-counts an already-built index against the live selection. Each count answers: how many documents would I have if I ticked this as well? An already-selected facet reports the current result count.a919bf98— capture five search-filter findings indocs/outstanding-issues.md. After mergingmain(which claimed#169for unpushed local branches), these are#170–#174: phone filter sheet, four overlapping filtering surfaces,Sourcesas navigation, the stale-count defect (archived#173), and AND-within-group as a product decision.9f6cf337— mergemain, resolving the outstanding-issues id collision without dropping either side's rows.51eae876— disable zero-count unselected facet buttons in the documents tag rail so dead-end combinations cannot be selected.Verification
npm run verify:cheap— exit 0 (Test Files 449 passed,Tests 4697 passed | 4 skipped)npm run typecheckclean;npm run formatrun and committedtests/document-tags.test.ts— 16 passed (six new projection cases; mutation-verified)npm run check:outstanding-issues—172 rows (56 open, 116 archived),next-id=175git merge-tree --write-tree origin/main HEADclean; GitHubmergeable: MERGEABLEProduction UIgates in CIRisk and rollout
filterDocumentsBySmartTagFacetIndexis unmodified.RAG impact: no retrieval behaviour change — display/disable of facet counts only; no
src/lib/rag/**, clinical-search, retrieval-selection, ranking, eval, or golden fixture changes.Clinical Governance Preflight
Clinical KB Database(sjrfecxgysukkwxsowpy)Presents counts over an already-retrieved result set. No retrieval, ranking, or source-selection change. More conservative: dead-end facets report zero and cannot be selected.
Notes
Batch A from PR #1523. Still outstanding after renumber:
#171+#172— merge the four filtering surfaces; moveSourcesto nav as Browse library#170— adoptui/sheet.tsxfor phone filter controls#174— OR-within-group product decisionThis file is a CI sync template only. A follow-up commit on this branch deletes it so squash-merge does not leave a leftover body template on
main.