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
I’ll locate the file-watch/reload path and its tests, then reproduce how an externally conflicted notebook is parsed and potentially rewritten. I’ll implement the guard at the narrowest point so normal parsing behavior remains unchanged outside watch mode.
- Assistant
ripgrepis unavailable, so I’ll use recursivegrepto map the relevant implementation and test coverage. - Assistant
The watcher extension delegates actual reload behavior through a server callback. I’ll inspect both layers and nearby tests to determine where file contents are read and where a conflict can be safely ignored without disabling future watch events.
- Assistant
I’ll trace construction of
SessionFileWatcherExtensioninsession_manager.py, then inspect the file manager’s reload method because that is likely where conflicted source becomes an unparsable cell. - Assistant
There is a dedicated
file_change_handler, which is the appropriate policy boundary. I’ll inspect it fully along with its tests and coordinator behavior, especially hash bookkeeping and exception handling. - Assistant
The coordinator currently checks the save hash and immediately calls
reload(), which deliberately tolerates syntax errors by creating unparsable cells. I’ll inspect coordinator tests and search for an existing conflict-marker utility before adding a reusable predicate or a localized pre-reload content check. - Assistant
No existing helper appears present. I’ll review the remaining coordinator tests to preserve expected return semantics and then implement detection using the manager’s storage abstraction (
read_file) rather than direct filesystem I/O, ensuring virtual/custom storage remains supported. - Assistant
I’ll add a small line-based predicate and invoke it immediately before
reload(). A conflicted file will returnhandled=Falsewithout an error or state mutation; the watcher remains active, so resolving the conflict and saving will produce a later normal reload. The check intentionally matches only lines beginning with seven<characters, as requested, andsplitlines()handles LF/CRLF robustly. - Assistant
The guard is in place. I’ll first run the focused existing test module to detect regressions in coordinator behavior and typing/mock assumptions.
- Assistant
Next I’ll run a temporary end-to-end reproduction (without adding tests): initialize an
AppFileManager, write real Git conflict text, invoke the coordinator, verify no app mutation/reload notification, then resolve the file and verify the next event reloads successfully. I’ll also exercise CRLF and non-line-start edge cases directly. - Assistant
The reproduction confirms the conflict is neither parsed nor rewritten, and a later resolved save reloads normally. I’ll now run formatting/lint checks on the changed source plus the watcher integration tests, then inspect the final diff for accidental changes.
- Assistant
All focused tests and lint checks pass (the sole skip is an optional
watchdogdependency test). Before submitting, I’ll run the repository’s configured Python type checker on the changed module if available, and verify no temporary or generated files remain. - Assistant
The type checker is configured but not installed in the current default environment (
uvcould not spawn either checker). Since the source has passed Ruff and runtime tests and the change uses concretestr/booltypes, I won’t alter the environment further. I’ll do a final diff/status check and then submit with the required checklist assessment.
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.