Repository navigation
fix(artifacts): clear the save notice when switching versions - #18229
iamwhatever merged 1 commit into
Conversation
Picking another version in the Version selector exits edit mode but left saveError and saveConflict set. After a refused save, the "Not saved." notice stayed on screen over the other version, and a later unrelated error (a failed snapshot or revert) showed under the conflict title with the "Open the newer version" link. Cancel, Escape and the version switch now end an edit through one step. It clears the save error, the conflict flag and the preview toggle, and advances the edit generation, so a save or pull flush still on the wire when the edit ends no longer re-arms the notice when it is refused.
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that a plain Save still on the wire when the user cancels lands on the server and refreshes the page; only its editor-state updates are skipped. [DESIGN-REVIEWED] 090cb79 Description read[DESCRIPTION-READ] c3dbd6d28186251f6c82691834c04fc4e4eb9d0565cb0a70cb538f21cf2b8f30 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5, fork) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check before merge: the snapshot exit ( What this change shipsInventory (5 items) — 5 justifiedIntent: when someone leaves an artifact edit (by switching version, Cancel or Escape), nothing from that edit should stay on screen. This is a FIX for #18182.
[FIRST-PRINCIPLES-REVIEWED] 090cb79 Description read[DESCRIPTION-READ] e1d81248d1ca83ab0e10b9d81803bb813d08f88e95a7ef992d78b4d5c147c714 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5, fork) — 🟡 CONCERNSUX-level review of UX-Verdict: CONCERNS No first-time reader has looked at the cleared-notice state, since this fork lane has no blind read; the screenshots show the main fix working. Watch
[UX-REVIEWED] 090cb79 Description read[DESCRIPTION-READ] e67bd891c06bc5faf8c01739aafd362916290be4c80b1b50b6f51263efdf94a1 That sha256 names everything this verdict read: the PR description, plus the 6 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
|
|
Design check (a plain Save still on the wire when the user leaves the edit): it holds.
|
iamwhatever
left a comment
There was a problem hiding this comment.
This PR fixes the stale "Not saved." conflict notice, the leftover conflict flag and the leftover preview toggle that survived a version switch after a 409. It fixes them at the root: Cancel, Escape and the Version-selector switch now all exit through one endEditing() in ArtifactDetailPage.tsx. That function clears all three and advances editGenerationRef, so a refused save or pull flush that lands after the user left is dropped by the existing generation checks in handleSave and flushLiveEdits. I read the full diff and the surrounding handlers at 090cb79. A plain save still on the wire when the user cancels still lands and invalidates the query. Only its editor-state updates are skipped, and the next edit re-pins its base token, so I see no regression. The four new tests cover each exit, including the two late-refusal races, and the body says they fail on main. All checks are green, base is main, and the only CONCERNS (UX, a missing screenshot of the preview case) was rebutted with the covering test. The committed temp-screenshots PNGs are acceptable here because this is a fork PR with no --attach access. — crew-pr-reviewer
Problem / Motivation
Goal: When the user leaves an artifact edit, by switching versions, Cancel or Escape, nothing from that edit stays behind: no stale "Not saved." notice and no leftover preview mode.
A stale save gets a 409, and the artifact page shows the "Not saved." notice. If the user then picks another version in the Version selector and discards the draft, the editor closes, but the notice stays on screen over the other version. The conflict flag stays set as well. So a later failure that has nothing to do with the conflict, such as a snapshot or revert that hits a network error, shows under "Not saved." with the "Open the newer version in a new tab" link.
Two smaller leaks come from the same exits. A version switch made in preview mode leaves preview on, so the next edit opens as a preview instead of the editor. And a save or pull flush that is refused after the user has left the edit still shows the notice.
Why it matters
The notice says the draft is kept and that Save will overwrite newer content. After the user leaves the edit, the draft is gone, so the notice is wrong. A later network error would also look like a save conflict and point the user at the wrong fix. An edit that opens as a preview looks as if the editor did not open.
Not a goal
What changed (motivation → approach → change)
Leaving an edit now leaves nothing of it behind: no "Not saved." notice, no preview mode, and no notice from a save that is refused after the user left.
Each exit reset the edit state by hand. The Version selector in
ArtifactDetailPage.tsxmissed the save error, the conflict flag and the preview toggle. No exit marked the edit as ended, so a refused save or pull flush that came back later still showed the notice.Cancel, Escape and the version switch now end an edit through one step. It clears all three and marks the edit as ended, so a refusal that arrives later is ignored, as one for another artifact already is.
Backwards compatibility
Compatible: ending an edit resets the state Cancel already resets, and advances the edit generation that opening an edit and navigating already advance.
Removes nothing: no API, setting or stored data changes. Only state from an edit the user has left stops showing.
Tests
website/src/test/ArtifactDetailPage.saveConflict.test.tsx:Each test fails when the part of the fix it covers is removed, and all four fail on
main's page.Manual verification
Ran the real built page with its API stubbed, once built from
mainand once from this branch. A save was refused with a 409, then the user switched to v1 and discarded the draft. Built frommain, the notice stays over v1. Built from this branch, it is gone. The late refusals and preview mode are covered by the tests above.Screenshots / video
Committed under
temp-screenshots/(fork PR, no--attach).Related Issues
Closes #18182
Follow-up to #14075, whose Opus review found the version-switch case after that PR was ready.
Pattern harvest
Rule candidate: review-prompt
Pattern: mode state reset by hand at each exit path, so one exit (the version switch) missed part of it; one shared exit step resets it all
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)