From 84143d31b24aa5fdf56373795b518043130036d1 Mon Sep 17 00:00:00 2001 From: chengyongru <2755839590@qq.com> Date: Fri, 19 Jun 2026 01:04:53 +0800 Subject: [PATCH] refactor: reuse onboard config refresh path Simplify pass: share the existing-config refresh flow between non-interactive defaults and declined overwrite prompts without changing behavior. --- nanobot/cli/commands.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/nanobot/cli/commands.py b/nanobot/cli/commands.py index 191c80ff..2e7c984f 100644 --- a/nanobot/cli/commands.py +++ b/nanobot/cli/commands.py @@ -474,16 +474,20 @@ def onboard( loaded.agents.defaults.workspace = workspace return loaded + def _refresh_existing_config() -> Config: + refreshed = _apply_workspace_override(load_config(config_path)) + save_config(refreshed, config_path) + console.print( + f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)" + ) + return refreshed + # Create or update config if config_path.exists(): if use_wizard: config = _apply_workspace_override(load_config(config_path)) elif default_fallback or default_refresh_without_prompt: - config = _apply_workspace_override(load_config(config_path)) - save_config(config, config_path) - console.print( - f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)" - ) + config = _refresh_existing_config() else: console.print(f"[yellow]Config already exists at {config_path}[/yellow]") console.print( @@ -497,11 +501,7 @@ def onboard( save_config(config, config_path) console.print(f"[green]✓[/green] Config reset to defaults at {config_path}") else: - config = _apply_workspace_override(load_config(config_path)) - save_config(config, config_path) - console.print( - f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)" - ) + config = _refresh_existing_config() else: config = _apply_workspace_override(Config()) # In wizard mode, don't save yet - the wizard will handle saving if should_save=True