From a82a6104e010a0344f9d7b0e6af84f90eb723451 Mon Sep 17 00:00:00 2001 From: Kjell Kind Date: Tue, 17 Nov 2026 19:51:31 +0100 Subject: [PATCH 1/3] feat: find guilds from the Cmd+K search Co-Authored-By: Claude Opus 5.5 --- resources/js/components/search-dialog.tsx | 61 +++++++++++++++++++-- resources/js/lib/guild-search.ts | 59 +++++++++++++++++++++ tests/Unit/GuildSearch.test.ts | 64 +++++++++++++++++++++++ 3 files changed, 180 insertions(+), 4 deletions(-) create mode 100644 resources/js/lib/guild-search.ts create mode 100644 tests/Unit/GuildSearch.test.ts diff --git a/resources/js/components/search-dialog.tsx b/resources/js/components/search-dialog.tsx index ce29f40198..664851a314 100644 --- a/resources/js/components/search-dialog.tsx +++ b/resources/js/components/search-dialog.tsx @@ -15,11 +15,13 @@ import { import type { KeyboardEvent, ReactNode } from 'react'; import { useEffect, useRef, useState } from 'react'; import CommitController from '@/actions/App/Http/Controllers/CommitController'; +import GuildController from '@/actions/App/Http/Controllers/GuildController'; import HeadlineController from '@/actions/App/Http/Controllers/HeadlineController'; import ProfileSearchController from '@/actions/App/Http/Controllers/ProfileSearchController'; import SearchController from '@/actions/App/Http/Controllers/SearchController'; import { AuthorAvatar } from '@/components/author-avatar'; import { GuildSearchHeading } from '@/components/commit-search-results'; +import { GuildIcon } from '@/components/guild-icon'; import { HotTopicContent } from '@/components/hot-topics'; import { OrganizationAvatar } from '@/components/organization-avatar'; import { DialogOverlay, DialogPortal } from '@/components/ui/dialog'; @@ -35,6 +37,7 @@ import { signIn } from '@/lib/auth'; import { searchCandidates } from '@/lib/chat'; import { searchCommits, TooManySearches } from '@/lib/commit-search'; import { groupSearchCommits } from '@/lib/commit-search-results'; +import { matchGuilds } from '@/lib/guild-search'; import { useKeyLabels } from '@/lib/keyboard'; import type { SearchAction } from '@/lib/search-actions'; import { searchActions } from '@/lib/search-actions'; @@ -51,6 +54,7 @@ import { } from '@/lib/utils'; import { show } from '@/routes/user'; import type { Commit, CommitAuthor, Organization, User } from '@/types'; +import type { Guild } from '@/types/guild'; const developerDebounce = 120; @@ -67,14 +71,15 @@ type Option = | { kind: 'action'; id: string; action: SearchAction } | { kind: 'developer'; id: string; user: User; reason?: string | null } | { kind: 'organization'; id: string; organization: Organization } + | { kind: 'guild'; id: string; guild: Guild } | { kind: 'commit'; id: string; commit: Commit } | { kind: 'all'; id: string; needsSignIn: boolean } | { kind: 'topic'; id: string; term: string; summary: string | null } | { kind: 'recent'; id: string; term: string }; /** - * Searches developers, organizations and commits. Guests only search developers and organizations: each commit search pays for AI, so they're asked to - * sign in for those instead. Picking a developer for a new conversation narrows it to developers, says why + * Searches developers, organizations, guilds and commits. Guests only search developers and organizations: each commit search pays for AI, so they're asked to + * sign in for those instead, and guilds are for members only. Picking a developer for a new conversation narrows it to developers, says why * anyone can't be messaged, and hands the pick back instead of opening their profile. Given `onAction`, it also offers * to write a commit, open an issue or go live when the search names one, above what it found. */ @@ -101,7 +106,7 @@ export function SearchDialog({ pickerScope?: 'remote' | 'share'; onCloseAutoFocus?: (event: Event) => void; }) { - const { auth, hotTopics = [] } = usePage().props; + const { auth, hotTopics = [], guilds } = usePage().props; const userId = auth.user?.id ?? null; const recentSearches = useRecentSearches(userId); const keys = useKeyLabels(); @@ -140,6 +145,7 @@ export function SearchDialog({ const visibleOrganizations = developers .resultsFor(developerTerm) .filter((found): found is FoundOrganization => 'organization' in found); + const visibleGuilds = isPicking ? [] : matchGuilds(guilds, term); const visibleCommits = commits.resultsFor(commitTerm); const results = optionsFor( intent, @@ -147,6 +153,7 @@ export function SearchDialog({ intent === 'topic' ? visibleOrganizations.slice(0, 2) : visibleOrganizations, + intent === 'topic' ? visibleGuilds.slice(0, 2) : visibleGuilds, visibleCommits, commitQuery, !isMember, @@ -289,7 +296,7 @@ export function SearchDialog({ {isPicking ? 'Find a developer by name or handle to message.' - : 'Find developers and organizations by name or handle, or commits by what they are about.'} + : 'Find developers, organizations and guilds by name or handle, or commits by what they are about.'}
@@ -543,6 +550,7 @@ function optionsFor( intent: ReturnType, developers: FoundDeveloper[], organizations: FoundOrganization[], + guilds: Guild[], commits: Commit[], commitTerm: string, needsSignIn: boolean, @@ -566,6 +574,11 @@ function optionsFor( organization, }), ); + const guildOptions: Option[] = guilds.map((guild) => ({ + kind: 'guild', + id: `guild-${guild.id}`, + guild, + })); const commitOptions: Option[] = groupSearchCommits(commits) .flatMap(([, group]) => group) .map((commit) => ({ @@ -583,6 +596,7 @@ function optionsFor( ...seeAll, ...developerOptions, ...organizationOptions, + ...guildOptions, ]; } @@ -590,6 +604,7 @@ function optionsFor( ...actionOptions, ...developerOptions, ...organizationOptions, + ...guildOptions, ...commitOptions, ...seeAll, ]; @@ -599,6 +614,7 @@ const headings: Record = { action: 'Actions', developer: 'Developers', organization: 'Organizations', + guild: 'Guilds', commit: 'Most relevant commits', all: null, recent: ( @@ -651,6 +667,10 @@ function hrefFor( return show(option.organization); } + if (option.kind === 'guild') { + return GuildController.show(option.guild.handle); + } + if (option.kind === 'commit') { return CommitController.show({ profile: option.commit.author, @@ -764,6 +784,10 @@ function OptionContent({ option }: { option: Option }): ReactNode { return ; } + if (option.kind === 'guild') { + return ; + } + if (option.kind === 'commit') { return ; } @@ -903,6 +927,35 @@ function OrganizationResult({ organization }: { organization: Organization }) { ); } +function GuildResult({ guild }: { guild: Guild }) { + return ( + <> + + + + + {guild.name} + + + #{guild.handle} + + + {guild.description && ( + + {guild.description} + + )} + + + ); +} + function CommitResult({ commit }: { commit: Commit }) { const now = useNow(); diff --git a/resources/js/lib/guild-search.ts b/resources/js/lib/guild-search.ts new file mode 100644 index 0000000000..39699e26e7 --- /dev/null +++ b/resources/js/lib/guild-search.ts @@ -0,0 +1,59 @@ +import type { Guild } from '@/types/guild'; + +/** + * The guilds whose handle or name matches the term, closest first and then biggest. Every guild is already on the + * page for members, so this filters them in place instead of asking the server. An "@" search is for developers, so + * it finds no guilds; a leading "#" is how guilds are written, so it is ignored. + */ +export function matchGuilds( + guilds: Guild[] | null | undefined, + term: string, + limit = 3, +): Guild[] { + const trimmed = term.trim(); + + if (!guilds || trimmed.startsWith('@')) { + return []; + } + + const needle = trimmed.replace(/^#/u, '').trim().toLowerCase(); + + if (needle === '') { + return []; + } + + return guilds + .map((guild) => ({ guild, rank: rank(guild, needle) })) + .filter(({ rank }) => rank !== null) + .sort( + (a, b) => + a.rank! - b.rank! || + b.guild.member_count - a.guild.member_count || + a.guild.handle.localeCompare(b.guild.handle), + ) + .slice(0, limit) + .map(({ guild }) => guild); +} + +function rank(guild: Guild, needle: string): number | null { + const handle = guild.handle.toLowerCase(); + const name = guild.name.toLowerCase(); + + if (handle === needle) { + return 0; + } + + if (handle.startsWith(needle)) { + return 1; + } + + if (name.startsWith(needle)) { + return 2; + } + + if (handle.includes(needle) || name.includes(needle)) { + return 3; + } + + return null; +} diff --git a/tests/Unit/GuildSearch.test.ts b/tests/Unit/GuildSearch.test.ts new file mode 100644 index 0000000000..dad1bd167c --- /dev/null +++ b/tests/Unit/GuildSearch.test.ts @@ -0,0 +1,64 @@ +import assert from 'node:assert/strict'; +import { test } from 'node:test'; +import { matchGuilds } from '../../resources/js/lib/guild-search.ts'; +import type { Guild } from '../../resources/js/types/guild'; + +function guild(handle: string, name: string, member_count = 1): Guild { + return { + id: handle, + handle, + name, + description: '', + emoji: '#', + icon_url: null, + member_count, + is_joined: false, + is_muted: false, + is_paused: false, + }; +} + +const guilds = [ + guild('laravel', 'Laravel', 40), + guild('php', 'PHP folks', 90), + guild('rust', 'Rustaceans', 10), + guild('larabelles', 'Larabelles', 5), + guild('frontend', 'Frontend in PHP', 200), +]; + +await test('finds guilds by handle or name, case-insensitively', () => { + assert.deepEqual( + matchGuilds(guilds, 'RUST').map(({ handle }) => handle), + ['rust'], + ); + assert.deepEqual( + matchGuilds(guilds, 'folks').map(({ handle }) => handle), + ['php'], + ); +}); + +await test('puts an exact handle first, then handle and name prefixes, then the biggest', () => { + assert.deepEqual( + matchGuilds(guilds, 'php').map(({ handle }) => handle), + ['php', 'frontend'], + ); + assert.deepEqual( + matchGuilds(guilds, 'lara').map(({ handle }) => handle), + ['laravel', 'larabelles'], + ); +}); + +await test('ignores a leading # and keeps to the limit', () => { + assert.deepEqual( + matchGuilds(guilds, ' #rust ').map(({ handle }) => handle), + ['rust'], + ); + assert.equal(matchGuilds(guilds, 'a', 2).length, 2); +}); + +await test('finds nothing for guests, empty terms or developer searches', () => { + assert.deepEqual(matchGuilds(null, 'php'), []); + assert.deepEqual(matchGuilds(guilds, ''), []); + assert.deepEqual(matchGuilds(guilds, '#'), []); + assert.deepEqual(matchGuilds(guilds, '@php'), []); +}); From e10c12d7d18e7b5a34b73bb263cfef2f5d631d5a Mon Sep 17 00:00:00 2001 From: Kjell Kind Date: Mon, 30 Nov 2026 14:10:30 +0100 Subject: [PATCH 2/3] fix: look guilds up on the server now that pages no longer carry every guild Co-Authored-By: Claude Opus 5.5 --- resources/js/components/search-dialog.tsx | 37 +++++++------ resources/js/lib/guild-search.ts | 61 ++++----------------- tests/Unit/GuildSearch.test.ts | 67 ++++------------------- 3 files changed, 41 insertions(+), 124 deletions(-) diff --git a/resources/js/components/search-dialog.tsx b/resources/js/components/search-dialog.tsx index 50bdac2c49..9c15eacc7e 100644 --- a/resources/js/components/search-dialog.tsx +++ b/resources/js/components/search-dialog.tsx @@ -37,7 +37,8 @@ import { signIn } from '@/lib/auth'; import { searchCandidates } from '@/lib/chat'; import { searchCommits, TooManySearches } from '@/lib/commit-search'; import { groupSearchCommits } from '@/lib/commit-search-results'; -import { matchGuilds } from '@/lib/guild-search'; +import { guildSearchLimit, guildSearchTerm } from '@/lib/guild-search'; +import { fetchGuilds } from '@/lib/guilds'; import { useKeyLabels } from '@/lib/keyboard'; import type { SearchAction } from '@/lib/search-actions'; import { searchActions } from '@/lib/search-actions'; @@ -54,7 +55,7 @@ import { } from '@/lib/utils'; import { show } from '@/routes/user'; import type { Commit, CommitAuthor, Organization, User } from '@/types'; -import type { Guild } from '@/types/guild'; +import type { GuildBadge } from '@/types/guild'; const developerDebounce = 120; @@ -71,7 +72,7 @@ type Option = | { kind: 'action'; id: string; action: SearchAction } | { kind: 'developer'; id: string; user: User; reason?: string | null } | { kind: 'organization'; id: string; organization: Organization } - | { kind: 'guild'; id: string; guild: Guild } + | { kind: 'guild'; id: string; guild: GuildBadge } | { kind: 'commit'; id: string; commit: Commit } | { kind: 'all'; id: string; needsSignIn: boolean } | { kind: 'topic'; id: string; term: string; summary: string | null } @@ -106,7 +107,7 @@ export function SearchDialog({ pickerScope?: 'remote' | 'share'; onCloseAutoFocus?: (event: Event) => void; }) { - const { auth, hotTopics = [], guilds } = usePage().props; + const { auth, hotTopics = [], guildsEnabled } = usePage().props; const userId = auth.user?.id ?? null; const recentSearches = useRecentSearches(userId); const keys = useKeyLabels(); @@ -121,6 +122,7 @@ export function SearchDialog({ const intent = isPicking ? 'developer' : searchIntent(term); const commitQuery = searchesCommits(intent) ? term : ''; const commitTerm = isMember ? commitQuery : ''; + const guildTerm = isPicking ? '' : guildSearchTerm(term, guildsEnabled); const developers = useDebouncedSearch( developerTerm, @@ -130,6 +132,11 @@ export function SearchDialog({ searchCandidates(value, { for: pickerScope }, signal) : searchDevelopers, ); + const guilds = useDebouncedSearch( + guildTerm, + developerDebounce, + (value, signal) => fetchGuilds({ q: value }, signal), + ); const commits = useDebouncedSearch( commitTerm, commitDebounce, @@ -145,7 +152,9 @@ export function SearchDialog({ const visibleOrganizations = developers .resultsFor(developerTerm) .filter((found): found is FoundOrganization => 'organization' in found); - const visibleGuilds = isPicking ? [] : matchGuilds(guilds, term); + const visibleGuilds = guilds + .resultsFor(guildTerm) + .slice(0, guildSearchLimit); const visibleCommits = commits.resultsFor(commitTerm); const results = optionsFor( intent, @@ -159,9 +168,11 @@ export function SearchDialog({ !isMember, onAction && !isPicking ? searchActions(term, { isLive }) : [], ); - const isLoading = developers.isLoading || commits.isLoading; + const isLoading = + developers.isLoading || guilds.isLoading || commits.isLoading; const hasSearched = developers.hasSearched(developerTerm) && + (guildTerm === '' || guilds.hasSearched(guildTerm)) && (commitTerm === '' || commits.hasSearched(commitTerm)); const isEmpty = term === ''; const isAwaitingDeveloperName = @@ -550,7 +561,7 @@ function optionsFor( intent: ReturnType, developers: FoundDeveloper[], organizations: FoundOrganization[], - guilds: Guild[], + guilds: GuildBadge[], commits: Commit[], commitTerm: string, needsSignIn: boolean, @@ -576,7 +587,7 @@ function optionsFor( ); const guildOptions: Option[] = guilds.map((guild) => ({ kind: 'guild', - id: `guild-${guild.id}`, + id: `guild-${guild.handle}`, guild, })); const commitOptions: Option[] = groupSearchCommits(commits) @@ -930,7 +941,7 @@ function OrganizationResult({ organization }: { organization: Organization }) { ); } -function GuildResult({ guild }: { guild: Guild }) { +function GuildResult({ guild }: { guild: GuildBadge }) { return ( <> @@ -946,14 +957,6 @@ function GuildResult({ guild }: { guild: Guild }) { #{guild.handle} - {guild.description && ( - - {guild.description} - - )} ); diff --git a/resources/js/lib/guild-search.ts b/resources/js/lib/guild-search.ts index 39699e26e7..8e29288371 100644 --- a/resources/js/lib/guild-search.ts +++ b/resources/js/lib/guild-search.ts @@ -1,59 +1,18 @@ -import type { Guild } from '@/types/guild'; +/** + * How many guilds the search shows, after the developers and organizations. + */ +export const guildSearchLimit = 3; /** - * The guilds whose handle or name matches the term, closest first and then biggest. Every guild is already on the - * page for members, so this filters them in place instead of asking the server. An "@" search is for developers, so - * it finds no guilds; a leading "#" is how guilds are written, so it is ignored. + * The term to look guilds up by, or an empty one when the search shouldn't find guilds: for guests and users without + * guilds, and for an "@" search, which is for developers. A leading "#" is how guilds are written, so it is dropped. */ -export function matchGuilds( - guilds: Guild[] | null | undefined, - term: string, - limit = 3, -): Guild[] { +export function guildSearchTerm(term: string, guildsEnabled: boolean): string { const trimmed = term.trim(); - if (!guilds || trimmed.startsWith('@')) { - return []; - } - - const needle = trimmed.replace(/^#/u, '').trim().toLowerCase(); - - if (needle === '') { - return []; - } - - return guilds - .map((guild) => ({ guild, rank: rank(guild, needle) })) - .filter(({ rank }) => rank !== null) - .sort( - (a, b) => - a.rank! - b.rank! || - b.guild.member_count - a.guild.member_count || - a.guild.handle.localeCompare(b.guild.handle), - ) - .slice(0, limit) - .map(({ guild }) => guild); -} - -function rank(guild: Guild, needle: string): number | null { - const handle = guild.handle.toLowerCase(); - const name = guild.name.toLowerCase(); - - if (handle === needle) { - return 0; - } - - if (handle.startsWith(needle)) { - return 1; - } - - if (name.startsWith(needle)) { - return 2; - } - - if (handle.includes(needle) || name.includes(needle)) { - return 3; + if (!guildsEnabled || trimmed.startsWith('@')) { + return ''; } - return null; + return trimmed.replace(/^#/u, '').trim().toLowerCase(); } diff --git a/tests/Unit/GuildSearch.test.ts b/tests/Unit/GuildSearch.test.ts index dad1bd167c..65d16a627b 100644 --- a/tests/Unit/GuildSearch.test.ts +++ b/tests/Unit/GuildSearch.test.ts @@ -1,64 +1,19 @@ import assert from 'node:assert/strict'; import { test } from 'node:test'; -import { matchGuilds } from '../../resources/js/lib/guild-search.ts'; -import type { Guild } from '../../resources/js/types/guild'; +import { guildSearchTerm } from '../../resources/js/lib/guild-search.ts'; -function guild(handle: string, name: string, member_count = 1): Guild { - return { - id: handle, - handle, - name, - description: '', - emoji: '#', - icon_url: null, - member_count, - is_joined: false, - is_muted: false, - is_paused: false, - }; -} - -const guilds = [ - guild('laravel', 'Laravel', 40), - guild('php', 'PHP folks', 90), - guild('rust', 'Rustaceans', 10), - guild('larabelles', 'Larabelles', 5), - guild('frontend', 'Frontend in PHP', 200), -]; - -await test('finds guilds by handle or name, case-insensitively', () => { - assert.deepEqual( - matchGuilds(guilds, 'RUST').map(({ handle }) => handle), - ['rust'], - ); - assert.deepEqual( - matchGuilds(guilds, 'folks').map(({ handle }) => handle), - ['php'], - ); -}); - -await test('puts an exact handle first, then handle and name prefixes, then the biggest', () => { - assert.deepEqual( - matchGuilds(guilds, 'php').map(({ handle }) => handle), - ['php', 'frontend'], - ); - assert.deepEqual( - matchGuilds(guilds, 'lara').map(({ handle }) => handle), - ['laravel', 'larabelles'], - ); +await test('looks guilds up by the trimmed, lowercased term', () => { + assert.equal(guildSearchTerm(' RUST ', true), 'rust'); + assert.equal(guildSearchTerm('php folks', true), 'php folks'); }); -await test('ignores a leading # and keeps to the limit', () => { - assert.deepEqual( - matchGuilds(guilds, ' #rust ').map(({ handle }) => handle), - ['rust'], - ); - assert.equal(matchGuilds(guilds, 'a', 2).length, 2); +await test('ignores a leading #', () => { + assert.equal(guildSearchTerm(' #rust ', true), 'rust'); + assert.equal(guildSearchTerm('#', true), ''); }); -await test('finds nothing for guests, empty terms or developer searches', () => { - assert.deepEqual(matchGuilds(null, 'php'), []); - assert.deepEqual(matchGuilds(guilds, ''), []); - assert.deepEqual(matchGuilds(guilds, '#'), []); - assert.deepEqual(matchGuilds(guilds, '@php'), []); +await test('finds no guilds for guests, users without guilds or developer searches', () => { + assert.equal(guildSearchTerm('php', false), ''); + assert.equal(guildSearchTerm('@php', true), ''); + assert.equal(guildSearchTerm('', true), ''); }); From fbea4a9e2e9615f38dc73917f97995befc312aa8 Mon Sep 17 00:00:00 2001 From: Kjell Kind Date: Tue, 1 Dec 2026 18:50:51 +0100 Subject: [PATCH 3/3] fix: say guild searches are throttled instead of finding nothing Co-Authored-By: Claude Opus 5.5 --- resources/js/components/search-dialog.tsx | 1 + resources/js/lib/guilds.ts | 5 ++ tests/Unit/SearchDialogComposition.test.tsx | 57 +++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/resources/js/components/search-dialog.tsx b/resources/js/components/search-dialog.tsx index 9c15eacc7e..45482b5670 100644 --- a/resources/js/components/search-dialog.tsx +++ b/resources/js/components/search-dialog.tsx @@ -179,6 +179,7 @@ export function SearchDialog({ awaitsDeveloperName(term) || (isPicking && isEmpty); const isThrottled = developers.isThrottled(developerTerm) || + guilds.isThrottled(guildTerm) || commits.isThrottled(commitTerm); const foundNothing = !isEmpty && diff --git a/resources/js/lib/guilds.ts b/resources/js/lib/guilds.ts index 04c7813509..fab7c9a9a5 100644 --- a/resources/js/lib/guilds.ts +++ b/resources/js/lib/guilds.ts @@ -1,4 +1,5 @@ import { index } from '@/actions/App/Http/Controllers/GuildSuggestionController'; +import { TooManySearches } from '@/lib/commit-search'; import type { GuildBadge } from '@/types/guild'; export async function fetchGuilds( @@ -13,6 +14,10 @@ export async function fetchGuilds( signal, }); + if (response.status === 429) { + throw new TooManySearches(); + } + if (!response.ok) { throw new Error(`Guild lookup failed: ${response.status}`); } diff --git a/tests/Unit/SearchDialogComposition.test.tsx b/tests/Unit/SearchDialogComposition.test.tsx index e11c767f3a..938fdc12fe 100644 --- a/tests/Unit/SearchDialogComposition.test.tsx +++ b/tests/Unit/SearchDialogComposition.test.tsx @@ -9,6 +9,7 @@ let cursor = 0; let effects: Array<() => unknown> | null = null; const visit = vi.fn(); let userId: string | null = null; +let guildsEnabled = false; const storage = new Map(); let hotTopics = [ { id: 'topic-one', name: 'Database indexes', summary: null }, @@ -60,6 +61,7 @@ vi.doMock('@inertiajs/react', async () => ({ usePage: () => ({ props: { auth: { user: userId ? { id: userId } : null }, + guildsEnabled, ...(userId ? { hotTopics } : {}), }, }), @@ -206,6 +208,61 @@ test.each([200, 429])( }, ); +test('says searches are throttled when only the guild lookup is', async () => { + state = []; + storage.clear(); + userId = 'author'; + guildsEnabled = true; + const topics = hotTopics; + hotTopics = []; + effects = []; + vi.useFakeTimers(); + const fetch = vi + .spyOn(globalThis, 'fetch') + .mockImplementation(async (url) => + String(url).includes('/search/guilds') + ? new Response('', { status: 429 }) + : new Response( + JSON.stringify({ users: [], organizations: [] }), + ), + ); + + try { + (input().props.onChange as (event: unknown) => void)({ + target: { value: 'jobs' }, + }); + cursor = 0; + SearchDialog({ open: true, onOpenChange: () => {} }); + effects.forEach((effect) => effect()); + await vi.runAllTimersAsync(); + + cursor = 0; + const settled = SearchDialog({ open: true, onOpenChange: () => {} }); + const statuses = elements(settled) + .filter((element) => element.props.role === 'status') + .map((element) => + React.Children.toArray( + element.props.children as ReactNode, + ).join(''), + ); + assert.ok( + statuses.some((text) => + text.startsWith('error: too many searches'), + ), + ); + assert.equal( + statuses.some((text) => text.startsWith('fatal: nothing matches')), + false, + ); + } finally { + effects = null; + guildsEnabled = false; + hotTopics = topics; + fetch.mockRestore(); + vi.useRealTimers(); + } +}); + test('persists only three distinct searches, evicting the oldest and promoting repeats', () => { storage.clear(); for (const query of [