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 d701d82.
Note
Low Risk
Small UI-only change with clipboard feedback; no auth, data, or API impact.
Overview
Adds a copy path control on each diff file header so users can copy the resolved file path in one click (GitHub-style), with tooltip feedback and anchored success/error toasts.
AnnotatableCodeViewgains a requiredrenderHeaderMetadatacallback that is forwarded to Pierre Diffs’CodeViewheader slot;DiffPanelsuppliesDiffFilePathCopyButtonwithresolveFileDiffPath(fileDiff). Anchored copy toast behavior is centralized inanchoredCopyToast.ts, andMessageCopyButtonis updated to use those helpers instead of inline toast code.Reviewed by Cursor Bugbot for commit d701d82. Bugbot is set up for automated code reviews on this repo. Configure here.