1.7 KiB
1.7 KiB
Repository Agent Guide
Project context
- This is an Electron application with a secure IPC boundary.
- Frontend is a React app that uses TanStack Router (not Next.js or React Router).
- Data fetching/mutations should be handled with TanStack Query when touching IPC-backed endpoints.
IPC architecture expectations
src/ipc/ipc_client.tsruns in the renderer. Access it viaIpcClient.getInstance()and expose dedicated methods per IPC channel.src/preload.tsdefines the renderer allowlist. New IPC APIs must be added here.src/ipc/ipc_host.tsregisters handlers that live in files undersrc/ipc/handlers/(e.g.,app_handlers.ts,chat_stream_handlers.ts,settings_handlers.ts).- IPC handlers should
throw new Error("...")on failure instead of returning{ success: false }style payloads.
React + IPC integration pattern
When creating hooks/components that call IPC handlers:
- Wrap reads in
useQuery, providing a stablequeryKey, asyncqueryFnthat calls the relevantIpcClientmethod, and conditionally useenabled/initialData/metaas needed. - Wrap writes in
useMutation; validate inputs locally, call the IPC client, and invalidate related queries on success. Use shared utilities (e.g., toast helpers) inonError. - Synchronize TanStack Query data with any global state (like Jotai atoms) via
useEffectonly if required.
General guidance
- Favor descriptive module/function names that mirror IPC channel semantics.
- Keep Electron security practices in mind (no
remote, validate/lock byappIdwhen mutating shared resources). - Add tests in the same folder tree when touching renderer components.
Use these guidelines whenever you work within this repository.