Skip to content

refactor(web): extract clipboard hook and item subcomponents from context-picker#764

Merged
selfcontained merged 2 commits into
mainfrom
agt_a921933e3444/job-componentizer-53caa149
Jul 13, 2026
Merged

refactor(web): extract clipboard hook and item subcomponents from context-picker#764
selfcontained merged 2 commits into
mainfrom
agt_a921933e3444/job-componentizer-53caa149

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

Summary

  • Extracted use-context-picker-clipboard.ts (142 lines) — a custom hook encapsulating all clipboard-related state (4 useState, 3 useRef) and handlers (handleCheckClipboard, handleClipboardPasteInput, handleClipboardPasteBlur, handlePaste) from context-picker.tsx.
  • Extracted context-picker-items.tsx (85 lines) — ContextFileItem and ContextLinkItem subcomponents for file thumbnail and link badge rendering.
  • Deduplicated the popover content JSX that was repeated in both the empty-state and has-items branches into a shared popoverContent variable.

Result: context-picker.tsx reduced from 609 → 441 lines. The component now has 3 useState hooks (down from 7) and the render tree is easier to follow.

New file structure

context-picker.tsx              (441 lines — main component + small inline helpers)
use-context-picker-clipboard.ts (142 lines — clipboard logic hook)
context-picker-items.tsx         (85 lines — file/link item renderers)

Next run

changes-tab.tsx (893 lines) is queued as the next componentizer target.

Test plan

  • TypeScript type check passes (pnpm run check:web)
  • Production build succeeds (pnpm run build:web)
  • E2E tests pass (122/123, 1 pre-existing split-pane flake)
  • Purely structural — no behavior or UI changes

🤖 Generated with Claude Code

selfcontained and others added 2 commits July 13, 2026 02:09
…text-picker

Split context-picker.tsx (609 → 441 lines) by extracting:
- use-context-picker-clipboard.ts (142 lines): all clipboard state, refs, and
  handlers (checkClipboard, pasteInput, pasteFeedback) into a custom hook
- context-picker-items.tsx (85 lines): ContextFileItem and ContextLinkItem
  subcomponents for file thumbnail and link badge rendering

Also deduplicated the popover content JSX that was repeated in both the
empty-state and has-items branches.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Address architecture review feedback: rename stuttery hook return keys
(e.g. clipboard.clipboardPasteMode → clipboard.pasteMode) since the
clipboard namespace already provides context.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@selfcontained selfcontained merged commit 8297bb2 into main Jul 13, 2026
1 check passed
@selfcontained selfcontained deleted the agt_a921933e3444/job-componentizer-53caa149 branch July 13, 2026 08:19
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