fix(watch): skip reload when notebook has git conflict markers#9626
Merged
Conversation
## Summary When `marimo edit --watch` is running and a git operation (cherry-pick, `git stash pop`, merge) writes conflict markers into the notebook file, the watcher parses the file and the conflict markers become an `app._unparsable_cell`. This clobbers the on-disk conflict markers through the round-trip and breaks conflict-resolution tools like `git-mediate`. The fix: before reloading, scan the file for lines starting with `<<<<<<<` (git's unambiguous conflict start marker). If present, log a warning and skip the reload until the user resolves the conflicts. Fixes #9613.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
Pull request overview
Prevents marimo edit --watch from clobbering on-disk git conflict markers by detecting merge-conflict start markers in the notebook file and skipping reloads until conflicts are resolved (fixes #9613).
Changes:
- Add a pre-reload scan for git conflict markers (
<<<<<<<at start of a line) and skip reload with a warning when present. - Refactor “skip our own writes” logic to reuse a single file read via a new
content_matches_last_save()helper. - Add a regression test ensuring reload is skipped and a warning is emitted when conflict markers exist.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| tests/_session/test_file_change_handler.py | Adds a regression test asserting watch reload is skipped when conflict markers are present. |
| marimo/_session/notebook/file_manager.py | Introduces content_matches_last_save() and reuses it from file_content_matches_last_save(). |
| marimo/_session/file_change_handler.py | Reads file once for pre-reload checks; skips reload on conflict markers and on own writes. |
Contributor
There was a problem hiding this comment.
No issues found across 3 files
Architecture diagram
sequenceDiagram
participant FS as File System
participant Watch as File Watcher
participant Handler as FileChangeHandler
participant FM as AppFileManager
participant Session as Session
Note over FS,Session: File change detection and reload flow
FS->>Watch: File modified event
Watch->>Handler: handle_change(file_path, session)
Handler->>FM: read_file()
FM-->>Handler: current_content (str)
alt Content matches last save (our own write)
Handler->>Handler: Return FileChangeResult(handled=False)
Note over Handler: Skip reload to avoid echo loop
else Content has git conflict markers (<<<<<<<)
Handler->>Handler: Log warning
Handler->>Handler: Return FileChangeResult(handled=False)
Note over Handler: NEW: Skip reload to preserve conflict markers
else Normal content change
Handler->>FM: reload() with current_content
FM->>FM: Parse notebook, apply changes
alt Parsable notebook
FM-->>Handler: Success
Handler->>Session: Apply cell changes
Session-->>Handler: OK
Handler-->>Watch: FileChangeResult(handled=True)
else Unparsable notebook
FM->>FM: Create _unparsable_cell
FM-->>Handler: Partial/error
Handler-->>Watch: FileChangeResult with error
end
end
Note over FS,Handler: Error handling path
alt read_file() fails
Handler->>Handler: Log debug, set current_content=None
Handler->>Handler: Fall through to reload()
Note over Handler: reload() has its own error handling
end
Address PR review: capture and restore the previous ``propagate`` value in a ``finally`` block so the test doesn't leak global logger state to later tests.
akshayka
reviewed
May 21, 2026
akshayka
previously approved these changes
May 21, 2026
akshayka
reviewed
May 21, 2026
akshayka
reviewed
May 21, 2026
Co-authored-by: Akshay Agrawal <akshaykagrawal7@gmail.com>
akshayka
approved these changes
May 21, 2026
|
🚀 Development release published. You may be able to view the changes at https://marimo.app?v=0.23.7-dev82 |
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
When
marimo edit --watchis running and a git operation (cherry-pick,git stash pop, merge) writes conflict markers into the notebook file,the watcher parses the file and the conflict markers become an
app._unparsable_cell. This clobbers the on-disk conflict markersthrough the round-trip and breaks conflict-resolution tools like
git-mediate.The fix: before reloading, scan the file for lines starting with
<<<<<<<(git's unambiguous conflict start marker). If present, log awarning and skip the reload until the user resolves the conflicts.
Fixes #9613.