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.
This commit is contained in:
chengyongru
2026-06-22 13:04:05 +08:00
committed by Xubin Ren
parent 3d773d9054
commit 84143d31b2
+10 -10
View File
@@ -474,16 +474,20 @@ def onboard(
loaded.agents.defaults.workspace = workspace loaded.agents.defaults.workspace = workspace
return loaded 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 # Create or update config
if config_path.exists(): if config_path.exists():
if use_wizard: if use_wizard:
config = _apply_workspace_override(load_config(config_path)) config = _apply_workspace_override(load_config(config_path))
elif default_fallback or default_refresh_without_prompt: elif default_fallback or default_refresh_without_prompt:
config = _apply_workspace_override(load_config(config_path)) config = _refresh_existing_config()
save_config(config, config_path)
console.print(
f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)"
)
else: else:
console.print(f"[yellow]Config already exists at {config_path}[/yellow]") console.print(f"[yellow]Config already exists at {config_path}[/yellow]")
console.print( console.print(
@@ -497,11 +501,7 @@ def onboard(
save_config(config, config_path) save_config(config, config_path)
console.print(f"[green]✓[/green] Config reset to defaults at {config_path}") console.print(f"[green]✓[/green] Config reset to defaults at {config_path}")
else: else:
config = _apply_workspace_override(load_config(config_path)) config = _refresh_existing_config()
save_config(config, config_path)
console.print(
f"[green]✓[/green] Config refreshed at {config_path} (existing values preserved)"
)
else: else:
config = _apply_workspace_override(Config()) config = _apply_workspace_override(Config())
# In wizard mode, don't save yet - the wizard will handle saving if should_save=True # In wizard mode, don't save yet - the wizard will handle saving if should_save=True