Skip to content

fix(client): silence react-hooks/incompatible-library on AgentSettingsTab#129

Merged
jackmusick merged 2 commits intomainfrom
fix/react-hooks-71-sweep
Apr 27, 2026
Merged

fix(client): silence react-hooks/incompatible-library on AgentSettingsTab#129
jackmusick merged 2 commits intomainfrom
fix/react-hooks-71-sweep

Conversation

@jackmusick
Copy link
Copy Markdown
Owner

Summary

Partial progress on #74. Replaces 4 `form.watch(name)` calls in `AgentSettingsTab.tsx` with `useWatch({ control: form.control, name })` to satisfy `react-hooks/incompatible-library`. Also aligns 3 `useMemo` deps from `toolsGrouped?.workflow` to `toolsGrouped` so the React Compiler's inferred deps match the manual ones (`react-hooks/preserve-manual-memoization`).

Lint: 2 warnings → 1.

Deferred

The remaining warning is on `FormRenderer.tsx:598` (`const formValues = watch();`). Applying the same substitution here is mechanically possible, but it unblocks the React Compiler which then surfaces 5 pre-existing latent issues in the same file (set-state-in-effect, ref deps, ref writes during render). Those need a real refactor of the form's data-provider auto-fill ref-bridge — too risky for this PR. Tracked in #74 (which stays open for that follow-up).

Test plan

  • `npm run tsc` clean
  • `npm run lint` → 1 warning, 0 errors (was 2)
  • `npm test` → 766/766 vitest passes
  • `AgentSettingsTab.test.tsx` (sibling) passes 11/11

🤖 Generated with Claude Code

…sTab

Replace `form.watch(name)` calls with `useWatch({ control, name })` so the
React Compiler can memoize the component. `watch()` returns a function
reference that cannot be safely memoized (react-hooks 7.1's
`incompatible-library` rule).

Also align the deps of two `useMemo` calls with what React Compiler infers
(`toolsGrouped` instead of `toolsGrouped?.workflow`) to keep manual
memoization preservable. Behaviorally a no-op since `toolsGrouped`
identity changes only when `workflow` does in the calling code paths.

Rule categories addressed:
- react-hooks/incompatible-library (4 sites in AgentSettingsTab)
- react-hooks/preserve-manual-memoization (3 sites in AgentSettingsTab)

Verification: `npm run lint` reports 0 errors and 1 warning (down from
2). `npm run tsc` clean. Vitest 766/766 passing.

Deferred — `client/src/components/forms/FormRenderer.tsx:598` still
emits one `react-hooks/incompatible-library` warning for the bare
`watch()` snapshot. Fixing it (substituting `useWatch({ control })`)
unblocks the React Compiler, which then surfaces 5 pre-existing latent
bugs in that file (`react-hooks/refs` × 4, `react-hooks/set-state-in-effect`
× 1) — the data-provider/auto-fill ref-bridge architecture writes refs
during render and reads them from effect deps. Resolving those needs
the broader sweep tracked in #74; tackling it here would exceed the
30-min budget for this small fix and risk behavioral regressions.

Refs #74

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jackmusick jackmusick enabled auto-merge (squash) April 27, 2026 01:38
@jackmusick jackmusick merged commit 72a50cb into main Apr 27, 2026
13 checks passed
@jackmusick jackmusick deleted the fix/react-hooks-71-sweep branch April 27, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant