Problem
useContextFolders.ts contains 7 separate typeof window.clawwork.xxx === 'function' checks for the same set of IPC methods:
Location
File: packages/desktop/src/renderer/components/ChatInput/useContextFolders.ts
// Line 17
if (typeof window.clawwork.unwatchContextFolder === 'function') { ... }
// Line 22
if (typeof window.clawwork.watchContextFolder === 'function') { ... }
// Line 35
if (typeof window.clawwork.unwatchContextFolder === 'function') { ... }
// Line 43
if (typeof window.clawwork.selectContextFolder !== 'function' || typeof window.clawwork.watchContextFolder !== 'function') { return; }
// Line 63
if (typeof window.clawwork.unwatchContextFolder === 'function') { ... }
// Line 82
if (typeof window.clawwork.listContextFiles !== 'function') { ... }
Fix Approach
Option A: Check once at the top of the hook:
const isContextFolderApiAvailable =
typeof window.clawwork.unwatchContextFolder === 'function' &&
typeof window.clawwork.watchContextFolder === 'function' &&
typeof window.clawwork.selectContextFolder === 'function' &&
typeof window.clawwork.listContextFiles === 'function';
Then use the single boolean in all branches.
Option B: If the API always exists (check preload types), remove all guards entirely and trust the TypeScript declarations.
Verification
- Run
pnpm check — must pass
- Add a context folder, remove it, switch tasks — verify watch/unwatch still works
Context
- WG: UI & Design System
- Priority: Low (good first issue)
- Estimated effort: ~10 minutes
Problem
useContextFolders.tscontains 7 separatetypeof window.clawwork.xxx === 'function'checks for the same set of IPC methods:Location
File:
packages/desktop/src/renderer/components/ChatInput/useContextFolders.tsFix Approach
Option A: Check once at the top of the hook:
Then use the single boolean in all branches.
Option B: If the API always exists (check preload types), remove all guards entirely and trust the TypeScript declarations.
Verification
pnpm check— must passContext