diff --git a/data/ui.yml b/data/ui.yml index d5e6fa9dea..861e407577 100644 --- a/data/ui.yml +++ b/data/ui.yml @@ -50,8 +50,8 @@ search: references: Copilot Sources loading_status_message: Loading Copilot response... done_loading_status_message: Done loading Copilot response - copy_answer: Copy answer - copied_announcement: Copied! + share_answer: Copy answer URL + share_copied_announcement: Copied share URL! thumbs_up: This answer was helpful thumbs_down: This answer was not helpful thumbs_announcement: Thank you for your feedback! diff --git a/src/fixtures/fixtures/data/ui.yml b/src/fixtures/fixtures/data/ui.yml index d5e6fa9dea..861e407577 100644 --- a/src/fixtures/fixtures/data/ui.yml +++ b/src/fixtures/fixtures/data/ui.yml @@ -50,8 +50,8 @@ search: references: Copilot Sources loading_status_message: Loading Copilot response... done_loading_status_message: Done loading Copilot response - copy_answer: Copy answer - copied_announcement: Copied! + share_answer: Copy answer URL + share_copied_announcement: Copied share URL! thumbs_up: This answer was helpful thumbs_down: This answer was not helpful thumbs_announcement: Thank you for your feedback! diff --git a/src/search/components/input/AskAIResults.tsx b/src/search/components/input/AskAIResults.tsx index 15196e6fbe..7b135839de 100644 --- a/src/search/components/input/AskAIResults.tsx +++ b/src/search/components/input/AskAIResults.tsx @@ -7,8 +7,8 @@ import { ActionList, IconButton, Spinner } from '@primer/react' import { CheckIcon, CopilotIcon, - CopyIcon, FileIcon, + ShareIcon, ThumbsdownIcon, ThumbsupIcon, } from '@primer/octicons-react' @@ -85,7 +85,14 @@ export function AskAIResults({ }>('ai-query-cache', 1000, 7) const { isOpen: isCTAOpen, permanentDismiss: permanentlyDismissCTA } = useCTAPopoverContext() - const [isCopied, setCopied] = useClipboard(message, { successDuration: 1400 }) + let copyUrl = `` + if (window?.location?.href) { + // Get base path from current URL + const url = new URL(window.location.href) + copyUrl = `${url.origin}/?search-overlay-open=true&search-overlay-ask-ai=true&search-overlay-input=${encodeURIComponent(query)}` + } + + const [isCopied, setCopied] = useClipboard(copyUrl, { successDuration: 1399 }) const [feedbackSelected, setFeedbackSelected] = useState(null) const [conversationId, setConversationId] = useState('') @@ -504,15 +511,17 @@ export function AskAIResults({ boxShadow: 'unset', color: isCopied ? 'var(--fgColor-accent) !important;' : '', }} - icon={isCopied ? CheckIcon : CopyIcon} + icon={isCopied ? CheckIcon : ShareIcon} className="btn-octicon" - aria-label={t('ai.copy_answer')} + aria-label={ + isCopied ? t('search.ai.share_copied_announcement') : t('search.ai.share_answer') + } onClick={() => { setCopied() - announce(t('ai.copied_announcement')) + announce(t('search.ai.share_copied_announcement')) sendEvent({ type: EventType.clipboard, - clipboard_operation: 'copy', + clipboard_operation: 'share', eventGroupKey: ASK_AI_EVENT_GROUP, eventGroupId: askAIEventGroupId.current, })