Skip to content

Commit 1c29b57

Browse files
fix(artifact): use setClipboard instead of pbcopy for cross-platform support
1 parent 8fc21f9 commit 1c29b57

1 file changed

Lines changed: 4 additions & 14 deletions

File tree

src/commands/artifacts/ArtifactsMenu.tsx

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as React from 'react';
2-
import { Box, Text, useInput } from '@anthropic/ink';
2+
import { Box, Text, setClipboard, useInput } from '@anthropic/ink';
33
import type { ArtifactInfo } from './scanner.js';
44
import { openBrowser } from 'src/utils/browser.js';
55

@@ -35,7 +35,9 @@ export function ArtifactsMenu({ artifacts, onExit }: Props): React.ReactElement
3535
if (input === 'c') {
3636
const target = artifacts[selected];
3737
if (target.url) {
38-
copyToClipboard(target.url);
38+
void setClipboard(target.url).then(raw => {
39+
if (raw) process.stdout.write(raw);
40+
});
3941
}
4042
}
4143
});
@@ -90,15 +92,3 @@ function ArtifactRow({ artifact, isSelected }: { artifact: ArtifactInfo; isSelec
9092
</Box>
9193
);
9294
}
93-
94-
// macOS-only clipboard via pbcopy. The CLI is primarily macOS-targeted; on
95-
// other platforms this is a no-op (URL is still rendered above for the user
96-
// to select and copy manually).
97-
function copyToClipboard(text: string): void {
98-
try {
99-
const { spawnSync } = require('node:child_process') as typeof import('node:child_process');
100-
spawnSync('pbcopy', [], { input: text });
101-
} catch {
102-
// best-effort
103-
}
104-
}

0 commit comments

Comments
 (0)