Repository navigation
fix(editor): refuse saves that would overwrite unnoticed disk changes - #30417
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 Walkthrough
Priority: ➖ Normal Merge Risk: 🟡 Moderate · up to
|
There was a problem hiding this comment.
Actionable comments posted: 5
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c67a40fb-ab9f-4f22-91fb-1eeaf1c2190c
📒 Files selected for processing: 26
src/main/ipc/filesystem.test.tssrc/main/ipc/filesystem/filesystem-write-handlers.tssrc/main/ipc/filesystem/local-disk-write-precondition.test.tssrc/main/ipc/filesystem/local-disk-write-precondition.tssrc/main/providers/local-filesystem-provider.tssrc/main/runtime/files/file-mutations.tssrc/main/runtime/rpc/methods/files-mutation-methods.tssrc/main/runtime/rpc/methods/files-write-disk-precondition.test.tssrc/preload/api/filesystem-api.tssrc/preload/api/fs-bridge.tssrc/renderer/src/components/editor/diff-content-signature.tssrc/renderer/src/components/editor/editor-autosave-controller-test-fixture.tssrc/renderer/src/components/editor/editor-save-disk-precondition.test.tssrc/renderer/src/components/editor/editor-save-disk-precondition.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/editor/restored-editor-owner-save-lifecycle.test.tssrc/renderer/src/lib/rename-user-named-tab-access.test.tssrc/renderer/src/runtime/runtime-file-mutation-client.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.test.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.tssrc/renderer/src/web/web-file-mutation-methods.tssrc/shared/disk-baseline-signature.tssrc/shared/file-write-disk-precondition.test.tssrc/shared/file-write-disk-precondition.tssrc/shared/protocol-version.tssrc/shared/rpc-contract/files-mutation-params.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.
| if (diskConflict) { | ||
| return { ok: false, diskConflict } | ||
| } | ||
| await writeFile(authorizedPath, content, 'utf-8') |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Make the guarded write conditional on the validated disk state.
If another process changes the file after checkLocalDiskWritePrecondition returns, this writeFile overwrites that change. The separate read and write operations do not enforce the precondition for that case. Use a write mechanism that coordinates the comparison and replacement with other writers; another check before writeFile would only narrow the race.
| expect(file?.externalMutation).toBe('changed') | ||
| expect(file?.lastKnownDiskSignature).toBe(getDiskBaselineSignature('original')) | ||
| expect(store.getState().editorDrafts[FILE_ID]).toBe('edited') | ||
| expect(hasRecentSelfWrite(FILE_ID, 'agent rewrite')).toBe(false) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Check the self-write stamp under the tab’s actual key.
This tab has no runtimeEnvironmentId, but the assertion passes 'agent rewrite' as that ID. The assertion can pass even if the failed save leaves a stamp that suppresses a real disk-change event. Call hasRecentSelfWrite(FILE_ID) instead.
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
9e3ea51a-b2fb-40cf-897e-0165e18667e0
📒 Files selected for processing: 30
src/main/ipc/filesystem/local-disk-write-precondition.test.tssrc/main/ipc/filesystem/local-disk-write-precondition.tssrc/main/ipc/filesystem/local-regular-file-read.tssrc/renderer/src/components/editor/ExternalFileChangeBanner.test.tsxsrc/renderer/src/components/editor/ExternalFileChangeBanner.tsxsrc/renderer/src/components/editor/editor-autosave-controller-test-fixture.tssrc/renderer/src/components/editor/editor-autosave.tssrc/renderer/src/components/editor/editor-file-save-attempt.test.tssrc/renderer/src/components/editor/editor-file-save-attempt.tssrc/renderer/src/components/editor/editor-save-baseline-flow.test.tssrc/renderer/src/components/editor/editor-save-disk-precondition.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/runtime-file-mutation-client.tssrc/renderer/src/runtime/runtime-file-mutation-rpc.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.test.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.tssrc/renderer/src/store/slices/editor/actions/open-file-mutations.tssrc/renderer/src/store/slices/editor/types/editor-files-slice.tssrc/renderer/src/store/slices/editor/types/open-file.tssrc/renderer/src/web/preload-api/web-filesystem-api.tssrc/renderer/src/web/web-file-mutation-methods.test.tssrc/renderer/src/web/web-file-mutation-methods.tssrc/renderer/src/web/web-file-write-disk-precondition.test.tssrc/shared/disk-baseline-signature.ts
💤 Files with no reviewable changes: 1
- src/renderer/src/runtime/runtime-file-write-disk-precondition.ts
🚧 Files skipped from review as they are similar to previous changes: 1
- src/renderer/src/web/web-file-mutation-methods.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.
| "changedOnDisk": "This file changed on disk. Review the change before saving.", | ||
| "deletedOnDisk": "This file was deleted on disk." |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Translate the save-refusal strings into Spanish.
changedOnDisk and deletedOnDisk contain the English source text. Spanish users therefore see an English toast when a save is refused. The fr, ja and zh catalogs have translated values for these keys.
🌐 Proposed translation
- "changedOnDisk": "This file changed on disk. Review the change before saving.",
- "deletedOnDisk": "This file was deleted on disk."
+ "changedOnDisk": "Este archivo cambió en el disco. Revisa el cambio antes de guardar.",
+ "deletedOnDisk": "Este archivo se eliminó del disco."📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "changedOnDisk": "This file changed on disk. Review the change before saving.", | |
| "deletedOnDisk": "This file was deleted on disk." | |
| "changedOnDisk": "Este archivo cambió en el disco. Revisa el cambio antes de guardar.", | |
| "deletedOnDisk": "Este archivo se eliminó del disco." |
| "changedOnDisk": "This file changed on disk. Review the change before saving.", | ||
| "deletedOnDisk": "This file was deleted on disk." |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Translate the save-refusal strings into Korean.
changedOnDisk and deletedOnDisk contain the English source text. Korean users therefore see an English toast when a save is refused. The fr, ja and zh catalogs have translated values for these keys.
🌐 Proposed translation
- "changedOnDisk": "This file changed on disk. Review the change before saving.",
- "deletedOnDisk": "This file was deleted on disk."
+ "changedOnDisk": "이 파일이 디스크에서 변경되었습니다. 저장하기 전에 변경 사항을 확인하세요.",
+ "deletedOnDisk": "이 파일이 디스크에서 삭제되었습니다."📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "changedOnDisk": "This file changed on disk. Review the change before saving.", | |
| "deletedOnDisk": "This file was deleted on disk." | |
| "changedOnDisk": "이 파일이 디스크에서 변경되었습니다. 저장하기 전에 변경 사항을 확인하세요.", | |
| "deletedOnDisk": "이 파일이 디스크에서 삭제되었습니다." |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
628950a7-9ef6-4c33-956a-a0565d04434c
⛔ Files ignored due to path filters: 1
src/shared/rpc-contract/rpc-params-catalog.generated.tsis excluded by!**/*.generated.*
📒 Files selected for processing: 32
src/main/ipc/filesystem/local-disk-write-precondition.test.tssrc/main/ipc/filesystem/local-disk-write-precondition.tssrc/main/runtime/rpc/methods/files-mutation-methods.tssrc/main/runtime/rpc/methods/files-write-disk-precondition.test.tssrc/renderer/src/components/editor/combined-diff/CombinedDiffViewer.tsxsrc/renderer/src/components/editor/combined-diff/review-controls/combined-diff-section-save-refusal.tssrc/renderer/src/components/editor/combined-diff/review-controls/use-combined-diff-section-actions.disk-precondition.test.tsxsrc/renderer/src/components/editor/combined-diff/review-controls/use-combined-diff-section-actions.tssrc/renderer/src/components/editor/editor-autosave-controller.tssrc/renderer/src/components/editor/editor-autosave.tssrc/renderer/src/components/editor/editor-file-save-attempt.tssrc/renderer/src/components/editor/editor-save-overwrite-consent.test.tssrc/renderer/src/components/right-sidebar/file-explorer-delete-undo-precondition.test.tsxsrc/renderer/src/components/right-sidebar/useFileDeletion.tssrc/renderer/src/components/settings/McpConfigSection.host-owner.test.tsxsrc/renderer/src/components/settings/McpConfigSection.tsxsrc/renderer/src/components/use-terminal-editor-close-dialog-actions.save-refusal.test.tsxsrc/renderer/src/components/use-terminal-editor-close-dialog-actions.tssrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/i18n/locales/es.jsonsrc/renderer/src/i18n/locales/fr.jsonsrc/renderer/src/i18n/locales/ja.jsonsrc/renderer/src/i18n/locales/ko.jsonsrc/renderer/src/i18n/locales/zh.jsonsrc/renderer/src/runtime/runtime-file-mutation-client.tssrc/renderer/src/runtime/runtime-file-mutation-rpc.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.test.tssrc/renderer/src/web/web-file-mutation-methods.tssrc/renderer/src/web/web-file-write-disk-precondition.test.tssrc/shared/disk-baseline-signature.tssrc/shared/file-write-disk-precondition.tssrc/shared/rpc-contract/files-mutation-params.ts
🚧 Files skipped from review as they are similar to previous changes: 6
- src/renderer/src/i18n/locales/fr.json
- src/renderer/src/i18n/locales/es.json
- src/renderer/src/i18n/locales/ko.json
- src/renderer/src/i18n/locales/ja.json
- src/renderer/src/i18n/locales/zh.json
- src/renderer/src/i18n/locales/en.json
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
| } | ||
| throw error | ||
| } | ||
| return (await diskSignatureOfUtf8(buffer)) === precondition.expectedSignature ? null : 'changed' |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift
Keep the guarded write bound to the file that was checked.
If another process replaces filePath after this comparison, the later path-based writeFile can overwrite the replacement without checking its content. The process-local lock does not prevent that replacement. Keep the comparison and write bound to one file handle where possible; use exclusive creation when the checked path was missing. Node.js documents the race between a filesystem check and a later path-based operation. (nodejs.org)
Based on learnings, “Repeated filename-based operations re-resolve the path each time,” creating a TOCTOU race.
Source: Learnings
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
c919f1aa-0f64-452f-806c-14ebdb530210
📒 Files selected for processing: 12
src/main/ipc/filesystem/local-disk-write-precondition.test.tssrc/main/ipc/filesystem/local-disk-write-precondition.tssrc/renderer/src/components/editor/combined-diff/review-controls/use-combined-diff-section-actions.refusal-resolution.test.tsxsrc/renderer/src/components/editor/combined-diff/review-controls/use-combined-diff-section-actions.tssrc/renderer/src/components/editor/working-file-diff-disk-baseline.test.tssrc/renderer/src/components/editor/working-file-diff-disk-baseline.tssrc/renderer/src/runtime/runtime-file-mutation-client.tssrc/renderer/src/runtime/runtime-file-mutation-rpc.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.test.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.tssrc/shared/file-write-disk-precondition.test.tssrc/shared/file-write-disk-precondition.ts
🚧 Files skipped from review as they are similar to previous changes: 1
- src/renderer/src/components/editor/combined-diff/review-controls/use-combined-diff-section-actions.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| try { | ||
| return await attempt() | ||
| } catch (error) { | ||
| if (error instanceof RuntimeConnectionChangedError) { | ||
| // Why: nothing was sent; one retry re-probes the new connection's capabilities. | ||
| return attempt() | ||
| } | ||
| // Why: a reply lost to the transport may follow a write that landed; keeping it avoids refusing the next save. | ||
| if ( | ||
| isRecoverableRemoteRuntimeConnectionError(toRemoteRuntimeClientErrorLike(error)) && | ||
| (await diskHoldsWrittenContent(context, filePath, content)) | ||
| ) { | ||
| return FILE_WRITE_OK | ||
| } | ||
| throw error | ||
| } |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
Apply the lost-reply recovery to the retried attempt.
After a RuntimeConnectionChangedError, Line 105 calls return attempt() outside the try. The retry runs on a connection that just changed, so a transport timeout there is a realistic case. If the retry's write lands but its reply is lost, the save fails without the diskHoldsWrittenContent check. The draft stays dirty while disk already holds the new content. The next guarded save then compares against the old baseline and refuses with changed. This is the outcome the recovery branch exists to prevent. Route both attempts through the same recovery.
🐛 Proposed fix
--- "a/src/renderer/src/runtime/runtime-file-write-disk-precondition.ts"
+++ "b/src/renderer/src/runtime/runtime-file-write-disk-precondition.ts"
@@ -97,22 +97,30 @@
15_000
)
)
- try {
- return await attempt()
- } catch (error) {
- if (error instanceof RuntimeConnectionChangedError) {
- // Why: nothing was sent; one retry re-probes the new connection's capabilities.
- return attempt()
- }
- // Why: a reply lost to the transport may follow a write that landed; keeping it avoids refusing the next save.
- if (
- isRecoverableRemoteRuntimeConnectionError(toRemoteRuntimeClientErrorLike(error)) &&
- (await diskHoldsWrittenContent(context, filePath, content))
- ) {
- return FILE_WRITE_OK
- }
- throw error
- }
+ const attemptOrRecover = async (): Promise<FileWriteResult> => {
+ try {
+ return await attempt()
+ } catch (error) {
+ // Why: a reply lost to the transport may follow a write that landed; keeping it avoids refusing the next save.
+ if (
+ !(error instanceof RuntimeConnectionChangedError) &&
+ isRecoverableRemoteRuntimeConnectionError(toRemoteRuntimeClientErrorLike(error)) &&
+ (await diskHoldsWrittenContent(context, filePath, content))
+ ) {
+ return FILE_WRITE_OK
+ }
+ throw error
+ }
+ }
+ try {
+ return await attemptOrRecover()
+ } catch (error) {
+ if (error instanceof RuntimeConnectionChangedError) {
+ // Why: nothing was sent; one retry re-probes the new connection's capabilities.
+ return attemptOrRecover()
+ }
+ throw error
+ }
}
export async function checkDiskPreconditionFromClient(📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| try { | |
| return await attempt() | |
| } catch (error) { | |
| if (error instanceof RuntimeConnectionChangedError) { | |
| // Why: nothing was sent; one retry re-probes the new connection's capabilities. | |
| return attempt() | |
| } | |
| // Why: a reply lost to the transport may follow a write that landed; keeping it avoids refusing the next save. | |
| if ( | |
| isRecoverableRemoteRuntimeConnectionError(toRemoteRuntimeClientErrorLike(error)) && | |
| (await diskHoldsWrittenContent(context, filePath, content)) | |
| ) { | |
| return FILE_WRITE_OK | |
| } | |
| throw error | |
| } | |
| const attemptOrRecover = async (): Promise<FileWriteResult> => { | |
| try { | |
| return await attempt() | |
| } catch (error) { | |
| // Why: a reply lost to the transport may follow a write that landed; keeping it avoids refusing the next save. | |
| if ( | |
| !(error instanceof RuntimeConnectionChangedError) && | |
| isRecoverableRemoteRuntimeConnectionError(toRemoteRuntimeClientErrorLike(error)) && | |
| (await diskHoldsWrittenContent(context, filePath, content)) | |
| ) { | |
| return FILE_WRITE_OK | |
| } | |
| throw error | |
| } | |
| } | |
| try { | |
| return await attemptOrRecover() | |
| } catch (error) { | |
| if (error instanceof RuntimeConnectionChangedError) { | |
| // Why: nothing was sent; one retry re-probes the new connection's capabilities. | |
| return attemptOrRecover() | |
| } | |
| throw error | |
| } |
0a5c9ac to
e07e72b
Compare
1ffd4fe to
2bdb993
Compare
a114e54 to
aea304b
Compare
aea304b to
541e524
Compare
6317bce to
9eabd83
Compare
9d9e840 to
7692b61
Compare
f3a33ec to
4e4cf54
Compare
ca6f78c to
c1a7f39
Compare
|
Pausing as draft: reviews of this stack keep tracing back to one root cause — an open file's content and unsaved state live in several places (per-tab store fields, per-panel caches, the draft store, the editor model, rich editors). A short design for a single editor buffer per file is being written first; this PR will be re-scoped against it. |
4e4cf54 to
1198438
Compare
2915277 to
d41bf5d
Compare
Every editor save carries the disk version its text came from and the host refuses the write when disk moved on; only the banner's explicit Overwrite writes without that check. Older hosts compare from the client first. Co-Authored-By: Claude <[email protected]>
2619d82 to
7302aac
Compare
origin/main's #30417 edited the renderer Markdown bridge this branch removes; with no window relay left, its rollback module and the editor's 'mobile' save trigger have no caller, so they go too.
ELI5
When you save a file in Orca's editor, Orca now asks the machine that holds the file to check that nobody else changed it since that tab last read or wrote it. If an agent (or anything else) rewrote the file and Orca didn't notice, the save is stopped and the usual "This file changed on disk" banner appears, instead of the save silently wiping out the newer content.
What Changed
Before: autosave, Cmd/Ctrl+S, "Save" in the save-before-closing dialog, and the save-all before a restart wrote the tab's text straight to disk. If file watching missed an outside write, the newer content was overwritten with no warning.
After, for every editor surface that writes a file (code, rich Markdown, notebook, CSV, unstaged diff tabs, and combined-diff sections) and every save path (explicit save, autosave, save-and-close, the quit dialog, restart save):
lastKnownDiskSignature, the same one the changed-on-disk banner and restart scan already use. The host compares it with the file inside the write, under the per-file lock from feat(files): guarded file writes that refuse to overwrite a changed file #30605, and writes only if they still match.written,blocked-stale, orfailed. Closing a tab, the quit dialog, and the "saved" event act only onwritten. Anything else keeps the tab open and dirty. A refused save shows "This file changed on disk..." instead of "Failed to save", and a refused save-and-close answers the close dialog at once instead of after a 10 second timeout.Older hosts: a remote Orca server or paired web host that predates the checked write (
files.write.disk-precondition.v1) gets the compatibility fallback from #30605: Orca reads the file from that host, compares it with the tab's version, and writes only if they match. The gap between that read and the write is wider than on a current host, but it still catches the common case. There is no editor path that writes to an older host without comparing first, except the explicit Overwrite.Which state is shared between tabs of one file
Rule: one baseline per code-view model; no content push; every other view stands alone. "Siblings" are only tabs in code view (Monaco, not the Changes view) showing one live editor model: the same file on one host, open in two workspaces. They hold one disk fingerprint, written only through
setEditorDiskBaseline, so there is nothing for them to disagree about. A write, a clean load, Keep My Edits, Reload and its Undo move that one value. The model is dirty when any of its tabs has unsaved edits: a clean tab of a dirty model is never reloaded on its own, and a disk change marks every tab of the model with the banner. Text is never copied from one tab to another. A tab whose cached copy is stale mounts the live model's text (the truth) and stays editable; only when no live model exists is the stale copy dropped and reloaded from disk, once. Rich Markdown, notebook, CSV, preview, Changes and diff views are never siblings: each is checked against its own fingerprint, and if that is behind disk its save is refused and the banner offers Reload / Compare / Overwrite.lastKnownDiskSignaturesetEditorDiskBaseline, which sets every code-view sibling at onceeditorDraftsOpenFile.isDirtymayPushTabTextIntoModel); only Reload and Overwrite resolve a dirty modelfileContentsexternalMutationsaveQueuependingBaselineRestampspastesInFlightpendingDiskBaselineVerificationpendingLiveDiskVerificationpendingOwnerMigrationwritten; a refusal marks every code-view siblingWhy
The goal is #30415: stop file-watching workspaces that aren't active, which takes load off the macOS file event service. That is only safe if a save from a tab whose workspace isn't watched can never silently overwrite a change it hasn't seen. Watching can't promise that, so the write itself has to check.
Doing the compare inside the write, on the machine that owns the file, keeps the gap between check and write to one file read. A separate read-then-write from the client would leave a larger gap and add a round trip to every remote save.
Each tab is checked against the baseline it already keeps for the banner and the restart scan, so this needs no new stored state. Tabs that share one editor text model must agree on it, because the text being saved belongs to the model, not to one tab.
For older hosts we compare from the client rather than refuse, so saving against a remote server that hasn't updated keeps working while still catching most outside changes.
SSH, WSL and folder workspaces: SSH files are written by the remote Orca server, which compares on the remote machine. WSL and local folder workspaces use the desktop writer, which always supports the check. Nothing here depends on the git provider or on the workspace being a git worktree.
Known limits: another process can still write in the moment between the compare and the write. Tabs showing the same file in two workspaces keep separate drafts but share one disk fingerprint, so a hidden tab holding an older unsaved draft can later overwrite a newer save made from the other tab: the check sees no change on disk. This was already possible before this PR and is out of scope here.
Linked Issue
Fixes #
Visual Proof
N/A for screenshots: the visual changes are an Overwrite button on the existing changed-on-disk banner (whose sentence now says "Overwrite replaces the newer disk content."), a tooltip on Keep My Edits, and a one-line conflict bar on a combined-diff section whose save was refused. All use existing buttons and status colors.
Testing
editor-save-disk-precondition.test.ts(new), against a fake host that compares like the real writer:editor-save-disk-precondition.races.test.ts: concurrent identical saves from sibling tabs both succeed with one write; Cmd+S in one tab waits for Keep in its sibling; a sibling that remounts after Keep keeps the kept edits; a sibling's cached text follows another tab's save, so remounting, editing and saving it writes on top of that save; unstaged diff tab guarded; a save superseded mid-write still rebaselines; Keep's older read doesn't restamp over a newer write; stale message; save-and-close refusal answered at once.editor-save-large-paste.test.ts: the real chunked paste holds autosave until the last chunk, then saves guarded; a 70 KiB paste followed by an outside write is refused.mobile-markdown-bridge.test.tsandmobile-markdown-bridge-save-guards.test.ts: the fake writer now compares the precondition like the real one; a phone save refused after an outside write gets the phone message and leaves a clean desktop tab without a banner.useFileDeletion.save-refusal.test.tsx: a refused save cancels the explorer delete.monaco-large-text-paste.test.ts: a throwing paste still reports a result.use-combined-diff-section-actions.disk-precondition.test.tsx: section saves are guarded, a refusal marks the section conflict, and only the conflict bar's Overwrite writes plain.use-monaco-editor-mount.stale-cache.test.tsx: mounting a retained, stale cached text keeps the live model's text and stays editable; with no live model the stale copy is dropped once, and repeated mounts don't loop.editor-save-shared-model-dirty.test.ts: with a dirty sibling, an external change banners both tabs with no lone reload, no eviction and no disk reads; after a restart, a file changed while closed banners every tab of the model.editor-save-shared-model.test.ts: a Changes-view tab is never reached by Keep or Reload; two tabs sharing one model through save, autosave, Keep, Reload, Overwrite, an external change, save-and-close, the quit save, and a refused mobile save; a slow save in a code-view tab leaves a rich-Markdown tab's pending typing alone (its own save is then refused); Undo of Reload leaves a sibling that typed since alone.use-combined-diff-section-actions.disk-precondition.test.tsxalso covers overlapping saves of one section;mobile-markdown-bridge.test.tscovers a phone save after an external change to a clean desktop tab.editor-save-guarded-write-paths.test.ts: the raw file write appears only insidewriteEditorSave; the precondition builder never returns a plain write except for the explicit Overwrite; overwrite consent comes only from the conflict UI.Existing editor save suites updated for the new write arguments and results.
pnpm tc, oxlint, andpnpm run check:code-quality:changedpass locally.I manually tested these changes locally
Automated tests added/updated, or explained why not below
AI Disclosure
Review
Agent skill upstream boundary
Notes
Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)