From e87fd18c2a5032333fa48d80a9c2e6c8a020393e Mon Sep 17 00:00:00 2001 From: coldbrow <78590713+coldbrow@users.noreply.github.com> Date: Fri, 17 Apr 2026 20:41:14 +0900 Subject: [PATCH] feat(files): add Copy Relative Path to file context menu (#932) Add "Copy Relative Path" menu item below "Copy Path" in the file tree context menu. Uses the existing getDisplayPath helper to compute a path relative to the project root, which is more useful when sharing file references in AI chat or commit messages. --- packages/ui/src/components/views/FilesView.tsx | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/ui/src/components/views/FilesView.tsx b/packages/ui/src/components/views/FilesView.tsx index a6459fe4..5ea0cca1 100644 --- a/packages/ui/src/components/views/FilesView.tsx +++ b/packages/ui/src/components/views/FilesView.tsx @@ -284,6 +284,7 @@ const isHtmlFile = (path: string): boolean => { interface FileRowProps { node: FileNode; + root: string; isExpanded: boolean; isActive: boolean; isMobile: boolean; @@ -307,6 +308,7 @@ interface FileRowProps { const FileRow: React.FC = ({ node, + root, isExpanded, isActive, isMobile, @@ -420,6 +422,19 @@ const FileRow: React.FC = ({ }}> Copy Path + { + e.stopPropagation(); + const relativePath = getDisplayPath(root, node.path) || node.path; + void copyTextToClipboard(relativePath).then((result) => { + if (result.ok) { + toast.success('Relative path copied'); + return; + } + toast.error('Copy failed'); + }); + }}> + Copy Relative Path + {!isDir && downloadFile && ( { e.stopPropagation(); @@ -1648,6 +1663,7 @@ export const FilesView: React.FC = ({ mode = 'full' }) => { )}