refactor: Simplify trigger filtering in Copilot

- Removed unnecessary filtering logic for triggers based on user queries, streamlining the search process.
- Updated response messages to clarify the context of displayed triggers, enhancing user understanding.

This update improves the efficiency of the trigger search functionality within the Copilot interface.
This commit is contained in:
tusharmagar 2025-10-08 17:21:26 +08:00
parent 15bc85145f
commit b3d041677c

View file

@ -293,16 +293,7 @@ async function searchRelevantTriggers(
return `No triggers are currently available for toolkit "${trimmedSlug}".`;
}
let filteredTriggers = triggers;
if (trimmedQuery) {
const queryLc = trimmedQuery.toLowerCase();
filteredTriggers = triggers.filter(trigger => {
const baseText = `${trigger.name} ${trigger.slug} ${trigger.description}`.toLowerCase();
const propertyNames = Object.keys(trigger.config?.properties || {}).join(' ').toLowerCase();
return baseText.includes(queryLc) || propertyNames.includes(queryLc);
});
logger.log(`filtered triggers to ${filteredTriggers.length} results using query`);
}
const filteredTriggers = triggers;
if (!filteredTriggers.length) {
return `No triggers found for toolkit "${trimmedSlug}"${trimmedQuery ? ` matching "${trimmedQuery}"` : ''}.`;
@ -321,11 +312,11 @@ async function searchRelevantTriggers(
}).join('\n\n');
const header = trimmedQuery
? `The following triggers match "${trimmedQuery}" in toolkit "${trimmedSlug}":`
? `Showing triggers for toolkit "${trimmedSlug}" (you searched for "${trimmedQuery}"):\n`
: `Available triggers for toolkit "${trimmedSlug}":`;
const note = truncated
? `\n\nOnly showing the first ${MAX_RESULTS} results out of ${filteredTriggers.length}. Refine your query for more specific results.`
? `\n\nOnly showing the first ${MAX_RESULTS} results out of ${filteredTriggers.length}.`
: '';
const response = `${header}\n\n${formattedTriggers}${note}`;