diff --git a/frontend/src/components/CommandPalette.tsx b/frontend/src/components/CommandPalette.tsx index 78886f2..9135762 100644 --- a/frontend/src/components/CommandPalette.tsx +++ b/frontend/src/components/CommandPalette.tsx @@ -43,6 +43,7 @@ interface CommandPaletteProps { interface Searchable { searchText: string; + keyText?: string; } interface SearchableContact extends Searchable { @@ -106,7 +107,9 @@ function filterList(items: T[], query: string): T[] { if (!query) return items.slice(0, MAX_PER_GROUP); const results: T[] = []; for (const item of items) { - if (fuzzyMatch(item.searchText, query)) { + const nameMatch = fuzzyMatch(item.searchText, query); + const keyMatch = item.keyText ? item.keyText.startsWith(query) : false; + if (nameMatch || keyMatch) { results.push(item); if (results.length >= MAX_PER_GROUP) break; } @@ -159,7 +162,8 @@ export function CommandPalette({ const entry: SearchableContact = { contact: c, displayName, - searchText: `${displayName} ${c.public_key}`.toLowerCase(), + searchText: displayName.toLowerCase(), + keyText: c.public_key.toLowerCase(), }; if (c.type === CONTACT_TYPE_REPEATER) { (c.favorite ? fr : rp).push(entry); @@ -174,7 +178,8 @@ export function CommandPalette({ for (const ch of channels) { const entry: SearchableChannel = { channel: ch, - searchText: `${ch.name} ${ch.key}`.toLowerCase(), + searchText: ch.name.toLowerCase(), + keyText: ch.key.toLowerCase(), }; (ch.favorite ? fch : rch).push(entry); } diff --git a/frontend/src/components/Sidebar.tsx b/frontend/src/components/Sidebar.tsx index 084e1e5..add9e02 100644 --- a/frontend/src/components/Sidebar.tsx +++ b/frontend/src/components/Sidebar.tsx @@ -364,7 +364,7 @@ export function Sidebar({ () => query ? sortedChannels.filter( - (c) => c.name.toLowerCase().includes(query) || c.key.toLowerCase().includes(query) + (c) => c.name.toLowerCase().includes(query) || c.key.toLowerCase().startsWith(query) ) : sortedChannels, [sortedChannels, query] @@ -374,7 +374,8 @@ export function Sidebar({ const visible = sortedNonRepeaterContacts.filter((c) => !isContactBlocked(c)); return query ? visible.filter( - (c) => c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().includes(query) + (c) => + c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().startsWith(query) ) : visible; }, [sortedNonRepeaterContacts, query, isContactBlocked]); @@ -383,7 +384,8 @@ export function Sidebar({ const visible = sortedRooms.filter((c) => !isContactBlocked(c)); return query ? visible.filter( - (c) => c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().includes(query) + (c) => + c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().startsWith(query) ) : visible; }, [sortedRooms, query, isContactBlocked]); @@ -392,7 +394,8 @@ export function Sidebar({ const visible = sortedRepeaters.filter((c) => !isContactBlocked(c)); return query ? visible.filter( - (c) => c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().includes(query) + (c) => + c.name?.toLowerCase().includes(query) || c.public_key.toLowerCase().startsWith(query) ) : visible; }, [sortedRepeaters, query, isContactBlocked]); diff --git a/frontend/src/components/TracePane.tsx b/frontend/src/components/TracePane.tsx index 871923b..e1cf4c5 100644 --- a/frontend/src/components/TracePane.tsx +++ b/frontend/src/components/TracePane.tsx @@ -224,8 +224,8 @@ export function TracePane({ contacts, config, onRunTracePath }: TracePaneProps) const matching = query ? repeaters.filter( (contact) => - contact.public_key.toLowerCase().includes(query) || - (contact.name ?? '').toLowerCase().includes(query) + (contact.name ?? '').toLowerCase().includes(query) || + contact.public_key.toLowerCase().startsWith(query) ) : repeaters;