@@ -4,6 +4,8 @@ import cn from '@ably/ui/core/utils/cn';
44import Icon from '@ably/ui/core/Icon' ;
55import { IconName } from '@ably/ui/core/Icon/types' ;
66import { componentMaxHeight , HEADER_HEIGHT , HEADER_BOTTOM_MARGIN } from '@ably/ui/core/utils/heights' ;
7+ import Tooltip from '@ably/ui/core/Tooltip' ;
8+ import { track } from '@ably/ui/core/insights' ;
79
810import { LanguageSelector } from './LanguageSelector' ;
911import { useLayoutContext } from 'src/contexts/layout-context' ;
@@ -58,19 +60,33 @@ const externalLinks = (
5860 **Requested change or enhancement**:
5961` ) ;
6062
61- const requestPath = `${ requestBasePath } ?title=${ requestTitle } &body=${ requestBody } ` ;
62- const prompt = `Tell me more about ${ activePage . product ? productData [ activePage . product ] ?. nav . name : 'Ably' } 's '${ activePage . page . name } ' feature from https://ably.com${ activePage . page . link } ${ language ? ` for ${ languageInfo [ language ] ?. label } ` : '' } ` ;
63- const gptPath = `https://chatgpt.com/?q=${ encodeURIComponent ( prompt ) } ` ;
64-
6563 return [
6664 {
6765 label : 'Edit on GitHub' ,
6866 icon : 'icon-social-github-mono' ,
6967 link : githubEditPath ,
7068 type : 'github' ,
7169 } ,
72- { label : 'Request changes' , icon : 'icon-gui-hand-raised-outline' , link : requestPath , type : 'request' } ,
73- { label : 'Open in ChatGPT' , icon : 'icon-tech-openai' , link : gptPath , type : 'llm' } ,
70+ {
71+ label : 'Request changes' ,
72+ icon : 'icon-gui-hand-raised-outline' ,
73+ link : `${ requestBasePath } ?title=${ requestTitle } &body=${ requestBody } ` ,
74+ type : 'request' ,
75+ } ,
76+ ] ;
77+ } ;
78+
79+ const llmLinks = (
80+ activePage : ActivePage ,
81+ language : LanguageKey ,
82+ ) : { model : string ; label : string ; icon : IconName ; link : string } [ ] => {
83+ const prompt = `Tell me more about ${ activePage . product ? productData [ activePage . product ] ?. nav . name : 'Ably' } 's '${ activePage . page . name } ' feature from https://ably.com${ activePage . page . link } ${ language ? ` for ${ languageInfo [ language ] ?. label } ` : '' } ` ;
84+ const gptPath = `https://chatgpt.com/?q=${ encodeURIComponent ( prompt ) } ` ;
85+ const claudePath = `https://claude.ai/new?q=${ encodeURIComponent ( prompt ) } ` ;
86+
87+ return [
88+ { model : 'gpt' , label : 'ChatGPT' , icon : 'icon-tech-openai' , link : gptPath } ,
89+ { model : 'claude' , label : 'Claude (must be logged in)' , icon : 'icon-tech-claude-mono' , link : claudePath } ,
7490 ] ;
7591} ;
7692
@@ -244,7 +260,7 @@ const RightSidebar = () => {
244260 </ >
245261 ) : null }
246262 < div className = "bg-neutral-100 dark:bg-neutral-1200 border border-neutral-300 dark:border-neutral-1000 rounded-lg transition-colors mt-6" >
247- { externalLinks ( activePage , location ) . map ( ( { label, icon, link, type } , index ) => (
263+ { externalLinks ( activePage , location ) . map ( ( { label, icon, link, type } ) => (
248264 < a
249265 key = { label }
250266 href = { link }
@@ -253,12 +269,7 @@ const RightSidebar = () => {
253269 className = "group/external-link"
254270 data-testid = { `external-${ type } -link` }
255271 >
256- < div
257- className = { cn (
258- 'flex items-center p-4' ,
259- index > 0 && 'border-t border-neutral-300 dark:border-neutral-1000' ,
260- ) }
261- >
272+ < div className = "flex items-center p-4 border-b border-neutral-300 dark:border-neutral-1000" >
262273 < div className = "flex-1 flex items-center gap-3" >
263274 < Icon
264275 size = "20px"
@@ -279,6 +290,38 @@ const RightSidebar = () => {
279290 </ div >
280291 </ a >
281292 ) ) }
293+ < div className = "flex items-center p-4 gap-2" >
294+ < span className = "text-p4 font-semibold text-neutral-900 dark:text-neutral-400" > Open in </ span >
295+ { llmLinks ( activePage , language ) . map ( ( { model, label, icon, link } ) => (
296+ < a
297+ key = { model }
298+ href = { link }
299+ target = "_blank"
300+ rel = "noopener noreferrer"
301+ className = "flex h-5 ui-theme-dark group/llm-link cursor-pointer"
302+ onClick = { ( ) => {
303+ track ( 'llm_link_clicked' , {
304+ model,
305+ location : location . pathname ,
306+ link,
307+ } ) ;
308+ } }
309+ >
310+ < Tooltip
311+ content = { label }
312+ triggerElement = {
313+ < Icon
314+ name = { icon }
315+ size = "20px"
316+ additionalCSS = "transition-colors text-neutral-900 dark:text-neutral-400 group-hover/llm-link:text-neutral-1300 dark:group-hover/llm-link:text-neutral-000"
317+ />
318+ }
319+ >
320+ { label }
321+ </ Tooltip >
322+ </ a >
323+ ) ) }
324+ </ div >
282325 </ div >
283326 </ div >
284327 </ div >
0 commit comments