agent-ecosystem/src/renderer/utils/mentionSuggestions.ts
iliya dd42cf0069 fix(team): scan inbox for permission_request during provisioning
relayLeadInboxMessages only processes unread messages after
provisioningComplete, but CLI marks permission_request messages as
read after native delivery -- before our relay runs.

Move permission_request inbox scan BEFORE provisioningComplete check.
Scan ALL messages (including read=true), track processed IDs via
processedPermissionRequestIds Set on ProvisioningRun to prevent
re-emitting. Also look up both alive and provisioning runs so the
scan works during team bootstrap.
2026-03-27 23:35:52 +02:00

34 lines
1.1 KiB
TypeScript

import type { MentionSuggestion } from '@renderer/types/mention';
export function getSuggestionTriggerChar(suggestion: MentionSuggestion): '@' | '#' | '/' {
if (suggestion.type === 'task') return '#';
if (suggestion.type === 'command') return '/';
return '@';
}
export function getSuggestionInsertionText(suggestion: MentionSuggestion): string {
if (suggestion.type === 'command') {
return suggestion.command?.slice(1) ?? suggestion.insertText ?? suggestion.name;
}
return suggestion.insertText ?? suggestion.name;
}
export function doesSuggestionMatchQuery(suggestion: MentionSuggestion, query: string): boolean {
const normalizedQuery = query.trim().toLowerCase();
if (!normalizedQuery) return true;
const haystacks = [
suggestion.name,
suggestion.subtitle,
suggestion.description,
suggestion.relativePath,
suggestion.searchText,
suggestion.teamDisplayName,
suggestion.teamName,
suggestion.command,
]
.filter(Boolean)
.map((value) => value!.toLowerCase());
return haystacks.some((value) => value.includes(normalizedQuery));
}