From e2a473481d8bab277e64f1398bca4a1c5e1fd4a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=9B=B7=E7=94=B5=E8=8A=BD=E8=A1=A3?= Date: Mon, 24 Aug 2026 20:53:12 -0400 Subject: [PATCH] Wizard: preserve prior profile until new config passes its test Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_01QKxGW1raAWaqeU8WdHsMsp --- bin/omarchy-cn-ai-setup | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/bin/omarchy-cn-ai-setup b/bin/omarchy-cn-ai-setup index d64f16ff..ff9f070f 100755 --- a/bin/omarchy-cn-ai-setup +++ b/bin/omarchy-cn-ai-setup @@ -50,15 +50,27 @@ if ! omarchy-cn-ai-secret get "$provider" > /dev/null 2>&1; then printf '%s' "$key" | omarchy-cn-ai-secret set "$provider" fi +# Keep any existing profile intact until the new config proves itself +profile_file="$CN_AI_PROFILE_DIR/$name.toml" +if [[ -f $profile_file ]]; then + cp "$profile_file" "$profile_file.omarchycn-prev" +fi + omarchy-cn-ai-profile-create "$name" "$harness" "$provider" "$model" -# Activate only after the test passes (or the user skips it) if gum confirm "运行连接测试?"; then if ! omarchy-cn-ai-test "$name"; then - echo "测试未通过,Profile $name 已创建但未设为默认;修复后运行: omarchycn ai profile use $name" >&2 + if [[ -f $profile_file.omarchycn-prev ]]; then + mv "$profile_file.omarchycn-prev" "$profile_file" + echo "测试未通过,已恢复原 Profile $name" >&2 + else + rm -f "$profile_file" + echo "测试未通过,Profile $name 未保留" >&2 + fi exit 1 fi fi +rm -f "$profile_file.omarchycn-prev" omarchy-cn-ai-profile-use "$name" echo "完成。启动: omarchycn ai launch"