Repository navigation
fix: ask before registering a recording whose surgery was not registered - #58
Merged
Merged
Conversation
vrrigs
force-pushed
the
t3/confirm-surgery-registration
branch
from
December 1, 2026 20:50
9e7ea1c to
d8ba6bf
Compare
This was referenced Dec 1, 2026
With "Add surgery & insertion device if missing ?" checked, createRecording opened the surgery dialog and then carried on whatever happened there. A failed surgery insert, or a dialog closed without registering, still moved the files to cup (ROBOCOPY /MOV, local copies deleted) and registered the recording without a surgery. The failed insert only showed a dialog and was not reported to Slack. - The surgery dialog now records how it ended (registered, failed or closed), and addSurgeryData returns it. - registerSurgery reports a failed insert to Slack through notifySlackJobFailure, like the other write callbacks. - When the surgery was not registered, createRecording asks the operator (confirmRecordingWithoutSurgery) whether to register the recording without it, before any file is moved. Cancel, the default, stops there and frees the button again. Whether a missing surgery should block the recording is still open, so this does not block it. Fixes #56 Assisted-by: ClaudeCode:claude-opus-5-5
They grepped createRecording, registerSurgery and the surgery dialog for specific wording, so they broke on harmless rewording. The remaining tests cover confirmRecordingWithoutSurgery itself. Assisted-by: ClaudeCode:claude-opus-5-5
…swer The error uiconfirm in registerSurgery has no output, so it does not wait. The figure closed at once and createRecording opened its 'Surgery not registered' prompt on the same figure, which could cover the error. The prompt now shows the error itself, and registerSurgery only keeps it. registerSurgery also closes the surgery figure after the try, so nothing that runs after the commit can turn a registered surgery into a failed one. Assisted-by: ClaudeCode:claude-opus-5-5
vrrigs
force-pushed
the
t3/confirm-surgery-registration
branch
from
December 1, 2026 21:15
d8ba6bf to
10a6d5e
Compare
tabedzki
marked this pull request as ready for review
December 1, 2026 21:58
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 AI text below 🤖
Fixes #56
Follows #51 (merged). Stacked on #57: merge that first (it changes the same
registerSurgerycatch block); GitHub then retargets this PR tomain.Problem
With "Add surgery & insertion device if missing ?" checked,
createRecordingopens the surgery dialog (addSurgeryData, blocked onuiwait) and then carries on whatever happened there:registerSurgeryshows "Surgery data could not be registered" and closes the dialog. Nothing is reported to Slack.In both cases
createRecordinggoes on to move the files to cup withcopyRecording(ROBOCOPY /MOV, so the local copies are deleted) and registers the recording without a surgery. Nobody is told.Fix
app.AllSurgeryStuff.outcome.createComponentsSurgeryFigurestarts it as'closed'.registerSurgerysets'registered'after the commit, or'failed'as the first line of itscatch. It closes the surgery figure after thetry, so nothing after the commit can turn a registered surgery into a failed one.addSurgeryDatanow returns it, and the classdef declaration is updated to match.registerSurgeryreports a failed insert to Slack throughnotifySlackJobFailure('Surgery registration', ...), the same waycreateRecording,CreateNewJobandRerunJobreport their failures. The context lists system, modality, subject, user, surgery date and device count. It no longer shows its own error dialog: thatuiconfirmdid not wait, so the prompt below could open on top of it. The error is kept inapp.AllSurgeryStuff.error_messageand shown in the prompt instead.confirmRecordingWithoutSurgery(subject, outcome, askFcn, error_message). If the surgery was registered it returns true without asking. Otherwise it tells the operator why (the insert failed, with its error, and was reported to Slack; or the dialog was closed) and asks Register without surgery / Cancel. Cancel is the default, closing the prompt also counts as Cancel, and any other answer stops. An unknown outcome is an error, which lands increateRecording's existing "Recording preparation" catch, so it also stops before the move.createRecordingcalls it right after the surgery dialog, inside the preparationtryand beforecopyRecording. On Cancel it re-enables the button, sets the GUI back to "Ready" and returns. Nothing has been moved or written at that point.registerSurgeryrollback goes through fix: never let a failed rollback skip the write callbacks' error handling #57'scancelOpenTransaction. The vendored toolboxes anddj_local_conf.jsonare untouched.Screenshots
The prompt
createRecordingshows before any file is moved, when the surgery insert failed:and when the surgery dialog was closed:
Rendered in MATLAB R2023b by calling the PR's code with a stand-in figure, not on a rig.
confirmRecordingWithoutSurgerybuilt the text; the error is an example.Tests
tests/TestRecordingWithoutSurgery.m, added to CI, AGENTS.md and README.md. It needs no DB and no GUI, because the prompt is a stub:confirmRecordingWithoutSurgerydoesn't ask when the surgery was registered. It asks, naming the subject and the reason, for'failed'and'closed'. Cancel is the default and the cancel option. Cancel, closing the prompt and unexpected answers ('',[], cells, wrong case, string arrays) all stop. Only the exact proceed option (char or string) goes ahead. Unknown outcomes are an error, and string inputs are accepted. A failed insert's error appears in the prompt as given (including%), and a closed dialog shows no error.8bd2fb5c, where the helper doesn't exist.test_jsonencodeprettypasses, on R2023b. TheRecordingProcessJobGUIclass still loads, andaddSurgeryDatadeclares theoutcomeoutput.uvx prek run --all-filespasses.Not tested: a real registration through the GUI on a rig (dialog closed, insert failed, then Cancel and proceed), or a real Slack post from
registerSurgery.Assisted-by: ClaudeCode:claude-opus-5-5