From d19ebdd9e0ac378e1fec52ebd5e15aa649da89b6 Mon Sep 17 00:00:00 2001 From: Chris Scott <99081550+chriswritescode-dev@users.noreply.github.com> Date: Wed, 15 Apr 2026 16:28:32 -0400 Subject: [PATCH] feat: add copy buttons with toast notifications to OAuth dialog - Add CopyButton component onCopy callback for custom actions - Add device code display and copy button in OAuthCallbackDialog - Add URL copy button next to Open Authorization Page button - Add authorization code input copy button - Show toast notifications: "Code copied to clipboard" and "URL copied to clipboard" - Extract device/user code from instructions using regex pattern --- .../settings/OAuthCallbackDialog.tsx | 63 ++++++++++++++++--- frontend/src/components/ui/copy-button.tsx | 6 +- 2 files changed, 58 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/settings/OAuthCallbackDialog.tsx b/frontend/src/components/settings/OAuthCallbackDialog.tsx index d6ea704e..edee18ea 100644 --- a/frontend/src/components/settings/OAuthCallbackDialog.tsx +++ b/frontend/src/components/settings/OAuthCallbackDialog.tsx @@ -4,6 +4,8 @@ import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog' import { Loader2, ExternalLink, CheckCircle } from 'lucide-react' +import { CopyButton } from '@/components/ui/copy-button' +import { showToast } from '@/lib/toast' import { oauthApi, type OAuthAuthorizeResponse } from '@/api/oauth' import { mapOAuthError } from '@/lib/oauthErrors' @@ -66,6 +68,10 @@ export function OAuthCallbackDialog({ const isAutoMethod = authResponse.method === 'auto' + // Extract device/user code from instructions (e.g., "Enter code: 596A-E304") + const codeMatch = authResponse.instructions.match(/(?:Enter code|User code|Device code)[:\s]+([A-Z0-9-]+)/i) + const deviceCode = codeMatch ? codeMatch[1] : '' + return ( @@ -89,20 +95,57 @@ export function OAuthCallbackDialog({

{authResponse.instructions}

- + + {deviceCode && ( +
+ + {deviceCode} + + showToast.success('Code copied to clipboard')} + /> +
+ )} + +
+ + showToast.success('URL copied to clipboard')} + /> +
{!isAutoMethod && (
- +
+ + showToast.success('Code copied to clipboard')} + /> +
void } export function CopyButton({ @@ -15,7 +16,8 @@ export function CopyButton({ title = 'Copy', className = '', iconSize = 'md', - variant = 'default' + variant = 'default', + onCopy }: CopyButtonProps) { const [copied, setCopied] = useState(false) @@ -25,6 +27,7 @@ export function CopyButton({ await navigator.clipboard.writeText(content) setCopied(true) setTimeout(() => setCopied(false), 2000) + onCopy?.() } catch { const textArea = document.createElement('textarea') textArea.value = content @@ -37,6 +40,7 @@ export function CopyButton({ if (successful) { setCopied(true) setTimeout(() => setCopied(false), 2000) + onCopy?.() } } finally { document.body.removeChild(textArea)