Added a `mentionMatching.ts` utility to normalize agent mention filtering across the codebase, fixing the handling of handles containing underscores. Updated `AgentMentionPopup`, `ChatView`, and `QuickChatFAB` to use the new utility, with corresponding tests added including a new `mentionMatching.te Fusion-Task-Id: FN-3809
19 lines
593 B
TypeScript
19 lines
593 B
TypeScript
export function normalizeMentionToken(value: string): string {
|
|
return value
|
|
.trim()
|
|
.toLowerCase()
|
|
.replace(/[\s-]+/g, "_")
|
|
.replace(/_+/g, "_");
|
|
}
|
|
|
|
export function matchesAgentMentionFilter(agentName: string, filter: string): boolean {
|
|
const trimmedFilter = filter.trim();
|
|
if (!trimmedFilter) {
|
|
return true;
|
|
}
|
|
|
|
const normalizedFilter = normalizeMentionToken(trimmedFilter);
|
|
const normalizedAgentName = normalizeMentionToken(agentName);
|
|
return normalizedAgentName.includes(normalizedFilter) || agentName.toLowerCase().includes(trimmedFilter.toLowerCase());
|
|
}
|