Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

Revert "don't override auto-save by when in --watch mode" (#7071)

Myles Scolnick928e8a0e316e
diff --git a/marimo/_config/manager.py b/marimo/_config/manager.py
index 65815135ec..62790668c1 100644
--- a/marimo/_config/manager.py
+++ b/marimo/_config/manager.py
@@ -110,10 +110,6 @@ class MarimoConfigReader:
return self._config["language_servers"]
return {}
- @property
- def is_auto_save_enabled(self) -> bool:
- return self._config["save"]["autosave"] == "after_delay"
-
@property
def experimental(self) -> ExperimentalConfigType:
if "experimental" in self._config:
diff --git a/marimo/_server/start.py b/marimo/_server/start.py
index 21a912a2a7..7bf886f158 100644
--- a/marimo/_server/start.py
+++ b/marimo/_server/start.py
@@ -208,8 +208,19 @@ def start(
min_port=DEFAULT_PORT + 400,
)
- if watch and config_reader.is_auto_save_enabled:
- LOGGER.warning("Enabling watch mode may interfere with auto-save.")
+ # If watch is true, disable auto-save and format-on-save,
+ # watch is enabled when they are editing in another editor
+ if watch:
+ config_reader = config_reader.with_overrides(
+ {
+ "save": {
+ "autosave": "off",
+ "format_on_save": False,
+ "autosave_delay": 1000,
+ }
+ }
+ )
+ LOGGER.warning("Watch mode enabled, auto-save is disabled")
if GLOBAL_SETTINGS.MANAGE_SCRIPT_METADATA:
config_reader = config_reader.with_overrides(
diff --git a/tests/_server/test_sessions.py b/tests/_server/test_sessions.py
index c47e6184e8..76e9141f2b 100644
--- a/tests/_server/test_sessions.py
+++ b/tests/_server/test_sessions.py
@@ -601,14 +601,23 @@ def __():
@save_and_restore_main
-def test_watch_mode_does_not_override_config(tmp_path: Path) -> None:
- """Test that watch mode does not override config settings."""
+def test_watch_mode_config_override(tmp_path: Path) -> None:
+ """Test that watch mode properly overrides config settings."""
# Create a temporary file
tmp_file = tmp_path / "test_watch_mode_config_override.py"
tmp_file.write_text("import marimo as mo")
- # Create a default config (autosave enabled by default)
+ # Create a config with autosave enabled
config_reader = get_default_config_manager(current_path=None)
+ config_reader_watch = config_reader.with_overrides(
+ {
+ "save": {
+ "autosave": "off",
+ "format_on_save": False,
+ "autosave_delay": 2000,
+ }
+ }
+ )
# Create a session manager with watch mode enabled
file_router = AppFileRouter.from_filename(MarimoPath(str(tmp_file)))
@@ -619,7 +628,7 @@ def test_watch_mode_does_not_override_config(tmp_path: Path) -> None:
quiet=True,
include_code=True,
lsp_server=MagicMock(),
- config_manager=config_reader,
+ config_manager=config_reader_watch,
cli_args={},
argv=None,
auth_token=None,
@@ -645,8 +654,13 @@ def test_watch_mode_does_not_override_config(tmp_path: Path) -> None:
)
try:
- # Verify that the config was not overridden for watch mode
+ # Verify that the config was overridden
config = session_manager._config_manager.get_config()
+ assert config["save"]["autosave"] == "off"
+ assert config["save"]["format_on_save"] is False
+
+ # Verify that the config was not overridden
+ config = session_manager_no_watch._config_manager.get_config()
assert config["save"]["autosave"] == "after_delay"
assert config["save"]["format_on_save"] is True