From abdd4eb13587787a64bff32c4c60edd7cc42d7f1 Mon Sep 17 00:00:00 2001 From: vgcman16 <155417613+vgcman16@users.noreply.github.com> Date: Thu, 5 Jun 2025 19:36:40 -0500 Subject: [PATCH] feat(chat): add ask bolt action for code blocks --- app/components/chat/ChatBox.tsx | 13 ++++++++++++- app/components/chat/CodeBlock.module.scss | 2 +- app/components/chat/CodeBlock.tsx | 16 ++++++++++++++-- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/app/components/chat/ChatBox.tsx b/app/components/chat/ChatBox.tsx index 3eaab0cd..70f23899 100644 --- a/app/components/chat/ChatBox.tsx +++ b/app/components/chat/ChatBox.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useEffect } from 'react'; import { ClientOnly } from 'remix-utils/client-only'; import { classNames } from '~/utils/classNames'; import { PROVIDER_LIST } from '~/utils/constants'; @@ -69,6 +69,17 @@ interface ChatBoxProps { } export const ChatBox: React.FC = (props) => { + useEffect(() => { + (window as any).__BOLT_ASK_SNIPPET__ = (code: string, lang: string) => { + const message = `*What does this code do?*\n\`\`\`${lang || 'plaintext'}\n${code}\n\`\`\`\n`; + props.handleSendMessage?.({} as any, message); + }; + + return () => { + delete (window as any).__BOLT_ASK_SNIPPET__; + }; + }, [props.handleSendMessage]); + return (
)} +