Split unified-diff-view.tsx into focused modules - #883
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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,languageFromPathunified-diff-utils.ts(121) —LineSelectiontype plus the pure hunk helpers:tokenizeHunksIndependently,getNewLineNumber,collectSelectedChangeKeys,findLastChangeKeyInRangeuse-diff-widgets.tsx(172) —useDiffWidgetshook 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 positioningThe test file moved with the utilities it covers (
unified-diff-view.test.ts→unified-diff-utils.test.ts).changes-tab.tsxandchanges-diff-section.tsxnow importLineSelection/findLastChangeKeyInRangefromunified-diff-utils.Purely structural — no behavior change. The widgets
useMemomoved 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:webgreenpnpm run test:e2egreen (175 passed)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