Skip to content

Open page in llm copy button with dropdown#354

Draft
JopMolenaar wants to merge 6 commits intomainfrom
feat/open-page-in-llm-copy-button-with-dropdown
Draft

Open page in llm copy button with dropdown#354
JopMolenaar wants to merge 6 commits intomainfrom
feat/open-page-in-llm-copy-button-with-dropdown

Conversation

@JopMolenaar
Copy link
Copy Markdown
Contributor

Changes

  • Adds copy page button on every page if AllowAIBots is true
  • Adds llmLinks in a popover next to the copy button, if these are configured in the CMS
    • These llm links will open a llm with the prompt you've added in the CMS.
    • Otherwise it will only add the pageUrl as promp
  • Adds migration file for added cms options
  • Adds translations // TODO

Associated issue

Resolves #341

How to test

  1. Open a page
  2. Copy the page and paste it somewhere to verify that it has copied the right content.
  3. Test errors. What if the fetch fails, remove the alternate link for example.
  4. Change CMS settings like AllowAIBots in order to check if the button is not rendered in this case.
  5. Check the popover on accessibility
  6. Open the page in llm via the popover link

Checklist

  • I have performed a self-review of my own code
  • I have made sure that my PR is easy to review (not too big, includes comments)
  • I have made updated relevant documentation files (in project README, docs/, etc)
  • I have added a decision log entry if the change affects the architecture or changes a significant technology
  • I have notified a reviewer

@JopMolenaar JopMolenaar self-assigned this Apr 22, 2026
@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages Bot commented Apr 23, 2026

Deploying head-start with  Cloudflare Pages  Cloudflare Pages

Latest commit: c9059c4
Status: ✅  Deploy successful!
Preview URL: https://0e4ff2d8.head-start.pages.dev
Branch Preview URL: https://feat-open-page-in-llm-copy-b.head-start.pages.dev

View logs

Comment thread src/components/OpenInLlm/OpenInLlm.astro Outdated
setTimeout(() => this.#setLabel(this.#originalLabel), 2000);
};

#buildCopyText = async (pageUrl: string): Promise<string> => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

When I click Copy page. The button says 'Failed to copy page'. This error however is a bit obscure and I think it would be nice to add a console error for this with more info about what went wrong.

Comment on lines +10 to +16

const { llmOptions, prompt } = Astro.props;

const popoverId = 'open-in-llm-popover';
const pageUrl = Astro.url.href;

let searchText = prompt.replace('{ pageUrl }', pageUrl);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

.replace('{ pageUrl }') is really fragile. I think you should implement a more robust way. Maybe a regex key? Or third party package?

Also this replaces the first instance of the { pageUrl }. What if someone wants to add multiple { pageUrl }{ pageUrl }{ pageUrl }? You could handle that through a regex or .replaceAll('{ pageUrl }') for example.

Object.assign(popover.style, {
left: `${x}px`,
top: `${y}px`,
width: `${this.#buttonGroup!.offsetWidth}px`,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think you should remove the width limitation since this causes every line to break because the width of the button set is always way smaller probably. If you're trying to prevent the box to flow off screen then I think you should alter your positioning to detect that and adjust the position.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Open page in LLM button

3 participants