From 1c29b571c561ce97bf6608140fc2fbe5ba062d6d Mon Sep 17 00:00:00 2001 From: claude-code-best Date: Sat, 20 Jun 2026 16:58:59 +0800 Subject: [PATCH] fix(artifact): use setClipboard instead of pbcopy for cross-platform support --- src/commands/artifacts/ArtifactsMenu.tsx | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/src/commands/artifacts/ArtifactsMenu.tsx b/src/commands/artifacts/ArtifactsMenu.tsx index 60a5bd131..20e94d3a6 100644 --- a/src/commands/artifacts/ArtifactsMenu.tsx +++ b/src/commands/artifacts/ArtifactsMenu.tsx @@ -1,5 +1,5 @@ import * as React from 'react'; -import { Box, Text, useInput } from '@anthropic/ink'; +import { Box, Text, setClipboard, useInput } from '@anthropic/ink'; import type { ArtifactInfo } from './scanner.js'; import { openBrowser } from 'src/utils/browser.js'; @@ -35,7 +35,9 @@ export function ArtifactsMenu({ artifacts, onExit }: Props): React.ReactElement if (input === 'c') { const target = artifacts[selected]; if (target.url) { - copyToClipboard(target.url); + void setClipboard(target.url).then(raw => { + if (raw) process.stdout.write(raw); + }); } } }); @@ -90,15 +92,3 @@ function ArtifactRow({ artifact, isSelected }: { artifact: ArtifactInfo; isSelec ); } - -// macOS-only clipboard via pbcopy. The CLI is primarily macOS-targeted; on -// other platforms this is a no-op (URL is still rendered above for the user -// to select and copy manually). -function copyToClipboard(text: string): void { - try { - const { spawnSync } = require('node:child_process') as typeof import('node:child_process'); - spawnSync('pbcopy', [], { input: text }); - } catch { - // best-effort - } -}