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
code{ "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
Assistant
Let me analyze this issue. The user is reporting that when
marimo edit --watchis running and a file has merge conflict markers (like<<<<<<<), marimo parses them asapp._unparsable_cell, which interferes with conflict resolution tools.The suggestion is to avoid updating the notebook if the file contains conflict markers, recognizable by
<<<<<<<at the beginning of a line.Let me start by exploring the repository structure to understand how marimo handles file parsing and watching.
Assistant
Let me explore the main marimo directory structure.
Assistant
Let me look at the main marimo package directory to understand its structure better.
Assistant
Let me search for where the
_unparsable_cellis defined and where the file watching logic is implemented.Assistant
None
Assistant
Let me look at the file change handler and file watcher integration files.
Assistant
Now I need to find where the file is actually reloaded. Let me look at the
app_file_manager.reload()method.Assistant
Now I can see the flow. The
reload()method inAppFileManagercalls_load_app()which loads the file. Let me check the_load_appmethod and then trace back to the parsing logic:Assistant
Now let me look at the
load.load_appfunction to understand how files are parsed:Assistant
Now I understand the flow. Let me look at the
file_change_handler.pyagain to see where I should add the conflict marker check. The key is in the_handle_file_change_lockedmethod that callsreload(). I should check for conflict markers before attempting to reload.Let me look at how the reload is being called in the file change handler:
Assistant
The ideal place to add the check is in the
_handle_file_change_lockedmethod, right before callingsession.app_file_manager.reload(). Let me also check what conflict markers look like in git:Assistant
The issue mentions
<<<<<<<at the beginning of a line. Let me search for any existing tests related to file watching or conflict markers:Assistant
Good, now I understand the test structure. Let me look at the specific file where I need to add the conflict marker check. The best place is in
file_change_handler.pyin the_handle_file_change_lockedmethod. Let me also check how the storage reads files:Assistant
Now I have a good understanding of the codebase. The fix should be in the
_handle_file_change_lockedmethod infile_change_handler.py. I need to check if the file contains conflict markers before attempting to reload it.Let me create a simple test script to reproduce the issue first:
Assistant
The conflict marker check function works. Now let me implement the fix in
file_change_handler.py. I'll add a helper function to check for conflict markers and skip the reload if they're present.Assistant
Now I understand the code structure. I need to add a check in
_handle_file_change_lockedbefore thereload()call. I'll add a helper function to check for conflict markers and skip the reload if they're present.Let me implement the fix:
Assistant
Now I need to add the
_has_conflict_markershelper function at the end of the file:Assistant
The changes look good. Now let me verify the full file to make sure everything is correct:
Assistant
The code looks good. Now let me run the existing tests to make sure my changes don't break anything:
Assistant
I need to install the dependencies first or use the virtual environment.
Assistant
I need to use the Python from the venv to run the tests. Let me try using the venv's Python directly.
Assistant
All 23 tests passed. Now let me create a test script to verify my fix works correctly with conflict markers:
Assistant
All tests passed. Let me also verify that the existing tests still pass after my changes:
Assistant
Let me also run the related file watcher integration tests:
Assistant
All tests pass. Let me clean up my test script:
Assistant
Now let me verify my solution is complete by checking the git diff:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.