Skip to content

fix(artifacts): clear the save notice when switching versions - #18229

Merged
iamwhatever merged 1 commit into
kirodotdev:mainfrom
peterhieuvu:fix/artifact-version-switch-conflict
Oct 9, 2026
Merged

iamwhatever merged 1 commit into
kirodotdev:mainfrom
peterhieuvu:fix/artifact-version-switch-conflict

Conversation

@peterhieuvu

Copy link
Copy Markdown
Contributor

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

  • Changing the conflict notice's wording or the overwrite button.
  • Changing the stale-write guard or the 409 it returns.

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.tsx missed 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:

    • After a 409, switching to an older version leaves edit mode with no conflict notice or "Not saved." on screen.
    • A refused pull flush that returns after a version switch shows no notice.
    • A refused save that returns after Escape and discard shows no notice.
    • After a switch from preview mode, the next edit opens the editor, not the preview.

    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 main and once from this branch. A save was refused with a 409, then the user switched to v1 and discarded the draft. Built from main, 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

A stale save is refused: the "Not saved." notice shows and the draft is kept (the same on main and on this branch)

Before, on main: after switching to v1 and discarding the draft, the "Not saved." notice is still shown over v1

After, on this branch: the same switch to v1 clears the notice

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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

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.
@peterhieuvu
peterhieuvu requested review from a team and KiroCrewCaptain as code owners October 8, 2026 20:38
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 8, 2026
@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 090cb79edf38486c08d75e9addbc7777c4502457 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 090cb79edf38486c08d75e9addbc7777c4502457 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

First-Principles-Verdict: PASS

Check before merge: the snapshot exit (ArtifactDetailPage.tsx:868) and the pull-flush exit (:936) still reset edit state by hand and skip endEditing.

What this change ships

Inventory (5 items) — 5 justified

Intent: 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.

  1. Switching version after a 409 save conflict now clears the "Not saved." notice and the conflict link — justified
  2. Switching version from preview mode turns preview off, so the next edit opens the editor — justified
  3. A save or pull refusal that arrives after the user has left the edit no longer shows a notice — justified
  4. Cancel and Escape now end the edit through the same step as the version switch — justified
  5. Three before/after screenshots are committed under temp-screenshots/ — justified

[FIRST-PRINCIPLES-REVIEWED] 090cb79

Description read

[DESCRIPTION-READ] e1d81248d1ca83ab0e10b9d81803bb813d08f88e95a7ef992d78b4d5c147c714

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — 🟡 CONCERNS

UX-level review of 090cb79edf38486c08d75e9addbc7777c4502457 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

  • Preview mode resetting after a switch has no screenshot. The diff adds setPreviewDuringEdit(false) to the version-switch path through endEditing(). With it, the next edit after a switch from preview opens the editor instead of the preview. No image shows that next edit, so only the test covers it. This is low severity: users rarely hit this path, it only causes friction, and it fixes itself once they toggle out of preview. A still of the editor opening after a switch from preview would close it.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 090cb79edf38486c08d75e9addbc7777c4502457 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 090cb79

@github-actions

github-actions Bot commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 090cb79edf38486c08d75e9addbc7777c4502457 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 090cb79

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Oct 8, 2026
@peterhieuvu

Copy link
Copy Markdown
Contributor Author
  • rebutted span=5dda283a5bdb Preview mode resetting after a switch has no screenshot

The behavior is locked by the test a version switch leaves preview mode, so the next edit opens the editor in website/src/test/ArtifactDetailPage.saveConflict.test.tsx. It fails on main's page and passes on this head.
Before and after stills of this exact flow are captured: main's build opens Edit in preview mode, and this branch opens the editor. They go in with the next push if this PR gets one. Pushing them alone would re-run every lane after readiness passed, for a gap the test already covers.

@peterhieuvu

Copy link
Copy Markdown
Contributor Author

Design check (a plain Save still on the wire when the user leaves the edit): it holds.

  • Only Escape can end an edit during a plain Save. Cancel and the Version selector are disabled while saving.
  • The PATCH has already been sent, so it lands. handleSave invalidates ['artifact', writeSlug] before the edit-generation check, so the page refreshes to the saved content.
  • Only the editor-state updates after that check are skipped: the base token and the conflict flag.

@iamwhatever iamwhatever left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@iamwhatever
iamwhatever enabled auto-merge (squash) October 9, 2026 06:05
@iamwhatever
iamwhatever merged commit d113dad into kirodotdev:main Oct 9, 2026
103 checks passed
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Artifact page keeps the "Not saved." notice after switching versions

2 participants