import React, { useState } from 'react'; import { Settings, X, Key, ShieldCheck, CheckCircle2, AlertCircle, ExternalLink, Sparkles, } from 'lucide-react'; import { logRealConsoleApiError } from '../utils/apiLogger'; interface SettingsModalProps { isOpen: boolean; onClose: () => void; hfToken: string; onSaveToken: (token: string) => void; temperature: number; onSetTemperature: (temp: number) => void; } export const SettingsModal: React.FC = ({ isOpen, onClose, hfToken, onSaveToken, temperature, onSetTemperature, }) => { const [tokenInput, setTokenInput] = useState(hfToken); const [testStatus, setTestStatus] = useState<'idle' | 'testing' | 'success' | 'error'>('idle'); const [testMessage, setTestMessage] = useState(''); if (!isOpen) return null; const handleSave = () => { onSaveToken(tokenInput.trim()); onClose(); }; const handleTestToken = async () => { if (!tokenInput.trim()) { setTestStatus('error'); setTestMessage('Please enter a Hugging Face token first.'); return; } setTestStatus('testing'); setTestMessage('Connecting to Hugging Face API...'); try { const res = await fetch('https://huggingface.co/api/whoami-v2', { headers: { Authorization: `Bearer ${tokenInput.trim()}`, }, }); if (res.ok) { const data = await res.json(); setTestStatus('success'); setTestMessage(`Authenticated successfully as @${data.name || data.fullname || 'user'}!`); } else { const errBody = await res.text().catch(() => ''); logRealConsoleApiError({ topic: 'Hugging Face Token Authentication Error', endpoint: 'https://huggingface.co/api/whoami-v2', status: res.status, statusText: res.statusText, message: `Authentication failed with status ${res.status} (${res.statusText || 'Unauthorized'})`, rawResponse: errBody, }); setTestStatus('error'); setTestMessage(`HF authentication failed (${res.status}). Verify your token permissions.`); } } catch (e: any) { logRealConsoleApiError({ topic: 'Hugging Face Token Validation Network Failure', endpoint: 'https://huggingface.co/api/whoami-v2', message: e.message || 'Network request failed or CORS blocked.', error: e, }); setTestStatus('error'); setTestMessage(`Connection error: ${e.message || 'Network request failed'}`); } }; return (
{/* Modal Header */}

Platform & API Configuration

{/* Modal Body */}
{/* RiShre Awakened Model Identity Card */}

RiShre Awakened

Flagship Unified Agent & Vibe Coding Engine

ACTIVATED
{/* Hugging Face Token Section */}
Get Token
{ setTokenInput(e.target.value); setTestStatus('idle'); }} className="flex-1 bg-[#120826] border border-purple-500/30 rounded-xl px-3.5 py-2 text-xs text-white focus:outline-none focus:border-purple-400 font-mono shadow-inner" />
{testStatus === 'success' && (
{testMessage}
)} {testStatus === 'error' && (
{testMessage}
)} {/* Static Security Notice */}
Client-Side Static Security Guarantee

Because RiShre runs as a static client application on Hugging Face Spaces without an intermediary server, your API token is stored exclusively in your browser's localStorage. It is sent only directly to Hugging Face API endpoints over encrypted HTTPS.

{/* Temperature Slider */}
Creativity / Temperature {temperature.toFixed(2)}
onSetTemperature(parseFloat(e.target.value))} className="w-full accent-purple-500 cursor-pointer" />
Precise & Analytical (0.2) Balanced Vibe (0.7) Visionary & Creative (1.0)
{/* Modal Footer */}
); };