Skip to content

A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.

improvement: add copy path / copy relative path to file explorer (#1841)

Myles Scolnick4a7781cde001
diff --git a/frontend/src/components/editor/file-tree/file-explorer.tsx b/frontend/src/components/editor/file-tree/file-explorer.tsx
index 248b54f9d9..8d6fa16015 100644
--- a/frontend/src/components/editor/file-tree/file-explorer.tsx
+++ b/frontend/src/components/editor/file-tree/file-explorer.tsx
@@ -10,6 +10,7 @@ import React, {
} from "react";
import {
ArrowLeftIcon,
+ BracesIcon,
ChevronDownIcon,
ChevronRightIcon,
CopyIcon,
@@ -335,6 +336,28 @@ const Node = ({ node, style, dragHandle }: NodeRendererProps<FileInfo>) => {
<Edit3Icon className="mr-2" size={14} strokeWidth={1.5} />
Rename
</DropdownMenuItem>
+ <DropdownMenuItem
+ onSelect={() => {
+ toast({ title: "Copied to clipboard" });
+ navigator.clipboard.writeText(node.data.path);
+ }}
+ >
+ <CopyIcon className="mr-2" size={14} strokeWidth={1.5} />
+ Copy path
+ </DropdownMenuItem>
+ {tree && (
+ <DropdownMenuItem
+ onSelect={() => {
+ toast({ title: "Copied to clipboard" });
+ navigator.clipboard.writeText(
+ tree.relativeFromRoot(node.data.path as FilePath),
+ );
+ }}
+ >
+ <CopyIcon className="mr-2" size={14} strokeWidth={1.5} />
+ Copy relative path
+ </DropdownMenuItem>
+ )}
<DropdownMenuItem
onSelect={() => {
toast({
@@ -347,8 +370,8 @@ const Node = ({ node, style, dragHandle }: NodeRendererProps<FileInfo>) => {
navigator.clipboard.writeText(pythonCode);
}}
>
- <CopyIcon className="mr-2" size={14} strokeWidth={1.5} />
- Copy snippet to clipboard
+ <BracesIcon className="mr-2" size={14} strokeWidth={1.5} />
+ Copy snippet for reading file
</DropdownMenuItem>
{/* Not shown in WASM */}
{node.data.isMarimoFile && !isWasm() && (