Skip to content

feat: polish result surfaces and add URL-backed sorting#560

Merged
BigSimmo merged 7 commits into
mainfrom
codex/result-sorting-design-polish
Jul 13, 2026
Merged

feat: polish result surfaces and add URL-backed sorting#560
BigSimmo merged 7 commits into
mainfrom
codex/result-sorting-design-polish

Conversation

@BigSimmo

Copy link
Copy Markdown
Owner

Summary

  • add shared Relevance and A–Z result sorting for documents, services, forms, and differentials
  • persist the non-default selection as sort=alpha and restore it through browser history
  • migrate fullscreen clinical tables to the shared Sheet focus/escape/return-focus behavior
  • raise meaningful production metadata to the design-system type floor and preserve current responsive result-card behavior
  • expose an optional Sheet test identifier on the actual dialog surface

Why

Long result lists needed a compact known-item ordering option, and the previous table fullscreen implementation duplicated modal behavior and allowed its test surface to diverge from the actual dialog root.

Validation

  • npm run test -- tests/result-sort.test.ts (3 passed)
  • npm run typecheck
  • targeted ESLint
  • npm run check:type-scale
  • Chromium sorting/history test (1 passed)
  • Chromium clinical-table expansion/focus tests at 390, 768, and 1280 px (3 passed)
  • Prettier and git diff --check
  • offline npm ci reported 0 vulnerabilities

No provider-backed API checks were run.

@supabase

supabase Bot commented Jul 13, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy because there are no changes detected in supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8ab40531-4c20-4a77-81d3-e768528fc9d9

📥 Commits

Reviewing files that changed from the base of the PR and between e64c38b and 5102846.

📒 Files selected for processing (4)
  • src/components/AccessibleTable.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/services/services-navigator-page.tsx
  • tests/ui-smoke.spec.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/components/clinical-dashboard/master-search-header.tsx
  • tests/ui-smoke.spec.ts
  • src/components/services/services-navigator-page.tsx
  • src/components/AccessibleTable.tsx

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added relevance and alphabetical sorting for clinical, forms, and services search results.
    • Sorting preferences persist in the URL and across browser navigation.
    • Improved fullscreen clinical-table expansion with consistent focus handling and accessibility.
  • Improvements

    • Increased readability and contrast across labels, badges, metadata, and compact mobile interfaces.
    • Removed unnecessary alternative sorting controls.
  • Tests

    • Expanded coverage for sorting persistence, keyboard focus containment, and fullscreen table interactions.

Walkthrough

The PR adds shared URL-backed sorting to multiple search views, replaces the clinical table’s custom fullscreen dialog with Sheet, updates fullscreen focus tests, and adjusts compact typography and muted color styling across application components.

Changes

Search sorting and accessibility UI

Layer / File(s) Summary
Result sort contract and controls
src/lib/result-sort.ts, src/components/use-result-sort.ts, src/components/clinical-dashboard/search-results-header-band.tsx, tests/result-sort.test.ts
Adds typed relevance/alpha sorting, URL synchronization, reusable controls, and utility coverage.
Sortable search result pages
src/components/clinical-dashboard/*, src/components/forms/forms-search-results-page.tsx, src/components/services/services-navigator-page.tsx, tests/ui-tools.spec.ts
Applies sorting to differential, document, form, and service results, including counts, explanatory text, rendered order, and browser history behavior.
Fullscreen table Sheet integration
src/components/AccessibleTable.tsx, src/components/ui/sheet.tsx, tests/ui-smoke.spec.ts
Moves expanded clinical table content into a fullscreen Sheet, exposes a test selector, and verifies focus remains within the dialog.
Compact typography adjustments
src/components/**/*.tsx, src/components/applications-launcher-page.tsx, src/components/DocumentViewer.tsx
Changes compact labels, badges, pills, metadata elements, and table text to text-2xs or muted styling.
Review record
docs/branch-review-ledger.md
Adds the dated production UI and accessibility review result with verification status.

Estimated code review effort: 4 (Complex) | ~45 minutes

🚥 Pre-merge checks | ✅ 9 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers summary and validation, but it omits the required Clinical Governance Preflight section and the template's verification checklist. Add the Clinical Governance Preflight checklist and align the Verification section to the repository template, including the ranking/retrieval eval requirement.
Docstring Coverage ⚠️ Warning Docstring coverage is 7.81% which is insufficient. The required threshold is 70.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (9 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately summarizes the main change: adding URL-backed sorting with UI polish.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Generated And Sensitive Files ✅ Passed Changed files are docs/src/tests only; scans found no secrets, keys, private keys, real .env files, caches, build outputs, or browser artifacts.
Verification Claims ✅ Passed Validation notes name the checks and outcomes (verify:cheap timed out, verify:ui deferred; named tests with counts). No vague pass-only claim found.
Risky Git Or Deployment Actions ✅ Passed Branch diff contains UI/docs updates only; no unsafe force-push/reset/clean/delete-branch/rebase/deploy-without-confirmation guidance was added.
Supabase Project And Schema Safety ✅ Passed PASS: Diff only changes UI/tests/docs and shared sort/sheet code; no Supabase project refs, migrations, RLS/policy edits, or DB-affecting files were added.
Runtime And Package Manager Integrity ✅ Passed Branch diff vs origin/main only changed UI/tests/docs; no manifest, lockfile, or runtime config was touched, and repo still pins Node 24.x/npm 11.x with engine-strict=true.
Api Route Failure Handling ✅ Passed No API route, server action, RAG, ingestion, or provider files changed; the diff is UI/search-sorting only, so this check is not applicable.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/result-sorting-design-polish
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch codex/result-sorting-design-polish

Comment @coderabbitai help to get the list of available commands.

@BigSimmo
BigSimmo marked this pull request as ready for review July 13, 2026 07:58
@BigSimmo
BigSimmo enabled auto-merge (squash) July 13, 2026 07:58
@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex fix all issues and failing CI and address any comments

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 00808ad9ee

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/document-search-results.tsx
@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

  • I reviewed the PR trigger and supplied comments. The only PR comments available were a Supabase preview notice and a CodeRabbit rate-limit notice; neither contained an actionable code finding to fix.
  • I inspected the repo state on branch work; the worktree remained clean after verification.
  • I did not make code changes, so I did not create a commit or call the PR creation tool. This follows the repository handoff rule that PR creation is only allowed after committing actual changes.
  • The repo requires Node 24.x and npm 11.x, and uses npm run verify:cheap as the first broad gate for non-trivial changes. package.jsonL6-L9 package.jsonL28-L29 AGENTS.mdL167-L167

Testing

  • ⚠️ npm run verify:cheap — initially failed because the shell was using Node 20.20.2 and dependencies were not installed; this was an environment/tooling limitation, not a source failure.
  • source ~/.nvm/nvm.sh && nvm install 24.18.0 && nvm use 24.18.0 && node -v && npm -v
  • source ~/.nvm/nvm.sh && nvm use 24.18.0 >/dev/null && npm ci — completed successfully with 0 vulnerabilities.
  • source ~/.nvm/nvm.sh && nvm use 24.18.0 >/dev/null && npm run verify:cheap — passed: runtime check, GitHub Actions pin check, sitemap check, brand check, type-scale check, icon-scale check, lint, typecheck, and Vitest (197 passed | 1 skipped, 1766 passed | 1 skipped).

View task →

@BigSimmo

Copy link
Copy Markdown
Owner Author

@copilot fix the failing CI tests

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2ad5ec7bc6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/components/clinical-dashboard/differentials-home.tsx
@github-actions

Copy link
Copy Markdown

@codex resolve actionable Codex review findings for this pull request and current head using the repository instructions. This is the pull request's single automatic repair pass: do not perform a fresh review, create new standalone findings, or request another review. Work only the existing unresolved Codex threads on the current head. Always fix P0 and P1 findings. For P2 and lower findings, fix only clear, scoped, low-risk issues; otherwise disposition them with a concise reason. After fixing or dispositioning a thread, reply in that thread with as the first line, followed by a concise summary; that marker authorizes the workflow to close that exact thread. If human input or new authorization is required, do not use the marker and leave the thread open with the blocker. Finish only after every actionable thread is fixed or dispositioned and closed, or explicitly left open for a human decision. Do not update the branch from main, address unrelated reviews, broaden scope, or create more than one scoped fix commit. Do not use external APIs, paid services, credentials, dependency changes, or broad refactors unless explicitly authorized. Add targeted tests where behavior changes and run the narrowest relevant validation.

@chatgpt-codex-connector

Copy link
Copy Markdown

To use Codex here, create a Codex account and connect to github.

coderabbitai[bot]
coderabbitai Bot previously requested changes Jul 13, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/clinical-dashboard/differentials-home.tsx (1)

1065-1078: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Mobile row numbers can skip a number when isBest isn't first (now possible under A–Z sort).

displayIndex is shared between DesktopResultRow (which always renders isBest inline) and MobileResultCard (which skips rendering isBest, since it's shown separately via BestAnswerCard). Because the skip doesn't renumber remaining mobile rows, a mid-list gap (e.g., "1, 2, 4, 5") appears whenever best isn't at position 0 in visibleResults — which is now common under sortValue === "alpha" (previously best was always index 0 under relevance-only sorting, so mobile numbering only had a fixed leading offset, not a mid-list gap).

🔢 Proposed fix: separate contiguous counter for mobile rows
+          {(() => {
+            let mobileRank = 0;
+            return visibleResults.map((result, displayIndex) => {
+              const isBest = result.kind === best.kind && result.id === best.id;
+              const mobileIndex = isBest ? mobileRank : mobileRank++;
+              return (
-          {visibleResults.map((result, displayIndex) => {
-                const isBest = result.kind === best.kind && result.id === best.id;
                return (
                  <div key={`${result.kind}-${result.id}`} className={cn(isBest && "max-lg:hidden")}>
                    <div className="hidden lg:block">
                      <DesktopResultRow
                        result={result}
                        index={displayIndex}
                        isBest={isBest}
                        selected={selectedIds.has(result.id)}
                        onToggle={result.kind === "diagnosis" ? () => toggleSelected(result.id) : undefined}
                      />
                    </div>
                    {!isBest ? (
                      <div className="lg:hidden">
                        <MobileResultCard
                          result={result}
-                         index={displayIndex}
+                         index={mobileIndex}
                          selected={selectedIds.has(result.id)}
                          onToggle={result.kind === "diagnosis" ? () => toggleSelected(result.id) : undefined}
                        />
                      </div>
                    ) : null}
                  </div>
                );
-          })}
+            });
+          })()}

Also applies to: 1084-1088

🤖 Prompt for 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.

In `@src/components/clinical-dashboard/differentials-home.tsx` around lines 1065 -
1078, Update the visibleResults mapping in the component so MobileResultCard
receives a separate contiguous row number that excludes the skipped isBest
result, while DesktopResultRow continues using displayIndex. Ensure mobile
numbering remains sequential regardless of where best appears in visibleResults,
including alpha sorting.
🤖 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/AccessibleTable.tsx`:
- Around line 463-476: Update the fullscreen Sheet rendering in AccessibleTable
so the low-confidence warning is displayed alongside both the expanded
AccessibleTableMarkup and the source-image fallback. Preserve the existing
showFallback branches and ensure expansion never omits lowConfidenceFallback,
using the same warning content already shown in the preview.

In `@src/components/services/services-navigator-page.tsx`:
- Around line 463-466: Update the service result flow around displayedMatches
and the ServiceCard rendering paths at the referenced sections so “Best fit,”
relevance styling, and the mobile relevance description are based only on
genuine relevance ranking, never alphabetical display position. When sortValue
is "alpha", suppress these relevance cues or pass a separate relevance rank
while preserving alphabetical ordering and conservative behavior for clinical
output.

---

Outside diff comments:
In `@src/components/clinical-dashboard/differentials-home.tsx`:
- Around line 1065-1078: Update the visibleResults mapping in the component so
MobileResultCard receives a separate contiguous row number that excludes the
skipped isBest result, while DesktopResultRow continues using displayIndex.
Ensure mobile numbering remains sequential regardless of where best appears in
visibleResults, including alpha sorting.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 756705da-0f23-4625-bc62-2a97c122c054

📥 Commits

Reviewing files that changed from the base of the PR and between 5e2e90f and 2ad5ec7.

📒 Files selected for processing (36)
  • docs/branch-review-ledger.md
  • src/components/AccessibleTable.tsx
  • src/components/DocumentOrganizationBadges.tsx
  • src/components/DocumentTagCloud.tsx
  • src/components/DocumentViewer.tsx
  • src/components/applications-launcher-page.tsx
  • src/components/clinical-dashboard/DocumentManagerPanel.tsx
  • src/components/clinical-dashboard/clinical-badge.tsx
  • src/components/clinical-dashboard/dashboard-nav.tsx
  • src/components/clinical-dashboard/differentials-home.tsx
  • src/components/clinical-dashboard/document-admin.tsx
  • src/components/clinical-dashboard/document-search-results.tsx
  • src/components/clinical-dashboard/document-ui.tsx
  • src/components/clinical-dashboard/evidence-panels.tsx
  • src/components/clinical-dashboard/favourites-hub.tsx
  • src/components/clinical-dashboard/favourites-library-nav.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/clinical-dashboard/medication-prescribing-workspace.tsx
  • src/components/clinical-dashboard/medication-record-page.tsx
  • src/components/clinical-dashboard/output-panel.tsx
  • src/components/clinical-dashboard/search-results-header-band.tsx
  • src/components/clinical-dashboard/settings-dialog.tsx
  • src/components/clinical-dashboard/visual-evidence.tsx
  • src/components/differentials/diagnosis-map-panel.tsx
  • src/components/differentials/differential-detail-page.tsx
  • src/components/differentials/differential-presentation-workflow-page.tsx
  • src/components/forms/form-detail-page.tsx
  • src/components/forms/forms-search-results-page.tsx
  • src/components/services/service-detail-page.tsx
  • src/components/services/services-navigator-page.tsx
  • src/components/ui/sheet.tsx
  • src/components/use-result-sort.ts
  • src/lib/result-sort.ts
  • tests/result-sort.test.ts
  • tests/ui-smoke.spec.ts
  • tests/ui-tools.spec.ts

Comment thread src/components/AccessibleTable.tsx
Comment thread src/components/services/services-navigator-page.tsx
auto-merge was automatically disabled July 13, 2026 09:59

Head branch was pushed to by a user without write access

Copilot AI commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

@copilot fix the failing CI tests

Addressed in e64c38b. The current failing CI issue was the Prettier check on docs/branch-review-ledger.md; that file is now formatted, and I also re-ran the three previously failing Chromium tests locally against the current head and they passed.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 13, 2026 10:08
@coderabbitai

coderabbitai Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Note

Autofix is a beta feature. Expect some limitations and changes as we gather feedback and continue to improve it.

Fixes Applied Successfully

Fixed 2 file(s) based on 2 unresolved review comments.

Files modified:

  • src/components/AccessibleTable.tsx
  • src/components/services/services-navigator-page.tsx

Commit: 1ddb82291e34f7aa526cf56cd615e40c49562007

The changes have been pushed to the codex/result-sorting-design-polish branch.

Time taken: 9m 47s

@BigSimmo

Copy link
Copy Markdown
Owner Author

@codex review all comments and implement the best and smallest fix for each and ensure all issues addressed without regression and merge safe.

@chatgpt-codex-connector

Copy link
Copy Markdown

Summary

Committed changes on the current branch:

  • aa7c148 fix: address result sorting review feedback

Created the PR via the make_pr tool with title:

  • fix: address result sorting review feedback

Testing

  • source ~/.nvm/nvm.sh && nvm install 24.18.0 && nvm use 24.18.0 >/dev/null && npm ci
  • source ~/.nvm/nvm.sh && nvm use 24.18.0 >/dev/null && npx eslint src/components/AccessibleTable.tsx src/components/services/services-navigator-page.tsx src/components/clinical-dashboard/differentials-home.tsx src/components/clinical-dashboard/document-search-results.tsx src/components/clinical-dashboard/search-results-header-band.tsx src/lib/result-sort.ts tests/result-sort.test.ts --max-warnings 0
  • source ~/.nvm/nvm.sh && nvm use 24.18.0 >/dev/null && npm run typecheck && npm run test -- tests/result-sort.test.ts && git diff --check
  • source ~/.nvm/nvm.sh && nvm use 24.18.0 >/dev/null && npm run verify:cheap — passed runtime, GitHub Actions pin check, sitemap, brand, type-scale, icon-scale, lint, typecheck, and Vitest (211 passed | 1 skipped; 1934 passed | 1 skipped).

View task →

coderabbitai Bot and others added 2 commits July 13, 2026 10:20
Fixed 2 file(s) based on 2 unresolved review comments.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
auto-merge was automatically disabled July 13, 2026 10:33

Head branch was pushed to by a user without write access

@BigSimmo
BigSimmo enabled auto-merge (squash) July 13, 2026 10:36
@BigSimmo
BigSimmo merged commit e7d974f into main Jul 13, 2026
14 of 15 checks passed
@BigSimmo
BigSimmo deleted the codex/result-sorting-design-polish branch July 13, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants