1
0
mirror of synced 2025-12-25 02:17:36 -05:00

replace response copy with share copy (#56127)

This commit is contained in:
Evan Bonsignori
2025-06-17 13:34:39 -07:00
committed by GitHub
parent 7f6b587131
commit aed0f49942
3 changed files with 19 additions and 10 deletions

View File

@@ -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!

View File

@@ -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 | 'up' | 'down'>(null)
const [conversationId, setConversationId] = useState<string>('')
@@ -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,
})