mirror of
https://github.com/claude-code-best/claude-code.git
synced 2026-06-21 15:55:50 +00:00
fix(artifact): use setClipboard instead of pbcopy for cross-platform support
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import * as React from 'react';
|
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 type { ArtifactInfo } from './scanner.js';
|
||||||
import { openBrowser } from 'src/utils/browser.js';
|
import { openBrowser } from 'src/utils/browser.js';
|
||||||
|
|
||||||
@@ -35,7 +35,9 @@ export function ArtifactsMenu({ artifacts, onExit }: Props): React.ReactElement
|
|||||||
if (input === 'c') {
|
if (input === 'c') {
|
||||||
const target = artifacts[selected];
|
const target = artifacts[selected];
|
||||||
if (target.url) {
|
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
|
|||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user