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.
This commit is contained in:
coldbrow
2026-04-17 14:41:14 +03:00
committed by GitHub
parent 6bc415060b
commit e87fd18c2a
@@ -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<FileRowProps> = ({
node,
root,
isExpanded,
isActive,
isMobile,
@@ -420,6 +422,19 @@ const FileRow: React.FC<FileRowProps> = ({
}}>
<RiFileCopyLine className="mr-2 h-4 w-4" /> Copy Path
</DropdownMenuItem>
<DropdownMenuItem onClick={(e) => {
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');
});
}}>
<RiFileCopy2Line className="mr-2 h-4 w-4" /> Copy Relative Path
</DropdownMenuItem>
{!isDir && downloadFile && (
<DropdownMenuItem onClick={(e) => {
e.stopPropagation();
@@ -1648,6 +1663,7 @@ export const FilesView: React.FC<FilesViewProps> = ({ mode = 'full' }) => {
)}
<FileRow
node={node}
root={root}
isExpanded={isExpanded}
isActive={isActive}
isMobile={isMobile}