fix(safety-plan): draft-mark incomplete plans and require contact reach methods - #1281
Conversation
…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
This pull request has been ignored for the connected project Preview Branches by Supabase. |
Warning Review limit reached
Next review available in:46 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the 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 configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughPatient 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. ChangesPatient Safety Plan Readiness
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tests/patient-safety-plan.dom.test.tsx (1)
24-54: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winCover 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
planTextand 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
📒 Files selected for processing (2)
src/components/patient-safety-plan.tsxtests/patient-safety-plan.dom.test.tsx
Use isStepComplete for StepBuilderCard's filled indicator and assert the clipboard draft banner for incomplete plans.
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. |
Polish on tip |
Uh oh!
There was an error while loading. Please reload this page.
* 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>
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):
Adds
tests/patient-safety-plan.dom.test.tsx; the existingpatient-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.verify:ui(Chromium) was not run in this sandbox. The change is a conditional draft banner + a readiness refinement on/safety-plan; the existingui-tools.spec.tssafety-plan export test stays valid because Copy/Print behaviour is unchanged. Recommendverify:uiin review/CI.verify:release/ eval gates: not applicable — no retrieval/ranking/answer-generation change.Risk and rollout
Clinical Governance Preflight
Touches clinical output (the safety-plan document):
Clinical KB Database(sjrfecxgysukkwxsowpy) — untouched.Notes
main— feat(tools): add Safety plan generator as a Tools-page tool (not a mode) #1068 was squash-merged and its branch auto-deleted. This lands the post-merge review findings that never reached feat(tools): add Safety plan generator as a Tools-page tool (not a mode) #1068 (Codex's fixes stayed on an internal branch).Generated by Claude Code
Summary by CodeRabbit
New Features
Bug Fixes
Tests