Repository navigation
Autosave relies on the guarded save instead of pause flags; identical saves don't rewrite; non-UTF-8 files aren't autosaved - #31768
Conversation
…oved tabs Delete the pendingDiskBaselineVerification and pendingLiveDiskVerification pause flags. Every editor save is already a guarded write; a refusal raises the changed-on-disk banner, which is what stops autosave until an explicit save. A guarded write now succeeds when disk changed but already holds exactly the text being saved (local/host compare is byte-exact; client-side fallbacks compare decoded text and refuse when it holds U+FFFD), so a restored draft that matches disk goes clean instead of showing a banner. The restore scan only raises the banner early for tabs that arrive dirty; a watch resync no longer re-checks dirty tabs. Co-Authored-By: Claude <[email protected]>
Return a compatible optional no-op result from hosts and client fallbacks, clean the tab, and clear its provisional self-write stamp without rewriting identical bytes. Co-Authored-By: Claude <[email protected]>
…er hosts, flag dirty tabs on resync - Autosave and pre-restart saves refuse when disk text can't be decoded losslessly, so a baseline that decoded to U+FFFD can't authorize overwriting different bytes. - New files.write.identical-noop.v1 capability; for hosts with only the v1 guarded write the client compares first, skips identical saves, then delegates to the host's guarded write. - Watch resync compares dirty tabs against disk and shows the changed-on-disk banner. - Local guarded writes check for identical content before the write-only regular-file probe. Co-Authored-By: Claude <[email protected]>
…false resync banners - Local guarded writes judge losslessness by bytes, so a valid UTF-8 file containing U+FFFD autosaves again. A file that really isn't UTF-8 is refused with its own reason, 'not-utf8' (older clients read it as 'changed'), which pauses autosave for that file with one notice until an explicit save converts it. - A watch resync whose disk read fails leaves dirty tabs alone; the guarded save still catches a real conflict. - Resync and restored-tab checks treat disk holding the tab's own just-written save as an echo. - On hosts with only the v1 guarded write, only automatic saves read the file first; explicit saves go straight to the host's guard. Co-Authored-By: Claude <[email protected]>
…d report disk changes first - The pause is released once no dirty tab of the file remains (close, reload from disk, discard), so a reopened or reloaded file's next autosave asks the host again and notifies. - Client-side precondition checks compare the signature before looking for U+FFFD, so an external rewrite shows the changed-on-disk banner rather than the non-UTF-8 notice. Co-Authored-By: Claude <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Priority: ⬇️ Low Merge Risk: 🔵 Low · up to
|
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:
f81b8071-7eb0-42cd-abc3-931ae9dd3216
📒 Files selected for processing: 53
src/main/ipc/filesystem/filesystem-write-handlers.tssrc/main/ipc/filesystem/filesystem-write-identical.test.tssrc/main/ipc/filesystem/local-disk-write-precondition.test.tssrc/main/ipc/filesystem/local-disk-write-precondition.tssrc/main/runtime/markdown-tab-disk-documents.test.tssrc/main/runtime/markdown-tab-disk-host.tssrc/main/runtime/orca-runtime-mobile-markdown-tab-routes.test.tssrc/main/runtime/rpc/methods/files-write-disk-precondition.test.tssrc/renderer/src/components/editor/editor-autosave-conflict-flow.test.tssrc/renderer/src/components/editor/editor-autosave-controller-test-fixture.tssrc/renderer/src/components/editor/editor-autosave.tssrc/renderer/src/components/editor/editor-non-utf8-autosave-pause.tssrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.recheck.test.tssrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.test.tssrc/renderer/src/components/editor/editor-restored-tab-conflict-scan.tssrc/renderer/src/components/editor/editor-save-disk-precondition.races.test.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-guarded-disk-fixture.tssrc/renderer/src/components/editor/editor-save-large-paste.test.tssrc/renderer/src/components/editor/editor-save-lossless-baseline.test.tssrc/renderer/src/components/editor/editor-save-queue.tssrc/renderer/src/components/editor/editor-save-rebaseline.tssrc/renderer/src/components/editor/editor-save-shared-model-dirty.test.tssrc/renderer/src/hooks/editor-external-watch-dirty-resync.test.tssrc/renderer/src/hooks/editor-external-watch-disk-verification.tssrc/renderer/src/hooks/editor-external-watch-overflow.test.tssrc/renderer/src/hooks/editor-external-watch-overflow.tssrc/renderer/src/hooks/useEditorExternalWatch-background-trim.test.tsxsrc/renderer/src/hooks/useEditorExternalWatch-self-move.test.tssrc/renderer/src/hooks/useEditorExternalWatch-shared-root.test.tsxsrc/renderer/src/hooks/useEditorExternalWatch-switch-back.test.tsxsrc/renderer/src/i18n/locales/en.jsonsrc/renderer/src/lib/execute-open-editor-path-move.test.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.test.tssrc/renderer/src/runtime/runtime-file-write-disk-precondition.tssrc/renderer/src/store/editor-buffer-record-lifecycle.test.tssrc/renderer/src/store/slices/editor-layout-owner-records.test.tssrc/renderer/src/store/slices/editor-read-only-tabs.test.tssrc/renderer/src/store/slices/editor-rekey-open-files.test.tssrc/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.tssrc/renderer/src/store/slices/editor/actions/open-file-mutations.tssrc/renderer/src/store/slices/editor/actions/rekey-open-files-action.tssrc/renderer/src/store/slices/editor/buffers/editor-buffer-record.tssrc/renderer/src/store/slices/editor/types/editor-files-slice.tssrc/renderer/src/store/slices/editor/types/open-file.tssrc/renderer/src/store/slices/restored-editor-owner-reparent.test.tssrc/renderer/src/web/web-file-mutation-methods.tssrc/renderer/src/web/web-file-write-disk-precondition.test.tssrc/shared/file-write-disk-precondition.test.tssrc/shared/file-write-disk-precondition.tssrc/shared/files-runtime-capabilities.tssrc/shared/rpc-contract/files-mutation-params.ts
💤 Files with no reviewable changes: 8
- src/renderer/src/store/slices/editor-layout-owner-records.test.ts
- src/renderer/src/store/slices/editor-read-only-tabs.test.ts
- src/renderer/src/store/slices/editor/types/open-file.ts
- src/renderer/src/components/editor/editor-save-shared-model-dirty.test.ts
- src/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.ts
- src/main/ipc/filesystem/filesystem-write-handlers.ts
- src/renderer/src/store/slices/editor/types/editor-files-slice.ts
- src/renderer/src/store/slices/editor/actions/open-file-mutations.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.
| if (writeResult.unchanged) { | ||
| clearSelfWrite(liveFile.filePath, liveFile.runtimeEnvironmentId) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
# Trace stamp replacement, clearing, and watcher classification.
rg -n -C 6 '\b(recordSelfWrite|clearSelfWrite|getRecentSelfWrite|hasRecentSelfWrite)\s*\(' \
src/renderer/src/components/editor/editor-self-write-registry.ts \
src/renderer/src/components/editor/editor-save-queue.ts \
src/renderer/src/hooksRepository: stablyai/orca
Length of output: 26413
Preserve the self-write stamp for the real save.
If a real save is followed by an unchanged save before the first watcher event arrives, clearSelfWrite removes the stamp for the real save. The watcher then treats the pending event as external because it uses getRecentSelfWrite to identify Orca’s own writes. Keep the stamp for the real write while avoiding a stamp for the unchanged attempt.
| // Why: compare dirty tabs asynchronously; autosave stays free to run its own guarded check. | ||
| if (file.isDirty) { | ||
| if (!resync) { | ||
| continue | ||
| } | ||
| // Why: a dirty tab is never reloaded; the restored-tab scan shows the changed-on-disk banner if disk moved. | ||
| // Mirrors the scan's eligibility so it always resolves the flag. | ||
| if ( | ||
| file.lastKnownDiskSignature && | ||
| file.externalMutation !== 'changed' && | ||
| canAutoSaveOpenFile(file) | ||
| ) { | ||
| requestRestoredTabReverification(file.id) | ||
| state.setPendingDiskBaselineVerification(file.id, true) | ||
| if (resync) { | ||
| scheduleEditorSelfMoveEchoVerification( | ||
| { | ||
| ...target, | ||
| connectionId: target.connectionId, | ||
| runtimeEnvironmentId: target.runtimeEnvironmentId ?? null | ||
| }, | ||
| [file.id], | ||
| false, | ||
| true | ||
| ) |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '90,118p' src/renderer/src/hooks/editor-external-watch-overflow.ts
sed -n '225,286p' src/renderer/src/hooks/editor-external-watch-disk-verification.ts
rg -n 'lastKnownDiskSignature|isDirty:' src/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.ts src/renderer/src/store/slices/editor/actions/open-file-mutations.tsRepository: stablyai/orca
Length of output: 4212
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- hydration ---'
sed -n '70,135p' src/renderer/src/store/slices/editor/actions/hydrated-editor-session-state.ts
printf '%s\n' '--- open-file mutations ---'
sed -n '1,180p' src/renderer/src/store/slices/editor/actions/open-file-mutations.ts
printf '%s\n' '--- verifier/reloadable symbols ---'
rg -n -F --glob '*.ts' -e 'function resolveLiveMoveVerification' -e 'const resolveLiveMoveVerification' -e 'isExternalReloadableEditorTab' -e 'markFileChangedOnDisk' src/renderer/src
printf '%s\n' '--- production dirty and signature references ---'
rg -n -F --glob '*.ts' -e 'isDirty:' -e 'lastKnownDiskSignature' -e 'setLastKnownDiskSignature' src/renderer/src --glob '!**/*.test.*'
printf '%s\n' '--- updateEditorBuffer callers ---'
rg -n -F --glob '*.ts' -e 'updateEditorBuffer(' src/renderer/src --glob '!**/*.test.*'Repository: stablyai/orca
Length of output: 21133
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- reloadable predicate ---'
sed -n '70,112p' src/renderer/src/components/editor/editor-autosave.ts
printf '%s\n' '--- verifier resolution ---'
sed -n '165,220p' src/renderer/src/hooks/editor-external-watch-disk-verification.ts
printf '%s\n' '--- session serialization ---'
sed -n '120,170p' src/renderer/src/lib/workspace-session.ts
printf '%s\n' '--- save precondition ---'
sed -n '80,155p' src/renderer/src/components/editor/editor-save-disk-precondition.ts
printf '%s\n' '--- open-file creation sites ---'
rg -n -F --glob '*.ts' -e 'openFiles.push' -e 'openFiles:' -e 'createOpenFile' -e 'filePath:' src/renderer/src/store/slices/editor/actions src/renderer/src/components/editor --glob '!**/*.test.*'
printf '%s\n' '--- direct signature setters ---'
rg -n -F --glob '*.ts' -e 'setLastKnownDiskSignature(' src/renderer/src --glob '!**/*.test.*'Repository: stablyai/orca
Length of output: 34625
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- open-file action and apply ---'
sed -n '1,220p' src/renderer/src/store/slices/editor/actions/open-file-action.ts
sed -n '1,340p' src/renderer/src/store/slices/editor/actions/open-file-apply.ts
printf '%s\n' '--- editor draft state ---'
sed -n '1,120p' src/renderer/src/store/slices/editor/actions/editor-draft-state.ts
printf '%s\n' '--- baseline initialization references ---'
rg -n -F --glob '*.ts' -e 'setEditorDiskBaseline' -e 'lastKnownDiskSignature:' -e 'markFileDirty(' src/renderer/src --glob '!**/*.test.*'
printf '%s\n' '--- resync callers and tests ---'
rg -n -F --glob '*.ts' -e 'reconcileEditorTabsAfterOverflow' -e 'scheduleEditorSelfMoveEchoVerification' src/renderer/src --glob '!**/*.test.*'Repository: stablyai/orca
Length of output: 26328
🏁 Script executed:
set -o pipefail
printf '%s\n' '--- edit and initial content handling ---'
sed -n '1,90p' src/renderer/src/components/editor/use-editor-content-change-handler.ts
sed -n '1,95p' src/renderer/src/components/editor/editor-clean-tab-disk-baseline.ts
printf '%s\n' '--- persisted file contract ---'
rg -n -F --glob '*.ts' -e 'type PersistedOpenFile' -e 'interface PersistedOpenFile' -e 'lastKnownDiskSignature?:' src/renderer/src
printf '%s\n' '--- overflow and marker ---'
sed -n '75,118p' src/renderer/src/hooks/editor-external-watch-overflow.ts
sed -n '1,55p' src/renderer/src/components/editor/editor-changed-on-disk-mark.ts
printf '%s\n' '--- restored scan guard ---'
sed -n '20,42p' src/renderer/src/components/editor/editor-restored-tab-conflict-scan.tsRepository: stablyai/orca
Length of output: 10056
Skip resync verification when no disk baseline exists.
During resync, a dirty edit tab without lastKnownDiskSignature reaches scheduleEditorSelfMoveEchoVerification. A successful read that is not a recent self-write cannot match the undefined baseline, so resolveLiveMoveVerification marks the dirty tab as changed on disk. This can show a false conflict banner.
Suggested fix
- if (resync) {
+ if (resync && file.lastKnownDiskSignature !== undefined) {
scheduleEditorSelfMoveEchoVerification(
ELI5
After a restart, a workspace move or a reconnect, Orca used to pause autosave on tabs with unsaved edits until it had re-read the file, using two internal flags. Those flags are gone: autosave now goes through the same "refuse if the file changed on disk" save as everything else. If the file on disk already holds exactly the text being saved, the save succeeds without writing. Autosave never writes over a file that isn't valid UTF-8 text.
What Changed
files.write.identical-noop.v1); for older hosts the client checks first on automatic saves.Why
The flags existed to stop a restored tab from writing over a newer file. The guarded save already refuses that, so the flags were a second mechanism doing the same job. Relying on one check is less code and fewer states to get stuck in. The identical-content shortcut keeps a restored draft that already matches disk from showing a false conflict. While reviewing, a pre-existing gap surfaced (two different invalid-UTF-8 files decode to the same text, so an automatic save could pass the check); automatic saves now check the bytes.
Linked Issue
Follow-up to #31655.
Visual Proof
The new notice for a non-UTF-8 file after typing with autosave on:
(screenshot removed: contained real product data)
Testing
Restored drafts (equal to baseline, equal to disk, disk changed), identical-content skip on every host path including a read-only file, lossy-decode refusal (small and >1 MB), valid UTF-8 containing
�autosaving normally, non-UTF-8 notice shown once and again after reopen, explicit save converting, resync banner with autosave off, read-error and own-echo ignored, older hosts skipping the pre-read on explicit saves.pnpm tc,check:code-quality:changed, oxfmt, oxlint, localization checks pass.filesystem-watcher-real/filesystem-watcher-ignore-realtime out in our local sandbox; this change doesn't touch the watcher.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
Mixed versions: the new write result field and request flag are optional; older hosts ignore the flag and older clients read the new refusal reason as "changed". The removed flags were never persisted or sent over the wire.
Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)