Merge branch 'main' of gitlab.com:soapbox-pub/act2

This commit is contained in:
Alex Gleason committed 2025-09-23 23:34:59 -05:00
commit 0df1ef1e9d
3 files changed
+66 -7

No files matched your search

+2 -2
View File
@@ -14,7 +14,7 @@ const ToastViewport = React.forwardRef<
<ToastPrimitives.Viewport
ref={ref}
className={cn(
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[420px]",
"fixed top-0 z-[100] flex max-h-screen w-full flex-col-reverse p-4 sm:bottom-0 sm:right-0 sm:top-auto sm:flex-col md:max-w-[480px]",
className
)}
{...props}
@@ -41,7 +41,7 @@ const toastVariants = cva(
const Toast = React.forwardRef<
React.ElementRef<typeof ToastPrimitives.Root>,
React.ComponentPropsWithoutRef<typeof ToastPrimitives.Root> &
VariantProps<typeof toastVariants>
VariantProps<typeof toastVariants>
>(({ className, variant, ...props }, ref) => {
return (
<ToastPrimitives.Root
+20
View File
@@ -254,6 +254,11 @@ const resources = {
recentlyUsed: 'Recently Used',
errorLoadingModels: 'Error Loading Models',
// API Authentication Errors
apiAuthenticationFailed: 'API Authentication Failed',
invalidApiKey: 'Invalid API key for {{provider}}. Please check your API key in Settings.',
checkApiKeySettings: 'Check API Key Settings',
// Context and Cost
contextUsage: 'Context usage: {{tokens}} / {{total}} tokens ({{percentage}}%)',
totalCostSession: 'Total cost for this chat session',
@@ -548,6 +553,11 @@ const resources = {
recentlyUsed: 'Usados Recentemente',
errorLoadingModels: 'Erro ao Carregar Modelos',
// API Authentication Errors
apiAuthenticationFailed: 'Falha na Autenticação da API',
invalidApiKey: 'Chave de API inválida para {{provider}}. Verifique sua chave de API nas Configurações.',
checkApiKeySettings: 'Verificar Configurações da Chave de API',
// Context and Cost
contextUsage: 'Uso de contexto: {{tokens}} / {{total}} tokens ({{percentage}}%)',
totalCostSession: 'Custo total para esta sessão de chat',
@@ -842,6 +852,11 @@ const resources = {
recentlyUsed: '最近使用',
errorLoadingModels: '加载模型时出错',
// API Authentication Errors
apiAuthenticationFailed: 'API身份验证失败',
invalidApiKey: '{{provider}}的API密钥无效。请在设置中检查您的API密钥。',
checkApiKeySettings: '检查API密钥设置',
// Context and Cost
contextUsage: '上下文使用:{{tokens}} / {{total}} 令牌 ({{percentage}}%)',
totalCostSession: '此聊天会话的总费用',
@@ -1136,6 +1151,11 @@ const resources = {
recentlyUsed: 'An yi amfani da su kwanan nan',
errorLoadingModels: 'Kuskure wajen Lodin Samfura',
// API Authentication Errors
apiAuthenticationFailed: 'Gazawar Tabbatarwar API',
invalidApiKey: 'Maɓallin API na {{provider}} ba daidai ba ne. Da fatan za a duba maɓallin API a cikin Saitunan.',
checkApiKeySettings: 'Duba Saitunan Maɓallin API',
// Context and Cost
contextUsage: 'Amfanin mahallin: {{tokens}} / {{total}} alamomi ({{percentage}}%)',
totalCostSession: 'Jimlar farashi don wannan zaman hira',
+44 -5
View File
@@ -7,9 +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 { 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';
@@ -18,6 +20,7 @@ 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';
@@ -32,6 +35,7 @@ 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] || '';
@@ -43,6 +47,41 @@ export default function Index() {
// 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.charAt(0).toUpperCase() + provider.slice(1);
} catch {
// Keep default 'Provider'
}
toast({
title: t('apiAuthenticationFailed'),
description: t('invalidApiKey', { provider: providerName }),
variant: 'destructive',
action: (
<ToastAction
altText={t('checkApiKeySettings')}
onClick={() => navigate('/settings/ai')}
>
{t('checkApiKeySettings')}
</ToastAction>
),
});
}
return isAuthError;
};
useEffect(() => {
if (!providerModel && settings.recentlyUsedModels?.length) {
setProviderModel(settings.recentlyUsedModels[0]);
@@ -222,6 +261,7 @@ export default function Index() {
navigate(`/project/${project.id}?${searchParams.toString()}`);
} catch (error) {
console.error('Failed to create project:', error);
checkForKeyFailure(error);
} finally {
setIsCreating(false);
}
@@ -246,9 +286,8 @@ export default function Index() {
<div className="mb-8 md:mb-12">
{/* Chat Input Container - matching the ChatPane style */}
<div
className={`relative rounded-2xl border border-input bg-background shadow-sm focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 transition-all ${
isDragOver ? 'border-primary bg-primary/5 ring-2 ring-primary/20' : ''
}`}
className={`relative rounded-2xl border border-input bg-background shadow-sm focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2 transition-all ${isDragOver ? 'border-primary bg-primary/5 ring-2 ring-primary/20' : ''
}`}
onDragEnter={handleDragEnter}
onDragOver={handleDragOver}
onDragLeave={handleDragLeave}
@@ -259,8 +298,8 @@ export default function Index() {
!hasProvidersConfigured
? t('examplePrompt')
: !providerModel.trim()
? t('selectModelToDescribe')
: t('examplePrompt')
? t('selectModelToDescribe')
: t('examplePrompt')
}
value={prompt}
onChange={handlePromptChange}