fix: preserve config during non-interactive defaults onboarding

Maintainer edit: make explicit --defaults refresh existing configs without prompting when no TTY is available, preserving user values for CI and Docker runs.
This commit is contained in:
chengyongru
2026-06-22 13:04:05 +08:00
committed by Xubin Ren
parent 9c7d1c9507
commit 3d773d9054
3 changed files with 50 additions and 8 deletions
+4 -2
View File
@@ -452,9 +452,11 @@ def onboard(
from nanobot.config.loader import get_config_path, load_config, save_config, set_config_path
from nanobot.config.schema import Config
can_prompt = _onboard_can_prompt()
wants_wizard = wizard or not defaults
use_wizard = wants_wizard and not defaults and _onboard_can_prompt()
use_wizard = wants_wizard and not defaults and can_prompt
default_fallback = wants_wizard and not use_wizard and not defaults
default_refresh_without_prompt = defaults and not can_prompt
if default_fallback:
console.print(
"[yellow]No interactive terminal detected; using --defaults setup instead.[/yellow]"
@@ -476,7 +478,7 @@ def onboard(
if config_path.exists():
if use_wizard:
config = _apply_workspace_override(load_config(config_path))
elif default_fallback:
elif default_fallback or default_refresh_without_prompt:
config = _apply_workspace_override(load_config(config_path))
save_config(config, config_path)
console.print(