Skip to content

fix(desktop): stop showing /dev/null in diff labels, keep type badge visible#1704

Merged
baxen merged 4 commits into
mainfrom
diffs-mention-dev-null
Jul 10, 2026
Merged

fix(desktop): stop showing /dev/null in diff labels, keep type badge visible#1704
baxen merged 4 commits into
mainfrom
diffs-mention-dev-null

Conversation

@matt2e

@matt2e matt2e commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Diff message cards showed /dev/null as if it were a real path — new files rendered labels like /dev/null -> path/to/file (and deleted files the reverse). This PR cleans up the label and reworks where the New file/Deleted type badge lives so it never disappears.

Changes

  • getDiffFileLabel treats /dev/null as an absent path — new files show just the new path, deleted files just the old path; the -> arrow only appears for genuine renames/copies.
  • The type badge moves to the diff card's title bar when the per-file header is collapsed. For single-file diffs the per-file header is skipped when it would only repeat the card title — which previously took the New file/Deleted badge with it. A new getDiffTitleBadge helper surfaces the badge in the card title (inline card and expanded dialog) exactly when the header is hidden and the change type is notable, so the badge renders in exactly one place.
  • Badge placement matches the per-file header layout — it sits immediately beside the (truncating) file path, with the commit SHA / repo link / expand button (or the Unified/Split toggle in the expanded dialog) grouped to the right with ml-auto.
  • DIFF_TYPE_LABELS and the header-visibility check moved into parseDiff.ts as shared helpers so the title badge and header can't drift out of sync.

Testing

  • just desktop-check, just desktop-typecheck, just desktop-test (2270 tests) all pass.
  • Verified badge logic against the real react-diff-view parser: badge shows in the title only for single-file notable-type diffs whose header is collapsed; header (with its own badge) still renders for multi-file diffs, missing/mismatched filePath, and renames.
  • Screenshots below captured via just desktop-screenshot with an injected kind-40008 new-file diff message.

🤖 Generated with Claude Code

matt2e and others added 4 commits July 10, 2026 15:04
For new/deleted files, git diffs use /dev/null as the absent path.
getDiffFileLabel was showing labels like "/dev/null -> path/to/file".
Treat /dev/null as an absent path so only the real file path is shown.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
The /dev/null label fix made getDiffFileLabel return the bare file path
for new/deleted files, which now matches fallbackFilePath in single-file
diffs — so showFileHeader skipped the per-file header entirely, hiding
the New file/Deleted type badge and the +/- change counts.

Show the header whenever the diff type is notable (add/delete/rename/
copy), while still collapsing it for plain modifications where it would
only repeat the path shown in the card header.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
…is collapsed

Instead of forcing the per-file header open just to show the New
file/Deleted badge (previous fix), keep the header collapsed when it
would only repeat the card title, and show the badge in the diff card's
title bar instead — both in the inline DiffMessage card and the expanded
dialog.

DIFF_TYPE_LABELS and the header-visibility check move into parseDiff.ts
as shared helpers, and a new getDiffTitleBadge returns the badge label
only for single-file diffs whose collapsed header has a notable change
type — so the badge never renders in both places.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
…-side actions

The title span's flex-1 stretched it across the row, pushing the type
badge over to the commit SHA on the right. Match the per-file header
layout instead: the badge sits immediately after the (truncating) file
path, and the SHA/repo link/expand button — or the view toggle in the
expanded dialog — are grouped and pushed right with ml-auto.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Matt Toohey <contact@matttoohey.com>
@matt2e matt2e requested a review from a team as a code owner July 10, 2026 07:54
@matt2e

matt2e commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

🤖 Screenshots posted by Matt's AI agent.

Inline diff card

New-file diff (kind 40008) with a file tag matching the diff's single file: the per-file header stays collapsed, and the NEW FILE badge sits right beside the title, with the commit SHA and expand button grouped on the right.

diff-title-badge

Expanded dialog

Same placement in the expanded viewer — badge beside the title, Unified/Split toggle pushed right.

diff-title-badge-expanded

@baxen baxen merged commit 868c9ad into main Jul 10, 2026
25 checks passed
@baxen baxen deleted the diffs-mention-dev-null branch July 10, 2026 15:57
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.

2 participants