diff --git a/frontend/src/lib/components/AskAiButton.svelte b/frontend/src/lib/components/AskAiButton.svelte new file mode 100644 index 0000000000..0ad318e889 --- /dev/null +++ b/frontend/src/lib/components/AskAiButton.svelte @@ -0,0 +1,29 @@ + + + diff --git a/frontend/src/lib/components/chat/GlobalChat.svelte b/frontend/src/lib/components/chat/GlobalChat.svelte index f7169825cf..d81317664b 100644 --- a/frontend/src/lib/components/chat/GlobalChat.svelte +++ b/frontend/src/lib/components/chat/GlobalChat.svelte @@ -4,6 +4,7 @@ import { Send, Loader2 } from 'lucide-svelte' import { chatRequest, prepareSystemMessage } from './core' import type { ChatCompletionMessageParam } from 'openai/resources/index.mjs' + import { globalChatInitialInput } from '$lib/stores' let chatHistory = [ { @@ -17,6 +18,17 @@ let currentReply = $state('') let messages = $state(chatHistory) + // Suggested questions for the user + const suggestions = $state([ + 'How do I create a new workflow?', + "What's the difference between scripts and flows?", + 'How can I connect to a database?', + 'How do I schedule a recurring job?' + ]) + + // Check if there are any user messages + const hasUserMessages = $derived(messages.some((msg) => msg.role === 'user')) + let abortController = new AbortController() async function handleSubmit() { @@ -45,6 +57,19 @@ inputValue = '' isSubmitting = false } + + function submitSuggestion(suggestion: string) { + inputValue = suggestion + handleSubmit() + } + + $effect(() => { + if (globalChatInitialInput) { + inputValue = $globalChatInitialInput + globalChatInitialInput.set('') + handleSubmit() + } + })