fix(wizard): preserve existing default model during setup auth choice… · openclaw/openclaw@b836946
ml12580
·
2026-06-17
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -979,6 +979,51 @@ describe("runSetupWizard", () => {
|
979 | 979 | expect(opts.openaiApiKey).toBe("sk-flag-value"); |
980 | 980 | }); |
981 | 981 | |
| 982 | +it("passes preserveExistingDefaultModel to applyAuthChoice to protect existing default model", async () => { |
| 983 | +applyAuthChoice.mockReset(); |
| 984 | +applyAuthChoice.mockResolvedValueOnce({ |
| 985 | +config: { |
| 986 | +agents: { |
| 987 | +defaults: { |
| 988 | +model: { |
| 989 | +primary: "google/gemini-3.1-pro-preview", |
| 990 | +}, |
| 991 | +}, |
| 992 | +}, |
| 993 | +}, |
| 994 | +}); |
| 995 | + |
| 996 | +const prompter = buildWizardPrompter({}); |
| 997 | +const runtime = createRuntime(); |
| 998 | + |
| 999 | +await runSetupWizard( |
| 1000 | +{ |
| 1001 | +acceptRisk: true, |
| 1002 | +flow: "quickstart", |
| 1003 | +authChoice: "google-api-key", |
| 1004 | +installDaemon: false, |
| 1005 | +skipChannels: true, |
| 1006 | +skipSkills: true, |
| 1007 | +skipSearch: true, |
| 1008 | +skipHealth: true, |
| 1009 | +skipUi: true, |
| 1010 | +}, |
| 1011 | +runtime, |
| 1012 | +prompter, |
| 1013 | +); |
| 1014 | + |
| 1015 | +expect(applyAuthChoice).toHaveBeenCalledTimes(1); |
| 1016 | +const call = getMockCallArg(applyAuthChoice, 0, 0, "google auth choice"); |
| 1017 | +// Preserve the user's existing default model when a new provider is |
| 1018 | +// configured through the setup wizard, matching the contract already |
| 1019 | +// used in configure.gateway-auth.ts. Without this flag, configuring a |
| 1020 | +// paid Google Gemini key would silently overwrite the user's default |
| 1021 | +// model, causing existing heartbeat turns to consume paid API quota. |
| 1022 | +expect((call as { preserveExistingDefaultModel?: boolean }).preserveExistingDefaultModel).toBe( |
| 1023 | +true, |
| 1024 | +); |
| 1025 | +}); |
| 1026 | + |
982 | 1027 | it("shows plugin compatibility notices for an existing valid config", async () => { |
983 | 1028 | buildPluginCompatibilitySnapshotNotices.mockReturnValue([ |
984 | 1029 | { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -728,6 +728,7 @@ export async function runSetupWizard(
|
728 | 728 | prompter, |
729 | 729 | runtime, |
730 | 730 | setDefaultModel: true, |
| 731 | +preserveExistingDefaultModel: true, |
731 | 732 | opts: { |
732 | 733 | ...opts, |
733 | 734 | token: opts.authChoice === "apiKey" && opts.token ? opts.token : undefined, |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。