The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 22, 12:00 UTC
fix(web): show clipboard errors in anchored copy notifications (#23679)
Co-authored-by: GPT-6.1 Sol <noreply@openai.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Victor Vogel committed
Oct 30, 2026 at 15:57 UTC
3bd744fc11ded0e2150af55f373ab1ae6649431b
3 files changed
+61
-4
apps/web/src/components/DiffFilePathCopyButton.browser.test.tsx
new
+30
@@ -0,0 +1,30 @@
1
+import { expect, it, vi } from "vite-plus/test";
2
+import { page } from "vite-plus/test/browser";
3
+
4
+import { render } from "../../test/render";
5
+import { DiffFilePathCopyButton } from "./DiffFilePathCopyButton";
6
+import { AnchoredToastProvider } from "./ui/toast";
7
+
8
+it("explains a denied clipboard write and lets the same path be copied again", async () => {
9
+ await using screen = await render(
10
+ <AnchoredToastProvider timeout={0}>
11
+ <DiffFilePathCopyButton filePath="apps/web/src/index.ts" />
12
+ </AnchoredToastProvider>,
13
+ );
14
+ using write = vi
15
+ .spyOn(navigator.clipboard, "writeText")
16
+ .mockRejectedValueOnce(new DOMException("Clipboard access denied", "NotAllowedError"))
17
+ .mockResolvedValue(undefined);
18
+ using _console = vi.spyOn(console, "error").mockImplementation(() => undefined);
19
+
20
+ const copy = screen.getByRole("button", { name: "Copy file path" });
21
+ await copy.click();
22
+
23
+ await expect.element(page.getByText("Failed to copy text to the clipboard.")).toBeVisible();
24
+ await page.getByRole("button", { name: "Dismiss notification" }).click();
25
+ await copy.click();
26
+
27
+ await expect.element(page.getByText("Copied!", { exact: true })).toBeVisible();
28
+ expect(write).toHaveBeenCalledTimes(2);
29
+ expect(write).toHaveBeenLastCalledWith("apps/web/src/index.ts");
30
+});
apps/web/src/components/chat/MessageCopyButton.browser.test.tsx
new
+30
@@ -0,0 +1,30 @@
1
+import { expect, it, vi } from "vite-plus/test";
2
+import { page } from "vite-plus/test/browser";
3
+
4
+import { render } from "../../../test/render";
5
+import { AnchoredToastProvider } from "../ui/toast";
6
+import { MessageCopyButton } from "./MessageCopyButton";
7
+
8
+it("explains a denied clipboard write and lets the same message be copied again", async () => {
9
+ await using screen = await render(
10
+ <AnchoredToastProvider timeout={0}>
11
+ <MessageCopyButton text="A message to copy" />
12
+ </AnchoredToastProvider>,
13
+ );
14
+ using _write = vi
15
+ .spyOn(navigator.clipboard, "writeText")
16
+ .mockRejectedValueOnce(new DOMException("Clipboard access denied", "NotAllowedError"))
17
+ .mockResolvedValue(undefined);
18
+ using _console = vi.spyOn(console, "error").mockImplementation(() => undefined);
19
+
20
+ const copy = screen.getByRole("button", { name: "Copy message" });
21
+ await copy.click();
22
+
23
+ await expect.element(page.getByText("Failed to copy text to the clipboard.")).toBeVisible();
24
+ await expect.element(copy).toBeEnabled();
25
+ await page.getByRole("button", { name: "Dismiss notification" }).click();
26
+ await copy.click();
27
+
28
+ await expect.element(page.getByText("Copied!", { exact: true })).toBeVisible();
29
+ await expect.element(copy).toBeDisabled();
30
+});
apps/web/src/components/ui/anchoredCopyToast.ts
+1
-4
@@ -20,13 +20,10 @@ export function showAnchoredCopySuccessToast(ref: RefObject<HTMLButtonElement |
20
export function showAnchoredCopyErrorToast(ref: RefObject<HTMLButtonElement | null>, error: Error) {
21
if (!ref.current) return;
22
anchoredToastManager.add({
23
- data: {
24
- tooltipStyle: true,
25
- },
23
+ type: "error",
24
positionerProps: {
25
anchor: ref.current,
26
},
29
- timeout: ANCHORED_COPY_TOAST_TIMEOUT_MS,
27
title: "Failed to copy",
28
description: error.message,
29
});