diff --git a/src/components/Shakespeare/ChatPane.tsx b/src/components/Shakespeare/ChatPane.tsx index 12488223..b0f98b8b 100644 --- a/src/components/Shakespeare/ChatPane.tsx +++ b/src/components/Shakespeare/ChatPane.tsx @@ -7,6 +7,7 @@ import { Skeleton } from '@/components/ui/skeleton'; import { CircularProgress } from '@/components/ui/circular-progress'; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip'; import { FileAttachment } from '@/components/ui/file-attachment'; +import { OnboardingDialog } from '@/components/OnboardingDialog'; import { Square, Loader2, ChevronDown, ArrowUp } from 'lucide-react'; import { useAISettings } from '@/hooks/useAISettings'; import { useFS } from '@/hooks/useFS'; @@ -70,6 +71,7 @@ export const ChatPane = forwardRef(({ const [attachedFiles, setAttachedFiles] = useState([]); const [isDragOver, setIsDragOver] = useState(false); const [scrolledProjects] = useState(() => new Set()); + const [showOnboarding, setShowOnboarding] = useState(false); // Use external state if provided, otherwise default to false const isBuildLoading = externalIsBuildLoading || false; @@ -344,7 +346,16 @@ export const ChatPane = forwardRef(({ }; const handleSend = async () => { - if ((!input.trim() && attachedFiles.length === 0) || isLoading || !providerModel.trim()) return; + if ((!input.trim() && attachedFiles.length === 0) || isLoading) return; + + // If AI is not configured, show onboarding dialog + if (!isConfigured) { + setShowOnboarding(true); + return; + } + + // If configured but no model selected, don't proceed + if (!providerModel.trim()) return; const modelToUse = providerModel.trim(); @@ -434,6 +445,16 @@ export const ChatPane = forwardRef(({ } }; + // Handle textarea focus - show onboarding if not configured + const handleTextareaFocus = () => { + if (!isConfigured) { + setShowOnboarding(true); + } + if (onFirstInteraction) { + onFirstInteraction(); + } + }; + // Handle first user interaction to enable audio context const handleFirstInteraction = () => { // This will be handled automatically by the useKeepAlive hook @@ -450,27 +471,6 @@ export const ChatPane = forwardRef(({ } }), [internalStartNewSession]); - if (!isConfigured) { - return ( -
-
-
-
🤖
-
-

{t('aiNotConfigured')}

-

- {t('configureAI')} -

-

- {t('useMenuForAI')} -

-
-
-
-
- ); - } - return ( @@ -585,10 +585,16 @@ export const ChatPane = forwardRef(({ onChange={(e) => setInput(e.target.value)} onKeyDown={handleKeyDown} onPaste={handlePaste} - onFocus={handleFirstInteraction} - placeholder={providerModel.trim() ? t('askToAddFeatures') : t('selectModelFirst')} + onFocus={handleTextareaFocus} + placeholder={ + !isConfigured + ? t('askToAddFeatures') + : providerModel.trim() + ? t('askToAddFeatures') + : t('selectModelFirst') + } className="flex-1 resize-none border-0 bg-transparent px-4 py-3 text-sm focus-visible:ring-0 focus-visible:ring-offset-0 placeholder:text-muted-foreground" - disabled={isLoading || !providerModel.trim()} + disabled={isLoading || (isConfigured && !providerModel.trim())} rows={1} aria-label="Chat message input" style={{ @@ -679,7 +685,7 @@ export const ChatPane = forwardRef(({