Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
fix: Add prompt click to AI Command Bar (#2471)
Ivan Starkov6dcddf5042de
diff --git a/apps/builder/app/builder/features/ai/ai-command-bar.tsx b/apps/builder/app/builder/features/ai/ai-command-bar.tsxindex 1163ebb2cf..e853260614 100644--- a/apps/builder/app/builder/features/ai/ai-command-bar.tsx+++ b/apps/builder/app/builder/features/ai/ai-command-bar.tsx@@ -78,7 +78,8 @@ export const AiCommandBar = () => {}const currentValue = getValue();- const newValue = `${currentValue} ${text}`;+ const newValue = [currentValue, text].filter(Boolean).join(" ");+setValue(newValue);setIsAudioTranscribing(false);@@ -145,6 +146,10 @@ export const AiCommandBar = () => {handleAiRequest(value);};+ const handlePropmptClick = (prompt: string) => {+ setValue(prompt);+ };+if (isAiCommandBarVisible === false) {return;}@@ -229,7 +234,12 @@ export const AiCommandBar = () => {<CommandBaropen={open}onOpenChange={setOpen}- content={<CommandBarContent prompts={prompts} />}+ content={+ <CommandBarContent+ prompts={prompts}+ onPromptClick={handlePropmptClick}+ />+ }><CommandBarTrigger><CommandBarButton color="dark-ghost">@@ -303,7 +313,10 @@ export const AiCommandBar = () => {);};-const CommandBarContent = (props: { prompts: string[] }) => {+const CommandBarContent = (props: {+ prompts: string[];+ onPromptClick: (value: string) => void;+}) => {const shortcutText = "⌘⇧Q";return (<>@@ -354,7 +367,10 @@ const CommandBarContent = (props: { prompts: string[] }) => {<ScrollArea css={{ maxHeight: theme.spacing[29], margin: -4 }}><Grid gap={2} css={{ margin: 4 }}>{props.prompts.map((prompt, index) => (- <CommandBarContentPrompt key={index}>+ <CommandBarContentPrompt+ key={index}+ onClick={() => props.onPromptClick(prompt)}+ >{prompt}</CommandBarContentPrompt>))}diff --git a/packages/design-system/src/components/ai-command-bar/command-bar.tsx b/packages/design-system/src/components/ai-command-bar/command-bar.tsxindex 93864fe20f..ea383cda96 100644--- a/packages/design-system/src/components/ai-command-bar/command-bar.tsx+++ b/packages/design-system/src/components/ai-command-bar/command-bar.tsx@@ -100,9 +100,12 @@ const CommandBarContentPromptText = styled("span", {whiteSpace: "break-spaces",});-export const CommandBarContentPrompt = (props: { children: ReactNode }) => {+export const CommandBarContentPrompt = (props: {+ children: ReactNode;+ onClick?: () => void;+}) => {return (- <CommandBarContentPromptStyled color="dark">+ <CommandBarContentPromptStyled color="dark" onClick={props.onClick}><CommandBarContentPromptText>{props.children}</CommandBarContentPromptText>