Skip to content

Commit bb1b30d

Browse files
committed
perf(wizard): keep explicit skip auth path cold
1 parent 9763d44 commit bb1b30d

2 files changed

Lines changed: 63 additions & 43 deletions

File tree

src/wizard/setup.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ describe("runSetupWizard", () => {
346346
);
347347

348348
expect(select).not.toHaveBeenCalled();
349+
expect(ensureAuthProfileStore).not.toHaveBeenCalled();
349350
expect(setupChannels).not.toHaveBeenCalled();
350351
expect(setupSkills).not.toHaveBeenCalled();
351352
expect(healthCommand).not.toHaveBeenCalled();

src/wizard/setup.ts

Lines changed: 62 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -483,36 +483,60 @@ export async function runSetupWizard(
483483
const { applyLocalSetupWorkspaceConfig } = await import("../commands/onboard-config.js");
484484
let nextConfig: OpenClawConfig = applyLocalSetupWorkspaceConfig(baseConfig, workspaceDir);
485485

486-
const { ensureAuthProfileStore } = await import("../agents/auth-profiles.runtime.js");
487-
const { promptAuthChoiceGrouped } = await import("../commands/auth-choice-prompt.js");
488-
const { promptCustomApiConfig } = await import("../commands/onboard-custom.js");
489-
const { applyAuthChoice, resolvePreferredProviderForAuthChoice, warnIfModelConfigLooksOff } =
490-
await import("../commands/auth-choice.js");
491-
const { applyPrimaryModel, promptDefaultModel } = await import("../commands/model-picker.js");
492-
493-
const authStore = ensureAuthProfileStore(undefined, {
494-
allowKeychainPrompt: false,
495-
});
496486
const authChoiceFromPrompt = opts.authChoice === undefined;
497-
const authChoice =
498-
opts.authChoice ??
499-
(await promptAuthChoiceGrouped({
487+
let authChoice = opts.authChoice;
488+
if (authChoiceFromPrompt) {
489+
const { ensureAuthProfileStore } = await import("../agents/auth-profiles.runtime.js");
490+
const { promptAuthChoiceGrouped } = await import("../commands/auth-choice-prompt.js");
491+
const authStore = ensureAuthProfileStore(undefined, {
492+
allowKeychainPrompt: false,
493+
});
494+
authChoice = await promptAuthChoiceGrouped({
500495
prompter,
501496
store: authStore,
502497
includeSkip: true,
503498
config: nextConfig,
504499
workspaceDir,
505-
}));
500+
});
501+
}
506502

507503
if (authChoice === "custom-api-key") {
504+
const { promptCustomApiConfig } = await import("../commands/onboard-custom.js");
508505
const customResult = await promptCustomApiConfig({
509506
prompter,
510507
runtime,
511508
config: nextConfig,
512509
secretInputMode: opts.secretInputMode,
513510
});
514511
nextConfig = customResult.config;
512+
} else if (authChoice === "skip") {
513+
// Explicit skip should stay cold: do not bootstrap auth/profile machinery
514+
// or run model/auth checks when the caller already chose to skip setup.
515+
if (authChoiceFromPrompt) {
516+
const { applyPrimaryModel, promptDefaultModel } = await import("../commands/model-picker.js");
517+
const modelSelection = await promptDefaultModel({
518+
config: nextConfig,
519+
prompter,
520+
allowKeep: true,
521+
ignoreAllowlist: true,
522+
includeProviderPluginSetups: true,
523+
workspaceDir,
524+
runtime,
525+
});
526+
if (modelSelection.config) {
527+
nextConfig = modelSelection.config;
528+
}
529+
if (modelSelection.model) {
530+
nextConfig = applyPrimaryModel(nextConfig, modelSelection.model);
531+
}
532+
533+
const { warnIfModelConfigLooksOff } = await import("../commands/auth-choice.js");
534+
await warnIfModelConfigLooksOff(nextConfig, prompter);
535+
}
515536
} else {
537+
const { applyAuthChoice, resolvePreferredProviderForAuthChoice, warnIfModelConfigLooksOff } =
538+
await import("../commands/auth-choice.js");
539+
const { applyPrimaryModel, promptDefaultModel } = await import("../commands/model-picker.js");
516540
const authResult = await applyAuthChoice({
517541
authChoice,
518542
config: nextConfig,
@@ -525,44 +549,39 @@ export async function runSetupWizard(
525549
},
526550
});
527551
nextConfig = authResult.config;
528-
529552
if (authResult.agentModelOverride) {
530553
nextConfig = applyPrimaryModel(nextConfig, authResult.agentModelOverride);
531554
}
532-
}
533555

534-
const authChoiceModelSelectionPolicy =
535-
authChoice === "custom-api-key"
536-
? undefined
537-
: await resolveAuthChoiceModelSelectionPolicy({
538-
authChoice,
539-
config: nextConfig,
540-
workspaceDir,
541-
resolvePreferredProviderForAuthChoice,
542-
});
543-
const shouldPromptModelSelection =
544-
authChoice !== "custom-api-key" &&
545-
(authChoiceFromPrompt || authChoiceModelSelectionPolicy?.promptWhenAuthChoiceProvided === true);
546-
if (shouldPromptModelSelection) {
547-
const modelSelection = await promptDefaultModel({
556+
const authChoiceModelSelectionPolicy = await resolveAuthChoiceModelSelectionPolicy({
557+
authChoice,
548558
config: nextConfig,
549-
prompter,
550-
allowKeep: authChoiceModelSelectionPolicy?.allowKeepCurrent ?? true,
551-
ignoreAllowlist: true,
552-
includeProviderPluginSetups: true,
553-
preferredProvider: authChoiceModelSelectionPolicy?.preferredProvider,
554559
workspaceDir,
555-
runtime,
560+
resolvePreferredProviderForAuthChoice,
556561
});
557-
if (modelSelection.config) {
558-
nextConfig = modelSelection.config;
559-
}
560-
if (modelSelection.model) {
561-
nextConfig = applyPrimaryModel(nextConfig, modelSelection.model);
562+
const shouldPromptModelSelection =
563+
authChoiceFromPrompt || authChoiceModelSelectionPolicy?.promptWhenAuthChoiceProvided;
564+
if (shouldPromptModelSelection) {
565+
const modelSelection = await promptDefaultModel({
566+
config: nextConfig,
567+
prompter,
568+
allowKeep: authChoiceModelSelectionPolicy?.allowKeepCurrent ?? true,
569+
ignoreAllowlist: true,
570+
includeProviderPluginSetups: true,
571+
preferredProvider: authChoiceModelSelectionPolicy?.preferredProvider,
572+
workspaceDir,
573+
runtime,
574+
});
575+
if (modelSelection.config) {
576+
nextConfig = modelSelection.config;
577+
}
578+
if (modelSelection.model) {
579+
nextConfig = applyPrimaryModel(nextConfig, modelSelection.model);
580+
}
562581
}
563-
}
564582

565-
await warnIfModelConfigLooksOff(nextConfig, prompter);
583+
await warnIfModelConfigLooksOff(nextConfig, prompter);
584+
}
566585

567586
const { configureGatewayForSetup } = await import("./setup.gateway-config.js");
568587
const gateway = await configureGatewayForSetup({

0 commit comments

Comments
 (0)