Implementing app search feature (#1302)
This PR implements app search feature and addresses the issue #1182. <!-- This is an auto-generated description by cubic. --> --- ## Summary by cubic Adds a fast app search with a command-style dialog so users can find apps by name or chat content and jump to them quickly. Implements the search experience requested in #1182. - New Features - Search dialog (Ctrl+K or “Search Apps” button) with result snippets from matching chat titles/messages. - Searches across app names, chat titles, and message content; case-insensitive; supports partial matches; empty query lists all apps. - Selecting a result navigates to the app and closes the dialog. - New IPC endpoint search-app with Zod-validated results, debounced React Query hook, and preload allowlist update. - Added E2E tests for dialog open/close, shortcuts, matching behavior, empty state, and navigation. <!-- End of auto-generated description by cubic. -->
This commit is contained in:
committed by
GitHub
parent
2edd122d9b
commit
a547aa3ac1
22
src/hooks/useSearchApps.ts
Normal file
22
src/hooks/useSearchApps.ts
Normal file
@@ -0,0 +1,22 @@
|
||||
import { IpcClient } from "@/ipc/ipc_client";
|
||||
import { AppSearchResult } from "@/lib/schemas";
|
||||
import { keepPreviousData, useQuery } from "@tanstack/react-query";
|
||||
|
||||
export function useSearchApps(query: string) {
|
||||
const enabled = Boolean(query && query.trim().length > 0);
|
||||
|
||||
const { data, isFetching, isLoading } = useQuery({
|
||||
queryKey: ["search-apps", query],
|
||||
enabled,
|
||||
queryFn: async (): Promise<AppSearchResult[]> => {
|
||||
return IpcClient.getInstance().searchApps(query);
|
||||
},
|
||||
placeholderData: keepPreviousData,
|
||||
retry: 0,
|
||||
});
|
||||
|
||||
return {
|
||||
apps: data ?? [],
|
||||
loading: enabled ? isFetching || isLoading : false,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user