Skip to content

add Ask AI button#555

Draft
sboldyreva wants to merge 1 commit into
cloudlinux:masterfrom
sboldyreva:claude/codeblock-ask-ai
Draft

add Ask AI button#555
sboldyreva wants to merge 1 commit into
cloudlinux:masterfrom
sboldyreva:claude/codeblock-ask-ai

Conversation

@sboldyreva
Copy link
Copy Markdown
Collaborator

Adds a sparkle-icon "Ask AI" button next to the copy button on every code block (CodeTabs and globally-injected fenced blocks). Clicking it opens the existing Chat.vue iframe pre-seeded with a prompt that includes the page title, URL, and the snippet (truncated to 4 KB).

Implementation:

  • New shared reactive store in composables/useChat.js coordinating openChatWithPrompt() between code-block buttons and Chat.vue.
  • Chat.vue watches the trigger counter, rebuilds iframeUrl with ?prompt=, and also postMessages {type:'prefill', prompt} to the iframe on load as a backup path.
  • Sparkle SVG icon, mirroring the existing copy button styling.

The chatbot at chatbot.cloudlinux.com/docs/tuxcare needs to honor either the ?prompt= query param or the postMessage on its side for the prefill to take effect; if neither is wired up the iframe just opens normally (no regression).

… prompt

Adds a sparkle-icon "Ask AI" button next to the copy button on every
code block (CodeTabs and globally-injected fenced blocks). Clicking it
opens the existing Chat.vue iframe pre-seeded with a prompt that
includes the page title, URL, and the snippet (truncated to 4 KB).

Implementation:
- New shared reactive store in composables/useChat.js coordinating
  openChatWithPrompt() between code-block buttons and Chat.vue.
- Chat.vue watches the trigger counter, rebuilds iframeUrl with
  ?prompt=<encoded>, and also postMessages {type:'prefill', prompt}
  to the iframe on load as a backup path.
- Sparkle SVG icon, mirroring the existing copy button styling.

The chatbot at chatbot.cloudlinux.com/docs/tuxcare needs to honor
either the ?prompt= query param or the postMessage on its side for
the prefill to take effect; if neither is wired up the iframe just
opens normally (no regression).

https://claude.ai/code/session_01QfJnUKM4fgcv1aJLHEeKUN
Copy link
Copy Markdown
Collaborator

@yel-hadd yel-hadd left a comment

Choose a reason for hiding this comment

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

Thank you for the new feature, LGTM!

@sboldyreva
Copy link
Copy Markdown
Collaborator Author

@yel-hadd is it good to go, to be nerged to give this feauture a try?

@yel-hadd
Copy link
Copy Markdown
Collaborator

@sboldyreva actually, I am working on improving the search UI. Let me contribute further to this PR before merging. Thank you

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