Skip to content

Commit 5353e17

Browse files
sohail2721claude
andcommitted
fix(portal): cancel quickstart when copilot key selection is cancelled
When the account has multiple Copilot keys and the user cancels the key-selection prompt, abort the quickstart (ActionResult.cancelled) instead of silently finishing without Copilot/AI integration. No-key and single-key paths are unchanged (skip silently / auto-use). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent c214970 commit 5353e17

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

src/actions/portal/quickstart.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,10 @@ export class PortalQuickstartAction {
195195

196196
const buildFile = await tempBuildContext.getBuildFileContents();
197197
buildFile.generatePortal!.languageConfig = getLanguagesConfig(languages);
198-
await this.configureApiCopilot(buildFile);
198+
if (await this.configureApiCopilot(buildFile)) {
199+
this.prompts.noCopilotKeySelected();
200+
return ActionResult.cancelled();
201+
}
199202
await tempBuildContext.updateBuildFileContents(buildFile);
200203

201204
const sourceDirectory = inputDirectory.join('src');
@@ -227,20 +230,29 @@ export class PortalQuickstartAction {
227230
// block, and enables AI editor integrations for every configured SDK language.
228231
// Copilot is opt-in based on account access: when the user has no Copilot key
229232
// (or the lookup fails) it is skipped silently, never fatal.
230-
private async configureApiCopilot(buildFile: BuildConfig): Promise<void> {
233+
// Returns true if the user cancelled Copilot key selection — quickstart should
234+
// abort. When the account has no Copilot key (or the lookup fails), Copilot is
235+
// skipped silently and this returns false so quickstart continues without it.
236+
private async configureApiCopilot(buildFile: BuildConfig): Promise<boolean> {
231237
const accountInfo = await this.apiService.getAccountInfo(this.configDir, this.commandMetadata.shell, null);
232238
if (accountInfo.isErr()) {
233-
return;
239+
return false;
234240
}
235241

236242
const copilotKeys = accountInfo.value.ApiCopilotKeys ?? [];
237243
if (copilotKeys.length === 0) {
238-
return;
244+
return false;
239245
}
240246

241-
const copilotKey = copilotKeys.length === 1 ? copilotKeys[0] : await this.prompts.selectCopilotKey(copilotKeys);
242-
if (!copilotKey) {
243-
return;
247+
let copilotKey: string;
248+
if (copilotKeys.length === 1) {
249+
copilotKey = copilotKeys[0];
250+
} else {
251+
const selectedKey = await this.prompts.selectCopilotKey(copilotKeys);
252+
if (!selectedKey) {
253+
return true;
254+
}
255+
copilotKey = selectedKey;
244256
}
245257

246258
const apiCopilotConfig: CopilotConfig = {
@@ -251,6 +263,7 @@ export class PortalQuickstartAction {
251263
buildFile.generatePortal!.baseUrl = defaultBaseUrl;
252264
buildFile.apiCopilotConfig = apiCopilotConfig;
253265
this.enableAiIntegrations(buildFile);
266+
return false;
254267
}
255268

256269
// Enables Cursor/Claude Code/VS Code integrations for the selected SDK languages.

src/prompts/portal/quickstart.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ ${f.link(referenceDocumentationUrl)}`;
226226
return selectedKey;
227227
}
228228

229+
public noCopilotKeySelected() {
230+
log.error("No API Copilot key was selected.");
231+
}
232+
229233
public printDirectoryStructure(inputDirectory: DirectoryPath, directory: Directory) {
230234
const heading = `${f.var("src")} directory containing source files created at ${f.path(inputDirectory)}\n`;
231235
const message = getTree(directory.toTreeNode());

0 commit comments

Comments
 (0)