Skip to content

Commit f6db75a

Browse files
committed
fix: HOTFIX allow default config fallback for headless
1 parent 7ba5604 commit f6db75a

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

extensions/cli/src/configLoader.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
import { DefaultApiInterface } from "@continuedev/sdk/dist/api/dist/index.js";
1414
import chalk from "chalk";
1515

16+
import { fileURLToPath } from "node:url";
1617
import { uriToPath, uriToSlug } from "./auth/uriUtils.js";
1718
import {
1819
AuthConfig,
@@ -24,6 +25,7 @@ import {
2425
} from "./auth/workos.js";
2526
import { CLIPlatformClient } from "./CLIPlatformClient.js";
2627
import { env } from "./env.js";
28+
import { logger } from "./util/logger.js";
2729

2830
export interface ConfigLoadResult {
2931
config: AssistantUnrolled;
@@ -95,16 +97,20 @@ function determineConfigSource(
9597
return { type: "cli-flag", path: cliConfigPath };
9698
}
9799

98-
// In headless, config fallback behavior isn't supported
99-
if (isHeadless) {
100-
return { type: "no-config" };
101-
}
102-
103100
// Priority 2: Saved config URI (only for file-based auth)
104101
if (!isEnvironmentAuthConfig(authConfig) && authConfig !== null) {
105102
const savedUri = getConfigUri(authConfig);
103+
106104
if (savedUri) {
107-
return { type: "saved-uri", uri: savedUri };
105+
if (
106+
fs.existsSync(
107+
savedUri.startsWith("file:") ? fileURLToPath(savedUri) : savedUri,
108+
)
109+
) {
110+
return { type: "saved-uri", uri: savedUri };
111+
} else {
112+
logger.warn("Saved URI does not exists");
113+
}
108114
}
109115
}
110116

@@ -117,6 +123,10 @@ function determineConfigSource(
117123
}
118124
return { type: "default-agent" };
119125
} else {
126+
// In headless, user assistant fallback behavior isn't supported
127+
if (isHeadless) {
128+
return { type: "no-config" };
129+
}
120130
// Authenticated: try user assistants first
121131
return { type: "user-assistant", slug: "" }; // Empty slug means "first available"
122132
}

extensions/cli/src/services/ConfigService.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,7 @@ export class ConfigService
215215
config: AssistantUnrolled,
216216
apiClient: DefaultApiInterface,
217217
authConfig: AuthConfig | undefined,
218+
isHeadless?: boolean,
218219
): Promise<AssistantUnrolled> {
219220
const hasChatModel = !!config.models?.find(
220221
(m) => !!m && (!m.roles || m.roles.includes("chat")),
@@ -233,8 +234,16 @@ export class ConfigService
233234
}
234235
config.models = [...(config.models || []), defaultModel];
235236
} catch (e) {
236-
logger.error("Failed to load default model with no model specified", e);
237-
throw new Error("No model specified and failed to load default model");
237+
if (isHeadless) {
238+
throw new Error(
239+
"No model specified in headless mode (and failed to load default model)",
240+
);
241+
} else {
242+
logger.error(
243+
"Failed to load default model with no model specified",
244+
e,
245+
);
246+
}
238247
}
239248
}
240249
return config;
@@ -270,6 +279,7 @@ export class ConfigService
270279
merged,
271280
apiClient,
272281
authConfig,
282+
init.isHeadless,
273283
);
274284

275285
// Config URI persistence is now handled by the streamlined loader

extensions/cli/src/services/ModelService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,9 @@ export class ModelService
6464
preferredModelName = agentFileServiceState.agentFileModel?.name;
6565
modelSource = "agentFile";
6666
} else {
67-
preferredModelName = getModelName(authConfig);
68-
if (preferredModelName) {
67+
const persistedName = getModelName(authConfig);
68+
if (persistedName) {
69+
preferredModelName = persistedName;
6970
modelSource = "persisted";
7071
}
7172
}

0 commit comments

Comments
 (0)