fix: route Live Mode changes to the watched file - #296
Merged
alecdotdev merged 5 commits intoAug 1, 2026
Conversation
Collaborator
Author
|
@alecdotdev This is the next dependent safety fix after #293. It prevents Live Mode from reloading a different, dirty tab when a background watched file changes. All required checks pass; merge order is #286 → #293 → #296. |
This was referenced Jul 31, 2026
PathGao
force-pushed
the
fix/live-mode-route-watched-path
branch
from
July 31, 2026 05:50
b4b34df to
8cec9a9
Compare
Collaborator
Author
|
The branch is now directly based on #293; please use the updated single-chain merge order in the PR description. |
This was referenced Jul 31, 2026
alecdotdev
approved these changes
Aug 1, 2026
PathGao
added a commit
that referenced
this pull request
Aug 2, 2026
…ying work (#374) **A truncated preview buffer could be written back over the whole file.** Opening a document larger than 50 KB starts with `open_markdown_preview(maxBytes: 50000)`, and `setTabRawContent` made that partial text both the buffer and the baseline, with `isDirty=false` and nothing marking it incomplete. The background full read is abandoned if the tab changes mode or gets edited in the meantime, and `toggleSplitView` only re-read when `!tab.rawContent` — a partial buffer is not empty, so it did not. Anything that then wrote the buffer truncated the file at 50 KB. Four routes reached that state, not one: entering split view, toggling a task checkbox from reading mode, editing front matter from reading mode, and `reloadFromDisk` (F5), which handed the editor itself a partial buffer. A tab now records whether its buffer is partial, every editable entry point completes it from disk first, and saving refuses a partial buffer as a backstop. Detaching a tab to another window completes it too: the transfer payload has no field for the flag and rebuilds the tab explicitly, so the destination would have inherited a short buffer that looked authoritative, with its own auto-save timer. **An external change overwrote unsaved edits silently.** The watcher listener checked live mode and the self-write grace window but never `tab.isDirty`, and `setTabRawContent` rewrites `originalContent` too, so a `git checkout`, a cloud sync, or another window saving the same file took the edits with no trace that anything had been dirty. A dirty tab now raises a conflict the user answers — reload, or keep mine — instead of reloading under them. The debounced auto-save is held back while a conflict is unanswered. Otherwise the timer would write 1.5 s later and drop the external change while the bar was still asking which version to keep. Explicit saves still go through: pressing Save *is* the answer "keep mine", and the save path clears the conflict so the bar comes down rather than re-asking. The debounce is the only thing that ever writes without being asked, so it is the only thing suppressed. Live Mode itself needed no change here — #296 already made toggling it install the watcher without reloading. The regression lock for that is kept and now points at the new tests. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This was referenced Aug 3, 2026
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.
Fixes #295
Live Mode now tracks the active file at the window layer and carries the watched path in file-change events. An event for a background tab can no longer reload the active tab or discard its unsaved buffer. Enabling Live Mode no longer reloads the current document.
Depends on #293. Please merge in this order: #286 → #287 → #288 → #293 → this PR.
Validation: