From 6f94d17b6c0253c66835dd11b5f8c7f8079c345b Mon Sep 17 00:00:00 2001 From: Myles Scolnick Date: Fri, 26 Sep 2025 09:46:39 -0400 Subject: [PATCH 1/2] don't override auto-save by when in --watch mode --- marimo/_config/manager.py | 4 ++++ marimo/_server/start.py | 15 ++------------- tests/_server/test_sessions.py | 24 +++++------------------- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/marimo/_config/manager.py b/marimo/_config/manager.py index 87fa9bd1157..4c03525a324 100644 --- a/marimo/_config/manager.py +++ b/marimo/_config/manager.py @@ -107,6 +107,10 @@ def language_servers(self) -> LanguageServersConfig: 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 d8dc807f087..fb7a9325450 100644 --- a/marimo/_server/start.py +++ b/marimo/_server/start.py @@ -196,19 +196,8 @@ def start( min_port=DEFAULT_PORT + 400, ) - # 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.info("Watch mode enabled, auto-save is disabled") + if watch and config_reader.is_auto_save_enabled: + LOGGER.warning("Watch mode enabled and may interfere with auto-save.") 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 1da82966180..93b1a24b444 100644 --- a/tests/_server/test_sessions.py +++ b/tests/_server/test_sessions.py @@ -604,23 +604,14 @@ def __(): @save_and_restore_main -def test_watch_mode_config_override(tmp_path: Path) -> None: - """Test that watch mode properly overrides config settings.""" +def test_watch_mode_does_not_override_config(tmp_path: Path) -> None: + """Test that watch mode does not override 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 config with autosave enabled + # Create a default config (autosave enabled by default) 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))) @@ -631,7 +622,7 @@ def test_watch_mode_config_override(tmp_path: Path) -> None: quiet=True, include_code=True, lsp_server=MagicMock(), - config_manager=config_reader_watch, + config_manager=config_reader, cli_args={}, argv=None, auth_token=None, @@ -657,13 +648,8 @@ def test_watch_mode_config_override(tmp_path: Path) -> None: ) try: - # Verify that the config was overridden + # Verify that the config was not overridden for watch mode 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 From fa8eb41db36b78ccb7d955bd0801869c4925950b Mon Sep 17 00:00:00 2001 From: Myles Scolnick Date: Fri, 26 Sep 2025 11:33:15 -0400 Subject: [PATCH 2/2] Update marimo/_server/start.py Co-authored-by: Trevor Manz --- marimo/_server/start.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/marimo/_server/start.py b/marimo/_server/start.py index fb7a9325450..6bd169b3611 100644 --- a/marimo/_server/start.py +++ b/marimo/_server/start.py @@ -197,7 +197,7 @@ def start( ) if watch and config_reader.is_auto_save_enabled: - LOGGER.warning("Watch mode enabled and may interfere with auto-save.") + LOGGER.warning("Enabling watch mode may interfere with auto-save.") if GLOBAL_SETTINGS.MANAGE_SCRIPT_METADATA: config_reader = config_reader.with_overrides(