Merge pull request #6635 from fbricon/open-proper-configfile

fix: open the proper config file
This commit is contained in:
Nate Sesti 2025-07-21 21:55:34 -07:00 • committed by GitHub
commit 71f7122f2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
22 changed files with 125 additions and 16 deletions

View file

@ -11,5 +11,6 @@ export function convertCustomCommandToSlashCommand(
description: customCommand.description ?? "",
prompt: customCommand.prompt,
source: "json-custom-command",
promptFile: customCommand.sourceFile, // TODO refactor promptFile to align with sourceFile
};
}

View file

@ -9,5 +9,6 @@ export function convertPromptBlockToSlashCommand(
description: prompt.description ?? "",
prompt: prompt.prompt,
source: "yaml-prompt-block",
promptFile: prompt.sourceFile, // Align with the sourceFile property
};
}

View file

@ -522,7 +522,10 @@ export class ConfigHandler {
return config;
}
async openConfigProfile(profileId?: string) {
async openConfigProfile(
profileId?: string,
element?: { sourceFile?: string },
) {
let openProfileId = profileId || this.currentProfile?.profileDescription.id;
if (!openProfileId) {
return;
@ -530,8 +533,10 @@ export class ConfigHandler {
const profile = this.currentOrg.profiles.find(
(p) => p.profileDescription.id === openProfileId,
);
if (profile?.profileDescription.profileType === "local") {
await this.ide.openFile(profile.profileDescription.uri);
const configFile = element?.sourceFile ?? profile.profileDescription.uri;
await this.ide.openFile(configFile);
} else {
const env = await getControlPlaneEnv(this.ide.getIdeSettings());
await this.ide.openUrl(`${env.APP_URL}${openProfileId}`);

View file

@ -652,6 +652,7 @@ function llmToSerializedModelDescription(llm: ILLM): ModelDescription {
configurationStatus: llm.getConfigurationStatus(),
apiKeyLocation: llm.apiKeyLocation,
envSecretLocations: llm.envSecretLocations,
sourceFile: llm.sourceFile,
};
}

View file

@ -56,6 +56,7 @@ function convertYamlRuleToContinueRule(rule: Rule): RuleWithSource {
rule: rule.rule,
globs: rule.globs,
name: rule.name,
ruleFile: rule.sourceFile,
};
}
}
@ -237,6 +238,7 @@ async function configYamlToContinueConfig(options: {
faviconUrl: doc.faviconUrl,
maxDepth: doc.maxDepth,
useLocalCrawling: doc.useLocalCrawling,
sourceFile: doc.sourceFile,
}));
config.mcpServers?.forEach((mcpServer) => {
@ -429,6 +431,7 @@ async function configYamlToContinueConfig(options: {
(config.mcpServers ?? []).map((server) => ({
id: server.name,
name: server.name,
sourceFile: server.sourceFile,
transport: {
type: "stdio",
args: [],

View file

@ -349,7 +349,10 @@ export class Core {
});
on("config/openProfile", async (msg) => {
await this.configHandler.openConfigProfile(msg.data.profileId);
await this.configHandler.openConfigProfile(
msg.data.profileId,
msg.data?.element,
);
});
on("config/reload", async (msg) => {

7
core/index.d.ts vendored
View file

@ -237,6 +237,7 @@ export interface SiteIndexingConfig {
maxDepth?: number;
faviconUrl?: string;
useLocalCrawling?: boolean;
sourceFile?: string;
}
export interface DocsIndexingDetails {
@ -660,6 +661,8 @@ export interface LLMOptions {
deploymentId?: string;
env?: Record<string, string | number | boolean>;
sourceFile?: string;
}
type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
@ -1037,6 +1040,7 @@ export interface CustomCommand {
name: string;
prompt: string;
description?: string;
sourceFile?: string;
}
export interface Prediction {
@ -1154,6 +1158,8 @@ export interface ModelDescription {
capabilities?: ModelCapability;
roles?: ModelRole[];
configurationStatus?: LLMConfigurationStatuses;
sourceFile?: string;
}
export interface JSONEmbedOptions {
@ -1309,6 +1315,7 @@ export interface MCPServerStatus extends MCPOptions {
tools: MCPTool[];
resources: MCPResource[];
resourceTemplates: MCPResourceTemplate[];
sourceFile?: string;
}
export interface ContinueUIConfig {

View file

@ -187,6 +187,9 @@ export abstract class BaseLLM implements ILLM {
maxEmbeddingChunkSize: number;
maxEmbeddingBatchSize: number;
//URI to local block defining this LLM
sourceFile?: string;
private _llmOptions: LLMOptions;
protected openaiAdapter?: BaseLlmApi;
@ -290,6 +293,7 @@ export abstract class BaseLLM implements ILLM {
this.embeddingId = `${this.constructor.name}::${this.model}::${this.maxEmbeddingChunkSize}`;
this.autocompleteOptions = options.autocompleteOptions;
this.sourceFile = options.sourceFile;
}
getConfigurationStatus() {

View file

@ -102,7 +102,10 @@ export type ToCoreFromIdeOrWebviewProtocol = {
),
void,
];
"config/openProfile": [{ profileId: string | undefined }, void];
"config/openProfile": [
{ profileId: string | undefined; element?: { sourceFile?: string } },
void,
];
"config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];
"config/updateSelectedModel": [
{

View file

@ -13,6 +13,7 @@ interface EditBlockButtonProps<T extends SectionKey> {
blockType: T;
block?: NonNullable<ConfigYaml[T]>[number];
className?: string;
sourceFile?: string;
}
function isUsesBlock(block: any): block is { uses: string } {
@ -23,6 +24,7 @@ export default function EditBlockButton<T extends SectionKey>({
block,
blockType,
className = "",
sourceFile,
}: EditBlockButtonProps<T>) {
const ideMessenger = useContext(IdeMessengerContext);
const { selectedProfile } = useAuth();
@ -37,6 +39,7 @@ export default function EditBlockButton<T extends SectionKey>({
if (selectedProfile?.profileType === "local") {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile },
});
} else if (block && isUsesBlock(block)) {
openUrl(`${block.uses}/new-version`);

View file

@ -121,6 +121,7 @@ export function PromptsSection() {
} else {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile: (prompt as any).sourceFile },
});
}
};
@ -149,7 +150,6 @@ export function PromptsSection() {
index = index + 1;
}
}
return promptsWithSlug.sort((a, b) => {
const aBookmarked = isCommandBookmarked(a.name);
const bBookmarked = isCommandBookmarked(b.name);

View file

@ -60,6 +60,7 @@ const RuleCard: React.FC<RuleCardProps> = ({ rule }) => {
} else {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile: (rule as any).sourceFile },
});
}
};

View file

@ -123,7 +123,11 @@ function DocsIndexingStatus({
/>
)}
<EditBlockButton blockType="docs" block={docFromYaml} />
<EditBlockButton
blockType="docs"
block={docFromYaml}
sourceFile={docConfig.sourceFile}
/>
{["aborted", "complete", "failed"].includes(
status?.status ?? "",

View file

@ -132,7 +132,11 @@ function MCPServerPreview({ server, serverFromYaml }: MCPServerStatusProps) {
{/* Refresh button */}
<div className="flex items-center gap-2">
<EditBlockButton blockType={"mcpServers"} block={serverFromYaml} />
<EditBlockButton
blockType={"mcpServers"}
block={serverFromYaml}
sourceFile={server.sourceFile}
/>
<div
className="text-lightgray flex cursor-pointer items-center hover:opacity-80"
onClick={onRefresh}

View file

@ -37,6 +37,7 @@ interface Option {
value: string;
title: string;
apiKey?: string;
sourceFile?: string;
}
function modelSelectTitle(model: any): string {
@ -56,8 +57,6 @@ function ModelOption({
showMissingApiKeyMsg,
isSelected,
}: ModelOptionProps) {
const ideMessenger = useContext(IdeMessengerContext);
function handleOptionClick(e: any) {
if (showMissingApiKeyMsg) {
e.preventDefault();
@ -132,6 +131,7 @@ function ModelSelect() {
value: model.title,
title: modelSelectTitle(model),
apiKey: model.apiKey,
sourceFile: model.sourceFile,
};
}),
);
@ -230,6 +230,7 @@ function ModelSelect() {
onClick={() =>
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: { sourceFile: selectedModel?.sourceFile },
})
}
/>

View file

@ -48,10 +48,13 @@ const ModelRoleSelector = ({
onSelect(models.find((m) => m.title === title) ?? null);
}
function onClickGear(e: MouseEvent<SVGSVGElement>) {
function onClickGear(e: MouseEvent<SVGSVGElement>, model: ModelDescription) {
e.stopPropagation();
e.preventDefault();
ideMessenger.post("config/openProfile", { profileId: undefined });
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: model,
});
}
function handleOptionClick(
@ -169,7 +172,9 @@ const ModelRoleSelector = ({
{hoveredIdx === idx && (
<Cog6ToothIcon
className="h-3 w-3 flex-shrink-0"
onClick={onClickGear}
onClick={(e: MouseEvent<SVGSVGElement>) =>
onClickGear(e, option)
}
/>
)}
{option.title === selectedModel?.title && (

View file

@ -77,6 +77,7 @@ const StreamErrorDialog = ({ error }: StreamErrorProps) => {
onClick={() => {
ideMessenger.post("config/openProfile", {
profileId: undefined,
element: selectedModel ?? undefined,
});
}}
>

View file

@ -210,6 +210,7 @@ export const siteIndexingConfigSchema = z.object({
maxDepth: z.number().optional(),
faviconUrl: z.string().optional(),
useLocalCrawling: z.boolean().optional(),
sourceFile: z.string().optional(),
});
export const controlPlaneConfigSchema = z.object({

View file

@ -452,7 +452,15 @@ export async function unrollBlocks(
registry,
);
return { blockType, resolvedBlock, error: null };
return {
blockType,
resolvedBlock,
source:
injectBlock.uriType === "file"
? injectBlock.filePath
: undefined,
error: null,
};
} catch (err) {
let msg = "";
if (injectBlock.uriType === "file") {
@ -475,7 +483,11 @@ export async function unrollBlocks(
const injectedResults = await Promise.all(injectedBlockPromises);
const injectedErrors: ConfigValidationError[] = [];
const injectedBlocks: { blockType: string; resolvedBlock: any }[] = [];
const injectedBlocks: {
blockType: string;
resolvedBlock: any;
source?: string;
}[] = [];
for (const result of injectedResults) {
if (result.error) {
@ -484,6 +496,7 @@ export async function unrollBlocks(
injectedBlocks.push({
blockType: result.blockType,
resolvedBlock: result.resolvedBlock,
source: result.source,
});
}
}
@ -521,12 +534,21 @@ export async function unrollBlocks(
}
// Add injected blocks
for (const { blockType, resolvedBlock } of injectedResult.injectedBlocks) {
for (const {
blockType,
resolvedBlock,
source,
} of injectedResult.injectedBlocks) {
const key = blockType as BlockType;
if (!unrolledAssistant[key]) {
unrolledAssistant[key] = [];
}
unrolledAssistant[key]?.push(...((resolvedBlock[blockType] ?? []) as any));
const blocksWithSourceFiles = injectLocalSourceFile(
key,
resolvedBlock,
source,
);
unrolledAssistant[key]?.push(...blocksWithSourceFiles);
}
const configResult: ConfigResult<AssistantUnrolled> = {
@ -541,6 +563,39 @@ export async function unrollBlocks(
return configResult;
}
function injectLocalSourceFile(
blockType: BlockType,
resolvedBlock: any,
source?: string,
): (any & { source?: string })[] {
const blocks: any[] = resolvedBlock[blockType] ?? [];
if (source === undefined) {
// If no source is provided, return blocks as is
return blocks;
}
if (blockType === "rules") {
// For rules, we need to ensure they are wrapped in an object with a `source
return blocks.map((block) => {
if (typeof block === "string") {
const rule = {
sourceFile: source,
name: block,
rule: block,
} as Rule;
return rule;
} else if (typeof block === "object") {
block.sourceFile = source;
}
return block;
});
}
// For other block types, we can directly inject the source file
return blocks.map((block) => ({
...block,
sourceFile: source,
}));
}
export async function resolveBlock(
id: PackageIdentifier,
inputs: Record<string, string> | undefined,

View file

@ -112,5 +112,6 @@ export function markdownToRule(
regex: frontmatter.regex,
description: frontmatter.description,
alwaysApply: frontmatter.alwaysApply,
sourceFile: id.uriType === "file" ? id.filePath : undefined,
};
}

View file

@ -25,6 +25,7 @@ const mcpServerSchema = z.object({
cwd: z.string().optional(),
connectionTimeout: z.number().gt(0).optional(),
requestOptions: requestOptionsSchema.optional(),
sourceFile: z.string().optional(),
});
export type MCPServer = z.infer<typeof mcpServerSchema>;
@ -33,6 +34,7 @@ const promptSchema = z.object({
name: z.string(),
description: z.string().optional(),
prompt: z.string(),
sourceFile: z.string().optional(),
});
export type Prompt = z.infer<typeof promptSchema>;
@ -44,6 +46,7 @@ const docSchema = z.object({
faviconUrl: z.string().optional(),
maxDepth: z.number().optional(),
useLocalCrawling: z.boolean().optional(),
sourceFile: z.string().optional(),
});
export type DocsConfig = z.infer<typeof docSchema>;
@ -55,6 +58,7 @@ const ruleObjectSchema = z.object({
globs: z.union([z.string(), z.array(z.string())]).optional(),
regex: z.union([z.string(), z.array(z.string())]).optional(),
alwaysApply: z.boolean().optional(),
sourceFile: z.string().optional(), //TODO refactor RuleWithSource.ruleFile to align with sourceFile
});
const ruleSchema = z.union([z.string(), ruleObjectSchema]);

View file

@ -163,6 +163,7 @@ export const modelSchema = z.union([
z.object({
...baseModelFields,
provider: z.string().refine((val) => val !== "continue-proxy"),
sourceFile: z.string().optional(),
}),
]);