Visitar URL original
refactor(ui): extract diff selection controller by benvinegar · Pull Request #1037 · modem-dev/hunk · GitHub
Skip to content

refactor(ui): extract diff selection controller - #1037

Merged
benvinegar merged 1 commit into
mainfrom
refactor/diffpane-selection-controller
Sep 7, 2026
Merged

benvinegar merged 1 commit into
mainfrom
refactor/diffpane-selection-controller

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • move pointer, keyboard, clipboard, comment, and invalidation state into useDiffSelectionController
  • extract the contextual Comment/Copy/Clear surface into SelectionActionBar
  • return complete action-bar bounds from the pure planner so rendering does not recompute width
  • preserve DiffPane as the authority for review geometry and pass one canonical selection context into the controller

Validation

  • bun run format
  • bun run lint
  • bun run typecheck
  • bun run deps:check
  • bun run test (2,118 passed, 10 skipped)
  • focused selection/component suite (184 passed)
  • focused PTY multiline-selection test
  • three independent subagent reviews

This PR description was generated by Pi using gpt-5.6-sol

@vercel

vercel Bot commented Sep 7, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
hunk-web Ignored Ignored Preview Sep 7, 2026 6:47pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR separates DiffPane’s persistent selection behavior and contextual action-bar rendering without changing the pane’s authority over review geometry.

  • Moves pointer, keyboard, clipboard, comment, cancellation, and invalidation coordination into useDiffSelectionController.
  • Extracts the contextual Comment/Copy/Clear UI into SelectionActionBar.
  • Makes the pure action-bar planner return its complete bounds, including the pane-clamped width.
  • Adds focused planner and component coverage while retaining existing DiffPane integration coverage.

Confidence Score: 5/5

The PR appears safe to merge, with no concrete correctness, security, or repository-rule issues identified.

The refactor preserves existing selection semantics, keeps review geometry in DiffPane, and consistently reconnects selection painting, commands, cancellation, and action-bar interactions through the extracted controller.

Important Files Changed

Filename Overview
packages/hunk/src/ui/components/panes/DiffPane.tsx Replaces inline selection state and handlers with the extracted controller while retaining canonical geometry and event wiring.
packages/hunk/src/ui/components/panes/useDiffSelectionController.ts Encapsulates persistent pointer and keyboard selection state, clipboard and comment actions, invalidation, and action-bar planning.
packages/hunk/src/ui/components/panes/SelectionActionBar.tsx Renders the planned contextual selection actions while suppressing native selection and pointer propagation.
packages/hunk/src/ui/components/panes/copySelection.ts Extends the pure action-bar placement result with its final pane-clamped width.
packages/hunk/src/ui/components/panes/SelectionActionBar.test.tsx Covers configurable labels, disabled reasons, compact layout, native-selection cleanup, and pointer callback routing.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  DP[DiffPane geometry and cursor state] --> CTX[Canonical CopySelectionContext]
  CTX --> CTRL[useDiffSelectionController]
  EVT[Pointer and keyboard events] --> CTRL
  CTRL --> PAINT[Selected row ranges and side]
  CTRL --> ACT[Copy, Comment, and Clear actions]
  CTRL --> VM[SelectionActionBar view model]
  VM --> BAR[SelectionActionBar]
  PAINT --> DP
  BAR --> ACT
Loading

Reviews (1): Last reviewed commit: "refactor(ui): extract diff selection con..." | Re-trigger Greptile

@benvinegar
benvinegar enabled auto-merge (squash) September 7, 2026 18:53
@benvinegar
benvinegar merged commit 9c58ac1 into main Sep 7, 2026
13 checks passed
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