Merge branch 'main' of https://github.com/continuedev/continue into dallin/con-4022-hide-empty-prompts-resources

This commit is contained in:
Dallin Romney 2025-09-30 02:27:27 -07:00
commit c0922151ce
3 changed files with 5 additions and 53 deletions

View file

@ -251,7 +251,6 @@ describe("E2E Scenarios", () => {
);
const config = unrolledConfig.config;
const errors = unrolledConfig.errors;
// The original rules array should have two items
expect(config?.rules?.length).toBe(3); // Now 3 with the injected block
@ -266,13 +265,9 @@ describe("E2E Scenarios", () => {
typeof config?.rules?.[2] !== "string" &&
config?.rules?.[2]?.rule === "Be humble",
);
// Check if we receive one error that is caused by duplicate rules
expect(errors?.length).toBe(1);
expect(errors?.[0].message.includes("Duplicate rules detected"));
});
it("duplicate detection should happen in the assistant config first and then the intected blocks", async () => {
it("duplicate detection should happen in the assistant config first and then the injected blocks", async () => {
const unrolledConfig = await unrollAssistant(
{
uriType: "file",
@ -313,21 +308,6 @@ describe("E2E Scenarios", () => {
expect(config?.rules?.length).toBe(1);
expect(config?.prompts?.length).toBe(1);
expect(config?.docs?.length).toBe(1);
// Check if there are 8 duplication detected
expect(errors?.length).toBe(8);
// Beginning of the assistant config duplication check
expect(
errors?.[0].message.includes("Duplicate models named gpt-5 detected"),
).toBe(true);
// Beginning of the injected blocks duplication check
expect(errors?.[4].message.includes("Duplicate rules detected")).toBe(true);
expect(
errors?.[6].message.includes(
"Duplicate mcpServers named Browser search detected",
),
).toBe(true);
});
it("should throw when a block is blocklisted", async () => {

View file

@ -36,11 +36,7 @@ export class BlockDuplicationDetector {
}
// Check if the name is duplicated within the same blockType
isDuplicated(
block: any,
blockType: BlockType,
injectError?: (errorMsg: string) => void,
): boolean {
isDuplicated(block: any, blockType: BlockType): boolean {
// Not checking any null or undefined object
if (block === null || block === undefined) {
return false;
@ -49,25 +45,16 @@ export class BlockDuplicationDetector {
switch (blockType) {
case "rules":
if (this.isRuleDuplicated(block)) {
injectError?.(
`Duplicate rules${typeof block === "string" ? "" : ` named ${block.name}`} detected. The duplicate one has been deleted for preventing unexpected behavior.`,
);
return true;
}
return false;
case "context":
if (this.isContextDuplicated(block)) {
injectError?.(
`Duplicate ${block.provider} context providers detected. The duplicate one has been deleted for preventing unexpected behavior.`,
);
return true;
}
return false;
default:
if (this.isCommonBlockDuplicated(block, blockType)) {
injectError?.(
`Duplicate ${blockType} named ${block.name} detected. The duplicate one has been deleted for preventing unexpected behavior.`,
);
return true;
}
return false;

View file

@ -357,13 +357,6 @@ export async function unrollBlocks(
): Promise<ConfigResult<AssistantUnrolled>> {
const errors: ConfigValidationError[] = [];
function injectDuplicationError(errorMsg: string) {
errors.push({
fatal: false,
message: errorMsg,
});
}
const unrolledAssistant: AssistantUnrolled = {
name: assistant.name,
version: assistant.version,
@ -622,12 +615,7 @@ export async function unrollBlocks(
for (const sectionResult of sectionResults) {
if (sectionResult.blocks) {
unrolledAssistant[sectionResult.section] = sectionResult.blocks.filter(
(block) =>
!detector.isDuplicated(
block,
sectionResult.section,
injectDuplicationError,
),
(block) => !detector.isDuplicated(block, sectionResult.section),
);
}
}
@ -635,7 +623,7 @@ export async function unrollBlocks(
// Assign rules result
if (rulesResult.rules) {
unrolledAssistant.rules = rulesResult.rules.filter(
(rule) => !detector.isDuplicated(rule, "rules", injectDuplicationError),
(rule) => !detector.isDuplicated(rule, "rules"),
);
}
@ -654,10 +642,7 @@ export async function unrollBlocks(
key,
resolvedBlock,
source,
).filter(
(block: any) =>
!detector.isDuplicated(block, blockType, injectDuplicationError),
);
).filter((block: any) => !detector.isDuplicated(block, blockType));
unrolledAssistant[key]?.push(...filteredBlocks);
}