From a4fe647c0e4a357268b5e4aa1c6e1407bf65d341 Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 8 May 2026 17:24:25 +0000 Subject: [PATCH] feat(codeblocks): add Ask AI button that opens chatbot with prefilled 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=, 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 --- docs/.vuepress/components/Chat.vue | 44 +++++++++++++++++++- docs/.vuepress/components/CodeTabs.vue | 36 ++++++++++++++++ docs/.vuepress/components/GlobalCopyCode.vue | 17 +++++++- docs/.vuepress/composables/useChat.js | 33 +++++++++++++++ docs/.vuepress/styles/theme.styl | 23 ++++++++++ 5 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 docs/.vuepress/composables/useChat.js diff --git a/docs/.vuepress/components/Chat.vue b/docs/.vuepress/components/Chat.vue index 2bf2db38f..7c9a02d12 100644 --- a/docs/.vuepress/components/Chat.vue +++ b/docs/.vuepress/components/Chat.vue @@ -65,6 +65,7 @@