Skip to content

fix: complete form services regression alignment for design-audit#836

Merged
7 commits merged into
mainfrom
codex/design-audit-main-safe-merge-20260719
Jul 18, 2026
Merged

fix: complete form services regression alignment for design-audit#836
7 commits merged into
mainfrom
codex/design-audit-main-safe-merge-20260719

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Resolve remaining merge-blocking failures in the active design-audit PR head:
    • page query-param typing in src/app/page.tsx
    • services navigator imports in src/components/services/services-navigator-page.tsx
    • chunk-load cache initialization in src/lib/rag.ts
    • Playwright motion-reduction config schema compatibility
    • targeted RAG test signature alignment in tests/rag-abort-signal.test.ts and tests/rag-classifier-memo.test.ts
  • Keep route-map synchronization via docs/site-map.md.
  • Keep the branch rebased cleanly onto current origin/main.
  • Outcome: blocker-related compiler/type/test regressions that prevented a clean merge path are resolved.

Verification

  • npm run typecheck
  • npm run test -- tests/rag-abort-signal.test.ts tests/rag-classifier-memo.test.ts
  • UI verification not run: this PR is a merge-blocker recovery patch; npm run verify:ui is intentionally deferred until these non-UI blockers are fully in-tree and the PR-policy issue is resolved.

Risk and rollout

  • Risk: low; behavioral impact is limited to recovery wiring, schema-compatible Playwright options, and test expectation alignment.
  • Rollback: revert commit d25ef25c8 if this patch needs to be rolled back.

Clinical Governance Preflight

  • Source-backed claims still require linked source verification before clinical use
  • No patient-identifiable document workflow was introduced or expanded without explicit governance approval
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy)
  • Service-role keys and private document access remain server-only
  • Demo/synthetic content remains clearly separated from real clinical sources
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative
  • Deployment classification/TGA SaMD impact was checked when clinical decision-support behavior changed

BigSimmo and others added 5 commits July 18, 2026 16:36
* fix: stop Escape focus restore from closing the app-mode menu

Scope dismiss deferred a focus restore onto the answer-options trigger.
When a mode-menu open landed in the same frame window, that restore stole
focus, blur-dismissed the menu, and flaked the Documents mode switch in
Production UI CI. Skip restore when the mode menu is open or focus already
moved, and wait for the scope popover to hide before opening the menu.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

* fix(test): fail closed when scope popover does not dismiss

Only wait for the scope popover when it is visible, and let that wait
throw if dismissal times out so the mode-menu open cannot recreate the
Escape focus-restore race.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>

---------

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@supabase

supabase Bot commented Jul 18, 2026

Copy link
Copy Markdown

Updates to Preview Branch (codex/design-audit-main-safe-merge-20260719) ↗︎

Deployments Status Updated
Database Sat, 18 Jul 2026 09:31:46 UTC
Services Sat, 18 Jul 2026 09:31:46 UTC
APIs Sat, 18 Jul 2026 09:31:46 UTC

Tasks are run on every commit but only new migration files are pushed.
Close and reopen this PR if you want to apply changes from existing seed or migration files.

Tasks Status Updated
Configurations Sat, 18 Jul 2026 09:31:50 UTC
Migrations Sat, 18 Jul 2026 09:31:53 UTC
Seeding ⏸️ Sat, 18 Jul 2026 09:31:40 UTC
Edge Functions ⏸️ Sat, 18 Jul 2026 09:31:40 UTC

❌ Branch Error • Sat, 18 Jul 2026 09:31:53 UTC

ERROR: Unsafe supabase_admin default privileges; migration blocked. (SQLSTATE 42501)
{"safe": false, "entries": ["function:PUBLIC:execute", "function:anon:execute", "function:authenticated:execute", "function:postgres:execute", "function:service_role:execute", "function:supabase_admin:execute", "sequence:anon:select", "sequence:anon:update", "sequence:anon:usage", "sequence:authenticated:select", "sequence:authenticated:update", "sequence:authenticated:usage", "sequence:postgres:select", "sequence:postgres:update", "sequence:postgres:usage", "sequence:service_role:select", "sequence:service_role:update", "sequence:service_role:usage", "sequence:supabase_admin:usage", "table:anon:delete", "table:anon:insert", "table:anon:maintain", "table:anon:references", "table:anon:select", "table:anon:trigger", "table:anon:truncate", "table:anon:update", "table:authenticated:delete", "table:authenticated:insert", "table:authenticated:maintain", "table:authenticated:references", "table:authenticated:select", "table:authenticated:trigger", "table:authenticated:truncate", "table:authenticated:update", "table:postgres:delete", "table:postgres:insert", "table:postgres:maintain", "table:postgres:references", "table:postgres:select", "table:postgres:trigger", "table:postgres:truncate", "table:postgres:update", "table:service_role:delete", "table:service_role:insert", "table:service_role:maintain", "table:service_role:references", "table:service_role:select", "table:service_role:trigger", "table:service_role:truncate", "table:service_role:update", "table:supabase_admin:delete", "table:supabase_admin:insert", "table:supabase_admin:maintain", "table:supabase_admin:references", "table:supabase_admin:select", "table:supabase_admin:trigger", "table:supabase_admin:truncate", "table:supabase_admin:update"], "role_exists": true, "schema_exists": true}
At statement: 3
do $$
declare
  v_status jsonb;
begin
  if not exists (select 1 from pg_catalog.pg_roles where rolname = 'supabase_admin') then
    raise notice 'role supabase_admin does not exist; default-privilege assertion is not applicable';
    return;
  end if;

  begin
    -- Local/Superuser-capable environments can assume the target role even
    -- when the migration role cannot use ALTER DEFAULT PRIVILEGES FOR ROLE
    -- directly. Hosted environments that cannot assume it fall through to the
    -- catalog assertion and block with operator instructions.
    execute 'set local role supabase_admin';
    -- Revokes must be global: per-schema ACLs cannot subtract privileges from
    -- built-in or previously granted global defaults.
    alter default privileges for role supabase_admin
      revoke all privileges on tables from public, anon, authenticated, service_role;
    alter default privileges for role supabase_admin in schema public
      revoke all privileges on tables from public, anon, authenticated, service_role;
    alter default privileges for role supabase_admin
      revoke all privileges on sequences from public, anon, authenticated, service_role;
    alter default privileges for role supabase_admin in schema public
      revoke all privileges on sequences from public, anon, authenticated, service_role;
    alter default privileges for role supabase_admin
      revoke execute on functions from public, anon, authenticated, service_role;
    alter default privileges for role supabase_admin in schema public
      revoke execute on functions from public, anon, authenticated, service_role;
    alter default privileges for role supabase_admin in schema public
      grant select, insert, update, delete on tables to service_role;
    alter default privileges for role supabase_admin in schema public
      grant usage, select on sequences to service_role;
    alter default privileges for role supabase_admin in schema public
      grant execute on functions to service_role;
    execute 'reset role';
  exception when insufficient_privilege then
    begin execute 'reset role'; exception when others then null; end;
    raise notice 'current role % cannot remediate supabase_admin default privileges; asserting the catalog postcondition', current_user;
  end;

  v_status := public.default_privileges_status('supabase_admin', 'public');
  if not coalesce((v_status->>'safe')::boolean, false) then
    raise exception using
      errcode = '42501',
      message = 'Unsafe supabase_admin default privileges; migration blocked.',
      detail = v_status::text,
      hint = E'Run these six statements as supabase_admin, then retry the migration:\n'
        'DO $remediate$ BEGIN ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin REVOKE ALL PRIVILEGES ON TABLES FROM PUBLIC, anon, authenticated, service_role; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL PRIVILEGES ON TABLES FROM PUBLIC, anon, authenticated, service_role; END $remediate$;\n'
        'DO $remediate$ BEGIN ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin REVOKE ALL PRIVILEGES ON SEQUENCES FROM PUBLIC, anon, authenticated, service_role; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE ALL PRIVILEGES ON SEQUENCES FROM PUBLIC, anon, authenticated, service_role; END $remediate$;\n'
        'DO $remediate$ BEGIN ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC, anon, authenticated, service_role; ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public REVOKE EXECUTE ON FUNCTIONS FROM PUBLIC, anon, authenticated, service_role; END $remediate$;\n'
        'ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT SELECT, INSERT, UPDATE, DELETE ON TABLES TO service_role;\n'
        'ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT USAGE, SELECT ON SEQUENCES TO service_role;\n'
        'ALTER DEFAULT PRIVILEGES FOR ROLE supabase_admin IN SCHEMA public GRANT EXECUTE ON FUNCTIONS TO service_role;';
  end if;
end;
$$

View logs for this Workflow Run ↗︎.
Learn more about Supabase for Git ↗︎.

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Updates presentation routing and sitemap output, dashboard and forms UI behavior, RAG RPC and classifier handling, and Supabase migrations with matching regression assertions.

Changes

Routing and sitemap updates

Layer / File(s) Summary
Redirect and sitemap contracts
docs/site-map.md, scripts/generate-site-map.ts, src/app/differentials/presentations/route.ts, tests/site-map.test.ts, tests/audit-navigation-auth-regressions.test.ts
Presentation redirects now use [workflow-slug], factsheet descriptions are removed, and empty query fallback behavior is no longer asserted.

Dashboard and forms UI behavior

Layer / File(s) Summary
Dashboard navigation and results
src/app/page.tsx, src/components/ClinicalDashboard.tsx, src/components/clinical-dashboard/master-search-header.tsx, src/components/services/services-navigator-page.tsx, playwright.config.ts
Dashboard result messaging, search-match placement, menu interactions, service rail remounting, and reduced-motion settings are updated.
Forms rendering and UI regressions
tests/audit-content-services-regressions.test.ts, tests/ui-tools.spec.ts
Forms source metadata, links, unsupported pathway claims, service navigation, and mobile dock transitions receive updated assertions.
Dashboard accessibility and gating
tests/audit-navigation-auth-regressions.test.ts, tests/ui-accessibility.spec.ts, tests/ui-smoke.spec.ts
Private API gating and dashboard heading assertions now target authenticated conditions and “Clinical KB”.

RAG and Supabase changes

Layer / File(s) Summary
RPC and classifier execution
src/lib/rag-candidate-sources.ts, src/lib/rag.ts, tests/rag-abort-signal.test.ts, tests/rag-classifier-memo.test.ts
RPC calls use exported error typing and direct client calls; classifier fallback abort plumbing and coalescing metrics are removed or simplified.
Database migrations and drift artifacts
supabase/migrations/*, supabase/drift-manifest.json
Title-word trigger comparisons, the document facts trigram index, and drift replay metadata are updated.
Database contract tests
tests/supabase-schema.test.ts
Schema assertions are aligned with updated migration names, cleanup predicates, trigram settings, and index creation.

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

Possibly related PRs

Suggested labels: codex

Suggested reviewers: claude, copilot

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is concise and generally matches the change set, though it is broader than the actual diff.
Description check ✅ Passed The description follows the template and includes summary, verification, risk, and governance sections, with only minor omissions.
✨ 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/design-audit-main-safe-merge-20260719

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

@github-actions

github-actions Bot commented Jul 18, 2026

Copy link
Copy Markdown

CI triage

CI failed on this PR. Automated classification of the 3 failed job(s):

  • Unit coverageneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • Production UIneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.
  • PR requiredneeds investigation: inspect the failing step and uploaded diagnostics; rerun only after classifying the cause.

Compared with main CI run #3245 (success).

Classification is evidence routing, not permission to ignore a failure. Exact quarantined Playwright identities remain governed by the flake ledger.

@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: 3

Caution

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

⚠️ Outside diff range comments (2)
src/components/services/services-navigator-page.tsx (1)

36-37: 🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Restore the missing service-metrics import

serviceNavigatorMetrics and canCompareServices are used in RightRail, but this file no longer imports them, so the component won’t compile.

Proposed fix
+import { canCompareServices, serviceNavigatorMetrics } from "`@/lib/service-navigator-metrics`";
🤖 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/services/services-navigator-page.tsx` around lines 36 - 37,
Restore the missing import for serviceNavigatorMetrics and canCompareServices in
services-navigator-page.tsx, alongside the existing service-related imports, so
the RightRail component resolves both referenced symbols and compiles
successfully.
src/lib/rag.ts (1)

1291-1292: 🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Thread the request signal through classifier fallback and retrieval RPCs.

src/lib/rag.ts#L1283-L1370 still waits for the shared classifier verdict after the caller aborts, and src/lib/rag-candidate-sources.ts#L79-L115 issues the versioned/legacy Supabase RPCs without abortSignal, so aborted requests keep consuming LLM/DB time.

  • Add an optional signal to analyzeQueryWithClassifierFallback and stop waiting once it aborts.
  • Pass that signal into callVersionedRetrievalRpc and chain .abortSignal(signal) on the RPC calls.
🤖 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/lib/rag.ts` around lines 1291 - 1292, Update
analyzeQueryWithClassifierFallback in src/lib/rag.ts (lines 1291-1292) to accept
an optional signal and stop awaiting the shared classifier verdict after abort;
propagate that signal through its retrieval call sites at lines 1362-1369 and
2398-2399 into callVersionedRetrievalRpc. In src/lib/rag-candidate-sources.ts,
update the versioned RPC at lines 85-92 and legacy RPC at lines 102-105 to chain
abortSignal(signal), preserving existing retrieval behavior when no signal is
provided.
🧹 Nitpick comments (1)
tests/audit-navigation-auth-regressions.test.ts (1)

46-46: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add coverage for the new empty-query contract.

The route now intentionally ignores q when query is present but blank. Replace the removed fallback case with an assertion for this behavior so the changed redirect contract remains protected.

🤖 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 `@tests/audit-navigation-auth-regressions.test.ts` at line 46, Update the
redirect test using redirectMedications to cover the empty-query contract:
provide a blank query alongside a populated q value and assert that q is ignored
rather than used as a fallback. Replace the removed fallback-case expectation
while preserving existing redirect assertions.
🤖 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/app/page.tsx`:
- Around line 8-10: Update the HomeProps.searchParams type to include optional
q, focus, and run properties alongside mode, using the appropriate string or
string-array types expected by the page’s query-param reads.

In `@tests/audit-navigation-auth-regressions.test.ts`:
- Around line 126-128: Fix the failing H1 assertion in the “keeps the root
dashboard H1 as Clinical KB” test by aligning its regex with the actual markup
emitted by ClinicalDashboard, or update the component’s root H1 to exactly match
the asserted sr-only Clinical KB structure; ensure the test passes while
preserving the single-H1 requirement.

In `@tests/ui-accessibility.spec.ts`:
- Line 51: Update the H1 rendered by ClinicalDashboard from “Clinical Guide” to
“Clinical KB” so it matches the updated assertions. Apply the production change
in ClinicalDashboard; retain the expectations at
tests/ui-accessibility.spec.ts:51, tests/ui-smoke.spec.ts:876, and
tests/ui-smoke.spec.ts:1271 unchanged because they are corrected by the H1
update.

---

Outside diff comments:
In `@src/components/services/services-navigator-page.tsx`:
- Around line 36-37: Restore the missing import for serviceNavigatorMetrics and
canCompareServices in services-navigator-page.tsx, alongside the existing
service-related imports, so the RightRail component resolves both referenced
symbols and compiles successfully.

In `@src/lib/rag.ts`:
- Around line 1291-1292: Update analyzeQueryWithClassifierFallback in
src/lib/rag.ts (lines 1291-1292) to accept an optional signal and stop awaiting
the shared classifier verdict after abort; propagate that signal through its
retrieval call sites at lines 1362-1369 and 2398-2399 into
callVersionedRetrievalRpc. In src/lib/rag-candidate-sources.ts, update the
versioned RPC at lines 85-92 and legacy RPC at lines 102-105 to chain
abortSignal(signal), preserving existing retrieval behavior when no signal is
provided.

---

Nitpick comments:
In `@tests/audit-navigation-auth-regressions.test.ts`:
- Line 46: Update the redirect test using redirectMedications to cover the
empty-query contract: provide a blank query alongside a populated q value and
assert that q is ignored rather than used as a fallback. Replace the removed
fallback-case expectation while preserving existing redirect assertions.
🪄 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 Plus

Run ID: 82c5833a-c654-4429-99a0-64af3961f0dd

📥 Commits

Reviewing files that changed from the base of the PR and between b45f095 and ed337c1.

📒 Files selected for processing (20)
  • docs/site-map.md
  • playwright.config.ts
  • scripts/generate-site-map.ts
  • src/app/differentials/presentations/route.ts
  • src/app/page.tsx
  • src/components/ClinicalDashboard.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/services/services-navigator-page.tsx
  • src/lib/rag-candidate-sources.ts
  • src/lib/rag.ts
  • supabase/drift-manifest.json
  • supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql
  • supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql
  • tests/audit-content-services-regressions.test.ts
  • tests/audit-navigation-auth-regressions.test.ts
  • tests/site-map.test.ts
  • tests/supabase-schema.test.ts
  • tests/ui-accessibility.spec.ts
  • tests/ui-smoke.spec.ts
  • tests/ui-tools.spec.ts

Comment thread src/app/page.tsx
Comment on lines +126 to +128
it("keeps the root dashboard H1 as Clinical KB", () => {
expect(clinicalDashboardSource.match(/<h1\b/g)).toHaveLength(1);
expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical Guide\s*<\/h1>/);
expect(clinicalDashboardSource).toMatch(/<h1 className="sr-only">\s*Clinical KB\s*<\/h1>/);

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Fix the failing H1 assertion before merging.

The exact regex on Line 128 does not match the current ClinicalDashboard.tsx source, and the test currently fails. Align the assertion with the actual markup or update the component to emit exactly the asserted <h1> structure.

🧰 Tools
🪛 GitHub Check: Unit coverage

[failure] 128-128: [node] tests/audit-navigation-auth-regressions.test.ts > audit navigation and auth regressions > keeps the root dashboard H1 as Clinical KB
AssertionError: expected '"use client";\n\nimport { useRouter, …' to match /

\s*Clinica…/h1>

  • Expected:
    /

    \sClinical KB\s</h1>/

  • Received:
    ""use client";

import { useRouter, useSearchParams } from "next/navigation";
import dynamic from "next/dynamic";
import {
CircleAlert,
BookOpen,
ChevronDown,
Clock3,
ExternalLink,
FileImage,
FileText,
FolderOpen,
Heart,
ListChecks,
Loader2,
Quote,
RefreshCw,
Search,
ShieldAlert,
Square,
UploadCloud,
WifiOff,
Wrench,
} from "lucide-react";
import { type CSSProperties, useCallback, useEffect, useMemo, useReducer, useRef, useState } from "react";
import { type DocumentDeleteResult } from "@/components/DocumentManagementActions";
import { extractSafetyFindings } from "@/lib/clinical-safety";
import { isLocalNoAuthMode, publicUploadsEnabled } from "@/lib/client-env";
import { readLocalProjectIdentity, unsafeLocalProjectMessage } from "@/lib/local-project-identity";
import { isDeployedClinicalKb } from "@/lib/deployed-app";
import {
appBackdrop,
answerSurface,
cn,
EmptyState,
floatingControl,
InlineNotice,
primaryControl,
textMuted,
} from "@/components/ui-primitives";
import { useAuthSession } from "@/lib/supabase/client";
import { AccountSetupDialog } from "@/components/clinical-dashboard/account-setup-dialog";
import { CrossModeLinksSection } from "@/components/clinical-dashboard/cross-mode-links";
import { useEventCallback } from "@/components/clinical-dashboard/use-event-callback";
import { AuthPanel } from "@/components/clinical-dashboard/auth-panel";
import { buildMobileSectionFabState, MobileSectionFab, ToolsHub } from "@/components/clinical-dashboard/dashboard-nav";
import { SettingsDialog } from "@/components/clinical-dashboard/settings-dialog";
import { useSidebarCollapsed } from "@/components/clinical-dashboard/use-sidebar-collapsed";
import { useTheme } from "@/components/clinical-dashboard/use-theme";
import {
deriveSidebarIdentity,
ClinicalDesktopSidebar,
ClinicalMobileSidebar,
} from "@/components/clinical-dashboard/ClinicalSidebar";
import {
SetupChecklist,
UploadPanel,
IndexingMonitor,
IngestionQualityConsole,
LibraryHealthStrip,
fallbackSetupChecks,
hasReadyRequiredPublicSearchConfig,
hasReadyPublicSearchSetup,
type SetupCheck,
type IngestionQualityReviewItem,
} from "@/components/clinical-dashboard/DocumentManagerPanel";
import { GuideDialog, GuideTrigger, UtilityDrawer } from "@/components/clinical-dashboard/dashboard-shell";
import { sanitizeAnswerDisplayText, sanitizeDisplayText } from "@/components/clinical-dashboard/display-text";
import {
isPreformattedGroundedAnswer,
NaturalLanguageAnswer,
ScopeAndGovernanceNotice,
UserQuestionBubble,
} from "@/components/clinical-dashboard/answer-content";
import { AnswerEmptyState, AnswerProgressStepper, AnswerSkeleton } from "@/components/clinical-dashboard/answer-status";
import {
type AnswerProgressUpdate,
type TimedAnswerProgressUpdate,
} from "@/components/clinical-dashboard/answer-progress";
import { evidenceMapRowsFromRenderModel } from "@/components/clinical-dashboard/evidence-map-model";
import { MasterSearchHeader } from "@/components/clinical-dashboard/master-search-header";
import { UniversalSearchAlsoMatches } from "@/components/clinical-dashboard/universal-search-also-matches";
import { useScrollHideReporter } from "@/components/clinical-dashboard/use-hide-on-scroll";
import { SearchCommandProvider } from "@/components/clinical-dashboard/search-command-context";
import {
answerReferencesDocument,
answerTimedOutError,
applyRenamedDocumentToAnswer,
compactScopeFilters,
hasActiveIndexingWork,
hasNonProductionSupabaseApiKeyFallback,
isAbortError,
mergeDocumentRefresh,
normalizeNavigationHash,
setupNeedsSlowRecheck,
setupRecheckPollMs,
shorterPollDelay,
} from "@/components/clinical-dashboard/clinical-dashboard-helpers";
import { answerRecovery, errorCopy } from "@/lib/ui-copy";
imp

🤖 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 `@tests/audit-navigation-auth-regressions.test.ts` around lines 126 - 128, Fix
the failing H1 assertion in the “keeps the root dashboard H1 as Clinical KB”
test by aligning its regex with the actual markup emitted by ClinicalDashboard,
or update the component’s root H1 to exactly match the asserted sr-only Clinical
KB structure; ensure the test passes while preserving the single-H1 requirement.

Source: Linters/SAST tools


async function expectDashboardUsable(page: Page) {
await expect(page.getByRole("heading", { level: 1, name: "Clinical Guide" })).toHaveCount(1);
await expect(page.getByRole("heading", { level: 1, name: "Clinical KB" })).toHaveCount(1);

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Align the dashboard H1 with these updated assertions.

src/components/ClinicalDashboard.tsx Line 3495 still renders Clinical Guide, so all three updated locators fail. Rename that H1 to Clinical KB (or retain the prior test expectation consistently).

  • tests/ui-accessibility.spec.ts#L51-L51: keep this expectation only after the rendered H1 is updated.
  • tests/ui-smoke.spec.ts#L876-L876: keep this expectation only after the rendered H1 is updated.
  • tests/ui-smoke.spec.ts#L1271-L1271: keep this expectation only after the rendered H1 is updated.
📍 Affects 2 files
  • tests/ui-accessibility.spec.ts#L51-L51 (this comment)
  • tests/ui-smoke.spec.ts#L876-L876
  • tests/ui-smoke.spec.ts#L1271-L1271
🤖 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 `@tests/ui-accessibility.spec.ts` at line 51, Update the H1 rendered by
ClinicalDashboard from “Clinical Guide” to “Clinical KB” so it matches the
updated assertions. Apply the production change in ClinicalDashboard; retain the
expectations at tests/ui-accessibility.spec.ts:51, tests/ui-smoke.spec.ts:876,
and tests/ui-smoke.spec.ts:1271 unchanged because they are corrected by the H1
update.

@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: 1

Caution

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

⚠️ Outside diff range comments (2)
src/lib/rag.ts (1)

1364-1367: 🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

Restore caller cancellation while waiting on a shared classifier request.

A request aborted while pending is unresolved now waits for the classifier/provider to finish before searchChunksWithTelemetry reaches its next abort check. This regresses prompt cancellation and retains abandoned request work; the changed test also removes coverage for it.

  • src/lib/rag.ts#L1364-L1367: restore the signal option and race the caller’s wait against it without cancelling the shared classifier promise.
  • tests/rag-classifier-memo.test.ts#L168-L177: retain/add a regression test proving an aborted coalesced caller rejects promptly.
🤖 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/lib/rag.ts` around lines 1364 - 1367, Restore caller cancellation in
src/lib/rag.ts at lines 1364-1367 by waiting on the shared classifier request
with the caller’s signal, racing the caller wait against abort without
cancelling pending, and preserving verdict memoization for completed requests.
In tests/rag-classifier-memo.test.ts lines 168-177, retain or add regression
coverage proving an aborted coalesced caller rejects promptly.
src/components/services/services-navigator-page.tsx (1)

601-609: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Keep universal-also-matches after the main results. SearchResultsLayout renders header before children, so placing this panel in the header makes it precede service-search-results in the DOM and breaks tests/ui-universal-search.spec.ts. If that order is intentional, update the regression and contract together.

🤖 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/services/services-navigator-page.tsx` around lines 601 - 609,
Move UniversalSearchAlsoMatches out of the SearchResultsLayout header and render
it after the main service-search-results children so universal-also-matches
follows the results in the DOM. Update the services navigator composition around
UniversalSearchAlsoMatches while preserving its modeId and query props; only
change the regression or contract tests if the ordering is intentionally
revised.
🤖 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 `@tests/rag-abort-signal.test.ts`:
- Line 38: Remove the duplicate rpcCalls const declaration in the test scope,
keeping a single Array<{ name: string; args: Record<string, unknown> }>
definition so the block-scoped redeclaration error is resolved.

---

Outside diff comments:
In `@src/components/services/services-navigator-page.tsx`:
- Around line 601-609: Move UniversalSearchAlsoMatches out of the
SearchResultsLayout header and render it after the main service-search-results
children so universal-also-matches follows the results in the DOM. Update the
services navigator composition around UniversalSearchAlsoMatches while
preserving its modeId and query props; only change the regression or contract
tests if the ordering is intentionally revised.

In `@src/lib/rag.ts`:
- Around line 1364-1367: Restore caller cancellation in src/lib/rag.ts at lines
1364-1367 by waiting on the shared classifier request with the caller’s signal,
racing the caller wait against abort without cancelling pending, and preserving
verdict memoization for completed requests. In tests/rag-classifier-memo.test.ts
lines 168-177, retain or add regression coverage proving an aborted coalesced
caller rejects promptly.
🪄 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 Plus

Run ID: 23cad46b-9290-4621-a1fa-b1bda5bb75f1

📥 Commits

Reviewing files that changed from the base of the PR and between ed337c1 and 5c81b2b.

📒 Files selected for processing (7)
  • docs/site-map.md
  • playwright.config.ts
  • src/app/page.tsx
  • src/components/services/services-navigator-page.tsx
  • src/lib/rag.ts
  • tests/rag-abort-signal.test.ts
  • tests/rag-classifier-memo.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/app/page.tsx

const controller = new AbortController();
const abortSignal = vi.fn(async () => ({ data: [], error: null }));
const supabase = { rpc: vi.fn(() => ({ abortSignal })) };
const rpcCalls: Array<{ name: string; args: Record<string, unknown> }> = [];

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.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Remove the duplicate rpcCalls declaration.

Line 38 declares the same const twice in one scope, causing a block-scoped redeclaration compile error.

🤖 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 `@tests/rag-abort-signal.test.ts` at line 38, Remove the duplicate rpcCalls
const declaration in the test scope, keeping a single Array<{ name: string;
args: Record<string, unknown> }> definition so the block-scoped redeclaration
error is resolved.

@BigSimmo BigSimmo closed this pull request by merging all changes into main in 5c3a0e5 Jul 18, 2026
@BigSimmo
BigSimmo deleted the codex/design-audit-main-safe-merge-20260719 branch July 18, 2026 10:40
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.

1 participant