Skip to content

Refactor create-agent-dialog: extract hook and type select#737

Merged
selfcontained merged 1 commit into
mainfrom
agt_a13aabda560f/job-componentizer-2eb8e263
Jul 9, 2026
Merged

Refactor create-agent-dialog: extract hook and type select#737
selfcontained merged 1 commit into
mainfrom
agt_a13aabda560f/job-componentizer-2eb8e263

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

  • Extracted use-create-agent-form.ts (377 lines) — all form state, effects, callbacks, and the submit handler moved into a custom hook
  • Extracted agent-type-select.tsx (119 lines) — self-contained agent type dropdown combobox with its own open/close state management
  • create-agent-dialog.tsx reduced from 760 → 357 lines, now a thin render shell

Why this was a candidate

The create-agent dialog had 760 lines with 15+ useState hooks, 6 useEffect hooks, 9 useCallback handlers, and a complex submit handler — all mixed with a two-step form JSX. The hook extraction separates logic from presentation; the type select extracts a self-contained UI widget.

New file structure

create-agent-dialog.tsx          357 lines  (was 760) — render shell
use-create-agent-form.ts         377 lines  (new)     — form logic hook
agent-type-select.tsx            119 lines  (new)     — type dropdown
create-agent-dialog-utils.ts     (unchanged)          — prefs, cwd history
create-agent-dialog-clipboard.ts (unchanged)          — clipboard helpers
create-agent-worktree-section.tsx (unchanged)          — worktree UI

Next run

The next componentizer run will tackle feedback-panel.tsx (660 lines).

Test plan

  • pnpm run finalize:web — type check + production build pass
  • pnpm run test:e2e — all 172 tests pass (12 terminal-live skipped as expected)
  • Pre-commit hooks (prettier, eslint, tsc) pass

🤖 Generated with Claude Code

Split create-agent-dialog.tsx (760 → 357 lines) by extracting:
- use-create-agent-form.ts (377 lines): all form state, effects,
  callbacks, and the submit handler
- agent-type-select.tsx (119 lines): self-contained agent type
  dropdown combobox with its own open/close state

The dialog component is now a thin render shell that delegates
to the hook for logic and the AgentTypeSelect for the dropdown.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@selfcontained
selfcontained merged commit 073d915 into main Jul 9, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_a13aabda560f/job-componentizer-2eb8e263 branch July 9, 2026 01:01
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