Skip to content

Optimize Height Estimation#718

Open
amadeus wants to merge 6 commits into
mainfrom
amadeus/cache-estimated-heights
Open

Optimize Height Estimation#718
amadeus wants to merge 6 commits into
mainfrom
amadeus/cache-estimated-heights

Conversation

@amadeus
Copy link
Copy Markdown
Member

@amadeus amadeus commented May 20, 2026

This is a pass at optimizing how we estimate height, yet another piece of the puzzle that can potentially improve performance in certain scenarios.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

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

Project Deployment Actions Updated (UTC)
pierre-docs-diffshub Ready Ready Preview May 21, 2026 12:24am
pierre-docs-trees Ready Ready Preview May 21, 2026 12:24am
pierrejs-diff-demo Ready Ready Preview May 21, 2026 12:24am
pierrejs-docs Ready Ready Preview May 21, 2026 12:24am

Request Review

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: d60fd50625

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines 124 to 129
const item: CodeViewItem<CommentMetadata> = {
id,
type: 'diff',
collapsed: fileDiff.type === 'deleted',
fileDiff,
version: 0,
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Preserve default collapsing for deleted diff items

This constructor no longer sets collapsed for deleted files, so type: 'deleted' entries now render expanded by default in Diffshub. On large patches with big deleted files, that forces full deleted-content layout/render work up front (instead of deferring it behind collapse), which is a user-visible performance regression compared to prior behavior.

Useful? React with 👍 / 👎.

amadeus added 6 commits May 20, 2026 17:23
Create small reusable utilities for the estimate helper and existing virtual
layout code.

- Extract or share the `getExpandedRegion` logic currently inside
  `iterateOverDiff` so expansion math cannot drift.
- Add a separator estimate helper that mirrors renderer/CSS behavior.
- Keep these helpers pure and independent of `VirtualizedFileDiff`
  instance state.

Separator helper rules:

- `simple`: render only when `hunkIndex > 0`; height is
  `metrics.hunkSeparatorHeight ?? 4`.
- `metadata`: render only when `hunkSpecs != null`; height is
  `metrics.hunkSeparatorHeight ?? 32`.
- `line-info-basic`: height is `metrics.hunkSeparatorHeight ?? 32`.
- `line-info`: height is `metrics.hunkSeparatorHeight ?? 32`, plus
  top/bottom spacing based on first/last position.
- `line-info`: omit top gap for `isFirstHunk`.
- `line-info`: omit bottom gap for `isLastHunk`.
- `custom`: estimate like `line-info` unless we decide to force custom
  separators to be measurement-only later.
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