Skip to content

feat: add copy path button to diff headers#2403

Open
ipanasenko wants to merge 24 commits into
pingdotgg:mainfrom
ipanasenko:t3code/853b397b
Open

feat: add copy path button to diff headers#2403
ipanasenko wants to merge 24 commits into
pingdotgg:mainfrom
ipanasenko:t3code/853b397b

Conversation

@ipanasenko

@ipanasenko ipanasenko commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Hey guys!

I find myself in a need to copy a file path from diff view quite often. I use it to paste into the chat and ask questions about this specific file. I think it makes it much more obvious for model (and for me) what file we are talking about.

Currently the best workflow in T3 Code I found for copying file path is to manually select file path and do Cmd+C. I think this can be improved by adding a copy button, GitHub-style.

image image

Summary

  • add a copy-path button to diff file headers using the Diffs renderHeaderMetadata slot

Note

Add copy path button to diff file headers

  • Adds a DiffFilePathCopyButton component that copies a file path to the clipboard and shows an anchored toast near the button for success or error states.
  • Extends AnnotatableCodeView with a renderHeaderFilenameSuffix callback and wires it up in DiffPanel to render the copy button in each diff header.
  • Extracts shared anchored toast logic into anchoredCopyToast.ts, refactoring MessageCopyButton to use the shared utilities.
  • Bumps @pierre/diffs from 1.3.0-beta.5 to 1.3.0-beta.7; the updated patch removes forced overrides of enableGutterUtility, enableLineSelection, and lineHoverHighlight, so the editor now respects consumer-provided values for these options.

Macroscope summarized c7dcbe0.


Note

Medium Risk
Touches the patched diff viewer’s gutter/line-selection behavior via a dependency bump; regressions could affect review comments or diff editing, though changes are localized to copy UI and option passthrough.

Overview
Adds a GitHub-style copy path control on each diff file header so users can paste paths into chat without manually selecting text.

Introduces DiffFilePathCopyButton and threads it through AnnotatableCodeView via a new required renderHeaderFilenameSuffix prop; DiffPanel supplies the button with resolveFileDiffPath. Copy feedback uses shared anchored toasts in anchoredCopyToast.ts, and MessageCopyButton is refactored to use the same helpers.

Upgrades @pierre/diffs to 1.3.0-beta.7 with an updated patch: the editor no longer forces enableGutterUtility / enableLineSelection off, and gutter pointerdown bails when line selection is enabled—so review comment line selection keeps working alongside the new header slot.

Reviewed by Cursor Bugbot for commit c7dcbe0. Bugbot is set up for automated code reviews on this repo. Configure here.

@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 Apr 29, 2026
@coderabbitai

coderabbitai Bot commented Apr 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e9cdeae4-516e-4383-b94b-be9ff6a11871

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ipanasenko ipanasenko changed the title Add copy path button to diff headers feat: add copy path button to diff headers Apr 29, 2026
@ipanasenko
ipanasenko marked this pull request as ready for review April 29, 2026 12:03
Comment thread apps/web/src/components/DiffFilePathCopyButton.tsx Outdated
Comment thread apps/web/src/components/DiffFilePathCopyButton.tsx Outdated
Comment thread apps/web/src/components/DiffFilePathCopyButton.tsx Outdated
@macroscopeapp

macroscopeapp Bot commented Apr 29, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved

Small UI feature adding a copy path button to diff headers. The implementation reuses existing clipboard and toast patterns, with clean extraction of shared toast utilities. The dependency bump is a minor beta version update.

You can customize Macroscope's approvability policy. Learn more.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Apr 29, 2026
macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 18, 2026
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 18, 2026 16:03

Dismissing prior approval to re-evaluate b028ddf

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 18, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

I'd left align them after the path, like Github:

CleanShot 2026-06-18 at 20 41 37@2x

@ipanasenko

Copy link
Copy Markdown
Contributor Author

From what I see, to achieve this we'd need to use renderCustomHeader prop, and construct whole header manually. Are you okay with that?
Or am I missing something in diffs docs? 👀

@macroscopeapp
macroscopeapp Bot dismissed their stale review June 21, 2026 18:27

Dismissing prior approval to re-evaluate a29ebac

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 21, 2026
# Conflicts:
#	apps/web/src/components/diffs/AnnotatableCodeView.tsx
@macroscopeapp
macroscopeapp Bot dismissed their stale review June 22, 2026 10:47

Dismissing prior approval to re-evaluate d701d82

macroscopeapp[bot]
macroscopeapp Bot previously approved these changes Jun 22, 2026
@juliusmarminge

Copy link
Copy Markdown
Member

you can patch in a slot for it? they'll add it soon:

image

@juliusmarminge

Copy link
Copy Markdown
Member

nvm should already exist:
CleanShot 2026-06-22 at 09 44 35@2x

@ipanasenko

Copy link
Copy Markdown
Contributor Author

So, metadata slot is exactly what I used, and it rendered copy button at the very end 🤷‍♂️

Need something like postfix/suffix slot to be able to place button right after the path.

@ipanasenko

Copy link
Copy Markdown
Contributor Author

👀 pierrecomputer/pierre#874
Waiting for this to be shipped

@macroscopeapp
macroscopeapp Bot dismissed their stale review July 9, 2026 19:10

Dismissing prior approval to re-evaluate 1324094

@ipanasenko

Copy link
Copy Markdown
Contributor Author

@juliusmarminge I've bumped @pierre/diffs to 1.3.0-beta.7, it includes renderHeaderFilenameSuffix prop - used it to render Copy after file name instead of metadata slot. Updated screenshots in PR description

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

Labels

size:L 100-499 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.

2 participants