* Add formatting conventions * Add a fmt lint check * rely on defaults --------- Co-authored-by: Julius Marminge <[email protected]>
1.3 KiB
1.3 KiB
Plan: Strengthen Typed IPC Boundaries in Main Process
Summary
Replace loose payload casting in IPC handlers with strict schema parsing and typed helper wrappers.
Motivation
apps/desktop/src/main.tscurrently uses casts likepayload as Parameters<...>.- Casts can hide contract breakages until runtime.
Scope
- Desktop main process IPC registration.
- Optional shared helper for handler registration.
Proposed Changes
- Add IPC helper utility (e.g.
apps/desktop/src/ipcHelpers.ts) to:- Parse payload(s) with Zod schemas
- Standardize typed handler signatures
- Refactor provider IPC handlers in
apps/desktop/src/main.tsto use:providerSessionStartInputSchema.parseproviderSendTurnInputSchema.parseproviderInterruptTurnInputSchema.parseproviderStopSessionInputSchema.parse
- Apply same pattern to agent/terminal handlers where possible.
- Add tests for handler parsing failure paths (invalid payloads).
Risks
- Refactor can subtly change IPC error shape/messages.
- Helper abstraction should stay simple and not obscure control flow.
Validation
bun run testbun run typecheck- Manual invalid payload check from renderer/devtools to confirm fast failure.
Done Criteria
- No provider handler uses
payload as Parameters<...>. - All IPC entrypoints parse unknown payloads at boundary.