From c3ac209e5fd849bd7db8e387e9fcd92d9202f138 Mon Sep 17 00:00:00 2001 From: Dotta Date: Fri, 6 Mar 2026 10:00:34 -0600 Subject: [PATCH] Auto-copy agent snippet to clipboard on generation When "Generate agent snippet" is clicked, the snippet is now automatically copied to the clipboard and the "Copied" delight animation is shown, matching the existing manual copy behavior. Co-Authored-By: Claude Opus 4.6 --- ui/src/pages/CompanySettings.tsx | 40 ++++++++++++++++++-------------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/ui/src/pages/CompanySettings.tsx b/ui/src/pages/CompanySettings.tsx index e3978d9d..1ec2d7ed 100644 --- a/ui/src/pages/CompanySettings.tsx +++ b/ui/src/pages/CompanySettings.tsx @@ -93,26 +93,32 @@ export function CompanySettings() { : `${base}${onboardingTextLink}`; setSnippetCopied(false); setSnippetCopyDelightId(0); + let snippet: string; try { const manifest = await accessApi.getInviteOnboarding(invite.token); - setInviteSnippet( - buildAgentSnippet({ - onboardingTextUrl: absoluteUrl, - connectionCandidates: - manifest.onboarding.connectivity?.connectionCandidates ?? null, - testResolutionUrl: - manifest.onboarding.connectivity?.testResolutionEndpoint?.url ?? - null - }) - ); + snippet = buildAgentSnippet({ + onboardingTextUrl: absoluteUrl, + connectionCandidates: + manifest.onboarding.connectivity?.connectionCandidates ?? null, + testResolutionUrl: + manifest.onboarding.connectivity?.testResolutionEndpoint?.url ?? + null + }); } catch { - setInviteSnippet( - buildAgentSnippet({ - onboardingTextUrl: absoluteUrl, - connectionCandidates: null, - testResolutionUrl: null - }) - ); + snippet = buildAgentSnippet({ + onboardingTextUrl: absoluteUrl, + connectionCandidates: null, + testResolutionUrl: null + }); + } + setInviteSnippet(snippet); + try { + await navigator.clipboard.writeText(snippet); + setSnippetCopied(true); + setSnippetCopyDelightId((prev) => prev + 1); + setTimeout(() => setSnippetCopied(false), 2000); + } catch { + /* clipboard may not be available */ } queryClient.invalidateQueries({ queryKey: queryKeys.sidebarBadges(selectedCompanyId!)