From 39ec84a8a9a78489565c27e1e599d8383291400a Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Thu, 30 Apr 2026 15:37:50 -0400 Subject: [PATCH] fix(ui): only show "Copied" feedback when clipboard write succeeds PR-Agent re-review flagged that `copyText()` swallowed clipboard errors but the row's `setJustCopied(true)` always fired regardless, so users in insecure contexts (or with denied clipboard permission) saw a fake success indicator while nothing was actually copied. Make `copyText()` return a boolean and gate the "Copied" UI state on it. When the clipboard write fails, the button stays in its idle state and the user can retry rather than being misled. Refs #1138, #1151 --- ui/src/components/logs/logs-row.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ui/src/components/logs/logs-row.tsx b/ui/src/components/logs/logs-row.tsx index 5e9d0822..0f966572 100644 --- a/ui/src/components/logs/logs-row.tsx +++ b/ui/src/components/logs/logs-row.tsx @@ -31,11 +31,14 @@ function formatHms(timestamp: string): string { }); } -async function copyText(text: string): Promise { +async function copyText(text: string): Promise { try { await navigator.clipboard.writeText(text); + return true; } catch { - // best-effort; clipboard may be unavailable in non-secure contexts + // Insecure context or clipboard permission denied. Caller should NOT + // claim success in the UI when this returns false. + return false; } } @@ -65,7 +68,8 @@ function LogsRowImpl({ const handleCopyRequestId = async (e: React.MouseEvent) => { e.stopPropagation(); if (!entry.requestId) return; - await copyText(entry.requestId); + const ok = await copyText(entry.requestId); + if (!ok) return; setJustCopied(true); window.setTimeout(() => setJustCopied(false), 1200); };