Repository navigation
Open shifts: take back your own request while it waits for approval - #3485
Conversation
A new roster_open_withdraw function lets only the doctor who asked put a waiting open-shift request back on the list. An approved, cancelled or expired request is refused with roster_conflict; anyone else's request reads as missing. The advert page offers "Take back my request" with a confirm sheet. roster_command is unchanged; no table or data changes. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CZwGiwt7eXkD4fwyFM83gY
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configuration
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 |
|
Updates to Preview Branch (claude/open-shifts-withdraw-hj3sp1) ↗︎
Tasks are run on every commit but only new migration files are pushed.
View logs for this Workflow Run ↗︎. |
🏁 CodeAnt Quality Gate ResultsCommit: ✅ Overall Status: PASSEDQuality Gate Details
|
Merging this PR will not alter performance
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CZwGiwt7eXkD4fwyFM83gY
🤖 CodeAnt AI — Review Status
|
Thanks for using CodeAnt! 🎉We're free for open-source projects. if you're enjoying it, help us grow by sharing. Share on X · |
There was a problem hiding this comment.
BigSimmo has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
PR Summary by QodoLet doctors take back pending open-shift requests
AI Description
Diagram
High-Level Assessment
Files changed (13)
|
Qodo FixerNo findings are available for this PR yet. Findings appear here once Qodo has reviewed the PR. |
|
Claude encountered an error after 2s —— View job I'll analyze this and get back to you. |
CodeAnt PR Risk: Low Risk
Assessed commit: |
Code Review by Qodo
No findings for this group No findings for this group No findings for this group Resolved findings 1.
|
|
Code review by qodo was updated up to the latest commit 9127b34 |
…-back spec The take-back override now applies only to the read it was made against, so a request made again from another tab or device shows as waiting rather than offering Request this shift. The new take-back browser spec joins the PR and release shard tables. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CZwGiwt7eXkD4fwyFM83gY
…ew and checks the re-read Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01CZwGiwt7eXkD4fwyFM83gY
|
Code review by qodo was updated up to the latest commit 08c5678 |
|
Code review by qodo was updated up to the latest commit 9fb65dc |
CI failed: The PR policy check failed because the added Supabase migration reuses version 20261012090000, which already exists on main; applied migration versions never re-run on live, so the migration needs a new, newer version.OverviewOne unique error template across 12 analyzed logs. The failure is a single blocking PR policy error from the migration-history check, and it is directly related to this change. Warnings (UI verification, governance preflight, operational-risk bundling) are advisory and omitted from the failure analysis. FailuresMigration version reused from main (confidence: high)
Summary
Code Review ✅ Approved 2 closed / 2 findings🔴 High risk · The production migration adds a function that clears a doctor's claim and reopens shifts, potentially letting others claim a slot if its checks misfire. Lets a doctor take back their own open-shift request while it awaits approval, via a new
✅ 2 closed✅ Edge Case: Failed take-back leaves a stale 'Waiting for approval' page
✅ Bug: Inline focus ref steals focus back on every page re-render
Review coverage🤖 Auto-approval Approved 📋 Rules No rules evaluated 🧪 Functional validation Not enabled · Set up Tip Comment OptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change the behavior for this request:
Was this helpful? React with 👍 / 👎 | Gitar |
User description
Summary
Before: once a doctor asked for an open shift, only a roster manager could clear the request. A doctor who asked by mistake, or whose plans changed, had to message the manager.
After: a request that is still waiting for approval shows "Take back my request" on the shift advert. A confirm sheet explains that the shift goes back on the list for everyone, and that the doctor can ask again while it stays open. An approved shift is already on the roster, so it can't be taken back this way. The doctor gives it away through Roster as for any other shift.
This is item 10 of the Open shifts expansion, which the owner approved on 12 Oct 2026 ("Go ahead with your recommendations", then "Go ahead with all improvements and recommendations"). It is kept apart from the UI work in #3483 because it contains a migration.
How: a new SQL function
roster_open_withdraw(actor, service, openShiftId)follows theroster_needs_replacepattern. It is security invoker, executable by service_role only, and uses the same lock order as every team write. It resets aclaimedrow toopenonly when the caller is the doctor who asked. Anyone else getsroster_not_found, so nobody learns who asked for what. A row that has been approved, cancelled or expired getsroster_conflict. The app sends a newopen.withdrawaction through the team route to that function.roster_commandis unchanged, and there are no table or data changes.Verification
npx tsc --noEmit: clean.npm run test:focusedon the changed source:Test Files 173 passed (173),Tests 2419 passed (2419).tests/open-shifts-withdraw.dom.test.tsxcovers the confirm, the success notice, the conflict message, and the button staying hidden on approved shifts and offline (3 tests passed).tests/roster-team-api.test.tscovers routing toroster_open_withdrawand refusing bad payloads (22 tests passed).tests/sql/roster-behaviour.sqlsection 8 now covers someone else's take-back (not found), a manager's take-back (not found), the doctor's own take-back (shift reopened and claimer cleared), a claim again, and a take-back after approval (conflict). This runs in CI's Migration replay, not locally.npm run check:migration-role: passed.check-migration-immutability --writesealed the new migration.def_hashwith the same expression asschema_drift_snapshoton a local Postgres 16 scratch database. The method reproduced the committedroster_needs_replacehash exactly (c9251a59…).schema_sha256was recomputed fromsupabase/schema.sql. CI's freshness step is the authoritative check.Risk and rollout
Clinical Governance Preflight
PsychSift Production(sjrfecxgysukkwxsowpy)Notes
open-shifts-advert-page.tsxis expected.🤖 Generated with Claude Code
https://claude.ai/code/session_01CZwGiwt7eXkD4fwyFM83gY
Generated by Claude Code
Summary by cubic
Lets a doctor take back their own open-shift request while it waits for approval, so a mistaken request or changed plans no longer require messaging a roster manager to clear it.
A waiting request now shows "Take back my request" on the shift advert, with a confirm sheet explaining the shift goes back on the list for everyone. The new
roster_open_withdrawfunction reopens only rows the caller themselves claimed; anyone else getsroster_not_found, and approved, cancelled, expired, or started requests getroster_conflict. The started check readsclock_timestamp()after the locks, so a take-back that waited on a lock is still refused once the start time has passed. If a request is decided before the take-back lands, the page forgets this visit's copy of it and re-reads it, pointing the doctor to My shifts; a take-back only overrides the read it was made against, so a request claimed again from another tab or device shows as waiting, and a "Waiting for approval" state from this visit lapses once a newer read no longer shows the shift as this doctor's. After a take-back, keyboard focus moves to the result, since the button that opened the sheet is gone. Approved shifts are already on the roster, so they're given away through Roster as before.roster_commandchanges.Written for commit 179461b. Summary will update on new commits.
Summary by Gitar
This will update automatically on new commits.
CodeAnt-AI Description
Let doctors take back open-shift requests awaiting approval
What Changed
Impact
✅ Doctors can correct mistaken shift requests✅ Open shifts return to the list when requests are withdrawn✅ Clearer outcomes when a request is already decided💡 Usage Guide
Checking Your Pull Request
Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.
Talking to CodeAnt AI
Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:
This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.
Example
Preserve Org Learnings with CodeAnt
You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:
This helps CodeAnt AI learn and adapt to your team's coding style and standards.
Example
Retrigger review
Ask CodeAnt AI to review the PR again, by typing:
Check Your Repository Health
To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.