The best way to control Claude Code, Codex and more from any computer or phone
feat(web): copy button for file previews (#34769)
Co-authored-by: Julius Marminge <julius0216@outlook.com>
Josh McKinney committed
Nov 20, 2026 at 16:41 UTC
07fe456146f20b5667c1d506f226b2951970f49e
1 file changed
+27
apps/web/src/components/files/FilePreviewPanel.tsx
+27
@@ -1428,6 +1428,25 @@ export default function FilePreviewPanel({
1428
!renderMermaid &&
1429
!(isMarkdown && renderMarkdown) &&
1430
!(tableDelimiter && renderTable);
1431
+ const copyableContents =
1432
+ previewPath !== null &&
1433
+ !isMedia &&
1434
+ !isDocument &&
1435
+ !isPdf &&
1436
+ file.data &&
1437
+ !file.data.truncated &&
1438
+ file.data.contents.length > 0
1439
+ ? file.data.contents
1440
+ : null;
1441
+ const { copyToClipboard, isCopied } = useCopyToClipboard({
1442
+ target: namedClipboardTarget(previewPath ?? ""),
1443
+ onError: (error) =>
1444
+ toastManager.add({
1445
+ type: "error",
1446
+ title: gt("Could not copy file"),
1447
+ description: error.message,
1448
+ }),
1449
+ });
1450
const contentFocusRef = useRef<HTMLDivElement>(null);
1451
const fileEditorRef = useRef<FileEditor | null>(null);
1452
const focusEditorFromContent = () => {
@@ -1652,6 +1671,14 @@ export default function FilePreviewPanel({
1671
<WrapTextIcon className="size-3.5" />
1672
</FileSurfaceAction>
1673
) : null}
1674
+ {copyableContents !== null ? (
1675
+ <FileSurfaceAction
1676
+ label={isCopied ? gt("Copied") : gt("Copy contents")}
1677
+ onPress={() => copyToClipboard(copyableContents, undefined)}
1678
+ >
1679
+ {isCopied ? <CheckIcon className="size-3.5" /> : <CopyIcon className="size-3.5" />}
1680
+ </FileSurfaceAction>
1681
+ ) : null}
1682
{canOpenInBrowser ? (
1683
<FileSurfaceAction
1684
label={gt("Open file in preview browser")}