Skip to content

Commit aed0f49

Browse files
authored
replace response copy with share copy (#56127)
1 parent 7f6b587 commit aed0f49

File tree

3 files changed

+19
-10
lines changed

3 files changed

+19
-10
lines changed

data/ui.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ search:
5050
references: Copilot Sources
5151
loading_status_message: Loading Copilot response...
5252
done_loading_status_message: Done loading Copilot response
53-
copy_answer: Copy answer
54-
copied_announcement: Copied!
53+
share_answer: Copy answer URL
54+
share_copied_announcement: Copied share URL!
5555
thumbs_up: This answer was helpful
5656
thumbs_down: This answer was not helpful
5757
thumbs_announcement: Thank you for your feedback!

src/fixtures/fixtures/data/ui.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ search:
5050
references: Copilot Sources
5151
loading_status_message: Loading Copilot response...
5252
done_loading_status_message: Done loading Copilot response
53-
copy_answer: Copy answer
54-
copied_announcement: Copied!
53+
share_answer: Copy answer URL
54+
share_copied_announcement: Copied share URL!
5555
thumbs_up: This answer was helpful
5656
thumbs_down: This answer was not helpful
5757
thumbs_announcement: Thank you for your feedback!

src/search/components/input/AskAIResults.tsx

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { ActionList, IconButton, Spinner } from '@primer/react'
77
import {
88
CheckIcon,
99
CopilotIcon,
10-
CopyIcon,
1110
FileIcon,
11+
ShareIcon,
1212
ThumbsdownIcon,
1313
ThumbsupIcon,
1414
} from '@primer/octicons-react'
@@ -85,7 +85,14 @@ export function AskAIResults({
8585
}>('ai-query-cache', 1000, 7)
8686
const { isOpen: isCTAOpen, permanentDismiss: permanentlyDismissCTA } = useCTAPopoverContext()
8787

88-
const [isCopied, setCopied] = useClipboard(message, { successDuration: 1400 })
88+
let copyUrl = ``
89+
if (window?.location?.href) {
90+
// Get base path from current URL
91+
const url = new URL(window.location.href)
92+
copyUrl = `${url.origin}/?search-overlay-open=true&search-overlay-ask-ai=true&search-overlay-input=${encodeURIComponent(query)}`
93+
}
94+
95+
const [isCopied, setCopied] = useClipboard(copyUrl, { successDuration: 1399 })
8996
const [feedbackSelected, setFeedbackSelected] = useState<null | 'up' | 'down'>(null)
9097

9198
const [conversationId, setConversationId] = useState<string>('')
@@ -504,15 +511,17 @@ export function AskAIResults({
504511
boxShadow: 'unset',
505512
color: isCopied ? 'var(--fgColor-accent) !important;' : '',
506513
}}
507-
icon={isCopied ? CheckIcon : CopyIcon}
514+
icon={isCopied ? CheckIcon : ShareIcon}
508515
className="btn-octicon"
509-
aria-label={t('ai.copy_answer')}
516+
aria-label={
517+
isCopied ? t('search.ai.share_copied_announcement') : t('search.ai.share_answer')
518+
}
510519
onClick={() => {
511520
setCopied()
512-
announce(t('ai.copied_announcement'))
521+
announce(t('search.ai.share_copied_announcement'))
513522
sendEvent({
514523
type: EventType.clipboard,
515-
clipboard_operation: 'copy',
524+
clipboard_operation: 'share',
516525
eventGroupKey: ASK_AI_EVENT_GROUP,
517526
eventGroupId: askAIEventGroupId.current,
518527
})

0 commit comments

Comments
 (0)