fix(fileSync): refresh open editors in real time and stop spurious save conflicts#259
Open
iabdousd wants to merge 1 commit into
Open
fix(fileSync): refresh open editors in real time and stop spurious save conflicts#259iabdousd wants to merge 1 commit into
iabdousd wants to merge 1 commit into
Conversation
…ve conflicts Open editors now react to disk changes immediately instead of waiting for window focus. fileSync subscribes to the watcher's file-tree-changed event and sweeps that task's open tabs: clean tabs silently reload, dirty tabs get a persistent "Conflicting changes" toast that mirrors the save-time modal (Cancel / Take disk / Keep mine). Other related fixes in the same area: - checkBeforeSave short-circuits when the editor has no local edits, so pressing cmd+S on an externally-modified file no longer opens a conflict dialog that claims you have unsaved edits to lose - Cached tabs re-verify against disk on reopen, so the editor can't serve stale content for files edited externally while the tab was closed - File deletion: read_worktree_file emits a NotFound: prefix for missing files; fileSync flips the tab to a deleted state (red ghost glyph + strikethrough). cmd+S on a deleted-state tab opens a Recreate confirm modal instead of writing blindly. Deletion declaration is debounced 250ms so atomic-write tmp->rename sequences don't briefly flash the deleted UI - FileConflictDialog and the dirty-tab toast share the same vocabulary (Conflicting changes / Cancel / Take disk / Keep mine). Toast description is rendered as a second muted line via a new Toast.description field - RecreateFileDialog mounts in both App.tsx and TaskWindowShell.tsx so detached task windows see the same Recreate flow Best-effort rename detection (follow an open tab when the file moves) is deferred to a follow-up issue.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
file-tree-changedevent instead of waiting forvisibilitychange. Clean tabs reload silently; dirty tabs surface a persistent "Conflicting changes" toast that mirrors the save-time modal.checkBeforeSaveno longer fires the conflict dialog when the user has no local edits - it silently syncs the editor to disk and skips the no-op write. Fixes the bug where pressing cmd+S on a file you didn't touch claims you have unsaved edits about to be overwritten.Behaviour matrix
Key changes
src/store/fileSync.ts: newfile-tree-changedlistener, optionalfilterTaskId/filterRelativePathon the sweep, deleted-files signal with debounced confirmation,requestRecreate/resolveRecreateflow, newcheckBeforeSaveshort-circuitsrc/store/ui.ts+src/components/ToastContainer.tsx:Toastgets adescriptionfield rendered as a muted second linesrc/components/FileConflictDialog.tsx: new "Conflicting changes" copy and Cancel / Take disk / Keep mine actionssrc/components/RecreateFileDialog.tsx(new): mirrorsFileConflictDialogat 24rem, mounted in bothApp.tsxandTaskWindowShell.tsxsrc/components/TaskPanel.tsx: deleted-state tab marker (red ⊘ + red-tinted strikethrough); close button stays visible in deleted statesrc/components/CodeEditor.tsx: re-verifies disk on cache-hit tab open; save flow routes deleted-state tabs to Recreate modalsrc-tauri/src/ipc.rs:read_worktree_fileemitsNotFound: <path>for missing files so the frontend can distinguish deletion from other read failuresDeferred
Best-effort rename-follow (option D5a from the UX discussion) split out to #260: needs in-place migration of editorView open tabs, MRU stack, mainView, files content cache, and CodeEditor's
editorStateCache/scrollPositionCachekeys. Phase E deleted-state UX is the fallback in the meantime.Test plan
pnpm checkcleanpnpm test- 629/629 pass (17 new infileSync.test.ts, including the atomic-write debounce case)cargo check+cargo test- 753 tests passcargo clippy --no-deps- no warnings