Elffuss BraidHub

kikocis/continue public

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

fix: open the proper config file
Changeset5cf29b825e2d0d3248ecf88786e4281abb186dde304e9c8f37aebcc3eb398938
AuthorNate Sesti <33237525+sestinj@users.noreply.github.com> · 2025-07-21 21:55 -07:00
CommitterGitHub <noreply@github.com> · 2025-07-21 21:55 -07:00
Parents81b34840d2fe, b3aa08a95d3b

Browse the files at this changeset

22 files changed

modified core/commands/slash/customSlashCommand.ts +1 −0
@@ -11,5 +11,6 @@
1111 description: customCommand.description ?? "",
1212 prompt: customCommand.prompt,
1313 source: "json-custom-command",
14+ promptFile: customCommand.sourceFile, // TODO refactor promptFile to align with sourceFile
1415 };
1516 }
modified core/commands/slash/promptBlockSlashCommand.ts +1 −0
@@ -9,5 +9,6 @@
99 description: prompt.description ?? "",
1010 prompt: prompt.prompt,
1111 source: "yaml-prompt-block",
12+ promptFile: prompt.sourceFile, // Align with the sourceFile property
1213 };
1314 }
modified core/config/ConfigHandler.ts +7 −2
@@ -522,7 +522,10 @@
522522 return config;
523523 }
524524
525- async openConfigProfile(profileId?: string) {
525+ async openConfigProfile(
526+ profileId?: string,
527+ element?: { sourceFile?: string },
528+ ) {
526529 let openProfileId = profileId || this.currentProfile?.profileDescription.id;
527530 if (!openProfileId) {
528531 return;
@@ -530,8 +533,10 @@
530533 const profile = this.currentOrg.profiles.find(
531534 (p) => p.profileDescription.id === openProfileId,
532535 );
536+
533537 if (profile?.profileDescription.profileType === "local") {
534- await this.ide.openFile(profile.profileDescription.uri);
538+ const configFile = element?.sourceFile ?? profile.profileDescription.uri;
539+ await this.ide.openFile(configFile);
535540 } else {
536541 const env = await getControlPlaneEnv(this.ide.getIdeSettings());
537542 await this.ide.openUrl(`${env.APP_URL}${openProfileId}`);
modified core/config/load.ts +1 −0
@@ -652,6 +652,7 @@
652652 configurationStatus: llm.getConfigurationStatus(),
653653 apiKeyLocation: llm.apiKeyLocation,
654654 envSecretLocations: llm.envSecretLocations,
655+ sourceFile: llm.sourceFile,
655656 };
656657 }
657658
modified core/config/yaml/loadYaml.ts +3 −0
@@ -56,6 +56,7 @@
5656 rule: rule.rule,
5757 globs: rule.globs,
5858 name: rule.name,
59+ ruleFile: rule.sourceFile,
5960 };
6061 }
6162 }
@@ -237,6 +238,7 @@
237238 faviconUrl: doc.faviconUrl,
238239 maxDepth: doc.maxDepth,
239240 useLocalCrawling: doc.useLocalCrawling,
241+ sourceFile: doc.sourceFile,
240242 }));
241243
242244 config.mcpServers?.forEach((mcpServer) => {
@@ -429,6 +431,7 @@
429431 (config.mcpServers ?? []).map((server) => ({
430432 id: server.name,
431433 name: server.name,
434+ sourceFile: server.sourceFile,
432435 transport: {
433436 type: "stdio",
434437 args: [],
modified core/core.ts +4 −1
@@ -349,7 +349,10 @@
349349 });
350350
351351 on("config/openProfile", async (msg) => {
352- await this.configHandler.openConfigProfile(msg.data.profileId);
352+ await this.configHandler.openConfigProfile(
353+ msg.data.profileId,
354+ msg.data?.element,
355+ );
353356 });
354357
355358 on("config/reload", async (msg) => {
modified core/index.d.ts +7 −0
@@ -237,6 +237,7 @@
237237 maxDepth?: number;
238238 faviconUrl?: string;
239239 useLocalCrawling?: boolean;
240+ sourceFile?: string;
240241 }
241242
242243 export interface DocsIndexingDetails {
@@ -660,6 +661,8 @@
660661 deploymentId?: string;
661662
662663 env?: Record<string, string | number | boolean>;
664+
665+ sourceFile?: string;
663666 }
664667
665668 type RequireAtLeastOne<T, Keys extends keyof T = keyof T> = Pick<
@@ -1037,6 +1040,7 @@
10371040 name: string;
10381041 prompt: string;
10391042 description?: string;
1043+ sourceFile?: string;
10401044 }
10411045
10421046 export interface Prediction {
@@ -1154,6 +1158,8 @@
11541158 capabilities?: ModelCapability;
11551159 roles?: ModelRole[];
11561160 configurationStatus?: LLMConfigurationStatuses;
1161+
1162+ sourceFile?: string;
11571163 }
11581164
11591165 export interface JSONEmbedOptions {
@@ -1309,6 +1315,7 @@
13091315 tools: MCPTool[];
13101316 resources: MCPResource[];
13111317 resourceTemplates: MCPResourceTemplate[];
1318+ sourceFile?: string;
13121319 }
13131320
13141321 export interface ContinueUIConfig {
modified core/llm/index.ts +4 −0
@@ -187,6 +187,9 @@
187187 maxEmbeddingChunkSize: number;
188188 maxEmbeddingBatchSize: number;
189189
190+ //URI to local block defining this LLM
191+ sourceFile?: string;
192+
190193 private _llmOptions: LLMOptions;
191194
192195 protected openaiAdapter?: BaseLlmApi;
@@ -290,6 +293,7 @@
290293 this.embeddingId = `${this.constructor.name}::${this.model}::${this.maxEmbeddingChunkSize}`;
291294
292295 this.autocompleteOptions = options.autocompleteOptions;
296+ this.sourceFile = options.sourceFile;
293297 }
294298
295299 getConfigurationStatus() {
modified core/protocol/core.ts +4 −1
@@ -102,7 +102,10 @@
102102 ),
103103 void,
104104 ];
105- "config/openProfile": [{ profileId: string | undefined }, void];
105+ "config/openProfile": [
106+ { profileId: string | undefined; element?: { sourceFile?: string } },
107+ void,
108+ ];
106109 "config/updateSharedConfig": [SharedConfigSchema, SharedConfigSchema];
107110 "config/updateSelectedModel": [
108111 {
modified gui/src/components/mainInput/Lump/EditBlockButton.tsx +3 −0
@@ -13,6 +13,7 @@
1313 blockType: T;
1414 block?: NonNullable<ConfigYaml[T]>[number];
1515 className?: string;
16+ sourceFile?: string;
1617 }
1718
1819 function isUsesBlock(block: any): block is { uses: string } {
@@ -23,6 +24,7 @@
2324 block,
2425 blockType,
2526 className = "",
27+ sourceFile,
2628 }: EditBlockButtonProps<T>) {
2729 const ideMessenger = useContext(IdeMessengerContext);
2830 const { selectedProfile } = useAuth();
@@ -37,6 +39,7 @@
3739 if (selectedProfile?.profileType === "local") {
3840 ideMessenger.post("config/openProfile", {
3941 profileId: undefined,
42+ element: { sourceFile },
4043 });
4144 } else if (block && isUsesBlock(block)) {
4245 openUrl(`${block.uses}/new-version`);
modified gui/src/components/mainInput/Lump/sections/PromptsSection.tsx +1 −1
@@ -121,6 +121,7 @@
121121 } else {
122122 ideMessenger.post("config/openProfile", {
123123 profileId: undefined,
124+ element: { sourceFile: (prompt as any).sourceFile },
124125 });
125126 }
126127 };
@@ -149,7 +150,6 @@
149150 index = index + 1;
150151 }
151152 }
152-
153153 return promptsWithSlug.sort((a, b) => {
154154 const aBookmarked = isCommandBookmarked(a.name);
155155 const bBookmarked = isCommandBookmarked(b.name);
modified gui/src/components/mainInput/Lump/sections/RulesSection.tsx +1 −0
@@ -60,6 +60,7 @@
6060 } else {
6161 ideMessenger.post("config/openProfile", {
6262 profileId: undefined,
63+ element: { sourceFile: (rule as any).sourceFile },
6364 });
6465 }
6566 };
modified gui/src/components/mainInput/Lump/sections/docs/DocsIndexingStatus.tsx +5 −1
@@ -123,7 +123,11 @@
123123 />
124124 )}
125125
126- <EditBlockButton blockType="docs" block={docFromYaml} />
126+ <EditBlockButton
127+ blockType="docs"
128+ block={docFromYaml}
129+ sourceFile={docConfig.sourceFile}
130+ />
127131
128132 {["aborted", "complete", "failed"].includes(
129133 status?.status ?? "",
modified gui/src/components/mainInput/Lump/sections/mcp/MCPSection.tsx +5 −1
@@ -132,7 +132,11 @@
132132
133133 {/* Refresh button */}
134134 <div className="flex items-center gap-2">
135- <EditBlockButton blockType={"mcpServers"} block={serverFromYaml} />
135+ <EditBlockButton
136+ blockType={"mcpServers"}
137+ block={serverFromYaml}
138+ sourceFile={server.sourceFile}
139+ />
136140 <div
137141 className="text-lightgray flex cursor-pointer items-center hover:opacity-80"
138142 onClick={onRefresh}
modified gui/src/components/modelSelection/ModelSelect.tsx +3 −2
@@ -37,6 +37,7 @@
3737 value: string;
3838 title: string;
3939 apiKey?: string;
40+ sourceFile?: string;
4041 }
4142
4243 function modelSelectTitle(model: any): string {
@@ -56,8 +57,6 @@
5657 showMissingApiKeyMsg,
5758 isSelected,
5859 }: ModelOptionProps) {
59- const ideMessenger = useContext(IdeMessengerContext);
60-
6160 function handleOptionClick(e: any) {
6261 if (showMissingApiKeyMsg) {
6362 e.preventDefault();
@@ -132,6 +131,7 @@
132131 value: model.title,
133132 title: modelSelectTitle(model),
134133 apiKey: model.apiKey,
134+ sourceFile: model.sourceFile,
135135 };
136136 }),
137137 );
@@ -230,6 +230,7 @@
230230 onClick={() =>
231231 ideMessenger.post("config/openProfile", {
232232 profileId: undefined,
233+ element: { sourceFile: selectedModel?.sourceFile },
233234 })
234235 }
235236 />
modified gui/src/pages/config/ModelRoleSelector.tsx +8 −3
@@ -48,10 +48,13 @@
4848 onSelect(models.find((m) => m.title === title) ?? null);
4949 }
5050
51- function onClickGear(e: MouseEvent<SVGSVGElement>) {
51+ function onClickGear(e: MouseEvent<SVGSVGElement>, model: ModelDescription) {
5252 e.stopPropagation();
5353 e.preventDefault();
54- ideMessenger.post("config/openProfile", { profileId: undefined });
54+ ideMessenger.post("config/openProfile", {
55+ profileId: undefined,
56+ element: model,
57+ });
5558 }
5659
5760 function handleOptionClick(
@@ -169,7 +172,9 @@
169172 {hoveredIdx === idx && (
170173 <Cog6ToothIcon
171174 className="h-3 w-3 flex-shrink-0"
172- onClick={onClickGear}
175+ onClick={(e: MouseEvent<SVGSVGElement>) =>
176+ onClickGear(e, option)
177+ }
173178 />
174179 )}
175180 {option.title === selectedModel?.title && (
modified gui/src/pages/gui/StreamError.tsx +1 −0
@@ -77,6 +77,7 @@
7777 onClick={() => {
7878 ideMessenger.post("config/openProfile", {
7979 profileId: undefined,
80+ element: selectedModel ?? undefined,
8081 });
8182 }}
8283 >
modified packages/config-types/src/index.ts +1 −0
@@ -210,6 +210,7 @@
210210 maxDepth: z.number().optional(),
211211 faviconUrl: z.string().optional(),
212212 useLocalCrawling: z.boolean().optional(),
213+ sourceFile: z.string().optional(),
213214 });
214215
215216 export const controlPlaneConfigSchema = z.object({
modified packages/config-yaml/src/load/unroll.ts +59 −4
@@ -452,7 +452,15 @@
452452 registry,
453453 );
454454
455- return { blockType, resolvedBlock, error: null };
455+ return {
456+ blockType,
457+ resolvedBlock,
458+ source:
459+ injectBlock.uriType === "file"
460+ ? injectBlock.filePath
461+ : undefined,
462+ error: null,
463+ };
456464 } catch (err) {
457465 let msg = "";
458466 if (injectBlock.uriType === "file") {
@@ -475,7 +483,11 @@
475483
476484 const injectedResults = await Promise.all(injectedBlockPromises);
477485 const injectedErrors: ConfigValidationError[] = [];
478- const injectedBlocks: { blockType: string; resolvedBlock: any }[] = [];
486+ const injectedBlocks: {
487+ blockType: string;
488+ resolvedBlock: any;
489+ source?: string;
490+ }[] = [];
479491
480492 for (const result of injectedResults) {
481493 if (result.error) {
@@ -484,6 +496,7 @@
484496 injectedBlocks.push({
485497 blockType: result.blockType,
486498 resolvedBlock: result.resolvedBlock,
499+ source: result.source,
487500 });
488501 }
489502 }
@@ -521,12 +534,21 @@
521534 }
522535
523536 // Add injected blocks
524- for (const { blockType, resolvedBlock } of injectedResult.injectedBlocks) {
537+ for (const {
538+ blockType,
539+ resolvedBlock,
540+ source,
541+ } of injectedResult.injectedBlocks) {
525542 const key = blockType as BlockType;
526543 if (!unrolledAssistant[key]) {
527544 unrolledAssistant[key] = [];
528545 }
529- unrolledAssistant[key]?.push(...((resolvedBlock[blockType] ?? []) as any));
546+ const blocksWithSourceFiles = injectLocalSourceFile(
547+ key,
548+ resolvedBlock,
549+ source,
550+ );
551+ unrolledAssistant[key]?.push(...blocksWithSourceFiles);
530552 }
531553
532554 const configResult: ConfigResult<AssistantUnrolled> = {
@@ -541,6 +563,39 @@
541563 return configResult;
542564 }
543565
566+function injectLocalSourceFile(
567+ blockType: BlockType,
568+ resolvedBlock: any,
569+ source?: string,
570+): (any & { source?: string })[] {
571+ const blocks: any[] = resolvedBlock[blockType] ?? [];
572+ if (source === undefined) {
573+ // If no source is provided, return blocks as is
574+ return blocks;
575+ }
576+ if (blockType === "rules") {
577+ // For rules, we need to ensure they are wrapped in an object with a `source
578+ return blocks.map((block) => {
579+ if (typeof block === "string") {
580+ const rule = {
581+ sourceFile: source,
582+ name: block,
583+ rule: block,
584+ } as Rule;
585+ return rule;
586+ } else if (typeof block === "object") {
587+ block.sourceFile = source;
588+ }
589+ return block;
590+ });
591+ }
592+ // For other block types, we can directly inject the source file
593+ return blocks.map((block) => ({
594+ ...block,
595+ sourceFile: source,
596+ }));
597+}
598+
544599 export async function resolveBlock(
545600 id: PackageIdentifier,
546601 inputs: Record<string, string> | undefined,
modified packages/config-yaml/src/markdown/markdownToRule.ts +1 −0
@@ -112,5 +112,6 @@
112112 regex: frontmatter.regex,
113113 description: frontmatter.description,
114114 alwaysApply: frontmatter.alwaysApply,
115+ sourceFile: id.uriType === "file" ? id.filePath : undefined,
115116 };
116117 }
modified packages/config-yaml/src/schemas/index.ts +4 −0
@@ -25,6 +25,7 @@
2525 cwd: z.string().optional(),
2626 connectionTimeout: z.number().gt(0).optional(),
2727 requestOptions: requestOptionsSchema.optional(),
28+ sourceFile: z.string().optional(),
2829 });
2930
3031 export type MCPServer = z.infer<typeof mcpServerSchema>;
@@ -33,6 +34,7 @@
3334 name: z.string(),
3435 description: z.string().optional(),
3536 prompt: z.string(),
37+ sourceFile: z.string().optional(),
3638 });
3739
3840 export type Prompt = z.infer<typeof promptSchema>;
@@ -44,6 +46,7 @@
4446 faviconUrl: z.string().optional(),
4547 maxDepth: z.number().optional(),
4648 useLocalCrawling: z.boolean().optional(),
49+ sourceFile: z.string().optional(),
4750 });
4851
4952 export type DocsConfig = z.infer<typeof docSchema>;
@@ -55,6 +58,7 @@
5558 globs: z.union([z.string(), z.array(z.string())]).optional(),
5659 regex: z.union([z.string(), z.array(z.string())]).optional(),
5760 alwaysApply: z.boolean().optional(),
61+ sourceFile: z.string().optional(), //TODO refactor RuleWithSource.ruleFile to align with sourceFile
5862 });
5963 const ruleSchema = z.union([z.string(), ruleObjectSchema]);
6064
modified packages/config-yaml/src/schemas/models.ts +1 −0
@@ -163,6 +163,7 @@
163163 z.object({
164164 ...baseModelFields,
165165 provider: z.string().refine((val) => val !== "continue-proxy"),
166+ sourceFile: z.string().optional(),
166167 }),
167168 ]);
168169