Skip to content

refactor(mockup): scope safety-plan id counter per instance - #1037

Merged
BigSimmo merged 1 commit into
mainfrom
claude/patient-safety-plan-mockup-wldmyc
Jul 21, 2026
Merged

refactor(mockup): scope safety-plan id counter per instance#1037
BigSimmo merged 1 commit into
mainfrom
claude/patient-safety-plan-mockup-wldmyc

Conversation

@BigSimmo

@BigSimmoBigSimmo commented Jul 21, 2026

Copy link
Copy Markdown
Owner

Summary

  • Tidies the one CodeRabbit nitpick deferred from the safety-plan mockup PR (Add patient safety plan generator mockup #1015): the module-level mutable seq counter behind uid().
  • Replaces it with a per-instance useRef counter inside PatientSafetyPlanMockup. The old module-level counter kept incrementing across unmount/remount (route revisits); a per-instance ref resets with the component. Ids only need to be unique within a mounted plan, so behaviour is unchanged.
  • uid is now a stable useCallback and is added to addEntry's dependency list (satisfies react-hooks/exhaustive-deps).

Scope: one file, dev-only mockup (/mockups/patient-safety-plan, 404 in production).

Verification

  • Typecheck (tsc --noEmit) — clean
  • Lint incl. react-hooks/exhaustive-deps — clean
  • Prettier — no changes
  • Not applicable (no retrieval/answer/clinical-workflow behaviour changed): eval:*, check:production-readiness, verify:ui

Risk and rollout

  • Risk: negligible — an internal id-generation refactor in a dev-only mockup. No user-visible behaviour change; entry ids remain unique within a plan.
  • Rollback: revert the one commit.
  • Provider or production effects: None.

Clinical Governance Preflight

Refactor of internal id generation in a dev-only mockup; no ingestion, answer generation, retrieval/ranking, source rendering, document-access, privacy, production-env, or clinical-output behaviour is touched — all items below hold unchanged.

  • 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

  • Closes the last open review item on the safety-plan mockup. CodeRabbit had tagged this "low value"; addressing it on request for cleanliness.

🤖 Generated with Claude Code

https://claude.ai/code/session_019g9m5emoPKCmDDPeGrchYd


Generated by Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Improved reliability when creating entries in patient safety plans.
    • Prevented identifier conflicts between separate patient safety plan instances.

Replace the module-level mutable `seq` counter behind `uid()` with a
per-instance `useRef` counter inside PatientSafetyPlanMockup. The old
module-level counter kept incrementing across unmount/remount (route
revisits); a per-instance ref resets with the component. Ids only need to
be unique within a mounted plan, so behaviour is unchanged. `uid` is a
stable useCallback and is added to `addEntry`'s dependency list.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019g9m5emoPKCmDDPeGrchYd
@supabase

supabaseBot commented Jul 21, 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 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 2d99b1b5-5029-4fe1-9147-48007de810a5

📥 Commits

Reviewing files that changed from the base of the PR and between 366eff9 and 167d998.

📒 Files selected for processing (1)
  • src/components/patient-safety-plan-mockup.tsx

📝 Walkthrough

Walkthrough

The patient safety plan mockup replaces its module-level ID sequence with an instance-scoped useRef counter and updates addEntry to use a memoized generator.

Changes

Patient safety plan ID generation

Layer / File(s)Summary
Instance-scoped ID generation
src/components/patient-safety-plan-mockup.tsx
Adds useRef, removes the module-level uid sequence, and wires addEntry to a memoized per-instance ID generator.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check nameStatusExplanation
Title check✅ PassedThe title is concise and accurately summarizes the main refactor to scope the safety-plan ID counter per instance.
Description check✅ PassedThe description matches the template well, with Summary, Verification, Risk and rollout, Clinical Governance Preflight, and Notes all completed.
Docstring Coverage✅ PassedDocstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
✨ 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 claude/patient-safety-plan-mockup-wldmyc

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

@BigSimmo
BigSimmo marked this pull request as ready for review July 21, 2026 02:31
@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 21, 2026 02:31
@BigSimmo
BigSimmo merged commit 8ab5885 into mainJul 21, 2026
19 checks passed
@BigSimmo
BigSimmo deleted the claude/patient-safety-plan-mockup-wldmyc branch July 21, 2026 02:39
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.

2 participants

@BigSimmo@claude