Skip to content

fix(web): explain binary files in PR code diffs - #33919

Open
voltcrash wants to merge 7 commits into
pingdotgg:mainfrom
voltcrash:t3/pr-binary-file-fallback
Open

voltcrash wants to merge 7 commits into
pingdotgg:mainfrom
voltcrash:t3/pr-binary-file-fallback

Conversation

@voltcrash

Copy link
Copy Markdown
Contributor

PNG changes in the PR Code tab expanded to blank content because the parser dropped their binary markers. Retain those markers and show “Binary file” with a link to the change on its host, visible whether the file is folded or expanded. GitHub links point to the file in Files changed.

Fixes #33909. This is a small, focused fix for the blank binary state. Empty text files, pure renames, omitted text patches, and LFS pointer hunks are not classified as binary.

Proof: the focused parser regression failed before the fix and passes afterward; the parser and existing Code-tab suites pass (23 tests). vp run check:changed passes after rebasing onto upstream main.

I reproduced the before/after in the isolated development client with two binary PNGs and two text changes, checked collapse/expand, pagination and a 900px viewport, then opened real PR #14254 and clicked its new link through to the matching GitHub file anchor. Browser-panel screenshots repeatedly timed out, so the captures use isolated Chromium against the same dev client. Desktop shares this renderer; native mobile rendering is unchanged.

Before — expanded PNG rows have no explanation:

Before: binary rows expand to blank content

After — binary rows have an explanation and host link:

After: binary rows show Binary file and View on GitHub

Additional captures: narrow layout, folded rows, pagination, and real GitHub navigation.

Other hosts link to their change-request page; selected-commit links target the whole PR. Full image previews are outside this fix.

Reviewed with review-loop: 1 round with Claude Opus 5.5. Reviewer verdict: approved.
Created with GPT-6.1 Sol on xhigh in the Codex harness.

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Nov 10, 2026
@macroscopeapp

macroscopeapp Bot commented Nov 10, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved at 52c6fc0

Macroscope's review found this PR approvable — Binary diffs now show a clear label and a link to the source-control provider instead of misleading line counts. The change is limited to display metadata and navigation, with existing text-diff behavior preserved.

You can add or adjust custom eligibility rules. Learn more.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • Resume reviews
  • Trigger review

No actionable comments were generated in the recent review.

Walkthrough

The GitHub adapter marks qualifying patchless changes as binary. The diff parser returns binary file identities. The pull request Code tab uses those identities to collapse binary files and show a “Binary file” label with a provider link. Other files retain their addition and deletion statistics.

Changes: Binary file indicators

Layer / File(s) Summary
Mark patchless GitHub changes as binary
packages/source-control-github/src/server/gitHubPullRequestJson.ts, packages/source-control-github/src/server/gitHubPullRequestJson.test.ts
The GitHub adapter adds a binary marker when a file has no patch, zero additions and deletions, a qualifying status, and a SHA other than the empty-blob SHA. The test checks the empty-blob exception.
Detect binary files in parsed diffs
apps/web/src/lib/diffRendering.ts, apps/web/src/lib/diffRendering.test.ts
getRenderablePatch identifies sections with binary markers or Git binary patches and returns file identity keys. Tests cover marker cases and hunkless files under both whitespace settings.
Render binary file headers
apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
The Code tab collects binary identities across parsed slices and collapses binary files. Binary headers show a label and provider link. GitHub links use a SHA-256 path diff anchor; other providers link to the pull request.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Severity of issue fixed: Low

Possibly related PRs

  • pingdotgg/t3code#27833: Memoizes parsed diff slices and file models used by the Code tab, which now also consumes binary file identities.
  • pingdotgg/t3code#22697: Caches parsed patches in the Code tab, connecting to this change’s expanded parsed patch result.
  • pingdotgg/t3code#28841: Changes Code tab file-header statistics, which this pull request replaces with a binary label and link for binary files.

Suggested reviewers: juliusmarminge, maria-rcks

Merge Risk: Minimal · up to c1c88

The change makes binary files such as PNGs show a "Binary file" label with a link to the host instead of a blank row. No merge-blocking risk was found. Patchless mode-only changes might be labelled as binary, which is a minor cosmetic edge.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: binary files in PR code diffs now get an explanation. It follows the conventional commit form with the web scope. The title matches the linked issue #33909 and the obj…
Description check Passed The description follows the template. It gives the problem (blank expanded PNG rows), the change (retained binary markers, a "Binary file" label, and a host link), scope (links to fixed issue #33909 a…
Linked Issues check Passed For [#33909], the head now restores the binary marker at the data boundary. In packages/source-control-github/src/server/gitHubPullRequestJson.ts, toFilesPatch marks an entry as binary when it has…
Out of Scope Changes check Passed All inspected changes support the binary-file explanation and host link for [#33909]. The new adapter logic in gitHubPullRequestJson.ts (optional sha field, EMPTY_BLOB_SHA guard, binary marker) …
Full details: Title check

Explanation

The title names the main change: binary files in PR code diffs now get an explanation. It follows the conventional commit form with the web scope. The title matches the linked issue #33909 and the objectives, which describe showing a "Binary file" label and host link in place of blank content.

Full details: Description check

Explanation

The description follows the template. It gives the problem (blank expanded PNG rows), the change (retained binary markers, a "Binary file" label, and a host link), scope (links to fixed issue #33909 and explicit exclusions), and verification (focused parser regression, 23 passing tests, check:changed, manual and browser checks, and screenshots). It also names the model and harness used, as the template asks. The Problem and Change sections are brief, but they are complete enough for review.

Full details: Linked Issues check

Explanation

For [#33909], the head now restores the binary marker at the data boundary. In packages/source-control-github/src/server/gitHubPullRequestJson.ts, toFilesPatch marks an entry as binary when it has no hunks, zero additions and deletions, a status of added, removed, or modified, and a sha other than the empty-blob SHA. It then emits Binary files ${from} and ${to} differ. This covers the files-API shape the issue reports: two PNGs with zero counts and no patch. The empty-blob exclusion keeps empty text files non-binary. The earlier binary-header scan in apps/web/src/lib/diffRendering.ts keeps the marker through Pierre parsing. PullRequestCodeTab.tsx then forces the row collapsed and shows a Binary file label with a host link in the stat slot, visible when folded or expanded. The issue allows an explicit binary-file message with a way to view the image in place of a preview, so the absence of a preview does not fail this check. Added tests cover the adapter (gitHubPullRequestJson.test.ts) and the classification (diffRendering.test.ts). Limits: the GitHub sha semantics for removed and modified entries, the GitHub anchor format, and the rendered UI were not independently verified here. The author's real PR #14254 navigation and Chromium captures were not reviewed.

Full details: Out of Scope Changes check

Explanation

All inspected changes support the binary-file explanation and host link for [#33909]. The new adapter logic in gitHubPullRequestJson.ts (optional sha field, EMPTY_BLOB_SHA guard, binary marker) addresses the files-API root cause. Its from/to path refactor keeps the same quoting and /dev/null rules and feeds the marker line, so it supports the same change. The diffRendering.ts scan, the diffModel plumbing, the forced collapse, the stat-slot label, and the GitHub anchor helper all serve the same explanation and link. The tests cover the same behavior. No change was found that is unrelated to binary-file explanation. No full image preview or native mobile code was added, which matches the stated scope.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between bcd1a00 and c1c888c.

Files selected for processing: 2

  • packages/source-control-github/src/server/gitHubPullRequestJson.test.ts
  • packages/source-control-github/src/server/gitHubPullRequestJson.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@coderabbitai coderabbitai Bot left a comment

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.

Additional comments: 1

apps/web/src/components/pullRequest/PullRequestCodeTab.tsx: 1

924-927: Trivial · Maintainability & Code Quality · Low value

Unverified finding
Verification ran but could not confirm this finding. It is shown for review, not as a verified issue.

Verify the GitHub anchor hash and the non-GitHub fallback link.

The GitHub link uses #diff-<sha256(path)>. This matches GitHub's Files changed anchor format as commonly observed. It is not a documented contract. If GitHub changes the format, the link still opens the Files changed tab but does not scroll to the file.

For renamed binary files, path is the new name. Confirm that GitHub anchors on the new name.

Also, the long inline hash expression is hard to read. Extract it into a small helper such as githubDiffAnchor(path).

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 20c3dd3 and 52c6fc0.

Files selected for processing: 3

  • apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
  • apps/web/src/lib/diffRendering.test.ts
  • apps/web/src/lib/diffRendering.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.

@voltcrash

Copy link
Copy Markdown
Contributor Author

Note

🤖 GPT-6.1 Sol responding on behalf of voltcrash

The advisory anchor/helper finding needs no code change for the reported added-PNG case. I clicked the generated link from T3 on real PR #14254 and confirmed the matching GitHub Files changed anchor; the runtime evidence includes that pass. The non-GitHub fallback intentionally uses the existing change-request URL. Rename-specific GitHub navigation was not exercised; path resolution uses the destination filename, and an absent anchor still opens Files changed. I’m keeping the single-use hash inline rather than adding a helper solely for this expression.

…lback

# Conflicts:
#	apps/web/src/components/pullRequest/PullRequestCodeTab.tsx
@maria-rcks

Copy link
Copy Markdown
Collaborator

Note

Written by claude-opus-5-5 on behalf of Maria

Merged current main (merge commit fe95c1e1ff, no rebase) to clear the conflict in PullRequestCodeTab.tsx. The only overlap was the import block: main dropped the lucide chevron import, this PR added sha256. The resolution keeps both. No other code changed. vp run check:changed passes (format, lint, knip, typecheck, diffRendering.test.ts, React compiler).

juliusmarminge and others added 4 commits November 12, 2026 20:05
AI-assisted; verified with the tests and tools listed above.
Expanding a binary file row revealed an empty body. Binary rows now stay
folded and drop their expand chevron, so the header's Binary file label
and host link are the whole row.

AI-assisted; verified with the tests and tools listed above.
…lback

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@juliusmarminge
juliusmarminge force-pushed the t3/pr-binary-file-fallback branch from 8e4e787 to bcd1a00 Compare November 13, 2026 00:05
GitHub's files API sends a binary change as an entry with no patch and no line counts, so the assembled patch had no 'Binary files ... differ' line and the Code tab could not tell a PNG from an empty row. Restore git's marker for those entries, except the empty blob.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PNG files in PR Code tab expand to blank content

3 participants