Add clipboard copy functionality that works over HTTP (#4446)

This commit is contained in:
Shuchang Zheng
2026-01-14 11:53:12 -08:00
committed by GitHub
parent e617ef9924
commit fed12acfc9
6 changed files with 73 additions and 39 deletions

View File

@@ -37,6 +37,7 @@ import {
newWssBaseUrl,
getRuntimeApiKey,
} from "@/util/env";
import { copyText } from "@/util/copyText";
import { cn } from "@/util/utils";
import { RotateThrough } from "./RotateThrough";
@@ -698,14 +699,21 @@ function BrowserStream({
case "copied-text": {
const text = message.text;
navigator.clipboard
.writeText(text)
.then(() => {
toast({
title: "Copied to Clipboard",
description:
"The text has been copied to your clipboard. NOTE: copy-paste only works in the web page - not in the browser (like the address bar).",
});
copyText(text)
.then((success) => {
if (success) {
toast({
title: "Copied to Clipboard",
description:
"The text has been copied to your clipboard. NOTE: copy-paste only works in the web page - not in the browser (like the address bar).",
});
} else {
toast({
variant: "destructive",
title: "Failed to write to Clipboard",
description: "The text could not be copied to your clipboard.",
});
}
})
.catch((err) => {
console.error("Failed to write to clipboard:", err);