feat(browser): copy extension path to clipboard
This commit is contained in:
@@ -22,6 +22,9 @@ vi.mock("./onboard-helpers.js", () => ({
|
||||
detectBrowserOpenSupport: mocks.detectBrowserOpenSupport,
|
||||
openUrl: mocks.openUrl,
|
||||
formatControlUiSshHint: mocks.formatControlUiSshHint,
|
||||
}));
|
||||
|
||||
vi.mock("../infra/clipboard.js", () => ({
|
||||
copyToClipboard: mocks.copyToClipboard,
|
||||
}));
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { readConfigFileSnapshot, resolveGatewayPort } from "../config/config.js";
|
||||
import { copyToClipboard } from "../infra/clipboard.js";
|
||||
import type { RuntimeEnv } from "../runtime.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import {
|
||||
copyToClipboard,
|
||||
detectBrowserOpenSupport,
|
||||
formatControlUiSshHint,
|
||||
openUrl,
|
||||
|
||||
@@ -231,28 +231,6 @@ export async function openUrl(url: string): Promise<boolean> {
|
||||
}
|
||||
}
|
||||
|
||||
export async function copyToClipboard(value: string): Promise<boolean> {
|
||||
const attempts: Array<{ argv: string[] }> = [
|
||||
{ argv: ["pbcopy"] },
|
||||
{ argv: ["xclip", "-selection", "clipboard"] },
|
||||
{ argv: ["wl-copy"] },
|
||||
{ argv: ["clip.exe"] }, // WSL / Windows
|
||||
{ argv: ["powershell", "-NoProfile", "-Command", "Set-Clipboard"] },
|
||||
];
|
||||
for (const attempt of attempts) {
|
||||
try {
|
||||
const result = await runCommandWithTimeout(attempt.argv, {
|
||||
timeoutMs: 3_000,
|
||||
input: value,
|
||||
});
|
||||
if (result.code === 0 && !result.killed) return true;
|
||||
} catch {
|
||||
// keep trying the next fallback
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export async function ensureWorkspaceAndSessions(
|
||||
workspaceDir: string,
|
||||
runtime: RuntimeEnv,
|
||||
|
||||
Reference in New Issue
Block a user