Skip to content

fix: gate demo-mode forms UI for ui test fixture compatibility#862

Closed
BigSimmo wants to merge 6 commits into
mainfrom
codex/merge-safe-819-mainfix-regression
Closed

fix: gate demo-mode forms UI for ui test fixture compatibility#862
BigSimmo wants to merge 6 commits into
mainfrom
codex/merge-safe-819-mainfix-regression

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • Align forms fixture handling in tests/ui-tools.spec.ts so test slug lookup no longer fails on unknown fixture slugs.
  • Gate unsupported pathway, refine, and footer sections in demo mode within src/components/forms/forms-search-results-page.tsx so fixture-backed form UI stays within expected assertions.
  • Carry forward the earlier service fixture/label work from f99d4cf on this branch.

Verification

  • npm run verify:pr-local
  • npm run verify:ui
  • Verification not run: Local environment repeatedly hit an active Playwright heavy command lock (scripts/run-playwright.mjs) after the branch-safety sync; targeted npm run test:e2e:pr -- tests/ui-tools.spec.ts ... checks could not complete while stale lock/processes were present.
  • UI verification not run: Targeted UI fixture checks are blocked by the same local heavy-command lock contention; they were not fully executed in this environment.

Risk and rollout

  • Risk: Demo-mode conditional rendering changes are intentionally scoped to fixture/registry-demo behavior; production form search behavior in non-demo mode is unchanged.
  • Rollback: Revert this PR or remove the demoMode guards in forms-search-results-page.tsx and restore tests/ui-tools.spec.ts slug filtering behavior.
  • Provider or production effects: None. No deployment, API, or runtime configuration changes.

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

Notes

  • PR title changed to match scope and maintain the policy format.

@supabase

supabase Bot commented Jul 18, 2026

Copy link
Copy Markdown

Updates to Preview Branch (codex/merge-safe-819-mainfix-regression) ↗︎

Deployments Status Updated
Database Sat, 18 Jul 2026 14:11:43 UTC
Services Sat, 18 Jul 2026 14:11:43 UTC
APIs Sat, 18 Jul 2026 14:11:43 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 14:11:45 UTC
Migrations Sat, 18 Jul 2026 14:11:48 UTC
Seeding ⏸️ Sat, 18 Jul 2026 14:11:37 UTC
Edge Functions ⏸️ Sat, 18 Jul 2026 14:11:37 UTC

❌ Branch Error • Sat, 18 Jul 2026 14:11:48 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

The PR updates Clinical KB headings and result rendering, hides demo-mode forms controls, adds caller cancellation to RAG retrieval and classifier waits, records coalescing metrics, adjusts Playwright motion settings, and refreshes regression assertions and Supabase validation fixtures.

Changes

Clinical KB UI and request handling

Layer / File(s) Summary
Dashboard and forms rendering
src/app/page.tsx, src/components/ClinicalDashboard.tsx, src/components/forms/forms-search-results-page.tsx, src/components/route-error-boundary.tsx
Search parameters accept generic keys; the dashboard heading is renamed to “Clinical KB”; answer-mode match rendering and demo-mode forms content are gated; error-heading outlines use focus-visible.
UI behavior regression coverage
tests/audit-navigation-auth-regressions.test.ts, tests/ui-accessibility.spec.ts, tests/ui-smoke.spec.ts, tests/ui-tools.spec.ts, tests/audit-content-services-regressions.test.ts
Regression expectations cover the renamed heading, gated forms content, normalized service mocks, provenance text, source links, and mobile dock transitions.

RAG cancellation and coalescing

Layer / File(s) Summary
Abort-aware retrieval and classifier fallback
src/lib/rag-candidate-sources.ts, src/lib/rag.ts
Retrieval RPCs and classifier waits accept caller abort signals; abort errors propagate while non-abort classifier failures retain deterministic fallback behavior.
Answer coalescing metrics
src/lib/rag.ts
Coalesced waiters and answer origination lifecycle events are recorded around in-flight answer promises.

Supabase validation and browser execution

Layer / File(s) Summary
Schema and manifest validation
tests/supabase-schema.test.ts, supabase/drift-manifest.json
Schema fixtures and SQL expectations are updated, and drift replay metadata is regenerated.
Browser motion configuration
playwright.config.ts
The suite retains reduced motion by default while Chromium explicitly uses no-preference.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

  • BigSimmo/Database#846: Overlaps across Playwright configuration, dashboard rendering, search parameter typing, RAG cancellation, and related tests.
  • BigSimmo/Database#813: Shares the RAG abort-signal and classifier-wait changes.
  • BigSimmo/Database#861: Shares the demo-mode gating changes in the forms search results page.
🚥 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 matches the main scope: demo-mode forms UI gating for test-fixture compatibility.
Description check ✅ Passed The description follows the template, covers summary, verification, risk, governance, and notes, with only non-critical missing runs.
✨ 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/merge-safe-819-mainfix-regression

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

@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: 6f20b807cd

ℹ️ 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 tests/ui-tools.spec.ts

@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

🤖 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/lib/rag-candidate-sources.ts`:
- Around line 91-99: Update both retrieval RPC invocations in rag.ts—at the
hybrid and vector search call sites—to pass args.signal as the fifth argument.
In the fallback logic after each RPC, re-check the cancellation state before
proceeding so an aborted request does not fall through to another retrieval
path.
🪄 Autofix (Beta)

✅ Autofix completed


ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 8580c8c8-6868-47ce-8726-d08ce7f90bb4

📥 Commits

Reviewing files that changed from the base of the PR and between 2f5b22a and 6f20b80.

📒 Files selected for processing (14)
  • playwright.config.ts
  • src/app/page.tsx
  • src/components/ClinicalDashboard.tsx
  • src/components/forms/forms-search-results-page.tsx
  • src/components/route-error-boundary.tsx
  • src/lib/rag-candidate-sources.ts
  • src/lib/rag.ts
  • supabase/drift-manifest.json
  • tests/audit-content-services-regressions.test.ts
  • tests/audit-navigation-auth-regressions.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/lib/rag-candidate-sources.ts
@BigSimmo

Copy link
Copy Markdown
Owner Author

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

ℹ️ 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 playwright.config.ts
versionedName: string,
legacyName: string,
args: Record<string, unknown>,
signal?: AbortSignal,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Pass caller abort signals into retrieval RPCs

This new signal parameter is never supplied by the production retrieval path: a repo-wide check of callVersionedRetrievalRpc call sites shows the searchChunksWithTelemetry/candidate-source callers still pass only the RPC args and their helper argument types do not carry signal. When a user hits Stop after retrieval starts, the code still waits for outstanding Supabase RPCs instead of aborting them, so the cancellation fix only covers the classifier boundary; thread args.signal through the candidate helpers and direct RPC calls so this hook is effective.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@codex fix

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

Testing

  • export PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm ci
  • export PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run typecheck
  • export PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run test -- tests/retrieval-selection.test.ts tests/rag-routing.test.ts tests/rag-offline-contract.test.ts
  • export PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run eval:rag:offline
  • export PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run verify:cheap — failed in unrelated tests/pdf-extraction-budget.test.ts child-process deadline expectation after lint/typecheck and the broader Vitest suite started successfully.
  • export PATH="$HOME/.nvm/versions/node/v24.15.0/bin:$PATH"; npm run test -- tests/pdf-extraction-budget.test.ts — reproduced the same unrelated PDF child-process deadline failure.

View task →

@BigSimmo
BigSimmo enabled auto-merge (squash) July 18, 2026 14:04
@coderabbitai

coderabbitai Bot commented Jul 18, 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 1 unresolved review comment.

Files modified:

  • src/lib/rag-candidate-sources.ts
  • src/lib/rag.ts

Commit: 1eb6153f75812fa76afdf76adb1f1fb48becad0a

The changes have been pushed to the codex/merge-safe-819-mainfix-regression branch.

Time taken: 5m 32s

@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: 2868f9040d

ℹ️ 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/forms/forms-search-results-page.tsx
Fixed 2 file(s) based on 1 unresolved review comment.

Co-authored-by: CodeRabbit <noreply@coderabbit.ai>
@BigSimmo

Copy link
Copy Markdown
Owner Author

@copilot resolve the merge conflicts on this branch.

@cursor

cursor Bot commented Jul 18, 2026

Copy link
Copy Markdown

Closing as superseded by merged PR #861 (and #859 earlier in the same remediation line).

#861 already landed the design-audit forms/registry UI gating, reduced-motion handling, retrieval abort propagation, and related test alignment on main. This branch is a stale overlapping remount of that work (DIRTY vs current main) and should not merge.

Branch retained; no branch deletion performed.

@BigSimmo BigSimmo closed this Jul 18, 2026
auto-merge was automatically disabled July 18, 2026 14:18

Pull request was closed

Copilot stopped work on behalf of BigSimmo due to an error July 18, 2026 14:19
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