- {Array.from({ length: 3 }).map((_, i) => (
-
- ))}
+
) : !payments || payments.length === 0 ? (
diff --git a/src/components/Quilly.tsx b/src/components/Quilly.tsx
index ffb746a0..b0b97f05 100644
--- a/src/components/Quilly.tsx
+++ b/src/components/Quilly.tsx
@@ -30,8 +30,17 @@ interface ErrorBody {
export function Quilly({ error, onDismiss, onNewChat, onOpenModelSelector, onRequestConsoleErrorHelp, providerModel }: QuillyProps) {
const navigate = useNavigate();
const { settings } = useAISettings();
- const { provider } = parseProviderModel(providerModel, settings.providers);
- const credits = useAICredits(provider);
+
+ // Handle empty provider model gracefully
+ let provider;
+ try {
+ provider = parseProviderModel(providerModel, settings.providers).provider;
+ } catch {
+ // If no valid provider model, use a default or undefined
+ provider = undefined;
+ }
+
+ const credits = useAICredits(provider || { id: '', name: '', apiKey: '', nostr: false });
const [showCreditsDialog, setShowCreditsDialog] = useState(false);
const renderBody = (error: Error): ErrorBody => {
diff --git a/src/hooks/useAIProjectId.ts b/src/hooks/useAIProjectId.ts
index 7c688c5e..a334c295 100644
--- a/src/hooks/useAIProjectId.ts
+++ b/src/hooks/useAIProjectId.ts
@@ -80,7 +80,7 @@ export function useAIProjectId({ onError }: UseAIProjectIdOptions = {}) {
} catch (error) {
const errorMessage = error instanceof Error ? error.message : 'Failed to generate project ID';
onError?.(errorMessage);
- throw new Error(errorMessage);
+ throw error;
} finally {
setIsLoading(false);
}
diff --git a/src/pages/Index.tsx b/src/pages/Index.tsx
index f15589b1..c0c1c0b0 100644
--- a/src/pages/Index.tsx
+++ b/src/pages/Index.tsx
@@ -7,12 +7,11 @@ import { useFS } from '@/hooks/useFS';
import { useLocalStorage } from '@/hooks/useLocalStorage';
import { useIsMobile } from '@/hooks/useIsMobile';
import { useAISettings } from '@/hooks/useAISettings';
-import { useToast } from '@/hooks/useToast';
import { AppLayout } from '@/components/AppLayout';
import { OnboardingDialog } from '@/components/OnboardingDialog';
import { Act1Dialog } from '@/components/Act1Dialog';
+import { Quilly } from '@/components/Quilly';
import { DotAI } from '@/lib/DotAI';
-import { parseProviderModel } from '@/lib/parseProviderModel';
import type { AIMessage } from '@/lib/SessionManager';
import { saveFileToTmp } from '@/lib/fileUtils';
import type OpenAI from 'openai';
@@ -20,7 +19,6 @@ import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { ModelSelector } from '@/components/ModelSelector';
import { FileAttachment } from '@/components/ui/file-attachment';
-import { ToastAction } from '@/components/ui/toast';
import { Plus } from 'lucide-react';
import { useSeoMeta } from '@unhead/react';
@@ -36,7 +34,6 @@ export default function Index() {
const { fs } = useFS();
const { generateProjectId, isLoading: isGeneratingId } = useAIProjectId();
const { settings, addRecentlyUsedModel } = useAISettings();
- const { toast } = useToast();
const [providerModel, setProviderModel] = useState(() => {
// Initialize with first recently used model if available, otherwise empty
return settings.recentlyUsedModels?.[0] || '';
@@ -44,45 +41,11 @@ export default function Index() {
const isMobile = useIsMobile();
const [attachedFiles, setAttachedFiles] = useState([]);
const [isDragOver, setIsDragOver] = useState(false);
+ const [quillyError, setQuillyError] = useState(null);
// Check if any providers are configured
const hasProvidersConfigured = settings.providers.length > 0;
- // Check for API key failures and show appropriate toast
- const checkForKeyFailure = (error: unknown): boolean => {
- // Check for authentication errors
- // Note: useAIProjectId re-throws OpenAI errors as generic Error objects
- const isAuthError = error instanceof Error && error.message === '401 No auth credentials found';
-
- if (isAuthError) {
- // Get provider name inline
- let providerName = 'Provider';
- try {
- const { provider } = parseProviderModel(providerModel, settings.providers);
- providerName = provider.id.charAt(0).toUpperCase() + provider.id.slice(1);
- } catch {
- // Keep default 'Provider'
- }
-
- toast({
- title: t('apiAuthenticationFailed'),
- description: t('invalidApiKey', { provider: providerName }),
- variant: 'destructive',
- action: (
- navigate('/settings/ai')}
- >
- {t('checkApiKeySettings')}
-
- ),
- });
- }
-
- return isAuthError;
- };
-
-
useEffect(() => {
if (!providerModel && settings.recentlyUsedModels?.length) {
setProviderModel(settings.recentlyUsedModels[0]);
@@ -196,6 +159,27 @@ export default function Index() {
}
};
+ // Quilly handlers
+ const handleQuillyDismiss = () => {
+ setQuillyError(null);
+ };
+
+ const handleQuillyNewChat = () => {
+ // Clear current prompt and start fresh
+ setPrompt('');
+ setStoredPrompt('');
+ setAttachedFiles([]);
+ setQuillyError(null);
+ };
+
+ const handleQuillyOpenModelSelector = () => {
+ // Focus on model selector or open AI settings if no providers
+ if (!hasProvidersConfigured) {
+ setShowOnboarding(true);
+ }
+ setQuillyError(null);
+ };
+
const handleCreateProject = async () => {
if (!prompt.trim() || !providerModel.trim()) return;
@@ -270,13 +254,7 @@ export default function Index() {
navigate(`/project/${project.id}?${searchParams.toString()}`);
} catch (error) {
console.error('Failed to create project:', error);
- if (!checkForKeyFailure(error)) {
- toast({
- title: "Project Creation Failed",
- description: error instanceof Error ? error.message : "An unexpected error occurred",
- variant: "destructive",
- });
- }
+ setQuillyError(error instanceof Error ? error : new Error("An unexpected error occurred"));
} finally {
setIsCreating(false);
}
@@ -299,6 +277,19 @@ export default function Index() {
+ {/* Quilly Helper - shows when there are errors */}
+ {quillyError && (
+
+
+
+ )}
+
{/* Chat Input Container - matching the ChatPane style */}