Skip to content

feat: add PWA shell, redirects, and Playwright readiness fix#739

Merged
BigSimmo merged 30 commits into
mainfrom
cursor/pwa-optimization-merge-02e7
Jul 17, 2026
Merged

feat: add PWA shell, redirects, and Playwright readiness fix#739
BigSimmo merged 30 commits into
mainfrom
cursor/pwa-optimization-merge-02e7

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 17, 2026

Copy link
Copy Markdown
Owner

Summary

Adds Progressive Web App shell/offline service worker support, dashboard interaction updates, legacy mode redirect route handlers, and a Playwright readiness fix so empty 307 redirect bodies from /applications (and similar) no longer false-fail CI Production UI.

This supersedes PR #721 with the readiness/H1 contract fixes + complete PR-policy evidence body (the cloud token cannot edit existing PR descriptions).

Verification

  • npm run verify:pr-local scope covered by CI static/unit/build on this PR
  • Focused Playwright readiness verification: production build + next start + identity/smoke paths — /applications 307 empty-body no longer fails readiness
  • npx vitest run tests/test-runner-safety.test.ts (12/12)
  • npx vitest run tests/audit-navigation-auth-regressions.test.ts (5/5) after H1 contract restore
  • CI Production UI pass / Advisory UI pass / Migration replay pass / PR required pass on this PR head
  • UI verification not run: full local npm run verify:ui matrix not re-run in this agent session; CI Production UI / Advisory UI are the authoritative browser gates

Risk and rollout

  • Risk: medium; touches UI/PWA shell, routing redirects (/applications, /medications, presentations), Playwright readiness smoke semantics, and dashboard H1 contract alignment with main.
  • Rollback: revert the PR branch commits (PWA/routes/tests and the Playwright empty-redirect body check). Schema/migrations already trimmed of regressive backdated RAG patches on this branch tip.
  • Provider or production effects: None authorized in this change set. No live OpenAI/Supabase data mutations from the app code path in this PR.

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

Open in Web Open in Cursor 

Summary by CodeRabbit

  • New Features

    • Added redirect handling for legacy entry points and legacy home mode values.
    • Added dynamic page titles/descriptions for form and service slugs.
    • Added service navigator metrics for comparison/verification states.
  • Bug Fixes

    • Improved mobile/layout behavior (overflow/clipping, responsive min-height, stable differential keys, tap-target sizing).
    • Refined accessibility interactions (mode menu closing, comparison control semantics, privacy link sizing).
    • Improved retrieval reliability via request-scoped chunk hydration caching.
  • Documentation

    • Updated sitemap contents and added WIP review/ledger handover docs.
  • Tests

    • Expanded regression/audit and hydration/cache tests; added schema-table gap coverage checks and more redirect/smoke coverage.
  • Chores

    • Updated install/script allow-scripts settings and codebase index coverage tooling.

BigSimmo and others added 12 commits July 18, 2026 00:05
…ific features

- Port legacyHomeRedirectUrl to src/proxy.ts for mode alias sanitization
- Add accessibility improvements to services-navigator-page.tsx (aria-pressed, comparison labels, animation key)
- Update H1 in ClinicalDashboard.tsx to 'Clinical KB'
- Upgrade supabase/schema.sql: bounded-probe correct_clinical_query_terms, document_title_words table, cleanup_registry_corpus_document trigger function
- Update drift-manifest.json SHA for updated schema.sql
- Regenerate docs/site-map.md for updated routes
- Update audit-content-services-regressions.test.ts assertions to match main's form catalog
- Update audit-navigation-auth-regressions.test.ts to match main's implementation patterns
- All 279 test files pass, typecheck and lint clean
…ific features

- Port legacyHomeRedirectUrl to src/proxy.ts for mode alias sanitization
- Add accessibility improvements to services-navigator-page.tsx (aria-pressed, comparison labels, animation key)
- Update H1 in ClinicalDashboard.tsx to 'Clinical KB'
- Upgrade supabase/schema.sql: bounded-probe correct_clinical_query_terms, document_title_words table, cleanup_registry_corpus_document trigger function
- Update drift-manifest.json SHA for updated schema.sql
- Regenerate docs/site-map.md for updated routes
- Update audit-content-services-regressions.test.ts assertions to match main's form catalog
- Update audit-navigation-auth-regressions.test.ts to match main's implementation patterns
- All 279 test files pass, typecheck and lint clean
Legacy /applications (and similar) route handlers return 307 with an
empty body. waitForServer treated falsy bodies as unhealthy, so the
server never passed smoke checks after Ready.
Re-export the PWA/readiness-fix branch for a PR with complete policy
evidence after fixing Playwright empty-redirect readiness.

Co-Authored-By: Cursor Agent <cursoragent@cursor.com>
@supabase

supabase Bot commented Jul 17, 2026

Copy link
Copy Markdown

This pull request has been ignored for the connected project sjrfecxgysukkwxsowpy due to reaching the limit of concurrent preview branches.
Go to Project Integrations Settings ↗︎ if you wish to update this limit.


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

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

This PR updates legacy routing, dynamic metadata, RAG chunk hydration, responsive and accessible UI behavior, sitemap and codebase coverage checks, install configuration, regression tests, and WIP review documentation.

Changes

Application and repository updates

Layer / File(s) Summary
Routing, metadata, and legacy navigation
src/app/..., src/lib/legacy-home-redirect.ts, src/proxy.ts, tests/audit-navigation-auth-regressions.test.ts
Legacy redirects move to route handlers, form and service metadata becomes slug-specific, and proxy navigation handles legacy home modes with query filtering.
Request-scoped RAG hydration
src/lib/rag-candidate-sources.ts, src/lib/rag.ts, tests/rag-chunk-load-cache.test.ts, tests/retrieval-hydration-scope.test.ts
Candidate searches share cached scope, document, and chunk loads, with tests covering retries, access-scope isolation, and concurrent deduplication.
Clinical, services, and mobile interface
src/components/..., src/lib/service-navigator-metrics.ts, tests/audit-content-services-regressions.test.ts, tests/mobile-interaction-regressions.test.ts, tests/ui-accessibility.spec.ts
UI sizing, overflow, focus dismissal, list keys, provenance tones, comparison semantics, service metrics, and accessibility behavior are updated and tested.
Sitemap and codebase coverage validation
scripts/generate-site-map.ts, scripts/check-codebase-index-coverage.mjs, docs/site-map.md, tests/*site-map*, tests/codebase-index-coverage.test.ts
Sitemap generation distinguishes app route handlers from redirects, while index coverage validates structured sections and schema-table parity.
Installation, runner checks, and review records
.npmrc, package.json, scripts/*, tests/pwa-service-worker.test.ts, tests/registry-corpus.test.ts, docs/*review*
Install script permissions, dependencies, migration stubbing, Playwright readiness handling, service-worker coverage, registry routing tests, and WIP review records are updated.

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

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 19.44% 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
Title check ✅ Passed Title is concise and matches the main changes: PWA shell, route redirects, and the Playwright readiness fix.
Description check ✅ Passed The description follows the template with Summary, Verification, Risk and rollout, Clinical Governance Preflight, and Notes filled in.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cursor/pwa-optimization-merge-02e7

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

Merge resolution changed the sr-only H1 to "Clinical KB", which broke
ui-smoke overflow and offline-demo assertions that require
heading level 1 "Clinical Guide" (matching main).

Co-Authored-By: Cursor Agent <cursoragent@cursor.com>
@BigSimmo
BigSimmo marked this pull request as ready for review July 17, 2026 18:29
@BigSimmo
BigSimmo enabled auto-merge July 17, 2026 18:30
Restore audit and accessibility assertions to expect the sr-only
dashboard H1 "Clinical Guide", matching main and ui-smoke.

Co-Authored-By: Cursor Agent <cursoragent@cursor.com>

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

🤖 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 `@docs/site-map.md`:
- Around line 840-843: Move the `/applications`, `/differentials/presentations`,
`/medications`, and `/auth/callback` entries out of the `## API routes` section
into the appropriate route-handler/legacy-route section. Mark the first three as
redirects and document each redirect’s canonical target, while preserving
`/auth/callback` as a user-facing route handler.

In `@src/components/services/services-navigator-page.tsx`:
- Line 523: Remove the cardinality-derived key from the RightRail render in
src/components/services/services-navigator-page.tsx:522-526 so selection-count
changes update it without remounting. In
tests/audit-content-services-regressions.test.ts:74-76, replace the
source-string assertion with an interaction regression that verifies keyboard
focus remains functional after deselecting a service.

In `@supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql`:
- Around line 33-40: Add the document_title_words_document_id_idx index on
document_title_words(document_id) in both
supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql lines
33-40 and supabase/schema.sql lines 855-862, keeping the migration and schema
definition consistent.
- Around line 46-79: Restrict the global correction vocabulary to public
documents by adding d.owner_id is null to the backfill and NEW.owner_id is null
to the indexed-document synchronization logic in
public.sync_document_title_words within
supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql.
Apply the same public-only filters in supabase/schema.sql at lines 868-900, and
remove any previously populated private document_title_words rows there.

In `@supabase/migrations/20260717010000_harden_rag_scalability_patch.sql`:
- Around line 63-96: Update the alias candidate branches in the RAG matching
query so aliases return lower(canonical) as term while retaining
similarity(lower(alias), tok) as the match score; project that score as
match_sim, and order the combined candidates by the stored match_sim before
term. Apply the corresponding term/match_sim projection and ordering in
supabase/migrations/20260717010000_harden_rag_scalability_patch.sql:63-96 and
supabase/schema.sql:3564-3599, leaving canonical and document-title matching
behavior unchanged.

In `@tests/audit-navigation-auth-regressions.test.ts`:
- Around line 125-128: Restore the required sr-only Clinical KB H1 in the
ClinicalDashboard component so it matches the existing test assertion exactly,
including the heading text and accessibility class. Keep the audit test contract
unchanged and ensure the dashboard contains only the expected root H1.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

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: 856d65ff-9ca5-4fd1-9977-7b392c1574fa

📥 Commits

Reviewing files that changed from the base of the PR and between d1b8959 and ff3ef8e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (46)
  • .npmrc
  • docs/branch-review-ledger.md
  • docs/rag-scalability-wip-review-handover-2026-07-15.md
  • docs/site-map.md
  • package.json
  • scripts/check-codebase-index-coverage.mjs
  • scripts/check-m13-migration.ts
  • scripts/run-playwright.mjs
  • src/app/applications/page.tsx
  • src/app/applications/route.ts
  • src/app/differentials/presentations/page.tsx
  • src/app/differentials/presentations/route.ts
  • src/app/forms/[slug]/page.tsx
  • src/app/medications/page.tsx
  • src/app/medications/route.ts
  • src/app/services/[slug]/page.tsx
  • src/components/clinical-dashboard/answer-status.tsx
  • src/components/clinical-dashboard/favourites-command-library-page.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/differentials/differential-presentation-workflow-page.tsx
  • src/components/differentials/differential-stream-page.tsx
  • src/components/forms/form-detail-page.tsx
  • src/components/privacy-input-notice.tsx
  • src/components/services/service-detail-page.tsx
  • src/components/services/services-navigator-page.tsx
  • src/lib/legacy-home-redirect.ts
  • src/lib/rag-candidate-sources.ts
  • src/lib/rag.ts
  • src/lib/service-navigator-metrics.ts
  • src/proxy.ts
  • supabase/drift-manifest.json
  • supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql
  • supabase/migrations/20260714190000_document_table_facts_trgm_idx.sql
  • supabase/migrations/20260717010000_harden_rag_scalability_patch.sql
  • supabase/schema.sql
  • tests/audit-content-services-regressions.test.ts
  • tests/audit-navigation-auth-regressions.test.ts
  • tests/codebase-index-coverage.test.ts
  • tests/mobile-interaction-regressions.test.ts
  • tests/pwa-service-worker.test.ts
  • tests/rag-chunk-load-cache.test.ts
  • tests/registry-corpus.test.ts
  • tests/retrieval-hydration-scope.test.ts
  • tests/supabase-schema.test.ts
  • tests/test-runner-safety.test.ts
  • tests/ui-accessibility.spec.ts
💤 Files with no reviewable changes (3)
  • src/app/medications/page.tsx
  • src/app/differentials/presentations/page.tsx
  • src/app/applications/page.tsx

Comment thread docs/site-map.md Outdated
Comment thread src/components/services/services-navigator-page.tsx Outdated
Comment thread supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql Outdated
Comment thread supabase/migrations/20260714180000_patch_rag_and_corrector_scalability.sql Outdated
Comment thread supabase/migrations/20260717010000_harden_rag_scalability_patch.sql Outdated
Comment thread tests/audit-navigation-auth-regressions.test.ts Outdated
BigSimmo and others added 6 commits July 18, 2026 02:39
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Remove the July 14/17 scalability SQL that would reintroduce unscoped
document_title_words seeding and alias correction after main's public-only
corrector. Keep schema/drift aligned with main, classify legacy redirect
route handlers outside the API sitemap section, and stop remounting the
services RightRail on selection-count changes.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Keep /api listings API-only, document legacy redirect handlers under
Redirects, and avoid remounting services RightRail on selection cardinality.

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

@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

🧹 Nitpick comments (1)
tests/site-map.test.ts (1)

60-61: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert section placement, not just route presence.

These checks only search the entire document for each route, so they would pass if a redirect remained under API routes or an app handler appeared under the wrong heading. Assert that appRouteHandlers are inside App route handlers and redirects are inside Redirects, including their targets.

🤖 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/site-map.test.ts` around lines 60 - 61, Update the checks around
expectDocumentedRoute so appRouteHandlers are asserted under the “App route
handlers” section and redirects under “Redirects,” verifying both each route and
its target within the correct section rather than searching the entire document.
Preserve the existing iteration over data.appRouteHandlers and data.redirects.
🤖 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 `@scripts/generate-site-map.ts`:
- Around line 209-212: Update the empty-state message in renderSiteMapRaw() from
“No page-level redirects discovered.” to “No redirects discovered” to reflect
redirects collected from both pageRoutes and nonApiHandlers.

---

Nitpick comments:
In `@tests/site-map.test.ts`:
- Around line 60-61: Update the checks around expectDocumentedRoute so
appRouteHandlers are asserted under the “App route handlers” section and
redirects under “Redirects,” verifying both each route and its target within the
correct section rather than searching the entire document. Preserve the existing
iteration over data.appRouteHandlers and data.redirects.
🪄 Autofix (Beta)

❌ Autofix failed (check again to retry)

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: 722d91bb-e96a-4321-ab29-025dde72519e

📥 Commits

Reviewing files that changed from the base of the PR and between 285c6c9 and 0df4476.

📒 Files selected for processing (5)
  • docs/site-map.md
  • scripts/generate-site-map.ts
  • src/components/services/services-navigator-page.tsx
  • tests/audit-content-services-regressions.test.ts
  • tests/site-map.test.ts
💤 Files with no reviewable changes (1)
  • src/components/services/services-navigator-page.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/audit-content-services-regressions.test.ts

Comment thread scripts/generate-site-map.ts Outdated
@github-actions

Copy link
Copy Markdown

CI triage

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

  • 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 #2910 (success).

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

cursoragent and others added 7 commits July 17, 2026 19:29
The Production UI failure came from focus=1's hydration retry reclaiming the
search input after the mode menu opened, which tripped blur-to-dismiss and
detached the Forms option before Playwright could click it. Skip the retry
when focus already left the search field, and harden mode-menu pointer
activation so blur-dismiss cannot unmount options mid-click.
The Production UI flake timed out waiting for Forms in the mode menu on
/services?focus=1 because the 300ms composer focus retry stole focus after
the menu opened and blur-dismiss closed it. Skip reclaim while the menu is
open, close the command dropdown when opening the mode control, and align
the tools mode-switch assertions with the sibling wait helper.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Resolve services navigator conflict by taking main's size-tap floor while
preserving comparison aria-pressed labels required by the PWA audit tests.

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

coderabbitai Bot commented Jul 17, 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.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@coderabbitai

coderabbitai Bot commented Jul 17, 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.

Autofix skipped. No unresolved CodeRabbit review comments with fix instructions found.

@BigSimmo
BigSimmo merged commit af5c025 into main Jul 17, 2026
17 checks passed
@BigSimmo
BigSimmo deleted the cursor/pwa-optimization-merge-02e7 branch July 17, 2026 20:11
cursor Bot pushed a commit that referenced this pull request Jul 17, 2026
Capture merge-readiness outcomes for the screenshot PR queue after
hosted CI babysitting and the #739 privacy/UI follow-up fixes.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Jul 17, 2026
Capture merge-readiness outcomes for the screenshot PR queue after
hosted CI babysitting and the #739 privacy/UI follow-up fixes.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Jul 17, 2026
Capture merge-readiness outcomes for the screenshot PR queue and keep
the historical ledger out of Prettier realignment.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
cursor Bot pushed a commit that referenced this pull request Jul 17, 2026
Capture merge-readiness outcomes for the screenshot PR queue and keep
the historical ledger out of Prettier realignment.

Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
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.

3 participants