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
Interface
No new interfaces are introduced.
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 uses to get the changes that need to be submitted. Assistant
I'll start by exploring the repository structure to understand how the
--watchmode works and where the file parsing occurs.Assistant
Let me explore the marimo directory structure and find where the
--watchmode is implemented.Assistant
Let me find the command-line entry point for the
edit --watchcommand.Assistant
Let me search more specifically for CLI commands.
<tool_call> <function=bash_terminal> <parameter=command> find /marimo/marimo -type d -name "_cli" </tool_call>
Assistant
Let me search for the CLI directory properly.
Assistant
Let me search for the "edit" command definition in the CLI.
Assistant
Let me look at the edit command definition.
Assistant
Let me continue looking at the edit command to see how the watch mode is handled.
Assistant
I need to see more of the edit function to understand how watch mode is handled.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '580,650p' /marimo/marimo/_cli/cli.py </tool_call>
Assistant
I need to continue looking at the edit function to see how the watch mode is handled.
Assistant
Now I see that the
editcommand callsstartwithwatch=watch. I need to find thestartfunction to see how it handles the watch mode.<tool_call> <function=bash_terminal> <parameter=command> grep -n "^def start" /marimo/marimo/_cli/cli.py </tool_call>
Assistant
I need to search for the
startfunction definition in the CLI file.Assistant
Let me search for "start" in a different way.
Assistant
I see that
startis called but it's not defined in the cli.py file. Let me search for it in the imports.Assistant
The
startfunction is imported frommarimo._server.start. Let me look at that file.Assistant
Let me look at the start.py file to understand how the watch mode is handled.
Assistant
Let me continue reading the start.py file to understand the watch mode.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "watch" /marimo/marimo/_server/start.py | head -20 </tool_call>
Assistant
I need to search for "watch" in the start.py file to see how watch mode is handled.
Assistant
Let me look at the
startfunction more closely, particularly around line 322 where it passeswatchto something.Assistant
The
startfunction creates aSessionManagerand passeswatch=watchto it. The issue is about the--watchmode parsing git conflict markers when a notebook is being edited. Let me search for where files are parsed and how the conflict markers might be affecting the parsing.Assistant
This is very helpful! The
_unparsable_cellis used in the parsing logic. Let me look at the scanner.py file to understand how it handles unparsable cells.Assistant
Let me look at the parse.py file to see how it handles the source code when parsing.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '420,480p' /marimo/marimo/_ast/parse.py </tool_call>
Assistant
I need to look at the parse.py file to understand how it handles source code parsing and where the _unparsable_cell generation happens.
Assistant
I need to understand where the source code is being parsed and where the conflict markers might be triggering the unparsable cell detection. Let me look at the parse function more thoroughly to see how it handles unparsable sections of code.
Assistant
Let me look at the parse_notebook function to see how it processes source code.
Assistant
Let me continue reading the parse_notebook function.
Assistant
Let me search for where the conflict markers are being parsed and causing the issue. The user mentioned that when the file contains conflict markers like
<<<<<<<, it gets parsed as_unparsable_cell. Let me search for where this happens.<tool_call> <function=bash_terminal> <parameter=command> grep -rn "<<<<<<" /marimo/marimo --include="*.py" | head -20 </tool_call>
Assistant
Let me search for where git conflict markers or unparsable cells are detected in the parsing logic.
Assistant
No matches for conflict markers. Let me look at the load.py file where it uses
_unparsable_cellto see what triggers this.<tool_call> <function=bash_terminal> <parameter=command> cat /marimo/marimo/_ast/load.py | head -150 </tool_call>
Assistant
Let me use the open command to view the load.py file.
Assistant
I see - I need to use the proper command format. Let me use the open tool with the correct syntax.
Assistant
I need to understand the flow better. Let me look at the codegen.py file to see where
generate_unparsable_cellis called and what triggers it.<tool_call> <function=bash_terminal> <parameter=command> sed -n '390,480p' /marimo/marimo/_ast/codegen.py </tool_call>
Assistant
Let me use sed to read the codegen.py file.
Assistant
Now I need to understand where the unparsable detection happens during the scanning phase. Let me look at the scanner.py file more closely to see how it determines if something is an unparsable cell.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '200,260p' /marimo/marimo/_ast/scanner.py </tool_call>
Assistant
Let me use sed to read the scanner.py file to see how unparsable cells are detected.
Assistant
Let me continue reading the scan_notebook function to see how it handles errors and unparsable cells.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '260,320p' /marimo/marimo/_ast/scanner.py </tool_call>
Assistant
I need to use the proper tool call format. Let me use sed to continue reading the scanner.py file to see how it handles errors and unparsable cells.
Assistant
Now let me look at where the actual cell code is extracted after the boundaries are found.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '320,420p' /marimo/marimo/_ast/scanner.py </tool_call>
Assistant
Let me use sed to read the next part of scanner.py where the cells are extracted from boundaries.
Assistant
Now I understand the flow. The scanner looks for boundary markers (like
@app.cell,with app, etc.) and alsoapp._unparsable_cell. When the tokenizer encounters an error, it falls back to scanning for these boundary lines.The issue is that when a file contains git conflict markers like
<<<<<<<, the tokenizer might fail, and the fallback scanner might pick up lines that look like cell boundaries. However, I need to find where exactly the conflict markers are being interpreted as unparsable cells.Let me search for where the conflict markers might be triggering the unparsable cell detection in the AST parsing phase.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '400,500p' /marimo/marimo/_ast/scanner.py </tool_call>
Assistant
I need to continue exploring the scanner.py file to find where git conflict markers are being detected and converted to unparsable cells. Let me use sed to read more of the file.
Assistant
Let me search for where the conflict marker detection happens by looking at the parse.py file more closely, particularly where it handles syntax errors and unparsable cells.
Assistant
No results for
<<<<<<<- let me search for where conflict markers might be detected differently. Let me look at the AST parser more carefully to understand where unparsable cells get generated from syntax errors.<tool_call> <function=bash_terminal> <parameter=command> grep -n "unparsable" /marimo/marimo/_ast/parse.py | head -30 </tool_call>
Assistant
I need to search for unparsable in the parse.py file. Let me use grep to find all occurrences.
Assistant
Let me look at line 675 where there's a comment about scanner-generated unparsable cells.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '660,720p' /marimo/marimo/_ast/parse.py </tool_call>
Assistant
Let me look at the parse.py file around line 675 to understand how scanner-generated unparsable cells are handled.
Assistant
Let me understand the issue better. The user reports that when using
marimo edit --watch, the git conflict markers (like<<<<<<<) cause the file to be parsed as containing_unparsable_cell. This happens during the AST parsing phase. Let me first create a reproduction script to see the issue in action.Assistant
I need to run the script with the correct Python path that includes the marimo package.
Assistant
Let me check if marimo is installed in the environment.
Assistant
The file is treated as empty or invalid, not with
_unparsable_cell. Let me try a different approach - perhaps the issue is specific to how the file watcher triggers updates. Let me check if the issue is when the file has some marimo content and then conflict markers are added.<tool_call> <function=bash_terminal> <parameter=command> cat > /tmp/reproduce_issue2.py << 'EOF' """Reproduction script for git conflict markers issue - variant 2""" import tempfile from pathlib import Path
Create a temporary directory for testing
with tempfile.TemporaryDirectory() as tmpdir: notebook_path = Path(tmpdir) / "test_notebook.py"
Assistant
Let me run the second reproduction script.
Assistant
The previous command was not executed. Let me try again with the proper syntax.
<tool_call> <function=bash_terminal> <parameter=command> cat > /tmp/reproduce_issue2.py << 'EOF' """Reproduction script for git conflict markers issue - variant 2""" import tempfile from pathlib import Path
Create a temporary directory for testing
with tempfile.TemporaryDirectory() as tmpdir: notebook_path = Path(tmpdir) / "test_notebook.py"
# Create a proper marimo notebook that would normally have cells content = '''import marimo as moapp = mo.App()
@app.cell def _(mo): x = 1 return (x,)
@app.cell def _(): return
<<<<<<< HEAD def func_head(): return "head version"
def func_base(): return "base version"
Assistant
The heredoc is still not being executed. Let me try a different approach - using echo with a file redirect instead.
Assistant
The command got too complex. Let me try a simpler approach using echo directly to write a Python script.
<tool_call> <function=bash_terminal> <parameter=command> python -c " import tempfile from pathlib import Path
with tempfile.TemporaryDirectory() as tmpdir: notebook_path = Path(tmpdir) / 'test_notebook.py'
content = '''import marimo as moapp = mo.App()
@app.cell def _(mo): x = 1 return (x,)
@app.cell def _(): return
<<<<<<< HEAD def func_head(): return 'head version'
def func_base(): return 'base version'
main '''
notebook_path.write_text(content) from marimo._ast.load import get_notebook_status print('Testing notebook:', notebook_path) print('-' * 80) result = get_notebook_status(str(notebook_path)) print(f'Status: {result.status}') if result.notebook: print(f'Violations: {result.notebook.violations}') print(f'Cells: {len(result.notebook.cells)}') for cell in result.notebook.cells: print(f' - Cell type: {type(cell).__name__}') if hasattr(cell, 'code'): code_preview = cell.code[:100] if cell.code else 'empty' print(f' Code preview: {code_preview}...')Assistant
Let me try a simpler approach to test the issue.
Assistant
Now I can see the issue! The file with conflict markers creates an
UnparsableCellthat contains the git conflict markers in its code. This happens because the parser treats the conflicting section as an unparsable cell.Now let me look at the code generation and file writing logic to see where we should add the conflict marker detection.
Assistant
Let me search more specifically.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "def " /marimo/marimo/_ast/codegen.py | head -20 </tool_call>
Assistant
Let me search for "def " in the codegen.py file to find the main functions.
Assistant
Let me look at the generate_filecontents function which is the main entry point for generating file contents.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '537,610p' /marimo/marimo/_ast/codegen.py </tool_call>
Assistant
I need to continue reading the codegen.py file to find the generate_filecontents function where I need to add the conflict marker check.
Assistant
Let me search for where the watch mode reads and parses files.
Assistant
Let me search for where the file contents are read and parsed during watch mode.
Assistant
Let me search in the session directory for file watching logic.
<tool_call> <function=bash_terminal> <parameter=command> find /marimo/marimo/_session -name "*.py" -exec grep -l "parse_notebook|load_notebook|get_notebook_status" {} ; </tool_call>
Assistant
Let me search for where the file is read and parsed during watch mode by looking at the session files.
Assistant
Let me search for where the notebook is loaded when watch mode triggers an update.
Assistant
Let me look at the workspace directory where files are managed.
Assistant
Let me search for where the file contents are read during watch mode updates. Let me look at the edit endpoint.
Assistant
Let me search for where file watch updates trigger code changes.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "watch|reload|update" /marimo/marimo/_server/session_manager.py | head -40 </tool_call>
Assistant
Let me continue searching for where file watch updates trigger code changes in the session manager.
Assistant
The file watcher is initialized but I need to find where it actually reads and parses the file when changes occur. Let me look for the reload strategy.
<tool_call> <function=bash_terminal> <parameter=command> find /marimo/marimo -name "*.py" -exec grep -l "reload_strategy|FileChangeCoordinator" {} ; 2>/dev/null | head -10 </tool_call>
Assistant
Let me search for the reload strategy and FileChangeCoordinator to understand how file changes are handled during watch mode.
Assistant
Let me find where FileChangeCoordinator is defined.
Assistant
Let me read the file_change_handler.py to understand how file changes are processed during watch mode.
Assistant
Let me continue reading to see where the file is actually reloaded and parsed.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '100,200p' /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me continue reading the file_change_handler.py to find where the file is reloaded and parsed during watch mode.
Assistant
Let me continue reading to see where the file is actually reloaded and parsed.
Assistant
Now I can see the issue! At line 225, when the file changes,
session.app_file_manager.reload()is called which reloads the notebook. This is where the parsing happens and where the conflict markers trigger the creation of_unparsable_cell.Let me look at the app_file_manager to understand how the reload works.
Assistant
Let me search for where the app_file_manager is defined.
Assistant
Let me search for AppFileManager definition.
Assistant
Let me read the file_manager.py to understand how the reload method works.
Assistant
Let me continue reading to find the reload method.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "def reload" /marimo/marimo/_session/notebook/file_manager.py </tool_call>
Assistant
Let me search for the reload method in the file_manager.py file.
Assistant
Let me read the reload method to see how it works.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '133,220p' /marimo/marimo/_session/notebook/file_manager.py </tool_call>
Assistant
Let me use sed to read the reload method properly.
Assistant
Now let me look at the _load_app method to see where the parsing happens.
<tool_call> <function=bash_terminal> <parameter=command> grep -n "def _load_app" /marimo/marimo/_session/notebook/file_manager.py </tool_call>
Assistant
The user wants me to continue searching for the _load_app method in the file_manager.py file. Let me search for it using grep.
Assistant
Let me read the _load_app method to see where the parsing happens.
<tool_call> <function=bash_terminal> <parameter=command> sed -n '278,330p' /marimo/marimo/_session/notebook/file_manager.py </tool_call>
Assistant
Let me use sed to read the _load_app method properly.
Assistant
Now I understand the issue. When a file contains git conflict markers and the file watcher triggers a reload in
--watchmode, the parser createsUnparsableCellentries for the conflicting code sections. This interferes with conflict resolution.The fix should detect git conflict markers (lines starting with
<<<<<<<,=======, or>>>>>>>) and skip the reload in that case. Let me implement the fix:Assistant
Now I have a good understanding of the issue. Let me implement the fix. The best place to add the conflict marker detection is in the
handle_changemethod of theFileChangeCoordinatorclass in/marimo/marimo/_session/file_change_handler.py. This will prevent the reload from happening when conflict markers are detected.Let me first create a helper function to detect conflict markers, then modify the file change handler:
Assistant
I need to now apply this fix to the actual file. Let me open the file and make the necessary changes using the edit command.
<tool_call> <function=bash_terminal> <parameter=command> head -45 /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
I need to add the conflict marker detection code to the file_change_handler.py. Let me use the edit command to modify the imports section first, then add the pattern detection and check in the _handle_file_change_locked method.
Assistant
Let me add the necessary import and constant at the top of the file:
Assistant
Now let me add the conflict marker pattern constant after the LOGGER definition:
Assistant
Let me add the conflict marker pattern constant after the LOGGER definition:
Assistant
Now let me verify the changes so far:
Assistant
I see there's an issue - the
\nliteral got added. Let me fix that:Assistant
Let me check if the sed command worked correctly:
Assistant
This is getting messy. Let me reset the file and try a different approach.
<tool_call> <function=bash_terminal> <parameter=command> cd /marimo && git checkout marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me reset the file and start fresh with a cleaner approach. I'll use the edit command to make the changes properly.
Assistant
Let me check the correct path:
Assistant
Good, let me restore the file using git restore:
Assistant
Let me check the file is back to its original state:
<tool_call> <function=bash_terminal> <parameter=command> head -30 /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me use the correct sed command to reset the file properly.
Assistant
Good, the file is now back to its original state. Now let me make the changes properly. I'll add the necessary imports and the conflict marker detection constant using a more careful approach:
<tool_call> <function=bash_terminal> <parameter=command> sed -i '8a import re' /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me add the import line properly after line 8:
Assistant
Let me verify the changes:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '1,35p' /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me verify the changes to the file by checking the imports section.
Assistant
I see there's an issue with the formatting - there's an 'n' before the comment. Let me fix that:
<tool_call> <function=bash_terminal> <parameter=command> sed -i 's/^n# Patterns/# Patterns/' /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me check if the formatting is fixed:
Assistant
The 'n' is still there. Let me try a different approach to fix it:
Assistant
Now let me verify the fix:
<tool_call> <function=bash_terminal> <parameter=command> sed -n '24,35p' /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me verify the sed command fixed the formatting issue:
Assistant
Good! The formatting is now correct. Now I need to add the logic to check for conflict markers before attempting to reload. Let me find where to add this check in the
_handle_file_change_lockedmethod:<tool_call> <function=bash_terminal> <parameter=command> sed -n '200,240p' /marimo/marimo/_session/file_change_handler.py </tool_call>
Assistant
Let me read the _handle_file_change_locked method to find where to add the conflict marker detection:
Assistant
I see the
_handle_file_change_lockedmethod. I need to add the conflict marker check before the reload attempt. Let me add the code after line 228 (after checking if content matches last save):Assistant
Let me verify the changes were added correctly:
Assistant
The sed command didn't work correctly. Let me restore the file and use a more reliable approach with a Python script to make the edit:
Assistant
Let me create a Python script to make the edit more reliably:
Assistant
Now let me verify the changes were applied correctly:
Assistant
The imports and LOGGER section look correct. Now let me check if the CONFLICT_MARKER_PATTERN was added and the conflict detection code:
Assistant
The CONFLICT_MARKER_PATTERN constant is missing. Let me fix this:
Assistant
Now let me verify the constant was added:
Assistant
Now let me check if the conflict marker check code was added properly:
Assistant
Excellent! The changes look good. Now let me create a test script to verify that the fix works correctly:
Assistant
The conflict marker detection pattern works correctly! Now let me check if there are existing tests to ensure we don't break anything:
Assistant
Great! There's a test file for the file change handler. Let me run it to make sure my changes don't break anything:
Assistant
All existing tests pass. Now let me add a test specifically for the conflict marker detection feature to ensure it works correctly:
Assistant
Now let me run the new tests to verify they work:
<tool_call> <function=bash_terminal> <parameter=command> source /marimo/.venv/bin/activate && python -m pytest /marimo/tests/_session/test_file_change_handler.py::test_file_change_coordinator_skips_reload_with_conflict_markers -v </tool_call>
Assistant
Let me run the new tests to verify they work.
Assistant
I need to install pytest-mock to use the mocker fixture.
<tool_call> <function=bash_terminal> <parameter=command> source /marimo/.venv/bin/activate && pip install pytest-mock </tool_call>
Assistant
Let me install pytest-mock properly.
Assistant
Now let me run the test again.
<tool_call> <function=bash_terminal> <parameter=command> source /marimo/.venv/bin/activate && python -m pytest /marimo/tests/_session/test_file_change_handler.py::test_file_change_coordinator_skips_reload_with_conflict_markers -v </tool_call>
Assistant
Let me run the test with the correct syntax.
Assistant
The mocker fixture is not available in the pyproject.toml. Let me check how other tests in the file use mocking:
Assistant
I see - the tests use
unittest.mock.MagicMockinstead of pytest-mock'smockerfixture. Let me update my test to useMagicMockinstead:Assistant
Now let me run the test again:
Assistant
Excellent! The test passes. Now let me run the test for the conflict marker patterns as well:
Assistant
Both new tests pass. Now let me run all the existing tests in the file_change_handler test file to make sure my changes don't break anything:
Assistant
All tests pass. Now let me create a more comprehensive test to verify that the fix works end-to-end with the actual watch mode scenario:
Assistant
The test shows that:
- Normal notebooks are parsed correctly (CellDef)
- Notebooks with conflict markers create UnparsableCells (this is the existing behavior when the parser tries to parse the content)
- The file change handler can now detect conflict markers and will skip the reload (which is the fix)
Now let me verify the fix works as expected by looking at the actual code changes:
<tool_call> <function=bash_terminal> <parameter=command> cd /marimo && git diff marimo/_session/file_change_handler.py </tool_call>
Assistant
I need to check the git diff to see the changes I made to the file_change_handler.py file. Let me use the correct command.
Assistant
Excellent! The changes look correct. Now let me also verify the changes to the test file:
<tool_call> <function=bash_terminal> <parameter=command> cd /marimo && git diff marimo/tests/_session/test_file_change_handler.py | head -80 </tool_call>
Assistant
Let me check the git diff for the test file.
Assistant
The test file might not be tracked. Let me check if it's been modified:
Assistant
The test file is in the
tests/directory, notmarimo/tests/. Let me check the diff:<tool_call> <function=bash_terminal> <parameter=command> cd /marimo && git diff -- tests/_session/test_file_change_handler.py | head -120 </tool_call>
Assistant
I need to check the git diff for the test file properly.
Assistant
The test file changes look good. Now let me run a broader set of tests to make sure nothing is broken. Let me run the session tests:
<tool_call> <function=bash_terminal> <parameter=command> source /marimo/.venv/bin/activate && python -m pytest tests/_session/test_file_change_handler.py -v --tb=short 2>&1 | tail -40 </tool_call>
Assistant
Let me run the session tests properly using pytest with the correct path.
Assistant
The tests pass. Now let me also run the file watcher integration tests to make sure those are not affected:
<tool_call> <function=bash_terminal> <parameter=command> source /marimo/.venv/bin/activate && python -m pytest tests/_session/test_file_watcher_integration.py -v --tb=short 2>&1 | tail -30 </tool_call>
Assistant
Let me run the file watcher integration tests to make sure the changes don't break anything.
Assistant
Assistant
Let me run the integration test to verify the fix works correctly.
Assistant
The integration test shows that the fix is working correctly! The file change coordinator now:
- Detects conflict markers in notebook files
- Skips the reload when conflict markers are present
- Logs a warning message to help users resolve conflicts
- Continues to work normally for files without conflict markers (attempts reload)
Now let me make sure all related tests pass before submitting. Let me run a broader set of tests:
<tool_call> <function=bash_terminal> <parameter=command> source /marimo/.venv/bin/activate && python -m pytest tests/_session/ -v --tb=short -x 2>&1 | tail -50 </tool_call>
Assistant
Let me run the session tests to verify nothing is broken.
Assistant
The failing test is unrelated to my changes - it's a test about process group killing which is unrelated to the conflict marker detection feature. Let me verify this by checking if this test was already failing before my changes by looking at the test:
<tool_call> <function=bash_terminal> <parameter=command> grep -A 20 "def test_try_kill_process_and_group_kills_grandchild" /marimo/tests/_session/managers/test_kernel.py </tool_call>
Assistant
Let me check if this test failure is pre-existing by running the specific test in isolation:
Assistant
This test failure is unrelated to my changes - it's a flaky test about process group killing. Let me verify my changes haven't broken anything by running the tests that are most relevant to the changes I made:
Assistant
All tests related to my changes pass. Let me also run the AST tests to make sure the parsing logic is not affected:
Assistant
The AST tests pass as well (the inline-snapshot warning is just a formatting issue, not a test failure). Now let me create a summary of what I've done and verify everything is in order:
Summary of Changes
I've implemented a fix to prevent
marimo edit --watchfrom parsing git conflict markers as_unparsable_cell. The fix consists of:-
Added conflict marker detection in
/marimo/marimo/_session/file_change_handler.py:- Added
import refor pattern matching - Added
CONFLICT_MARKER_PATTERNregex pattern to detect git conflict markers (<<<<<<<,=======,>>>>>>>) - Added logic in
_handle_file_change_lockedto check for conflict markers before attempting to reload the notebook - If conflict markers are detected, the reload is skipped and a warning is logged
- Added
-
Added tests in
/marimo/tests/_session/test_file_change_handler.py:
-
Assistant
Let me check the git diff to see the summary of changes.
Assistant
Perfect! The changes look good. Let me run one final comprehensive test to make sure everything works correctly:
Assistant
I have successfully implemented the fix for the git conflict markers issue in
marimo edit --watch. Here's a summary of what was done:Changes Made
1.
/marimo/marimo/_session/file_change_handler.py- Added
import refor regex pattern matching - Added
CONFLICT_MARKER_PATTERNregex to detect git conflict markers (<<<<<<<,=======,>>>>>>>) - Added logic in
_handle_file_change_lockedto check for conflict markers before attempting to reload the notebook - If conflict markers are detected, the reload is skipped and a warning is logged to help users resolve conflicts
2.
/marimo/tests/_session/test_file_change_handler.py- Added to verify the regex pattern correctly detects conflict markers
- Added
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.