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:
marimo edit --watchparses git conflict markers (like<<<<<<<,=======,>>>>>>>) asapp._unparsable_cell. This interferes with conflict resolution tools. 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 codebase to understand how
marimo edit --watchworks and where file parsing occursAssistant
I need to make single tool calls. Let me start with one search.
Assistant
Let me look at the file watching mechanism. The issue mentions
marimo edit --watch, so there must be a file watcher. Let me search for where file watching happens.Assistant
Let me look at the file watcher and the session/notebook file manager to understand how files are reloaded when they change.
Assistant
Let me look at the session file watcher integration and the file manager to understand how files are reloaded.
Assistant
Let me look at the session manager to understand the callback when a file changes.
Assistant
Let me look at the file change handler and the reload strategy.
Assistant
Now let me look at
AppFileManager.reload()and how notebook files are loadedAssistant
Let me look at the
_load_appmethod and how apps are loadedAssistant
Let me see the
_load_appmethod.Assistant
Let me find the right place to add the check. Let me look at existing tests and the file change handler more
Assistant
No existing references to conflict markers. Good, this is a new feature.
Let me look at the test files for file_change_handler and file_manager to understand the testing patterns.
Assistant
Let me look at the test file for file_change_handler.
Assistant
Let me check where
reload()is called from other than the file changeAssistant
Let me check the export endpoints that call reload() to understand context
Assistant
Let me check the
pathproperty ofAppFileManagerAssistant
Let me look for the
pathproperty:Assistant
Let me see the
pathproperty.Assistant
OK, let me see more of the
pathproperty:Assistant
Now I have a clear picture. Let me implement the fix. The best place is in
_handle_file_change_lockedinfile_change_handler.py— before callingreload(), we should check if the file contains git merge conflict markers.Assistant
The
opencommand works with file path and line number:Assistant
Let me try the open command with just the file path:
Assistant
Let me scroll down to see the
_handle_file_change_lockedmethodAssistant
I need to use the goto command properly.
Assistant
Let me see the full
_handle_file_change_lockedmethod. The fix should go between the "own writes" check (line 218-222) and thereload()call (line 227-228). Let me now implement it.First, let me add the import and the conflict marker detection pattern. Then add the check in `_handle_file_change_l
Assistant
I made a mess — there are now duplicate import lines. Let me fix this by reverting and trying again.
Assistant
Let me reopen the file and do the edits more
Assistant
Good, the file is reverted. Now let me make changes step by step. First, add the
import relineAssistant
Good. Now let me add the conflict marker pattern constant. I'll add it after LOGGER line:
Assistant
Let me scroll down to see the
_handle_file_change_lockedmethod:Assistant
Now I'll add the conflict marker check. I'll replace the blank line and comment before the
reload()call with the new check:Assistant
I notice there's a duplicate line. Let me fix it:
Assistant
There's a malformed line at 247. Let me fix it:
Assistant
The file looks good now. The backticks in the comment got lost but that's cosmetic. Let me verify the full file from the top
Assistant
The file looks good. Let me verify the file compiles by running Python on it:
Assistant
The file compiles. Now let me run the existing tests to ensure nothing is broken:
Assistant
Missing dependencies. Let me install them:
Assistant
Now let me run the tests again:
Assistant
Let me run without the timeout flag
Assistant
The async tests are failing due to missing pytest-asyncio. Let me install it and re-run:
Assistant
Now let me run the tests again:
Assistant
All 23 tests pass. Now let me write a quick script to verify the fix works correctly
Assistant
The regex works correctly. Let me also run related test files to make sure nothing is broken:
Assistant
The 2 failing tests are pre-existing and unrelated to my changes. Let me now create a reproduction script to verify the fix addresses the original issue:
Assistant
The fix works correctly. Let me verify the final state of my changes:
Assistant
The diff looks clean and correct. Let me now review the checklist:
-
Error reproduction: I verified that when a file with git merge conflict markers is reloaded, the
_CONFLICT_MARKER_PATTERNcorrectly detects them (confirmed with a test script). -
Fix confirmation: My fix adds a check in
_handle_file_change_lockedthat reads the file content and searches for<<<<<<<at the beginning of a line. If found, it logs a warning and skips the reload, preventing the notebook from being updated withapp._unparsable_cellentries. -
Edge cases:
- Normal files without conflict markers: no impact (check passes and reload proceeds normally)
- Files with only
>>>>>>>(end marker): not detected, correctly — since there's no<<<<<<<, the file is likely being edited normally <<<<<<<inside a string (not at line start): not detected by + anchor
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.