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
I’ll trace the watch/reload path and notebook parsing behavior, locate relevant tests, then reproduce the conflict-marker rewrite before making the smallest guard at the appropriate file-update boundary. First I’ll inspect the repository structure and search for watch handlers and unparsable-cell logic.
- Assistant
rgis unavailable, so I’ll use recursivegrepand narrow the results to Python source and tests. - Assistant
The likely boundary is
FileChangeHandler, where disk changes become notebook transactions. I’ll inspect that implementation and its focused tests to understand whether “avoid updating” means returning before parse/diff and how failures are currently handled. - Assistant
Reload catches parse exceptions, but conflict markers are deliberately tolerated as unparsable cells, so that catch cannot protect the in-memory document. A pre-reload content check is appropriate. I’ll inspect available async file helpers, content/hash methods, and the remaining coordinator tests to choose a convention-consistent implementation and preserve error semantics.
- Assistant
No existing conflict-marker utility exists. Since the locked method is synchronous and reload itself reads synchronously, the guard can read through the file manager before mutation. I’ll inspect
AppFileManagerloading and content APIs to avoid duplicate or inconsistent encoding/path behavior, then reproduce the mutation directly through the coordinator. - Assistant
I’ll reproduce with a temporary standalone script (outside the repository) that loads a valid notebook, writes a Git-conflicted version containing a syntactically valid alternative on each side, invokes the coordinator, and reports whether the original cell became an unparsable conflict cell. This directly demonstrates the reported in-memory update without modifying tests.
- Assistant
The first reproduction attempt did not reach application code because Python resolves imports relative to
/tmpfor that script. I’ll rerun it with the repository onPYTHONPATH. - Assistant
The system Python lacks project dependencies (
msgspec). The repository usesuv, so I’ll execute in its managed environment rather than altering dependency files. - Assistant
That conflict layout was rejected before mutation because markers surrounded the cell declaration itself. Git commonly places markers inside an existing cell body when only cell code differs; I’ll adjust the fixture to that realistic shape, which should exercise the scanner’s unparsable-cell fallback described in the issue.
- Assistant
The reproduction confirms the bug for conflict markers inside a cell. I’ll add a narrow detector for
<<<<<<<at column zero and invoke it immediately before reload. Read failures will fall through to existing reload/error handling, preserving current behavior; detected conflicts will return an unhandled/no-error result, like ignored self-writes, without mutating the notebook or notifying clients. - Assistant
The standalone reproduction now remains unhandled, does not call the reload strategy, and preserves the original document. Next I’ll run the full focused session test module plus lint/type checks available for the changed file; this also verifies ordinary syntax-error fallback and normal external reload behavior remain intact.
- Assistant
Focused tests and Ruff pass (23 tests). I’ll now validate edge semantics with a temporary script: markers at file start and after CRLF are detected, indented text is not (the requirement says beginning of line), and once the conflict is resolved a subsequent watch event reloads normally. Then I’ll run the adjacent watcher integration tests and inspect final repository status.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.