Skip to content

Split unified-diff-view.tsx into focused modules - #883

Merged
selfcontained merged 1 commit into
mainfrom
agt_89e4391d00ed/job-componentizer-239e8167
Aug 6, 2026
Merged

Split unified-diff-view.tsx into focused modules#883
selfcontained merged 1 commit into
mainfrom
agt_89e4391d00ed/job-componentizer-239e8167

Conversation

@selfcontained

Copy link
Copy Markdown
Owner

What

unified-diff-view.tsx (603 lines) was the top item in the componentizer backlog: it mixed refractor setup, language mapping, hunk tokenization utilities, widget construction, and the render shell in a single file.

New structure:

  • unified-diff-language.ts (118) — refractor language registrations, the highlight adapter, extension/filename→language maps, languageFromPath
  • unified-diff-utils.ts (121) — LineSelection type plus the pure hunk helpers: tokenizeHunksIndependently, getNewLineNumber, collectSelectedChangeKeys, findLastChangeKeyInRange
  • use-diff-widgets.tsx (172) — useDiffWidgets hook that builds the widget map (feedback annotations, draft annotations, inline comment form)
  • unified-diff-view.tsx (269, was 603) — render shell: diff parsing, tokenization, gutter events, selection, comment-button positioning

The test file moved with the utilities it covers (unified-diff-view.test.tsunified-diff-utils.test.ts). changes-tab.tsx and changes-diff-section.tsx now import LineSelection / findLastChangeKeyInRange from unified-diff-utils.

Purely structural — no behavior change. The widgets useMemo moved into the hook with an identical dependency list, and the two DOM effects stayed in the shell in their original registration order.

Validation

  • pnpm run finalize:web green
  • pnpm run test:e2e green (175 passed)
  • Unit test green after rename
  • Playwright visual pass on a seeded dev stack: syntax-highlighted diff, line selection, floating comment button, and inline comment form all render and function as before

Queued next

agent-card-header.tsx (254) is the top remaining backlog item — status badge stack and rename-prompt hook are the candidate extractions if it grows.

🤖 Generated with Claude Code

unified-diff-view.tsx (603 lines) mixed refractor setup, language
mapping, hunk tokenization utilities, widget construction, and the
diff render shell in one file. Split it into:
- unified-diff-language.ts (118): refractor registrations, adapter,
extension/filename-to-language maps, languageFromPath
- unified-diff-utils.ts (121): LineSelection type,
tokenizeHunksIndependently, getNewLineNumber,
collectSelectedChangeKeys, findLastChangeKeyInRange
- use-diff-widgets.tsx (172): useDiffWidgets hook building the
feedback/draft/comment-form widget map
- unified-diff-view.tsx (269): render shell with parsing, gutter
events, selection, and button positioning effects
The test file follows the utilities it covers, renamed to
unified-diff-utils.test.ts. Import sites (changes-tab,
changes-diff-section) now import LineSelection and
findLastChangeKeyInRange from unified-diff-utils.
Purely structural — no behavior change.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@selfcontained
selfcontained merged commit 6c28624 into mainAug 6, 2026
1 check passed
@selfcontained
selfcontained deleted the agt_89e4391d00ed/job-componentizer-239e8167 branch August 6, 2026 08:15
Sign up for freeto 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

@selfcontained