Skip to content

Commit bfb18c8

Browse files
authored
Merge pull request #2768 from ably/web-4561-claude-button
[WEB-4561] Generalise LLM links, add Claude and track clicks
2 parents da33452 + fb7769e commit bfb18c8

3 files changed

Lines changed: 61 additions & 18 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"validate-llms-txt": "ts-node bin/validate-llms.txt.ts"
4141
},
4242
"dependencies": {
43-
"@ably/ui": "17.4.2",
43+
"@ably/ui": "17.6.1",
4444
"@codesandbox/sandpack-react": "^2.20.0",
4545
"@codesandbox/sandpack-themes": "^2.0.21",
4646
"@gfx/zopfli": "^1.0.15",

src/components/Layout/RightSidebar.tsx

Lines changed: 56 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import cn from '@ably/ui/core/utils/cn';
44
import Icon from '@ably/ui/core/Icon';
55
import { IconName } from '@ably/ui/core/Icon/types';
66
import { 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

810
import { LanguageSelector } from './LanguageSelector';
911
import { 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>

yarn.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77
resolved "https://registry.yarnpkg.com/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz#bd9154aec9983f77b3a034ecaa015c2e4201f6cf"
88
integrity sha512-1Yjs2SvM8TflER/OD3cOjhWWOZb58A2t7wpE2S9XfBYTiIl+XFhQG2bjy4Pu1I+EAlCNUzRDYDdFwFYUKvXcIA==
99

10-
"@ably/ui@17.4.2":
11-
version "17.4.2"
12-
resolved "https://registry.yarnpkg.com/@ably/ui/-/ui-17.4.2.tgz#dd3834fbcb713c033f8ecb4d496977a677eab9db"
13-
integrity sha512-yB3AZjvtLvHtKRbllKJRFJf7eLnA6rEhMoR736giEvt0uI4b4GZDch2XFBVbLQVDr1i2XTi1WU1RrwP22m6tew==
10+
"@ably/ui@17.6.1":
11+
version "17.6.1"
12+
resolved "https://registry.yarnpkg.com/@ably/ui/-/ui-17.6.1.tgz#74b9b55bd1e63173bc4a4a9bf3b93bbab68d6a3b"
13+
integrity sha512-AJZLUvOYqLftQw/sslrWG2+hREW/ZKRl2wBqERxQj6AO8PScp83OvXhNCM/PQq4y1qTIqw6PxZ54cg0r6UX/gQ==
1414
dependencies:
1515
"@heroicons/react" "^2.2.0"
1616
"@radix-ui/react-accordion" "^1.2.1"

0 commit comments

Comments
 (0)