Skip to content

fix(safety-plan): draft-mark incomplete plans and require contact reach methods - #1281

Merged
BigSimmo merged 5 commits into
mainfrom
claude/safety-planning-tools-page-tsq4vs
Jul 27, 2026
Merged

fix(safety-plan): draft-mark incomplete plans and require contact reach methods#1281
BigSimmo merged 5 commits into
mainfrom
claude/safety-planning-tools-page-tsq4vs

Conversation

@BigSimmo

@BigSimmoBigSimmo commented Jul 27, 2026

Copy link
Copy Markdown
Owner

Summary

Follow-up to #1068's post-merge Codex review. Two clinical-safety gaps shipped unaddressed (the third finding — the patient-name field / privacy copy — was already resolved by #1119 making the tool identifier-free, so nothing to change there):

  • Incomplete-plan draft guard. An incomplete plan could be copied/printed with "(to be completed)" placeholders and handed to a patient as a finished safety plan. Rather than disabling the share actions — fix: keep Safety Plan Generator identifier-free #1119 deliberately keeps Copy/Print always available behind the privacy notice, with tests to match — the patient copy and the copied/printed text now carry an unmistakable "DRAFT — incomplete, not for patient handover" banner until every step is complete.
  • Contact completeness. The two contact steps (support, professional) now count as complete only when every listed contact has a reach method (the secondary field), so a plan can't reach "Ready to share" / finalise with a support or crisis contact that has a name but no phone or way to reach them.

Adds tests/patient-safety-plan.dom.test.tsx; the existing patient-safety-plan-privacy.dom.test.tsx (Copy/Print stay enabled) continues to pass.

RAG impact: no retrieval behaviour change — self-contained UI tool; no src/lib/rag/**, retrieval, ranking, or eval surfaces touched.

Verification

  • npm run verify:cheap — green (lint, typecheck, design-system contract, full unit suite 3537 passed / 5 skipped, sitemap/docs/knip). The new DOM tests pass and the previously-existing safety-plan privacy tests still pass.
  • UI verification not run: verify:ui (Chromium) was not run in this sandbox. The change is a conditional draft banner + a readiness refinement on /safety-plan; the existing ui-tools.spec.ts safety-plan export test stays valid because Copy/Print behaviour is unchanged. Recommend verify:ui in review/CI.
  • verify:release / eval gates: not applicable — no retrieval/ranking/answer-generation change.

Risk and rollout

  • Risk: Low. Additive UI on an existing tool — a conditional DRAFT banner on the patient copy plus a stricter completeness rule for contact steps. No auth/data/Supabase/provider paths touched; Copy/Print stay always-available.
  • Rollback: revert the single commit.
  • Provider or production effects: None.

Clinical Governance Preflight

Touches clinical output (the safety-plan document):

  • Source-backed claims still require linked source verification — N/A: client-side builder, no source-backed claims/retrieval.
  • No patient-identifiable document workflow introduced or expanded — the tool remains identifier-free (per fix: keep Safety Plan Generator identifier-free #1119); working content stays ephemeral in the browser tab. This change only adds a draft marker + a completeness rule.
  • Supabase target remains Clinical KB Database (sjrfecxgysukkwxsowpy) — untouched.
  • Service-role keys and private document access remain server-only — untouched.
  • Demo/synthetic content remains clearly separated — the seeded example is opt-in via "Load example".
  • Source metadata, review status, and outdated/unknown-source behavior remain conservative — untouched.
  • Deployment classification/TGA SaMD impact was checked — documentation/builder aid; the change makes incomplete output more conservative (draft-marked), with no new decision-support inference.

Notes


Generated by Claude Code

Summary by CodeRabbit

  • New Features

    • Contact steps now require both a name and a reachable contact method to count as complete.
    • Added a clear warning when a safety plan is incomplete and not ready to share.
    • Exported plan text now identifies incomplete plans as drafts.
  • Bug Fixes

    • Progress tracking and draft status now accurately reflect contact-step completion.
  • Tests

    • Added coverage for incomplete plans, completed plans, and partially completed contact details.

…ch methods
Follow-up to #1068's review. Two clinical-safety gaps remained after the tool
shipped (the third finding — the patient-name field — was already resolved by
#1119 making the tool identifier-free):
- Draft guard (was: "gate Copy/Print on completeness"): an incomplete plan could
be copied/printed with "(to be completed)" placeholders and handed to a patient
as a finished safety plan. Rather than disabling the share actions — #1119
deliberately keeps Copy/Print always available behind the privacy notice — the
patient copy and the copied/printed text now carry an unmistakable
"DRAFT — incomplete, not for patient handover" banner until every step is done.
- Contact completeness: the two contact steps (support, professional) now count
as complete only when every listed contact has a reach method (the secondary
field), so a plan can't reach "Ready to share"/finalise with a support or
crisis contact that has a name but no phone or way to reach them.
Adds tests/patient-safety-plan.dom.test.tsx covering the draft flag and the
contact-reach-method requirement. Existing safety-plan privacy tests (Copy/Print
stay enabled) continue to pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017Jurbrad9ZeWo45EQpxBzR
@supabase

supabaseBot commented Jul 27, 2026

Copy link
Copy Markdown

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


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

@coderabbitai

coderabbitaiBot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@cursor[bot], you've reached your PR review limit, so we couldn't start this review.

Next review available in:46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 5d31e09f-9849-4c8d-97d3-bf4ec9bbb10a

📥 Commits

Reviewing files that changed from the base of the PR and between db2ff23 and f7e616d.

📒 Files selected for processing (2)
  • src/components/patient-safety-plan.tsx
  • tests/patient-safety-plan.dom.test.tsx
📝 Walkthrough

Walkthrough

Patient safety plan readiness now requires every contact entry to include a reachable secondary method. Progress indicators, exported text, patient preview messaging, and DOM tests reflect the updated draft state.

Changes

Patient Safety Plan Readiness

Layer / File(s)Summary
Completion and readiness calculation
src/components/patient-safety-plan.tsx
Contact steps are complete only when entries include non-empty reach details; filled-step counts and progress coloring use the shared completion helper.
Draft-state outputs and validation
src/components/patient-safety-plan.tsx, tests/patient-safety-plan.dom.test.tsx
Incomplete plans receive draft notices in generated text and the patient preview, while tests cover empty, complete, and incomplete-contact states.

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

Possibly related PRs

Suggested reviewers:cursoragent

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Docstring Coverage✅ PassedNo functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check✅ PassedCheck skipped because no linked issues were found for this pull request.
Out of Scope Changes check✅ PassedCheck skipped because no linked issues were found for this pull request.
Title check✅ PassedThe title clearly summarizes the two main changes: draft-marking incomplete safety plans and requiring contact reach methods.
Description check✅ PassedThe description matches the template with Summary, Verification, Risk and rollout, Clinical Governance Preflight, and Notes filled in.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/safety-planning-tools-page-tsq4vs

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.

@BigSimmo
BigSimmo marked this pull request as ready for review July 27, 2026 21:34
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@BigSimmo
BigSimmo enabled auto-merge (squash) July 27, 2026 21:34

@coderabbitaicoderabbitaiBot 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.

🧹 Nitpick comments (1)
tests/patient-safety-plan.dom.test.tsx (1)

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

Cover copied draft text and both contact-step variants.

These tests validate only the preview warning and the support-contact step. Add a clipboard assertion for incomplete/complete planText and a missing-reach-method case for the professional-contact step.

🤖 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/patient-safety-plan.dom.test.tsx` around lines 24 - 54, Extend the
PatientSafetyPlan tests to assert clipboard planText content for both incomplete
and complete plans, verifying the draft marker is present or absent as
appropriate. Add a professional-contact-step case that removes reach methods
while retaining a contact and confirms the plan remains marked as a draft,
alongside the existing support-contact coverage.
🤖 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.
Nitpick comments:
In `@tests/patient-safety-plan.dom.test.tsx`:
- Around line 24-54: Extend the PatientSafetyPlan tests to assert clipboard
planText content for both incomplete and complete plans, verifying the draft
marker is present or absent as appropriate. Add a professional-contact-step case
that removes reach methods while retaining a contact and confirms the plan
remains marked as a draft, alongside the existing support-contact coverage.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 533f1f36-9aee-4d40-827d-0f7815a15831

📥 Commits

Reviewing files that changed from the base of the PR and between b3c5e18 and db2ff23.

📒 Files selected for processing (2)
  • src/components/patient-safety-plan.tsx
  • tests/patient-safety-plan.dom.test.tsx

@cursor
cursorBot disabled auto-merge July 27, 2026 21:50
@cursor

cursorBot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Temporarily disabled auto-merge so the StepBuilderCard completeness + clipboard draft-guard polish can land on this tip without racing the squash merge. Will re-arm or leave for review once the push is up and CI settles.

@cursor

cursorBot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Polish on tip f7e616d1: StepBuilderCard filled indicator now uses isStepComplete, plus a clipboard assertion for the incomplete-plan DRAFT banner. Temporarily disabled auto-merge to land this without a squash race; re-arm when CI is green if desired.

@BigSimmo
BigSimmo merged commit 7740535 into mainJul 27, 2026
18 checks passed
@BigSimmo
BigSimmo deleted the claude/safety-planning-tools-page-tsq4vs branch July 27, 2026 22:16
BigSimmo added a commit that referenced this pull request Jul 27, 2026
* docs(ledger): record open-PR review and Bugbot sweep
Append review outcomes for the current open PR queue after #1277
merged, including merge-tree classification and pr-bugbot findings.
* docs(ledger): record open-PR recommendation implementation
Capture closeouts for the unsafe audit cluster and the follow-up fixes
pushed to #1273, #1275, #1280, and #1281.
---------
Co-authored-by: Cursor Agent <cursoragent@cursor.com>
Sign up for freeto 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

@BigSimmo@claude@cursoragent