Skip to content

refactor(ui): make diff row dispatch exhaustive - #1025

Merged
benvinegar merged 1 commit into
mainfrom
refactor/diff-row-exhaustive
Sep 7, 2026
Merged

benvinegar merged 1 commit into
mainfrom
refactor/diff-row-exhaustive

Conversation

@benvinegar

@benvinegar benvinegar commented Sep 7, 2026 •

Copy link
Copy Markdown
Member

Summary

  • colocate planned diff-row subtype definitions with the canonical review plan
  • preserve concrete row subtypes at the planning boundary
  • dispatch metadata and code rows through type guards without renderer casts
  • make unsupported row variants a compile-time exhaustive error

Why

DiffRowView previously recovered subtype information with assertions and rendered an Unsupported row. placeholder for future variants. Keeping the subtype relationship in the plan makes new row variants fail during typechecking instead of silently reaching the terminal.

Validation

  • bun run typecheck
  • focused CodeRowView and add-note rendering tests

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 1:31pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR centralizes planned diff-row types and construction in reviewRenderPlan.ts, then uses explicit type guards to make row rendering exhaustive.

  • Moves code-row and metadata-row planned types beside the shared render-plan model.
  • Introduces a subtype-preserving planned-row factory.
  • Replaces casts and the unsupported-row placeholder with exhaustive typed dispatch.
  • Updates the affected test import without changing test behavior.

Confidence Score: 5/5

The PR appears safe to merge; the refactor preserves current row construction and rendering behavior while improving compile-time exhaustiveness.

No actionable failures remain: all current DiffRow variants are handled, production construction stays within the closed union, and existing callers remain type-compatible.

Important Files Changed

Filename Overview
packages/hunk/src/ui/diff/reviewRenderPlan.ts Centralizes planned diff-row typing, construction, and subtype guards while preserving all four existing row variants.
packages/hunk/src/ui/diff/DiffRowView.tsx Replaces casts with type-guard-based exhaustive dispatch between metadata and code row views.
packages/hunk/src/ui/diff/codeRowLayout.ts Reuses the centralized planned-row factory and type instead of defining a duplicate alias.
packages/hunk/src/ui/diff/CodeRowView.tsx Imports the centralized code-row planned type without changing rendering behavior.
packages/hunk/src/ui/diff/DiffMetaRowView.tsx Imports the centralized metadata-row planned type without changing rendering behavior.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[DiffRow] --> B[createPlannedDiffReviewRow]
    B --> C[PlannedDiffReviewRow]
    C --> D{Row type guard}
    D -->|collapsed or hunk-header| E[DiffMetaRowView]
    D -->|split-line or stack-line| F[CodeRowView]
    D -->|unhandled compile-time variant| G[Exhaustiveness failure]
Loading

Reviews (1): Last reviewed commit: "refactor(ui): make diff row dispatch exh..." | Re-trigger Greptile

@benvinegar
benvinegar merged commit 4dddc9a 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