@@ -7,8 +7,8 @@ import { ActionList, IconButton, Spinner } from '@primer/react'
77import {
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