Merge pull request #82 from continuedev/serve-headless

fix: don't try to onboard during serve
This commit is contained in:
Nate Sesti 2025-07-20 23:51:52 -07:00 • committed by GitHub
commit c29c90e2e9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 17 deletions

View file

@ -6,7 +6,7 @@ import {
getOrganizationId,
loadAuthConfig,
} from "../auth/workos.js";
import { initializeWithOnboarding } from "../onboarding.js";
import { runNormalFlow } from "../onboarding.js";
import { saveSession } from "../session.js";
import { constructSystemMessage } from "../systemMessage.js";
import telemetryService from "../telemetry/telemetryService.js";
@ -48,8 +48,8 @@ export async function serve(prompt?: string, options: ServeOptions = {}) {
// Initialize authentication
const authConfig = loadAuthConfig();
// Initialize with onboarding
const { config, llmApi, model } = await initializeWithOnboarding(
// Initialize with normal flow (skip onboarding like headless mode)
const { config, llmApi, model } = await runNormalFlow(
authConfig,
options.config,
options.rule
@ -382,4 +382,4 @@ async function streamChatResponseWithInterruption(
// currentStreamingMessage.isStreaming = false;
}
}
}
}

View file

@ -158,19 +158,28 @@ export async function runOnboardingFlow(
}
export async function runNormalFlow(
configPath: string | undefined,
authConfig: AuthConfig
authConfig: AuthConfig,
configPath?: string,
rules?: string[]
): Promise<OnboardingResult> {
// Step 1: Check if --config flag is provided
if (configPath) {
const result = await initialize(authConfig, configPath);
let result = await initialize(authConfig, configPath);
// Inject rules into the config if provided
if (rules && rules.length > 0) {
result.config = await injectRulesIntoConfig(result.config, rules);
}
return { ...result, wasOnboarded: false };
}
// Step 2: If user is logged in, look for first assistant in selected org
if (isAuthenticated()) {
try {
const result = await initialize(authConfig, undefined);
let result = await initialize(authConfig, undefined);
// Inject rules into the config if provided
if (rules && rules.length > 0) {
result.config = await injectRulesIntoConfig(result.config, rules);
}
return { ...result, wasOnboarded: false };
} catch (error) {}
}
@ -178,7 +187,11 @@ export async function runNormalFlow(
// Step 3: Look for local ~/.continue/config.yaml
if (fs.existsSync(CONFIG_PATH)) {
try {
const result = await initialize(authConfig, CONFIG_PATH);
let result = await initialize(authConfig, CONFIG_PATH);
// Inject rules into the config if provided
if (rules && rules.length > 0) {
result.config = await injectRulesIntoConfig(result.config, rules);
}
return { ...result, wasOnboarded: false };
} catch (error) {
console.log(chalk.yellow("⚠ Invalid config file found"));
@ -190,7 +203,11 @@ export async function runNormalFlow(
console.log(chalk.blue("✓ Using ANTHROPIC_API_KEY from environment"));
await createOrUpdateConfig(process.env.ANTHROPIC_API_KEY);
console.log(chalk.gray(` Config saved to: ${CONFIG_PATH}`));
const result = await initialize(authConfig, CONFIG_PATH);
let result = await initialize(authConfig, CONFIG_PATH);
// Inject rules into the config if provided
if (rules && rules.length > 0) {
result.config = await injectRulesIntoConfig(result.config, rules);
}
return { ...result, wasOnboarded: false };
}
@ -280,13 +297,13 @@ export async function initializeWithOnboarding(
await markOnboardingComplete();
}
} else {
result = await runNormalFlow(configPath, authConfig);
result = await runNormalFlow(authConfig, configPath, rules);
}
// Inject rules into the config if provided
if (rules && rules.length > 0) {
// Inject rules into the config if provided (for onboarding flow which doesn't handle rules directly)
if (rules && rules.length > 0 && !result.wasOnboarded) {
result.config = await injectRulesIntoConfig(result.config, rules);
}
return result;
}
}

View file

@ -61,7 +61,7 @@ describe("MarkdownRenderer", () => {
expect(result.length).toBe(3);
expect(result[0]).toBe("This is ");
expect(React.isValidElement(result[1])).toBe(true);
expect((result[1] as any).props.color).toBe("cyan");
expect((result[1] as any).props.color).toBe("magentaBright");
expect((result[1] as any).props.children).toBe("code");
expect(result[2]).toBe(" text");
});

View file

@ -64,7 +64,7 @@ const MarkdownRenderer: React.FC<MarkdownRendererProps> = React.memo(({ content,
{
regex: /`([^`\n]+)`/g,
render: (content, key) => (
<Text key={key} color="cyan">
<Text key={key} color="magentaBright">
{content}
</Text>
),
@ -212,4 +212,4 @@ MarkdownRenderer.displayName = "MarkdownRenderer";
export default MarkdownRenderer;
export type { SyntaxHighlighterTheme };
export { defaultTheme };
export { defaultTheme };