ISSUE DESCRIPTION marimo edit --watch messes with merge conflict markers Describe the…
- User
ISSUE DESCRIPTION
marimo edit --watch messes with merge conflict markers
Describe the bug
When cherry-picking commits, or
git stash poping, sometimes merge conflicts occur.If a notebook is open using
marimo edit --watchduring that time, it parses the git conflict markers asapp._unparsable_cell. This gets in the way of resolving the conflicts using conflict resolution tools likegit-mediateSuggestion: Avoid updating the notebook if the file contains conflict markers, recognizable by
<<<<<<<at the beginning of a line.Will you submit a PR?
- Yes
Environment
{ "marimo": "0.23.6", "editable": false, "location": "/Users/yairchu/dev/soundradix/Drum3D/.venv/lib/python3.13/site-packages/marimo", "OS": "Darwin", "OS Version": "25.2.0", "Processor": "arm", "Python Version": "3.13.1", "Locale": "C/en_US", "Binaries": { "Browser": "140.0.7339.134", "Node": "v23.11.0", "uv": "0.7.12 (dc3fd4647 2025-06-06)" }, "Dependencies": { "click": "8.4.0", "docutils": "0.22.4", "itsdangerous": "2.2.0", "jedi": "0.19.2", "markdown": "3.10.2", "narwhals": "2.21.2", "packaging": "26.2", "psutil": "7.2.2", "pygments": "2.20.0", "pymdown-extensions": "10.21.3", "pyyaml": "6.0.3", "starlette": "1.0.0", "tomlkit": "0.15.0", "typing-extensions": "4.15.0", "uvicorn": "0.47.0", "websockets": "16.0" }, "Optional Dependencies": { "altair": "6.1.0", "anywidget": "0.11.0", "loro": "1.10.3", "pandas": "3.0.3" }, "Experimental Flags": {} }Code to reproduce
No response
ADDITIONAL ADVICE
Since you are given a git repository, you can use git commands to simplify your work. For example, if you made a mistake and want to revert your changes, you can use
git checkout <file>to restore the file to its original state. You can also reset all changes in the repository usinggit reset --hardcommand. Additionally, you can usegit stashandgit stash popto temporarily save your changes and restore them later. Finally, you can see the changes that you've made (which will be submitted when you callsubmit) usinggit statusorgit diffcommands. However you don't need to usegit addorgit commitbefore submitting your changes. In fact,submitonly submits currently unstaged changes because it usesgit diffto get the changes that need to be submitted. Assistant
Let me understand the issue:
- When using
marimo edit --watch, if a file has git merge conflict markers (lines starting with<<<<<<<,=======,>>>>>>>), the notebook parses them and creates_unparsable_cellobjects. - This interferes with conflict resolution tools like
git-mediate. - The suggestion is: Avoid updating the notebook if the file contains conflict markers.
Let me explore the repository structure first.
- When using
Assistant
Let me explore the marimo directory and find relevant files related to file watching and notebook parsing.
Assistant
Let me look at the CLI directory, which likely has the
editcommand with--watchAssistant
Let me search for where the
--watchlogic is implemented and where_unparsable_cellisAssistant
Let me look at the key files. Let me start with
file_change_handler.pyand also search for where the notebook is parsed on file changes.Assistant
Let me look at
parse.pyandfile_change_handler.py:Assistant
Let me try again with the open command.
Assistant
Now let me look at the
file_change_handler.pyAssistant
Let me try opening the file differently.
Assistant
Let me read the rest of the file and also look at the notebook file manager:
Assistant
Let me see the rest of this function, especially the
_handle_file_change_lockedmethod.Assistant
Let me look at
file_manager.pyto see thereload()method:Assistant
Let me find the
reloadmethod:Assistant
Let me look at the reload method and surrounding code.
Assistant
Let me find
_load_app:Assistant
Let me look at the
_load_appmethod.Assistant
Now let me look at
load.pywhich hasload_appAssistant
Let me see the rest of the file.
Assistant
Let me look at the
file_content_matches_last_savemethod:Assistant
Let me look at that method.
Assistant
Let me open the file_manager.py again and look at that
Assistant
Now I understand the issue. Let me create a script to reproduce the problem first.
Assistant
Let me look at how the parser handles conflict markers and what happens:
Assistant
Let me use the installed marimo from the venv
Assistant
Let me check the Parser class interface
Assistant
Let me understand how the notebook serializer/deserializer works
Assistant
Let me look at
serializer.pyAssistant
Let me find
parse_notebookinparse.py:Assistant
Let me now look at the
parse_notebookfunction to understand the full deserialization flowAssistant
Let me check all callers of
reload():Assistant
Now I have a clear picture. Let me implement the fix. The issue is in
file_change_handler.pyin the_handle_file_change_lockedmethod. Before reloading the notebook, we should check if the file contains git merge conflict markers and skip the reload if it does.Let me first look at the full
file_change_handler.pyto decide exactly where to add the check:Assistant
Now I have a clear understanding. The fix should be in
_handle_file_change_lockedinfile_change_handler.py. Before callingreload(), we should check if the file contains git conflict markers and skip the reload if itAssistant
Let me write a proper reproduction script
Assistant
I've confirmed the problem. The scanner also crashes on conflict markers, but the primary fix needs to be: skip reloading when the file has conflict markers. Let me implement it
Assistant
Let me use the edit command properly:
Assistant
Now I need to add the
_file_has_conflict_markersfunction. Let me add it at the end of the file:Assistant
I see the edit merged incorrectly - the
create_reload_strategyfunction got broken. Let me fix itAssistant
The file looks correct. Let me verify the complete file and test it
Assistant
The function works correctly. Now let me run the existing tests for the file_change_handler module
Assistant
All tests pass. Let me also run the file watcher integration tests
Assistant
Let me also run the file_manager tests and the server sessions tests
Assistant
Let me check if those 2 failures are pre-existing (unrelated to my changes):
Assistant
Pre-existing failures, not related to my changes. Let me restore my changes
Assistant
Let me also run the websocket tests to make sure file watching still works
Assistant
Let me also check the server sessions tests that involve watch mode
Assistant
All tests pass, including all watch-mode related tests. Let me verify the final state of the file
Assistant
The diff is clean. Let me verify the final state of the file one more time
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.