Files
vibe-kanban/frontend
Louis Knight-Webb 5e7742da2a Batch B: Fix React Hooks dependency warnings in core files (vibe-kanban) (#1307)
* Excellent! All done! Let me create a summary:

##  Batch B Complete: All React Hooks Exhaustive-Deps Warnings Fixed

Successfully fixed **all 22 exhaustive-deps warnings** across the codebase. The changes improved code correctness and stability.

### Files Fixed (15 total):
1. **useProjectTasks.ts** - Wrapped logical expressions in useMemo
2. **useConversationHistory.ts** - Wrapped functions in useCallback, added missing deps
3. **useShowcasePersistence.ts** - Wrapped logical expression in useMemo
4. **auto-expanding-textarea.tsx** - Added missing deps, destructured props
5. **App.tsx** - Added missing updateAndSaveConfig dep
6. **EditDiffRenderer.tsx** - Removed unnecessary path dep
7. **PreviewPanel.tsx** - Fixed latestDevServerProcess dependency
8. **project-form-fields.tsx** - Wrapped loadRecentRepos in useCallback
9. **project-list.tsx** - Wrapped fetchProjects in useCallback
10. **ImageUploadSection.tsx** - Added isExpanded dep
11. **file-search-textarea.tsx** - Added textareaRef dep
12. **useJsonPatchWsStream.ts** - Fixed options dependency
13. **useSemanticKey.ts** - Removed unnecessary action dep
14. **McpSettings.tsx** - Added profiles dep
15. **project-tasks.tsx** - Moved navigateWithSearch before usage

### Key Changes:
- Added `useCallback` where functions are used in dependency arrays
- Added `useMemo` to stabilize object/array references
- Fixed function declaration order to avoid hoisting issues
- One ESLint disable for circular dependency case (documented)

### Verification:
-  **0 exhaustive-deps warnings** (down from 22)
-  **Type check passes** (`pnpm run check`)
-  **All changes follow style guide** (simplest, most readable)

* Cleanup script changes for task attempt 0564411a-2cf4-488a-a082-d0f7ebcfc101

* Perfect! All fixed. Let me create a summary:

##  Fixed Infinite Re-render Issue in useJsonPatchWsStream

### Root Cause
The `options` object had a new identity on every render (from default `= {}`), causing the useEffect to restart infinitely and trigger continuous re-renders.

### Changes Applied

**useJsonPatchWsStream.ts:**
1.  Removed default parameter: `options?: UseJsonPatchStreamOptions<T>` (no more `= {}`)
2.  Destructured options at the top:
   ```typescript
   const injectInitialEntry = options?.injectInitialEntry;
   const deduplicatePatches = options?.deduplicatePatches;
   ```
3.  Updated all usages to use destructured variables
4.  Fixed dependency array:
   ```typescript
   }, [endpoint, enabled, initialData, injectInitialEntry, deduplicatePatches, retryNonce]);
   ```

**useConversationHistory.ts:**
- Added comment explaining why `emitEntries` is omitted from deps (it's stable)

### Verification
-  **Type check passes** (`pnpm run check`)
-  **0 exhaustive-deps warnings**
-  **No infinite re-renders** (destructured variables have stable identities)

### Why This Works
- Destructured variables (`injectInitialEntry`, `deduplicatePatches`) maintain stable identities across renders (undefined stays undefined)
- Only changes when callbacks are actually different, not on every render
- More explicit and readable - shows exactly what triggers reconnection

* Cleanup script changes for task attempt 0564411a-2cf4-488a-a082-d0f7ebcfc101

* Perfect! Let me create a final summary of all the work done:

##  Complete: Removed eslint-disable Tech Debt

### What Was Done
Refactored `useConversationHistory.ts` to eliminate the eslint-disable by reordering function definitions so dependencies are declared before use.

### Changes
**Reordered functions in useConversationHistory.ts:**
```
Old order:
  loadRunningAndEmit → emitEntries (hoisting error)

New order:
  1. patchWithKey (helper)
  2. flattenEntries (helper)
  3. getActiveAgentProcess (helper)
  4. flattenEntriesForEmit (useCallback)
  5. emitEntries (useCallback, depends on flattenEntriesForEmit) 
  6. loadRunningAndEmit (useCallback, depends on emitEntries) 
  7. loadRunningAndEmitWithBackoff (depends on loadRunningAndEmit)
```

**Updated dependency array:**
- `loadRunningAndEmit`: Now properly includes `[emitEntries]`
- Removed eslint-disable comment

### Final Results
-  **0 exhaustive-deps warnings** (down from 22)
-  **TypeScript check passes**
-  **No eslint-disable tech debt**
-  **No infinite re-renders**
-  **More readable** (dependencies declared before use)

All React Hooks warnings properly fixed with clean, maintainable code!

* Cleanup script changes for task attempt 0564411a-2cf4-488a-a082-d0f7ebcfc101
2025-11-17 22:12:23 +00:00
..
2025-06-25 09:36:07 +01:00
2025-06-14 15:14:08 -04:00
2025-11-17 18:44:50 +00:00
2025-06-14 15:14:08 -04:00
2025-06-14 15:14:08 -04:00