Problem
useGatewayBootstrap is a god hook that handles 6 distinct concerns in a single function:
- Gateway dispatcher singleton initialization
- Event listener registration (status, catalogs, version)
- Task store subscription for ensemble hydration
- Performer candidate callback registration
- Approval handler wiring
- Debug event listener setup
This makes the hook hard to test, reason about, and modify without risking side effects in unrelated concerns.
Location
File: packages/desktop/src/renderer/hooks/useGatewayBootstrap.ts
Fix Approach
Split into focused hooks:
// useGatewayDispatcherSetup.ts — responsibility 1
export function useGatewayDispatcherSetup() { ... }
// useGatewayEventListeners.ts — responsibility 2
export function useGatewayEventListeners(dispatcher: GatewayDispatcher) { ... }
// useEnsembleSync.ts — responsibilities 3-4
export function useEnsembleSync(dispatcher: GatewayDispatcher) { ... }
// The original hook becomes a thin orchestrator:
export function useGatewayBootstrap() {
const dispatcher = useGatewayDispatcherSetup();
useGatewayEventListeners(dispatcher);
useEnsembleSync(dispatcher);
}
Verification
- Run
pnpm check — must pass
- Connect to gateway, create task, verify session events flow correctly
Context
- WG: UI & Design System + Task & Session Core
- Priority: Medium
- Estimated effort: ~1 hour
Problem
useGatewayBootstrapis a god hook that handles 6 distinct concerns in a single function:This makes the hook hard to test, reason about, and modify without risking side effects in unrelated concerns.
Location
File:
packages/desktop/src/renderer/hooks/useGatewayBootstrap.tsFix Approach
Split into focused hooks:
Verification
pnpm check— must passContext