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 start by understanding the repository structure and the issue. The issue is about
marimo edit --watchparsing git conflict markers (lines starting with<<<<<<<) asapp._unparsable_cell. The suggestion is to avoid updating the notebook if the file contains conflict markers.Let me explore the repository structure first.
Assistant
Let me explore the marimo package structure and find the relevant files for the
edit --watchfunctionalityAssistant
I need to make one command at a time.
Assistant
Let me look at the key files that handle file changes and the watch functionality.
Assistant
Now let me look at the file_manager.py and the
_unparsable_cell:Assistant
Let me look at the
_load_appmethod and theAppclass for_unparsablehandlingAssistant
Let me see the full _load_app method.
Assistant
Let me look at the
loadmodule to understand how_unparsable_cellis created.Assistant
Let's look at load.py to understand how apps are loaded and how unparsable cells come about.
Assistant
Let me look at the file watcher integration and understand where file changes are detected
Assistant
Now let me create a script to reproduce the issue. First, let me check what test infrastructure exists.
Assistant
Let me look at the test file and the existing tests for the file change handler
Assistant
Let me check where
reload()is called from besides the file change handlerAssistant
Now I have a good understanding of the issue. Let me look at how I can detect conflict markers. Let me first create a reproduction script.
Assistant
Let me use the correct Python environment.
Assistant
Let me check if marimo is installed or if we need to use the dev setup.
Assistant
Let me check for the virtual environment and install dependencies.
Assistant
Good, let me use the venv Python. Let me run the reproduction script
Assistant
Let me look at the App class to understand
_unparsable_cellAssistant
Let me look at the deserializer to understand how conflict markers would be handled during parsing
Assistant
Let me look at the codegen to understand when unparsable cells are created.
Assistant
Let me look at the
_unparsable_cellmethod in app.py to fully understand the flowAssistant
Let me create a more realistic reproduction to confirm
Assistant
Let me fix the syntax error.
Assistant
Let me test a scenario where conflict markers are inside a cell body (e.g., when only one cell has a conflict)
Assistant
Let me try another scenario - conflict markers between cell decorators
Assistant
Let me find where
UnparsableCellis used in the parserAssistant
Let me look at parse.py where UnparsableCell is created
Assistant
Let me get more context around the UnparsableCell creation
Assistant
Now I have a clear understanding. Let me implement the fix. The issue is in
file_change_handler.py- when a file with git conflict markers is detected by the file watcher, the reload parses those markers and corrupts the notebook.The fix: add a check for git conflict markers before reloading in
_handle_file_change_locked.Assistant
Let me use the correct command. I should use
openfrom the special commands.Assistant
Let me see more of the file
Assistant
Let me see the rest of the file
Assistant
Now let me implement the fix. I'll add a check for git conflict markers in
_handle_file_change_lockedto skip reloading when the file contains conflictAssistant
Let me use the proper heredoc syntax for the edit command.
Assistant
Good. Let me verify the end of the file looks correct
Assistant
Good, the edit looks correct. Now let me run the existing tests for the file change handler to make sure nothing is broken
Assistant
All existing tests pass. Now let me write a script to verify my fix works correctly
Assistant
Now let me test the full scenario - the FileChangeCoordinator should skip reload when the file has conflict markers
Assistant
The fix works correctly. Let me also run the related test files to make sure nothing else
Assistant
All tests pass. Let me also run the broader test suite for the session module
Assistant
340 tests passed, only 1 unrelated failure (kernel process group test). Our change is safe.
Let me verify the final state of our change and clean up
Assistant
Let me clean up the temporary test files
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.