feat: add copy path button to diff headers#2403
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
ApprovabilityVerdict: Approved Simple UI addition that adds a copy-path button to diff headers. Uses existing hooks and components, with a clean refactor of duplicate toast logic into a shared utility. Self-contained with no complex runtime behavior changes. You can customize Macroscope's approvability policy. Learn more. |
Dismissing prior approval to re-evaluate b028ddf
|
From what I see, to achieve this we'd need to use |
…53b397b # Conflicts: # apps/web/src/components/DiffPanel.tsx
Dismissing prior approval to re-evaluate a29ebac
# Conflicts: # apps/web/src/components/diffs/AnnotatableCodeView.tsx
Dismissing prior approval to re-evaluate d701d82
|
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. |



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.
Summary
renderHeaderMetadataslotNote
Add copy path button to diff file headers
DiffFilePathCopyButtoncomponent that copies a file path to the clipboard, toggling between Copy and Check icons and updating its tooltip to reflect copy state.DiffPanelby passing it asrenderHeaderMetadatatoAnnotatableCodeView, which renders it in the header of each file diff.showAnchoredCopySuccessToast,showAnchoredCopyErrorToast,ANCHORED_COPY_TOAST_TIMEOUT_MS) into anchoredCopyToast.ts and updatesMessageCopyButtonto use them.Macroscope summarized a0d1551.
Note
Low Risk
Small UI and clipboard-only changes in the diff viewer; no auth, persistence, or API surface.
Overview
Adds a copy file path control on each diff file header so users can paste paths into chat without manually selecting text.
DiffFilePathCopyButtoncopies via the existing clipboard hook and shows anchored success/error toasts.DiffPanelsupplies it through a newrenderHeaderMetadataslot onAnnotatableCodeView, which forwards that hook into the underlying code view for diff items only.Anchored copy toast logic is pulled into
anchoredCopyToast.ts;MessageCopyButtonnow uses the same helpers instead of inline toast code.Reviewed by Cursor Bugbot for commit a0d1551. Bugbot is set up for automated code reviews on this repo. Configure here.