Repository navigation
fix(studio): an Interfaces edit whose save was refused counts as unsaved, so leaving or reloading asks first - #29268
Merged
Conversation
…arked unsaved The Interfaces pillar now reports an open leaf's edit whose last save was refused (the leaf buffer's, or an object leaf's list view's) through onDirtyChange beside navDirty, so beforeunload, the header leave guard and the shell seam ask before it is dropped; the rail and the create dialog ask before another leaf's load replaces it. A landed save or a buffer install clears it. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSfsyajgxceM7R1qi6
…s its changeset Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01QsR2jSfsyajgxceM7R1qi6
Contributor
Author
|
domain:ui#5 · zhuangjianguo · session_01QsR2jQjvWkZ7is6GXbC6DB 席位核对 — ACCEPT ·
|
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.
Requested by Steedos · project thread
Fixes #29113
Clause-②: no
Metadata-protocol: none
维护者速读
ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx的refusedUnsent与它上报的onDirtyChangeeffect,以及doSave里三处setLeafRefusedFor;StudioDesignSurface.refusedLeafUnsaved-29113.test.tsx。What changes
InterfacesPillarmirrored onlynavDirtythroughonDirtyChange, so the surface'sbeforeunload, its header leave guard and the shell seam (useRegisterUnsavedEdits) never saw a leaf edit whose save the server refused. Such an edit stays in the buffer, anduseDraftAutoSavesends it again only after the next edit. The pillar now keepsleafRefusedFor, the leaf key of the last refused leaf save, set on each ofdoSave's three failure exits (the refused save itself, plus the customize door's refusal and its no-version answer) and cleared by a save that lands or by a buffer a load installs.refusedUnsentis true while the open leaf is dirty, its own buffer is loaded (draftLoaded), and that key is the open leaf's. The same reading covers anobjectleaf's list-view buffer, whosefailureis already kept byuseObjectListViewDraft(dirty && failure.during === 'save'). The mirror now reportsnavDirty || refusedUnsent.pickSurfaceandopenCreateasked only for a held edit (heldUnsent). They now ask forheldUnsent || refusedUnsent, the same way the list-view switcher already asks for a refused view edit.heldEditkeeps its meaning. The surface's held-clause state, which the Publish refusal toast reads, is untouched. A refused edit is unsent but not held, so it does not block Publish.Tests
StudioDesignSurface.refusedLeafUnsaved-29113.test.tsx(new). The report cases render the realStudioDesignSurfaceon the real route shape, with a stub report canvas and a client double that answers a draft save with a 422 while asked to.beforeunloadis prevented) and the Data pillar link ask. The next edit's save lands, and then neither asks.objectleaf's list-view edit refused with a 422 makes the pillar report dirty, and a later save that lands reports clean (real list-view panel,onDirtyChangeread directly).Acceptance notes
draft,doSave). Anobjectleaf's list view saves through its own buffer (useObjectListViewDraft), and nav edits through the app buffer (appDraft), whichnavDirtyalready covered.refusedUnsentcovers the first two, so one dirty report covers all three buffers.pickSurfaceand the New dialog'sopenCreatenow ask on a refused edit too (they asked only on a held one). Both live insideInterfacesPillar; no other file or component changed. Without them, opening another item in the rail still dropped the refused edit silently, which the dispatch scope ("beforeunload, the header guard and the rail treat it as unsaved") covers.Verification
Measured on
d6b4e8a1(baseorigin/main10bfd70e). Headd45ce04cmergesorigin/main74a19dd8, which does not touchStudioDesignSurface.tsx; the delta against main is still exactly the three files above. Ond45ce04cthe new file and the merged-inStudioDesignSurface.automationsReadOnly-11124.test.tsxwere rerun (2 files, 15/15), the derived gate list is unchanged (34), andcheck-sdui-manifest,check-changeset-no-majorandcheck-empty-changesetwere rerun (exit 0).New tests, the base run, and the ablation
vitest run StudioDesignSurface.refusedLeafUnsaved-29113.test.tsx: 4/4 passed.10bfd70ewritten over the source, restored fromHEADby trap, blob back to30a4c402= HEAD): 3 failed, 1 passed. The three are the report reload/pillar-link case, the rail case and the list-view case. The control passes.scripts/ablation-replace.mjs, replacingonDirtyChangeRef.current?.(navDirty || refusedUnsent);withonDirtyChangeRef.current?.(navDirty);(anchor 1 to 0, blob30a4c402to592451e1): 2 failed (the report reload/pillar-link case and the list-view case), 2 passed (the rail case, which readsleafUnsentdirectly, and the control). Restored: blob equals HEAD andgit diff HEADis empty.Real browser: showcase Studio, a report save forced to 422
examples/app-showcase(objectstack dev --seed-admin --fresh) with the Console's Vite dev server on app-shell source, Playwright (Chromium). Opened Interfaces, then reportshowcase_hours_by_status, pressed Customize, and typed in Description. The probe answered the report's draft PUT (/api/v1/meta/report/showcase_hours_by_status?mode=draft&package=com.example.showcase.custom) with a 422 while asked to.StudioDesignSurface.tsxserved): the red refusal strip showed, a dispatchedbeforeunloadwas not prevented, and the Data pillar link left the pillar with no confirm. The edit was dropped silently.beforeunloadwas prevented, and the Data link raised the native confirm "You have unsaved changes. Leave this page anyway?" (dismissed, so the pillar stayed). The next edit's PUT was let through and landed: the strip cleared andbeforeunloadwas no longer prevented. Untouched, nothing asked.Sweep, type-check and gates
InterfacesPillaror the/interfacesroute and reads a confirm,beforeunload,onDirtyChange, a refusal or a save (73 files, two batches): 73 passed, 528 tests passed.turbo run type-check --filter=@object-ui/app-shell: 65/65 tasks, exit 0.dispatch-gates --commands: 34 derived families, all exit 0, includingcheck-sdui-manifestandpnpm --dir ui exec vitest run scripts/(169 files passed, 2 skipped).dispatch-gates --ran: 34 derived, 34 run, 0 NOT-MEASURED.check-closing-keyword-parity,check-changeset-no-majorandcheck-adr-0087-registrationwere also run against this body.pnpm check:new-line-citations(ui): 0 new citations.Generated by Claude Code