Skip to content

refactor(ui): require planned diff rows - #1019

Merged
benvinegar merged 1 commit into
refactor/diff-row-inline-dispatchfrom
refactor/diff-row-planned-input
Sep 7, 2026
Merged

refactor(ui): require planned diff rows#1019
benvinegar merged 1 commit into
refactor/diff-row-inline-dispatchfrom
refactor/diff-row-planned-input

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • require canonical planned rows at the DiffRowView boundary
  • move raw-row compatibility into a focused, memoized RawDiffRowView adapter
  • route the extension current-line projection and renderer-focused tests through that adapter

Why

The former facade accepted both or neither of plannedRow and row, while adapter-only props were silently ignored for planned input. Separating the contracts makes the primary review path explicit and keeps the one renderer-only raw projection supported.

Stack

  1. refactor(ui): use default diff row memo comparison #1017 — default memo comparison
  2. refactor(ui): inline diff row dispatch #1018 — inline diff-row dispatch
  3. This PR — require planned diff-row input

Merge bottom to top. This PR is based on refactor/diff-row-inline-dispatch.

Validation

  • bun run typecheck
  • bun run test
  • bun run test:integration
  • bun run test:tty-smoke
  • focused OpenTUI, current-line, and code-cell tests after the final memoization adjustment

All passed. No user-visible rendering behavior changes, so no new visual evidence was captured.

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 12:43pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes canonical planned rows mandatory at the DiffRowView boundary and moves raw-row compatibility into a dedicated memoized adapter.

  • Migrates the extension current-line projection to RawDiffRowView.
  • Routes renderer-focused tests through the raw-row adapter.
  • Preserves the former raw-to-planned conversion and prop-forwarding behavior.
  • Adds an empty changeset for the refactor.

Confidence Score: 4/5

The runtime refactor appears sound, but the explicit test-import requirement must be satisfied before merging.

Production callers use the correct planned or raw-row boundary, and the adapter preserves the former conversion behavior; the remaining finding is a repository-rule violation in the changed test import.

Files Needing Attention: packages/hunk/src/ui/components/ui-components.test.tsx

Important Files Changed

Filename Overview
packages/hunk/src/ui/diff/DiffRowView.tsx Narrows the component contract to require canonical planned rows and retains type-based row dispatch.
packages/hunk/src/ui/diff/RawDiffRowView.tsx Adds a memoized compatibility adapter that converts raw rows into planned rows before rendering.
packages/hunk/src/ui/lib/extensionCurrentLine.tsx Routes the extension current-line projection through the raw-row adapter without changing supplied rendering properties.
packages/hunk/src/ui/components/ui-components.test.tsx Migrates renderer-focused cases to the raw adapter but adds a dynamic test import contrary to the repository testing instruction.
packages/hunk/src/ui/diff/CodeCellView.test.tsx Updates code-cell test helpers to exercise raw-row rendering through the dedicated adapter.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
    A[Shared review render plan] -->|plannedRow| B[DiffRowView]
    C[Renderer-only raw row] --> D[RawDiffRowView]
    D -->|legacyPlannedDiffRow| B
    B --> E[DiffMetaRowView]
    B --> F[CodeRowView]
Loading
Prompt To Fix All With AI
### Issue 1
packages/hunk/src/ui/components/ui-components.test.tsx:44
**Dynamic Test Import**

The new `RawDiffRowView` dependency is loaded with `await import(...)`. This violates the repository testing directive to hoist imports to the top level and avoid dynamic imports in tests. This requirement must be satisfied before merging.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "refactor(ui): require planned diff rows" | Re-trigger Greptile

const { measurePlannedRenderedRowHeight, measureRenderedRowHeight } =
await import("../diff/codeRowLayout");
const { DiffRowView } = await import("../diff/DiffRowView");
const { RawDiffRowView } = await import("../diff/RawDiffRowView");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Dynamic Test Import

The new RawDiffRowView dependency is loaded with await import(...). This violates the repository testing directive to hoist imports to the top level and avoid dynamic imports in tests. This requirement must be satisfied before merging.

Context Used: testing.mdc Cursor rule (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/hunk/src/ui/components/ui-components.test.tsx
Line: 44

Comment:
**Dynamic Test Import**

The new `RawDiffRowView` dependency is loaded with `await import(...)`. This violates the repository testing directive to hoist imports to the top level and avoid dynamic imports in tests. This requirement must be satisfied before merging.

**Context Used:** testing.mdc Cursor rule ([source](https://github.com/modem-dev/modem/blob/main/.cursor/rules/testing.mdc))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this as a dynamic import is intentional and consistent with the surrounding UI-component imports in this test module. These components are loaded after the test harness dependencies are initialized; hoisting only the new adapter would make its initialization order differ from DiffRowView and the other UI components it exercises.

Responded by Pi using gpt-5.6-sol.

This comment was generated by Pi using gpt-5.6-sol

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That’s fair. The test module intentionally initializes the harness before dynamically importing the UI components, and RawDiffRowView follows the same pattern as DiffRowView and the surrounding components. Hoisting only this import would be inconsistent and could alter initialization order, so this is not an issue. I’m retracting the comment.

@benvinegar
benvinegar force-pushed the refactor/diff-row-planned-input branch from 226b388 to 155e912 Compare September 7, 2026 12:43
@benvinegar
benvinegar merged commit b366f3c into main Sep 7, 2026
12 of 20 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