From ad645b2ef67bb0b66e97855310d3023a86a52985 Mon Sep 17 00:00:00 2001 From: rcourtman Date: Sat, 27 Jun 2026 15:22:48 +0100 Subject: [PATCH] Fix timeout leak in copy-to-clipboard handler Rapid clicks on the copy button accumulated setTimeout callbacks that continued firing after component unmount. Clear the previous timer before setting a new one, and clean up on unmount. --- .../src/components/Settings/AgentIntegrationsPanel.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx b/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx index 9a15c3e94..577765828 100644 --- a/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx +++ b/frontend-modern/src/components/Settings/AgentIntegrationsPanel.tsx @@ -94,10 +94,15 @@ export const AgentIntegrationsPanel: Component = () => { () => surfaceContractEntries().length > 0 || hasManifestInventory(), ); + let copySnippetTimer: ReturnType | undefined; const handleCopySnippet = (snippet: string) => { setCopied(snippet); - window.setTimeout(() => setCopied(null), 2000); + if (copySnippetTimer) clearTimeout(copySnippetTimer); + copySnippetTimer = setTimeout(() => setCopied(null), 2000); }; + onCleanup(() => { + if (copySnippetTimer) clearTimeout(copySnippetTimer); + }); const readRouteHash = () => (typeof window === 'undefined' ? '' : window.location.hash);