import {localeTag} from '../lib/i18n'; import { tr } from '../lib/i18n'; import { useEffect, useState } from 'react'; import { api } from '../lib/client'; import { nativeAction, useNative, type NativeJob } from '../lib/native'; import { Btn, Dialog, ErrorNotice, Select } from './ui'; import { NativeProgress } from './NativeModels'; import { jobErrorText } from '../lib/native-job-diagnostics'; import { SettingsEngine } from './SettingsEngine'; export function NativeBenchmark({ open, onClose }: { open: boolean; onClose: () => void; }) { const native = useNative(); const [selected, setSelected] = useState(''), [error, setError] = useState(''), [jobId, setJobId] = useState(''), [report, setReport] = useState | null>(null); const instance = native?.instances.find(i => i.id === selected) ?? native?.instances.find(i => i.id === native.defaultId) ?? native?.instances[0]; const job = native?.jobs.find(j => j.id === jobId), active = native?.jobs.some(j => j.state === 'running'); useEffect(() => { if (open) void api.get | null>('/api/native/benchmark').then(setReport).catch(() => { }); }, [open]); useEffect(() => { if (job?.state === 'done' && job.result) setReport(job.result); if (job?.state === 'error') setError(job.error ?? job.summary); }, [job?.state]); async function run() { setError(''); try { const job = await nativeAction('operations', { kind: 'benchmark', args: { instanceId: instance?.id } }); setJobId(job.id); } catch (e) { setError(e instanceof Error ? e.message : String(e)); } } function download() { if (!report) return; const url = URL.createObjectURL(new Blob([JSON.stringify(report, null, 2)], { type: 'application/json' })); const a = document.createElement('a'); a.href = url; a.download = 'strata-benchmark.json'; a.click(); URL.revokeObjectURL(url); } return {tr("Close")}{tr(job?.state === 'running' ? void nativeAction(`operations/${job.id}/cancel`).catch(e => setError(e.message))}>{tr("Stop benchmark")} : null)}{tr(report ? {tr("Save report")} : null)} void run()}>{tr(active ? 'Measuring…' : 'Run short benchmark')}}>

{tr("A fixed prompt with thinking off and up to 200 output tokens. Usually takes 10\u201360 seconds. Results are measured by your engine.")}

{tr((native?.instances.length ?? 0) > 1 ?