Skip to content

Add Open in ChatGPT and Open in Claude page actions#4658

Open
bilal-karim wants to merge 3 commits into
mainfrom
llm-ctas-chatgpt-claude
Open

Add Open in ChatGPT and Open in Claude page actions#4658
bilal-karim wants to merge 3 commits into
mainfrom
llm-ctas-chatgpt-claude

Conversation

@bilal-karim
Copy link
Copy Markdown
Member

@bilal-karim bilal-karim commented Jun 4, 2026

Summary

Adds two new external-link actions alongside the existing Copy for LLM and View as Markdown CTAs under the docs page title:

  • Open in ChatGPT — opens chatgpt.com in a new tab with a prompt prefilled to read the current page
  • Open in Claude — opens claude.ai in a new tab with the same prefilled prompt

The prompt sent to each assistant is: Read <page-url> and answer questions about the content.

Changes

  • src/components/LLMActions/LLMActions.tsx
    • Capture the page URL client-side (window is unavailable during SSR) and build encoded ChatGPT/Claude deep links
    • Render the two new actions as anchors with the OpenAI/Claude brand icons (react-icons/si) plus a trailing external-link icon
    • Carry the same data-analytics-* attributes as the existing actions (open-in-chatgpt / open-in-claude) so usage is tracked in Amplitude
  • src/components/LLMActions/LLMActions.module.css
    • Normalize height between <button> and <a> elements (line-height, box-sizing, font-family, text-decoration)
    • Add a muted, smaller externalIcon style

Testing

  • Verified locally via npm run start; all four actions render at a consistent height under the page title and the external links open the respective assistants with the page URL prefilled.

🤖 Generated with Claude Code

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 4, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
temporal-documentation Ready Ready Preview, Comment Jun 4, 2026 8:53pm

Request Review

@bilal-karim bilal-karim changed the title Add LLM-friendly page actions: Copy for LLM, View as Markdown, Open in ChatGPT/Claude Add LLM-friendly page actions: Open in ChatGPT/Claude Jun 4, 2026
@bilal-karim bilal-karim changed the title Add LLM-friendly page actions: Open in ChatGPT/Claude Add Open in ChatGPT and Open in Claude page actions Jun 4, 2026
@bilal-karim bilal-karim changed the base branch from main to llm-ctas June 4, 2026 19:32
Adds two external-link actions alongside the existing Copy for LLM and
View as Markdown CTAs under the page title. Each opens the respective
assistant in a new tab with a prompt prefilled to read the current page.

- Capture the page URL client-side (window unavailable during SSR)
- Render ChatGPT/Claude as anchors with OpenAI/Claude brand icons plus a
  trailing external-link icon
- Normalize button vs. anchor height (line-height, box-sizing, font-family)

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bilal-karim bilal-karim changed the base branch from llm-ctas to main June 4, 2026 19:37
@bilal-karim bilal-karim force-pushed the llm-ctas-chatgpt-claude branch from 5a6a69a to 49bc308 Compare June 4, 2026 19:37
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 4, 2026

📖 Docs PR preview links

This PR does not change any pages in /docs. If you make updates, links to the modified pages will appear here.

The new pageUrl state shadowed a local of the same name inside
handleCopyForLLM. Reuse the state value (added to the callback deps)
instead of re-reading window.location.href.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bilal-karim bilal-karim force-pushed the llm-ctas-chatgpt-claude branch from 49bc308 to 57fba60 Compare June 4, 2026 19:41
@bilal-karim bilal-karim marked this pull request as ready for review June 4, 2026 19:43
@bilal-karim bilal-karim requested a review from a team as a code owner June 4, 2026 19:43
@bilal-karim bilal-karim requested a review from alfredsmchan June 4, 2026 19:44
Copy link
Copy Markdown

@alfredsmchan alfredsmchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Copy Markdown
Contributor

@jsundai jsundai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!! Will take a full look sometime today.

@alfredsmchan
Copy link
Copy Markdown

alfredsmchan commented Jun 4, 2026

if it fails to get the Page URL, we should hide the buttons unless there is a valid URL.

Addresses review feedback: the ChatGPT/Claude prompts were built from a
client-side window.location.href captured in useEffect, which left the
URL empty during SSR and the first render. Derive a canonical absolute
URL from siteConfig.url + metadata.permalink instead, so the prompt is
always valid with no effect, state, or empty-URL window.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@bilal-karim
Copy link
Copy Markdown
Member Author

Good call — fixed in 3e09dfc, though I went a slightly different route than disabling the buttons.

Root cause: the prompt URL was built from window.location.href captured in a client-side useEffect, so it was empty during SSR and the first render — that's the window where a click would produce Read and answer questions.... (Note: the "failed to fetch" you saw is actually a separate path — that's Copy for LLM fetching the raw markdown, not the page-URL resolution. window.location.href itself is synchronous and doesn't throw.)

Rather than guard/disable on an empty value, I removed the failure mode entirely: the URL is now derived synchronously from Docusaurus's own data —

const { siteConfig } = useDocusaurusContext();
const pageUrl = `${siteConfig.url}${metadata.permalink}`;

So it's a valid canonical URL during SSR, first paint, and every render — no useEffect, no state, no empty-URL window to defend against. Bonus: it's the clean canonical URL (e.g. https://docs.temporal.io/evaluate/) rather than whatever query/hash happened to be on window.location.

Verified in the browser — the rendered links resolve to:
Read https://docs.temporal.io/evaluate/ and answer questions about the content.

Copy link
Copy Markdown

@alfredsmchan alfredsmchan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for update!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants