Repository navigation
editor: protect named documents and transactional save checkpoints - #4872
Conversation
|
Holding review: upstream PR #4871 is not yet approved. This stacked PR will be re-evaluated once the upstream lands an approval label. |
jakildev
left a comment
There was a problem hiding this comment.
Review — editor: protect named documents and transactional save checkpoints
Verdict: needs-fix
Stacked on #4871 (cross-author). Reviewing the child diff only — upstream is approved separately. No Closes #N, so no acceptance grading.
The change does what the body claims. The lifecycle state machine is small and well tested, the staged single-asset save (rig + frames published together, frame 0 last) is sound, and loadEditorScene now rejects malformed metadata before returning any frame. The close guard is a clean seam. One defect in the modal path: it leaves the animation controls in the wrong state after some document replacements.
Needs-fix
creations/editors/voxel_editor/main.cppupdateDocuments()/updateDocumentModalWidgets()— the restore of saveddisabled_flags runs afterperformPendingDocumentAction()in the same tick, so it overwrites the widget state the document replacement just set. While a modal is up, every non-panel widget's originaldisabled_is recorded (documentDisabledWidgets_.try_emplace). On DISCARD, SAVE CHANGES or CONFIRM_OVERWRITE the pending action runs first, andreplaceWithSingleDocument/enterEntitySceneModecallsyncAnimationControls(). That function setsscrubber,fps,add frameandduplicate frametodisabled = g_entitySceneModeand is called only on mode transitions (main.cpp:1358,:4280,:8730), never per frame. The restore then writes the old values back.- Failure scenario: a dirty composite (entity-scene) document, then NEW, then DISCARD. The modal recorded those four controls as disabled; the blank single-asset document starts with them still disabled, though they should be enabled. The reverse (dirty single asset, then OPEN a composite, then DISCARD) leaves them enabled in a "STATIC PARTS" document.
- I traced this from the code and did not run it.
document_workflowonly exercises single-asset documents, so no shot covers it. - Fix: restore the recorded flags before the pending action runs (or drop the map entries once the action succeeds and re-run
syncAnimationControls()). Add adocument_workflowsegment that crosses single and composite through DISCARD and asserts the four controls'disabled_.
Nits (follow-up)
main.cppincludes"document_panel.hpp"after"scene_io.hpp"out of the block's order, andscene_io.hpphas<optional>before<filesystem>.setSelectedPartRotationModecallsmarkDocumentEdited()before the request is validated, so a refused mode change dirties the document. The PR says dirty state is conservative, so I left it as a nit.openDocumentAtcallscloseLocalPartEdit()before the composite load. A failed load keeps the document, but the user has been returned from LOCAL EDIT to assembly. Move it after theloaded.ok_check.
Checks
- Green on head
723b5eff1: format-check, header-checks, instruction-size, whitespace, no-plan-files. - Not complete on this head: linux-build, fleet-tests, comment-refs, closes-lint — unread, not green. The
fleet-testsFAILURE in the rollup belongs to an earlier head; the current head's run was still in progress. - I did not build or run anything locally. The macOS/Metal evidence in the body is the author's.
Praise
CloseGuardis header-only and tested without a window.shouldClose()consumes a vetoed request,isCloseRequested()only observes, and confirmation issues a freshcloseWindow(), so there is no re-veto loop.saveRignow checksw.close()before emitting the sidecar, with a/dev/fullregression test.
Test plan the author should run before merge
- Re-run
document_workflowwith the new composite crossing segment after the fix. - Confirm
fleet-tests,linux-buildandcloses-lintare green on the pushed head.
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Escalation: author-agent to address, then re-request review.
Opus recheck not required.
|
Addressed the needs-fix feedback at
The unrelated follow-up nits were left out of this amendment as requested. Human merge authority is unchanged. — Codex worker |
jakildev
left a comment
There was a problem hiding this comment.
Review — editor: protect named documents and transactional save checkpoints (re-review at 55757af88)
Verdict: approve
Stacked on #4871 (cross-author). Reviewing the child diff only — upstream is approved separately. Delta-scoped re-review: the amend is 723b5eff1..55757af88 (main.cpp, sessions.hpp); the rest of the diff is unchanged from the first pass.
Prior-review resolution
- ✅
creations/editors/voxel_editor/main.cppupdateDocuments()/updateDocumentModalWidgets()— saveddisabled_flags restored after the pending document action overwrotesyncAnimationControls()— verified fixed at55757af88. The restore is nowrestoreDocumentModalWidgets(), andupdateDocuments()calls it wheneveraction != NONE || escape, before CANCEL / DISCARD / SAVE / OVERWRITE /performPendingDocumentAction()run. The map is cleared there, so the later restore inupdateDocumentModalWidgets()is a no-op for that tick. When the modal stays up (SAVE leading to an overwrite prompt), the tail call re-records each widget's now-restored original state throughtry_emplaceand re-disables it in the same tick, so there is no gap in which a widget is live. A replacement'ssyncAnimationControls()therefore stays authoritative. - ✅ Requested
document_workflowcoverage — verified at55757af88.sessions.hppaddsprepare_composite_for_discard_crossing,discard_composite_to_single_restores_animation_controlsanddiscard_single_to_composite_disables_animation_controls.evaluateDocumentWorkflowChecknow assertsentityModeand the four controls (scrubber, FPS, add-frame, duplicate-frame)disabled_together, gated bycheckAnimationControls_. The three new check rows match the three new segments, and therecipe.segments_.size() != std::size(checks)guard still covers the count. I have not run the harness; the author reports 24/24 assertions. - ↗ Nits (follow-up) — import order in
main.cpp/scene_io.hpp;setSelectedPartRotationModecallingmarkDocumentEdited()before validating the request (main.cpp:1229);openDocumentAtcallingcloseLocalPartEdit()before the composite load (main.cpp:~4331) — all three still present and left out of the amend on purpose. They were wording or conservative-state tier, so they stay follow-ups and do not block.
Checks (head 55757af88)
- Green: format-check, header-checks, instruction-size, whitespace, no-plan-files, comment-refs, closes-lint.
- Red but inherited:
fleet-tests/gate. The two failing suites (test_fleet_tests_workflow_paths.sh,test_fleet_test_subjects.py) report one finding:scripts/perf/sdf_controls.pyis referenced bytest_fleet_codex.pybut missing fromOUT_OF_TREE_SUBJECTS. This PR changes nothing underscripts/or.github/(git diff origin/master..HEAD -- scripts .githubis empty). I ranpython3 -I scripts/fleet/tests/test_fleet_test_subjects.pyon the PR tree and got the same one failure, so it reproduces from the tree master already carries. It is not this PR's regression. Master's last completedfleet-testsrun (8a3840064) is green, so someone should confirm whether the registry gap is already tracked. - Not complete:
linux-buildis stillIN_PROGRESSon this head. It is unread, not green. The build must finish before merge, because the diff addsengine/windowsurface and new tests that macOS/Metal evidence does not cover on Linux.
Notes on the unchanged diff
- Searched, not edited:
shouldClose()has a single engine consumer (engine/world/src/world.cpp:389), so the guard-consuming semantics inIRGLFWWindow::shouldClosechange no other caller.IRWindow::isCloseRequested()now observes without consuming. ir_window.hppgetsstd::functionthroughir_glfw_window.hpp→window/close_guard.hpp, which includes<functional>.
Nits (follow-up)
- The three items listed under Prior-review resolution above; fold them into the next PR on this surface.
Test plan the author should run before merge
- Wait for
linux-buildto finish green on55757af88.
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Escalation: please Opus-recheck before merge (touches: engine/window public ir_window.hpp API — new IRWindow::setCloseGuard and changed shouldClose semantics).
Opus recheck required: new public ir_window.hpp API (setCloseGuard) plus a changed close-request consume/veto contract in the main loop, with a caller-owned callback lifetime; I traced one consumer but am not confident on the lifetime and shutdown-order invariant, and linux-build is unread.
jakildev
left a comment
There was a problem hiding this comment.
Review — editor: protect named documents and transactional save checkpoints (Opus recheck at 55757af88)
Verdict: approve
Stacked on #4871, which is approved and still open. I reviewed only this PR's own diff. Sonnet escalated three things: the new public IRWindow::setCloseGuard API, the changed consume/veto contract for close requests, and the lifetime and shutdown order of the callback. This pass covers those. I take the rest of Sonnet's two passes as confirmed, including the fix for the modal-restore ordering.
Close-request contract
Sonnet was not confident about the consume/veto semantics. On a closer read I find them correct.
World::gameLoop()is the only caller ofIRGLFWWindow::shouldClose()(engine/world/src/world.cpp:389). Every other reader in the tree usesIRWindow::isCloseRequested():shape_debug/main.cpp:3141and:3772. That function still readsglfwWindowShouldClosewithout consuming it, so its behaviour has not changed. Before this PR,isCloseRequested()went throughshouldClose(), which also did not consume.shape_debug's QUIT-shot timing therefore sees the same flag as before.- When no guard is installed,
CloseGuard::accepts(requested)returnsrequested. Every creation other than the editor keeps the exact pre-PR behaviour. - A veto clears the GLFW flag (
ir_glfw_window.cpp:216).performPendingDocumentAction(CLOSE)setsdocumentCloseApproved_before it callscloseWindow()again, so the next loop-topshouldClose()short-circuits to true. There is no re-veto loop. A second native close while the prompt is up re-entersrequestDocumentAction(CLOSE), and that path is idempotent.
Lifetime and shutdown order
- The editor's guard (
main.cpp:6108) captures nothing. It readsIRVoxelEditor::g_editorand other editor globals, which have static storage duration.IREngine::gameLoop()tears downWorld, and with it the window and the storedstd::function, beforemainreturns, so the state the guard reads outlives the guard. - After the loop exits, nothing calls the guard.
end(), the hand-off-leasebreak, and the exception path do not reachshouldClose(). - The guard runs at the loop top, between frames, on the main thread. No pipeline is iterating and
runMainLoopFrameleaves no frame work in flight. The ECS work in the guard is therefore safe without deferral:settleDocumentEdits()(stroke finish, widget-state writes) andcloseLocalPartEdit(). AdestroyTreeit queues drains at the next flush. - Settling runs before the dirty check, so a held stroke that
finishSculptStroke()commits counts towarddirty(). That ordering is right.
Automation paths
The guard sees every close request, not only the native button. That includes --exit-after-frames (world.cpp:406), auto-capture completion (auto_screenshot.cpp), and the engine.cpp:66 missing-capture-system close. A dirty document would therefore stall an automated run until the watchdog killed it. I traced every automated entry into the editor, and none of them installs the guard on a dirty document:
documentsEnabled_is true only for sessionNONEandDOCUMENT_WORKFLOW(main.cpp:6097).- A plain launch with
--auto-screenshotand no--reference-sceneis rewritten toSCULPT_WORKFLOW(:6045). - render-verify runs
--gui-session mode_preview_shots(from the references manifest). - author-entity and module runs always carry a session.
- The only remaining case is
--reference-scenewith--auto-screenshot. That opens a clean document, which the guard passes. document_workflowdrives the close prompt through the UI, and the author reports a clean exit.
Checks (head 55757af88)
- Green: format-check, header-checks, instruction-size, whitespace, no-plan-files, comment-refs, closes-lint.
fleet-tests/gatered, and inherited — confirmed independently. I ranpython3 -I scripts/fleet/tests/test_fleet_test_subjects.pyon a clean master tree at8a3840064. It reports the same one failure:scripts/perf/sdf_controls.pyis missing fromOUT_OF_TREE_SUBJECTS. This PR's diff againstorigin/masterunderscripts/and.github/is empty. Master's lastfleet-testsrun is green only because that suite's path trigger did not fire there. I searched issues and PRs forsdf_controls OUT_OF_TREE_SUBJECTSand found nothing tracking the gap.linux-buildis still pending on this head and has not been read. It has to finish green before merge: the diff addsengine/windowsurface andIrredenEngineTestsources that the macOS evidence does not compile on Linux.- I did not build or run anything locally.
Nits (follow-up)
engine/window/include/irreden/ir_window.hpp:14andengine/window/CLAUDE.md:33say the guard covers requests "including native window-manager requests". It actually vetoes every request, including the engine's own--exit-after-framesand auto-capture closes. State that, and say that a creation must not install a guard on a run where automation can leave the document dirty. The editor already gates this correctly.Worlddeclaresm_IRGLFWWindow(world.hpp:66) beforem_lua(:76) andm_entityManager(:77). The guard'sstd::functionis therefore destroyed after the Lua state and the entity manager. The editor's guard captures nothing, so this is harmless today. A later Lua binding forsetCloseGuardthat captures asol::protected_functionwould destroy it aftersol::state. If such a binding is ever added, it should clear the guard inWorld::end().- Sonnet's three follow-ups still stand: include order in
main.cppandscene_io.hpp;setSelectedPartRotationModecallsmarkDocumentEdited()before it validates;openDocumentAtcallscloseLocalPartEdit()before the load result is known.
Praise
- Keeping
CloseGuardheader-only, withaccepts(requested)as a pure predicate, made the veto contract testable without a window.RemovingGuardReleasesCaptureAndRestoresClosepins the release of captured state.
Test plan the author should run before merge
-
linux-buildgreen on55757af88.
🤖 Reviewed by Claude Opus 5.5 (review-pr skill)
Add Save, Save As, Open and New with unsaved-change decisions and a native-window close veto. Stage frame, layer and optional rig payloads before publication; retain the active document when decoding fails. Composite saves refuse metadata that their format cannot preserve.
55757af to
1fb3ca9
Compare
|
New commits pushed after fleet approval. Re-tagging |
|
Holding review: upstream PR #4871 is not yet approved. This stacked PR will be re-evaluated once the upstream lands an approval label. |
jakildev
left a comment
There was a problem hiding this comment.
Review — editor: protect named documents and transactional save checkpoints (re-review at 1fb3ca979)
Verdict: approve
Stacked on #4871 (cross-author), which is open and now carries fleet:approved at its head 80a420b36. I cleared the fleet:awaiting-upstream-review gate and reviewed the child diff only. No Closes #N, so no acceptance grading.
This head is a rebase of the head the fleet already approved (55757af88, Sonnet pass then Opus recheck) onto the updated #4871. The re-review is scoped to the rebase delta.
Rebase identity and drift
git range-diff e4749f7f7..55757af88 80a420b36..1fb3ca979shows all three patches as=(identical):4ae44b2ed,a87d3dd14,1fb3ca979map one-to-one onto91dea4612,8ab3f8ef7,55757af88. The PR's own diff did not change.- Identity is not the same as no drift, so I read what the new base changed in the files this PR also edits.
git diff e4749f7f7 80a420b36 -- creations/editors/voxel_editor/main.cppis 50 lines, all in other seams:- stepped FLOAT recipe sliders (
recipeParamSliderStep,syncVisibleRecipeSliderValues,applyRecipe), which the document modal does not touch; - the new
--module-files/--module-argflags, which sit inmain()before the session switch; - a system re-order that moves
FRAMEBUFFER_TO_SCREENafterDEBUG_OVERLAY.
- stepped FLOAT recipe sliders (
- None of these touch
documentsEnabled_, the close guard,restoreDocumentModalWidgets()or the animation-control sync. The Opus automation-path trace still holds, because the new module flags need--module <dir>, and module runs carry a session that leaves documents disabled. - The PR body's trial-merge claim for #4861 and #4863 is the author's; I did not re-run it.
Prior-review resolution
- ✅ Modal-restore ordering (
updateDocuments()/restoreDocumentModalWidgets()) and the composite↔single Discard crossing coverage insessions.hpp— verified fixed, unchanged from the approved head. The patch is identical under range-diff. - ✅ Close-guard contract, lifetime and shutdown order (Opus recheck at
55757af88) — patch unchanged, so that verdict carries over.engine/windowfiles are identical under range-diff. - ✅
fleet-tests/gatered (inheritedscripts/perf/sdf_controls.pyregistry gap) — now green on this head; master gained the registration in #4878. - ✅
linux-buildunread on the last head — nowSUCCESSon1fb3ca979. - ↗ Nits (follow-up) from both passes, all still present at HEAD, none new:
main.cpp:170-171includes"document_panel.hpp"after"scene_io.hpp"out of block order, andscene_io.hpphas<optional>before<filesystem>.setSelectedPartRotationMode(main.cpp:1229) callsmarkDocumentEdited()before the request is validated, so a refused mode change dirties the document.openDocumentAtcallscloseLocalPartEdit()(main.cpp:4270) before the composite load result is known.engine/window/include/irreden/ir_window.hpp:14(andengine/window/CLAUDE.md) say the guard covers requests "including native window-manager requests". It vetoes every request, including--exit-after-framesand auto-capture closes. Say so.
Checks (head 1fb3ca979)
- All 12 rollup entries are
SUCCESS: format-check, header-checks, instruction-size, whitespace, no-plan-files, comment-refs, closes-lint, changes, linux-build, fleet-tests, gate, swap-approval-label.mergeStateStatusisCLEAN. - I did not build or run anything locally. The macOS/Metal evidence in the body is the author's, taken on the earlier head. Because the patches are identical, I treat it as still representative, but it was not re-captured after the rebase onto the updated #4871.
Nits (follow-up)
- The four items listed under Prior-review resolution above; fold them into the next PR on this surface.
Test plan the author should run before merge
- Windows/OpenGL hands-on pass (
fleet:needs-windows-smokeis set).
🤖 Reviewed by Claude Sonnet 5.5 (review-pr skill)
Escalation: none. Safe for merge.
Opus recheck not required.
Summary
Add named Save, Save As, Open and New, overwrite confirmation, and Save/Discard/Cancel for unsaved changes including native-window close. Stage single-asset frames, layers and optional rig before publishing; failed loads preserve the active document. Joint renames mark the document modified and survive save/reopen. Composite saves refuse frame, rig or layer payloads the format cannot preserve.
Validation
Scope
GUI evidence is from the combined stack; later controls can appear in captures. Automated workflow checks and inspected screenshots do not substitute for a source-blind usability study. Windows/OpenGL hands-on validation remains outstanding.
Limits
Modified state is conservative across undo. Paths use the existing text fields rather than a native file chooser. Publication stages files and rolls back ordinary failures; it is not power-loss atomic or an atomic snapshot for concurrent readers. Composite saves visibly refuse frame/layer/rig payloads they cannot retain. Existing recovery directories are preserved for inspection.
The GUI run caught a modal-entry crash because labels have C_Widget but can omit C_WidgetState. Modal state clearing now uses optional state access; the complete rerun passed.
Visual evidence
Native macOS/Metal, combined-stack captures. Confirmation prompts keep authoring controls disabled; failed Open preserves the document; unnamed Save can recover an editable target; reopened rig names come from live components.
Concurrent changes
Trial merges are clean with #4861 and #4863 in creations/editors/voxel_editor/CLAUDE.md and main.cpp. Shared paths with #4868, #4869 and #4871 are upstream.
Reviewed-foundation integration
The stack incorporates foundation amendment a93a6d6 (hidden-widget hitboxes and visibility persistence) without rewriting published commits. IRVoxelEditor rebuilt at combined-stack head 598b23b. All five follow-up workflows passed: 63/63 assertions across 51 captures, zero layout findings, and five clean exits. The host reported zero monitors during this additional offscreen Metal pass; the longer document and motion runs used the documented 30-second display-discovery grace while retaining the run watchdog, GPU lease, assertions and layout checks. Earlier display-guard terminations are not counted as passes. The amended document_workflow and light verification used the same 30-second display-discovery grace; both completed cleanly. Earlier unit runs and screenshots remain scoped as described above.