Skip to content

fix(ui): preserve unsaved file edits during interface reloads - #156208

Merged
steipete merged 1 commit into
mainfrom
codex/file-draft-reload458
Sep 23, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/file-draft-reload458

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes unsaved workspace-file edits disappearing when an update or an in-app Reload replaces the Control UI document.

User Impact

Unsaved file edits now block automatic and in-app reloads, including drafts in closed previews or other conversations. Save or discard all file edits to release the reload. Explicit browser reloads and closing the tab retain their existing behavior: these drafts live only in the current page's memory.

Why This Change Was Made

The retained file-draft owner now participates in the existing document reload guard. The guard follows the retained drafts rather than mounted editor panels, so closing a preview cannot release protection. A manual blocked reload explains the next step. No storage, Gateway, credential, or file-save contract changes.

Evidence

  • The new Chromium regression drives actual CodeMirror editing and both automatic and manual reload entry points. All four cases fail before the repair because reload proceeds after dirty previews close; all pass afterward. Two retained files prove that resolving one draft does not release the other, and final Save/Discard restores reload.
  • The final standalone regression (pnpm test ui/src/pages/chat/components/chat-file-drafts.browser.test.ts --maxWorkers=1) passes in 4.489 seconds wall time; the four cases total 1.283 seconds of browser-test execution in the sibling run. Together with existing text-file and HTML-editor cases, 32 Chromium tests pass in 6.09 seconds. Hosted CI run 35822154674 passes all three UI shards and all nine Chromium E2E shards; the Chromium jobs take 256–435 seconds each including setup and the full shard, rather than the individual regression alone.
  • UI chat-test and production typechecks, focused typed lint, i18n verification, formatting, and whitespace checks pass. The production UI builds in 7.41 seconds.
  • The screenshots use a synthetic workspace with the actual file editor and actual in-app reload owner. Before the fix, a real document navigation loses the draft; afterward, navigation is blocked and the draft remains editable. The surrounding small fixture exposes the reload action; it does not simulate editor or reload behavior.

Before

Before: in-app reload discarded unsaved file edits

After

After: the retained file draft blocks reload and explains how to continue

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review September 23, 2026 05:22
@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation app: web-ui App: web-ui size: S labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 23, 2026, 1:47 AM ET / 05:47 UTC.

ClawSweeper review

What this changes

The PR prevents automatic and in-app interface reloads while unsaved workspace-file edits remain, adds recovery guidance, and covers closed previews with browser regressions.

Merge readiness

✅ Ready for maintainer review

Keep open: this is a focused, supported fix that remains absent from current main and the latest release. No blocking correctness findings were identified.

Priority: P2
Reviewed head: b2abb57ad36e41e8a193b5412d6d1e97b3ff7b05

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level fix with relevant visible proof, meaningful browser coverage, and no actionable defects found.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (screenshot): Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.
Evidence reviewed 8 items Introduced change: The pinned merge-base-to-head patch connects the existing retained-draft owner to the existing reload guard, with English copy, documentation, and browser coverage; unrelated base-branch changes are excluded.
Still necessary on main: Fetched main retains file drafts but does not register their reload protection.
Latest release comparison: The same missing registration is present in v2026.9.5; its peeled commit matches the supplied latest-release identity.
Findings None None.
Security None None.

How this fits together

The Control UI retains workspace-file edits in page memory when editor previews close. Its shared reload guard decides whether update recovery or an in-app reload may replace that page.

flowchart TD
  A[Workspace file edits] --> B[Retained drafts]
  B --> C{Unsaved drafts remain?}
  D[Automatic or in-app reload] --> C
  C -->|Yes| E[Keep page and explain manual block]
  C -->|No| F[Allow document reload]
  G[Save or discard edits] --> B
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +14, Tests +133, Docs +5. Total +152 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 17 3 +14
Tests 1 133 0 +133
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 155 3 +152

Review metrics

Metric Value Why it matters
Reload regression coverage 4 cases; 2 retained drafts per case Covers both reload modes and both settlement actions, including protection after the first draft is resolved.

Technical review

Best possible solution:

Keep reload protection with the retained-draft owner until every edit is saved or discarded, preserving the existing memory-only storage contract.

Do we have a high-confidence way to reproduce the issue?

Yes: edit a workspace file, close its preview, and trigger an in-app reload; current main retains the buffer without registering reload protection. This review verified the source path and contributor evidence without executing it.

Is this the best way to solve the issue?

Yes: extending the existing retained-draft owner through the shared guard is a narrow repair and avoids a competing reload policy or new persistence mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 80bab7e23ce0.

Labels

Label changes:

  • add P2: Repairs a bounded Control UI workflow where interface reloads discard unsaved workspace-file edits.
  • add proof: sufficient: Contributor real behavior proof is sufficient. Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.
  • add proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.

Label justifications:

  • P2: Repairs a bounded Control UI workflow where interface reloads discard unsaved workspace-file edits.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.
  • proof: sufficient: Contributor real behavior proof is sufficient. Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. Inspected before/after captures from the actual file editor and in-app reload owner show the unsaved buffer retained with blocking guidance after the fix. Browser regressions supplement this with closed-preview and final-settlement coverage; no stored-data contract changes.

Evidence

What I checked:

  • Introduced change: The pinned merge-base-to-head patch connects the existing retained-draft owner to the existing reload guard, with English copy, documentation, and browser coverage; unrelated base-branch changes are excluded. (ui/src/pages/chat/components/chat-file-drafts.ts:24, b2abb57ad36e)
  • Still necessary on main: Fetched main retains file drafts but does not register their reload protection. (ui/src/pages/chat/components/chat-file-drafts.ts:20, 80bab7e23ce0)
  • Latest release comparison: The same missing registration is present in v2026.9.5; its peeled commit matches the supplied latest-release identity. (ui/src/pages/chat/components/chat-file-drafts.ts:20, ec9c1a13db89)
  • Guard and settlement lifecycle: Automatic and manual reload paths check the shared guard before and after awaited document probes. Editor changes retain drafts synchronously; successful Save or Discard clears settled drafts, while newer edits remain protected. (ui/src/app/stale-chunk-reload.ts:112, b2abb57ad36e)
  • Inspected before/after proof: Inspected both downloaded PR images: the before image shows saved disk content after reload; the after image shows the unsaved buffer and the new blocking toast. The captured body describes a synthetic workspace using the actual editor and reload owner. This proves the visible draft-retention outcome, not a network or security claim. (b2abb57ad36e)
  • Focused supplemental coverage: Four browser cases cross automatic/manual reload with Save/Discard, edit two real CodeMirror buffers, close their previews, and require the last draft to settle before reload resumes. The body reports pre-fix failures and post-fix passes, 4.489 seconds standalone wall time, and successful UI/Chromium shards. Tests were inspected, not executed during this read-only review. (ui/src/pages/chat/components/chat-file-drafts.browser.test.ts:42, b2abb57ad36e)

Likely related people:

  • Peter Steinberger: Raw commit ecfd906 adds ui/src/pages/chat/components/chat-file-drafts.ts:10 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ecfd906018b7; files: ui/src/pages/chat/components/chat-file-drafts.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@steipete
steipete enabled auto-merge (squash) September 23, 2026 05:53
@steipete
steipete merged commit 1030b43 into main Sep 23, 2026
178 of 179 checks passed
@steipete
steipete deleted the codex/file-draft-reload458 branch September 23, 2026 05:54
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash auto-merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui docs Improvements or additions to documentation P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant