fix: second round of fixes
This commit is contained in:
@@ -23,9 +23,6 @@ export const ChatPanel: React.FC<ChatPanelProps> = ({ conversationId }) => {
|
||||
const [availableModels, setAvailableModels] = useState<ChatModel[]>([]);
|
||||
const [showModelSelector, setShowModelSelector] = useState(false);
|
||||
const [needsApiKey, setNeedsApiKey] = useState(false);
|
||||
const [apiKeyInput, setApiKeyInput] = useState('');
|
||||
const [apiKeyError, setApiKeyError] = useState('');
|
||||
const [isValidating, setIsValidating] = useState(false);
|
||||
const [actionError, setActionError] = useState<string | null>(null);
|
||||
const messagesEndRef = useRef<HTMLDivElement>(null);
|
||||
const inputRef = useRef<HTMLTextAreaElement>(null);
|
||||
@@ -174,29 +171,6 @@ export const ChatPanel: React.FC<ChatPanelProps> = ({ conversationId }) => {
|
||||
scrollToBottom();
|
||||
}, [messages, streamingContent, scrollToBottom]);
|
||||
|
||||
const handleApiKeySubmit = async () => {
|
||||
if (!apiKeyInput.trim()) return;
|
||||
|
||||
setIsValidating(true);
|
||||
setApiKeyError('');
|
||||
|
||||
try {
|
||||
const result = await window.electronAPI?.chat.validateApiKey(apiKeyInput.trim());
|
||||
if (result?.isValid) {
|
||||
await window.electronAPI?.chat.setApiKey(apiKeyInput.trim());
|
||||
setNeedsApiKey(false);
|
||||
setApiKeyInput('');
|
||||
loadData();
|
||||
} else {
|
||||
setApiKeyError(tr('chat.apiKeyInvalid'));
|
||||
}
|
||||
} catch {
|
||||
setApiKeyError(tr('chat.apiKeyValidationFailed'));
|
||||
} finally {
|
||||
setIsValidating(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSend = async () => {
|
||||
const message = inputValue.trim();
|
||||
if (!message || isStreaming) return;
|
||||
@@ -303,6 +277,11 @@ export const ChatPanel: React.FC<ChatPanelProps> = ({ conversationId }) => {
|
||||
|
||||
// API key setup screen
|
||||
if (needsApiKey) {
|
||||
const handleOpenSettings = () => {
|
||||
useAppStore.getState().setActiveView('settings');
|
||||
useAppStore.getState().openTab({ type: 'settings', id: 'settings', isTransient: false });
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="chat-panel chat-surface">
|
||||
<div className="chat-panel-header">
|
||||
@@ -314,23 +293,12 @@ export const ChatPanel: React.FC<ChatPanelProps> = ({ conversationId }) => {
|
||||
<h2>{tr('chat.apiKeyRequiredTitle')}</h2>
|
||||
<p>{tr('chat.apiKeyRequiredDescription')}</p>
|
||||
<div className="api-key-form">
|
||||
<input
|
||||
type="password"
|
||||
className="api-key-input"
|
||||
value={apiKeyInput}
|
||||
onChange={(e) => setApiKeyInput(e.target.value)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleApiKeySubmit()}
|
||||
placeholder={tr('chat.apiKeyPlaceholder')}
|
||||
disabled={isValidating}
|
||||
/>
|
||||
<button
|
||||
className="api-key-submit"
|
||||
onClick={handleApiKeySubmit}
|
||||
disabled={!apiKeyInput.trim() || isValidating}
|
||||
onClick={handleOpenSettings}
|
||||
>
|
||||
{isValidating ? tr('chat.apiKeyValidating') : tr('chat.apiKeySave')}
|
||||
{tr('chat.openSettings')}
|
||||
</button>
|
||||
{apiKeyError && <div className="api-key-error">{apiKeyError}</div>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -192,13 +192,11 @@
|
||||
"settings.toast.thumbnailsComplete": "Generierung der Vorschaubilder abgeschlossen",
|
||||
"settings.toast.thumbnailsFailed": "Vorschaubilder konnten nicht erzeugt werden",
|
||||
"chat.setupTitle": "KI-Chat-Einrichtung",
|
||||
"chat.apiKeyRequiredTitle": "OpenCode Zen API-Schlüssel erforderlich",
|
||||
"chat.apiKeyRequiredDescription": "Gib deinen OpenCode API-Schlüssel ein, um den KI-Chat zu aktivieren.",
|
||||
"chat.apiKeyRequiredTitle": "API-Schlüssel erforderlich",
|
||||
"chat.apiKeyRequiredDescription": "Konfiguriere einen API-Schlüssel in den Einstellungen, um den KI-Chat zu aktivieren.",
|
||||
"chat.openSettings": "Einstellungen öffnen",
|
||||
"chat.apiKeyPlaceholder": "API-Schlüssel eingeben...",
|
||||
"chat.apiKeySave": "Schlüssel speichern",
|
||||
"chat.apiKeyValidating": "Wird validiert...",
|
||||
"chat.apiKeyInvalid": "Ungültiger API-Schlüssel. Bitte prüfen und erneut versuchen.",
|
||||
"chat.apiKeyValidationFailed": "API-Schlüssel konnte nicht validiert werden.",
|
||||
"chat.newChat": "Neuer Chat",
|
||||
"chat.welcomeTitle": "Willkommen beim KI-Assistenten",
|
||||
"chat.welcomeDescription": "Ich kann dir helfen, deinen Blog mit anschaulichen Darstellungen zu verwalten. Frag mich zum Beispiel:",
|
||||
|
||||
@@ -192,13 +192,11 @@
|
||||
"settings.toast.thumbnailsComplete": "Thumbnail generation complete",
|
||||
"settings.toast.thumbnailsFailed": "Failed to generate thumbnails",
|
||||
"chat.setupTitle": "AI Chat Setup",
|
||||
"chat.apiKeyRequiredTitle": "OpenCode Zen API Key Required",
|
||||
"chat.apiKeyRequiredDescription": "Enter your OpenCode API key to enable AI chat.",
|
||||
"chat.apiKeyRequiredTitle": "API Key Required",
|
||||
"chat.apiKeyRequiredDescription": "Configure an API key in Settings to enable AI chat.",
|
||||
"chat.openSettings": "Open Settings",
|
||||
"chat.apiKeyPlaceholder": "Enter your API key...",
|
||||
"chat.apiKeySave": "Save Key",
|
||||
"chat.apiKeyValidating": "Validating...",
|
||||
"chat.apiKeyInvalid": "Invalid API key. Please check and try again.",
|
||||
"chat.apiKeyValidationFailed": "Failed to validate API key.",
|
||||
"chat.newChat": "New Chat",
|
||||
"chat.welcomeTitle": "Welcome to the AI Assistant",
|
||||
"chat.welcomeDescription": "I can help you manage your blog with rich visualizations. Try asking me to:",
|
||||
|
||||
@@ -192,13 +192,11 @@
|
||||
"settings.toast.thumbnailsComplete": "Generación de miniaturas completa",
|
||||
"settings.toast.thumbnailsFailed": "No se pudieron generar miniaturas",
|
||||
"chat.setupTitle": "Configuración de chat IA",
|
||||
"chat.apiKeyRequiredTitle": "Se requiere clave API de OpenCode Zen",
|
||||
"chat.apiKeyRequiredDescription": "Introduce tu clave API de OpenCode para habilitar el chat de IA.",
|
||||
"chat.apiKeyRequiredTitle": "Clave API requerida",
|
||||
"chat.apiKeyRequiredDescription": "Configura una clave API en Ajustes para habilitar el chat de IA.",
|
||||
"chat.openSettings": "Abrir Ajustes",
|
||||
"chat.apiKeyPlaceholder": "Introduce tu clave API...",
|
||||
"chat.apiKeySave": "Guardar clave",
|
||||
"chat.apiKeyValidating": "Validando...",
|
||||
"chat.apiKeyInvalid": "Clave API no válida. Compruébala e inténtalo de nuevo.",
|
||||
"chat.apiKeyValidationFailed": "No se pudo validar la clave API.",
|
||||
"chat.newChat": "Nuevo chat",
|
||||
"chat.welcomeTitle": "Bienvenido al asistente de IA",
|
||||
"chat.welcomeDescription": "Puedo ayudarte a gestionar tu blog con visualizaciones interactivas. Prueba a pedirme que:",
|
||||
|
||||
@@ -190,13 +190,11 @@
|
||||
"settings.toast.thumbnailsComplete": "Génération des miniatures terminée",
|
||||
"settings.toast.thumbnailsFailed": "Impossible de générer les miniatures",
|
||||
"chat.setupTitle": "Configuration du chat IA",
|
||||
"chat.apiKeyRequiredTitle": "Clé API OpenCode Zen requise",
|
||||
"chat.apiKeyRequiredDescription": "Saisissez votre clé API OpenCode pour activer le chat IA.",
|
||||
"chat.apiKeyRequiredTitle": "Clé API requise",
|
||||
"chat.apiKeyRequiredDescription": "Configurez une clé API dans les Réglages pour activer le chat IA.",
|
||||
"chat.openSettings": "Ouvrir les Réglages",
|
||||
"chat.apiKeyPlaceholder": "Saisissez votre clé API...",
|
||||
"chat.apiKeySave": "Enregistrer la clé",
|
||||
"chat.apiKeyValidating": "Validation...",
|
||||
"chat.apiKeyInvalid": "Clé API invalide. Veuillez vérifier et réessayer.",
|
||||
"chat.apiKeyValidationFailed": "Impossible de valider la clé API.",
|
||||
"chat.newChat": "Nouveau chat",
|
||||
"chat.welcomeTitle": "Bienvenue dans l’assistant IA",
|
||||
"chat.welcomeDescription": "Je peux vous aider à gérer votre blog avec des visualisations riches. Essayez par exemple :",
|
||||
|
||||
@@ -190,13 +190,11 @@
|
||||
"settings.toast.thumbnailsComplete": "Generazione miniature completata",
|
||||
"settings.toast.thumbnailsFailed": "Impossibile generare le miniature",
|
||||
"chat.setupTitle": "Configurazione chat IA",
|
||||
"chat.apiKeyRequiredTitle": "Chiave API OpenCode Zen richiesta",
|
||||
"chat.apiKeyRequiredDescription": "Inserisci la tua chiave API OpenCode per abilitare la chat IA.",
|
||||
"chat.apiKeyRequiredTitle": "Chiave API richiesta",
|
||||
"chat.apiKeyRequiredDescription": "Configura una chiave API nelle Impostazioni per abilitare la chat IA.",
|
||||
"chat.openSettings": "Apri Impostazioni",
|
||||
"chat.apiKeyPlaceholder": "Inserisci la tua chiave API...",
|
||||
"chat.apiKeySave": "Salva chiave",
|
||||
"chat.apiKeyValidating": "Convalida in corso...",
|
||||
"chat.apiKeyInvalid": "Chiave API non valida. Controlla e riprova.",
|
||||
"chat.apiKeyValidationFailed": "Impossibile convalidare la chiave API.",
|
||||
"chat.newChat": "Nuova chat",
|
||||
"chat.welcomeTitle": "Benvenuto nell’assistente IA",
|
||||
"chat.welcomeDescription": "Posso aiutarti a gestire il tuo blog con visualizzazioni interattive. Prova a chiedermi di:",
|
||||
|
||||
Reference in New Issue
Block a user