Skip to content

fix: rebuild safe information-page back navigation#1161

Merged
BigSimmo merged 14 commits into
mainfrom
codex/back-navigation-clean-reconciliation
Jul 24, 2026
Merged

fix: rebuild safe information-page back navigation#1161
BigSimmo merged 14 commits into
mainfrom
codex/back-navigation-clean-reconciliation

Conversation

@BigSimmo

@BigSimmo BigSimmo commented Jul 24, 2026

Copy link
Copy Markdown
Owner

Summary

  • Rebuild the reviewed Add back navigation to information and settings pages #1121 back-navigation change on fresh origin/main, excluding the archived dirty branch ancestry.
  • Add deterministic in-app back targets to Privacy, Colour coding, Settings, and Safety Plan; preserve the identifier-free Safety Plan privacy contract and confirm before discarding dirty local-only plan content.
  • Return Tools-owned pages to the canonical Tools mode home, not browser history or the default answer home.
  • Harden Sheet focus restoration so unmount cleanup cannot schedule stale timers.

RAG impact: no retrieval behaviour change — navigation, local dirty-form confirmation, and UI focus teardown only.

Verification

  • npm run test -- tests/navigation-back-button.dom.test.tsx tests/patient-safety-plan-privacy.dom.test.tsx tests/privacy-ui.test.ts tests/sheet.dom.test.tsx tests/document-viewer-shell.dom.test.tsx — 5 files, 22 tests passed on the current functional head.
  • npm run test -- tests/route-reachability.test.ts tests/navigation-back-button.dom.test.tsx tests/privacy-ui.test.ts — 3 files, 12 tests passed after the privacy-return update; this caught and verified the static reachability fix.
  • npx prettier --check on the changed navigation/privacy files — passed.
  • npm run test -- tests/privacy-ui.test.ts tests/sheet.dom.test.tsx tests/settings-dialog-actions.dom.test.tsx tests/settings-inert-preferences.dom.test.tsx — 4 files, 16 tests passed after the final review fixes.
  • git diff --check — passed.
  • Verification not run: npm run verify:pr-local; the earlier verify:cheap attempt exceeded the five-minute tool window and lost its final result when the output pipe closed. Protected hosted checks are the broad gate.
  • UI verification not run locally: the PR's hosted Production UI and Advisory UI jobs are required before merge.
  • Verification not run: npm run verify:release; no release/handoff confidence claim is made by this PR alone.

Risk and rollout

  • Risk: Low UI navigation/focus risk. Navigation uses explicit canonical in-app fallbacks; no history.back() behavior is introduced.
  • Rollback: Revert this PR's merge commit.
  • Provider or production effects: None before merge; no provider-backed runtime or data operation.

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; this navigation-only change does not alter clinical decision-support output.

Notes

Summary by CodeRabbit

  • New Features

    • Added consistent back navigation across privacy, reference, settings, and safety-plan screens.
    • Privacy links now return to the originating app mode when applicable.
    • Added unsaved-changes confirmation when leaving an in-progress safety plan.
    • Improved mobile settings navigation with a dedicated back control.
  • Bug Fixes

    • Improved sheet focus restoration and cleanup when closing or unmounting.
  • Tests

    • Expanded coverage for navigation, privacy links, safety-plan warnings, and sheet behavior.

BigSimmo and others added 6 commits July 24, 2026 16:05
Replace legacy sm:h-11/sm:w-11 classes with IconButton size-tap, and mock next/navigation in privacy/safety-plan tests that render without App Router.

Co-authored-by: Cursor <cursoragent@cursor.com>
Always push fallbackHref instead of history.back() so external referrers
cannot eject users from Clinical KB. Settings back uses IconButton/size-tap.
Addresses Codex review on PR #1121.

Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
Guard the header back control when entries, reasons, or a plan date
have been edited so in-progress browser-only content is not discarded
without confirmation.
Cancel pending focus-restore rAF/timeouts on Sheet unmount and guard
document access so Vitest coverage workers cannot fail the suite with an
unhandled ReferenceError after document-viewer shell tests open a sheet.
Co-authored-by: BigSimmo <BigSimmo@users.noreply.github.com>
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Adds deterministic back navigation and privacy return links, protects safety-plan drafts with confirmation prompts, adds a settings back control, and hardens Sheet focus restoration during teardown with expanded tests.

Changes

Navigation and lifecycle hardening

Layer / File(s) Summary
Deterministic navigation and privacy return flow
src/components/navigation-back-button.tsx, src/components/privacy-input-notice.tsx, src/components/privacy-page-back-button.tsx, src/app/privacy/page.tsx, src/app/reference/colour-coding/page.tsx, src/components/clinical-dashboard/{DocumentManagerPanel.tsx,master-search-header.tsx}, tests/navigation-back-button.dom.test.tsx, tests/privacy-ui.test.ts
Adds explicit fallback navigation, mode-aware privacy links, privacy-page return routing, page back controls, and coverage for valid and invalid destinations.
Safety-plan draft confirmation
src/components/patient-safety-plan.tsx, tests/patient-safety-plan-privacy.dom.test.tsx
Tracks unsubmitted row drafts and prompts before leaving a dirty safety plan.
Mobile settings back control
src/components/clinical-dashboard/settings-dialog.tsx
Adds a mobile header back button wired to close the settings dialog.
Sheet focus-restore teardown
src/components/ui/sheet.tsx, tests/sheet.dom.test.tsx, tests/document-viewer-shell.dom.test.tsx
Cancels pending focus restoration during unmount and validates Sheet cleanup and document-action closing behavior.

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

Sequence Diagram(s)

sequenceDiagram
  participant PrivacyInputNotice
  participant PrivacyPage
  participant PrivacyPageBackButton
  participant NextRouter
  PrivacyInputNotice->>PrivacyPage: open /privacy?from=mode
  PrivacyPage->>PrivacyPageBackButton: render back control
  PrivacyPageBackButton->>NextRouter: push allowlisted mode home or /
Loading

Possibly related PRs

Suggested labels: codex

Suggested reviewers: claude

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 35.71% 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 clearly summarizes the main change: rebuilding safe in-app back navigation.
Description check ✅ Passed The description matches the template with Summary, Verification, Risk, Clinical Governance Preflight, and Notes, plus relevant test details.
✨ 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/back-navigation-clean-reconciliation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@supabase

supabase Bot commented Jul 24, 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 ↗︎.

@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: 004e191ee4

ℹ️ 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/patient-safety-plan.tsx Outdated
Comment thread src/components/ui/sheet.tsx
cursoragent and others added 3 commits July 24, 2026 08:22
# Conflicts:
#	src/components/ui/sheet.tsx

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

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

ℹ️ 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/patient-safety-plan.tsx Outdated
@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

Copy link
Copy Markdown

Summary

Testing

  • git diff --check
  • ⚠️ npm run test -- tests/patient-safety-plan-privacy.dom.test.tsx (blocked by environment setup: node_modules/vitest/vitest.mjs is missing, so Vitest is not installed)
  • ⚠️ Next.js docs check: node_modules/next/dist/docs/ was not available in this worktree because dependencies are not installed.

View task →

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

ℹ️ 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/app/reference/colour-coding/page.tsx Outdated

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

ℹ️ 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/app/privacy/page.tsx Outdated

@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: 605264ad6e

ℹ️ 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/privacy-ui.test.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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/components/clinical-dashboard/settings-dialog.tsx`:
- Around line 264-275: Add the lg:hidden responsive utility to the backButton
IconButton in the settings dialog, preserving its mobile visibility and existing
styling while hiding it at desktop breakpoints alongside the close button.

In `@tests/privacy-ui.test.ts`:
- Around line 8-13: Extend the `next/navigation` mock used by `PrivacyPage`
tests to provide a `useSearchParams` implementation alongside `useRouter`.
Ensure the mocked hook returns the search-params interface consumed by
`PrivacyPageBackButton`, while preserving the existing `back` and `push` router
mocks.

In `@tests/sheet.dom.test.tsx`:
- Around line 115-118: Update the unmount timer test around restoreFrameSpy so
it verifies restoreFrameSpy was not called after await vi.runAllTimersAsync(),
not only before the flush. Keep the timer-count assertion, and add or move the
no-call assertion to cover callbacks scheduled during timer processing.
🪄 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: e4e954b1-921f-4699-88b8-f5084391826a

📥 Commits

Reviewing files that changed from the base of the PR and between 2f407e8 and a3f057a.

📒 Files selected for processing (15)
  • src/app/privacy/page.tsx
  • src/app/reference/colour-coding/page.tsx
  • src/components/clinical-dashboard/DocumentManagerPanel.tsx
  • src/components/clinical-dashboard/master-search-header.tsx
  • src/components/clinical-dashboard/settings-dialog.tsx
  • src/components/navigation-back-button.tsx
  • src/components/patient-safety-plan.tsx
  • src/components/privacy-input-notice.tsx
  • src/components/privacy-page-back-button.tsx
  • src/components/ui/sheet.tsx
  • tests/document-viewer-shell.dom.test.tsx
  • tests/navigation-back-button.dom.test.tsx
  • tests/patient-safety-plan-privacy.dom.test.tsx
  • tests/privacy-ui.test.ts
  • tests/sheet.dom.test.tsx

Comment thread src/components/clinical-dashboard/settings-dialog.tsx
Comment thread tests/privacy-ui.test.ts
Comment thread tests/sheet.dom.test.tsx
@BigSimmo
BigSimmo merged commit 7a81cfa into main Jul 24, 2026
73 checks passed
@BigSimmo
BigSimmo deleted the codex/back-navigation-clean-reconciliation branch July 24, 2026 09:29
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