feat: Oberfläche neu, Modell-Adapter wählbar, Bewertung je Bereich
All checks were successful
release / deb (push) Successful in 3m59s
release / arch (push) Successful in 5m23s

Die erste Fassung der Oberfläche war inhaltlich und optisch schwach. Neu:
drei Reiter (Benchmark, Ergebnisse, Einstellungen). Modelle werden in den
Einstellungen mit Adapter (Ollama oder OpenAI-kompatibel), URL, Modell-ID
und Schlüssel-Variable angelegt, mit Verbindungstest. config.toml speichert
die Liste. Bewertung absolut in Prozent: ein Wert je Bereich A bis D und
eine Gesamtnote, gewichtet nach weight. Batch-Verlauf, Schritt-Ansicht,
Erklärung der Bewertung. 55 Unit-Tests grün, svelte-check ohne Fehler.
Im Browser mit Beispieldaten geprüft, nicht in der echten App.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 12:27:23 +01:00
parent 07994ed948
commit 105a3a11a3
16 changed files with 1878 additions and 625 deletions

279
src/lib/BenchPanel.svelte Normal file
View File

@ -0,0 +1,279 @@
<script lang="ts">
import { onMount, onDestroy } from "svelte";
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
import { api, groupLabel, type BatchEvent, type LoadReport, type ModelInfo, type TaskInfo } from "$lib/api";
let {
models,
tasks,
ongotosettings,
onfinished,
}: {
models: ModelInfo[];
tasks: LoadReport | null;
ongotosettings: () => void;
onfinished: (batchId: number) => void;
} = $props();
let chosenModels = $state<string[]>([]);
let chosenTasks = $state<string[]>([]);
let repeats = $state(1);
let running = $state(false);
let error = $state("");
let progress = $state<{ done: number; total: number } | null>(null);
let log = $state<{ text: string; cls: string }[]>([]);
let current = $state("");
let finishedBatch = $state<number | null>(null);
let cancelled = $state(false);
let unlisten: UnlistenFn | null = null;
onMount(async () => {
unlisten = await listen<BatchEvent>("batch-event", (ev) => onEvent(ev.payload));
});
onDestroy(() => unlisten?.());
function onEvent(e: BatchEvent) {
if (e.kind === "progress") {
progress = { done: e.done, total: e.total };
return;
}
if (e.kind === "model_unavailable") {
log.push({ text: `${e.model}: nicht erreichbar (${e.reason})`, cls: "error" });
return;
}
const label = `${e.model} · ${e.task} · Durchlauf ${e.repeat}`;
if (e.kind === "run_started") {
current = label;
} else if (e.kind === "run_skipped") {
log.push({ text: `übersprungen: ${label}`, cls: "muted" });
} else if (e.kind === "run_finished") {
const ok = e.class === "ok";
log.push({
text: `${ok ? "bestanden" : e.class}: ${label}, ${Math.round(e.score * 100)} %`,
cls: ok ? "ok" : "error",
});
current = "";
}
}
// Aufgaben nach Bereich gruppiert.
let byGroup = $derived.by(() => {
const m = new Map<string, TaskInfo[]>();
for (const t of tasks?.tasks ?? []) {
if (!m.has(t.group)) m.set(t.group, []);
m.get(t.group)!.push(t);
}
return [...m.entries()].sort((a, b) => a[0].localeCompare(b[0]));
});
function toggle(list: string[], id: string): string[] {
return list.includes(id) ? list.filter((x) => x !== id) : [...list, id];
}
function groupAll(group: string, on: boolean) {
const ids = (byGroup.find(([g]) => g === group)?.[1] ?? []).map((t) => t.id);
chosenTasks = on
? [...new Set([...chosenTasks, ...ids])]
: chosenTasks.filter((id) => !ids.includes(id));
}
let totalRuns = $derived(chosenModels.length * chosenTasks.length * repeats);
let canStart = $derived(!running && chosenModels.length > 0 && chosenTasks.length > 0 && repeats >= 1);
async function start() {
error = "";
log = [];
progress = null;
finishedBatch = null;
cancelled = false;
running = true;
try {
const s = await api.startBatch($state.snapshot(chosenModels), $state.snapshot(chosenTasks), repeats, "");
finishedBatch = s.batch_id;
cancelled = s.cancelled;
} catch (e) {
error = String(e);
} finally {
running = false;
current = "";
}
}
</script>
{#if models.length === 0}
<section class="card">
<h2>Noch kein Modell angebunden</h2>
<p class="muted">Bevor ein Benchmark laufen kann, braucht coding-bench mindestens ein Modell.</p>
<button class="primary" onclick={ongotosettings}>Modell in den Einstellungen anlegen</button>
</section>
{:else}
<section class="card">
<h2>1. Modelle</h2>
<div class="choices">
{#each models as m (m.name)}
<label class="choice">
<input
type="checkbox"
checked={chosenModels.includes(m.name)}
disabled={running}
onchange={() => (chosenModels = toggle(chosenModels, m.name))}
/>
<span>
<strong>{m.name}</strong>
<span class="muted">{m.adapter === "ollama" ? "Ollama" : "OpenAI-kompatibel"} · {m.url}</span>
</span>
</label>
{/each}
</div>
</section>
<section class="card">
<h2>2. Aufgaben</h2>
{#if !tasks}
<p class="muted">Lade Aufgaben …</p>
{:else if tasks.tasks.length === 0}
<p class="error">Keine gültigen Aufgaben gefunden.</p>
{/if}
{#each byGroup as [group, list] (group)}
<div class="group">
<div class="group-head">
<h3>{group} · {groupLabel(group)} <span class="muted">({list.length})</span></h3>
<button class="link" disabled={running} onclick={() => groupAll(group, true)}>alle</button>
<button class="link" disabled={running} onclick={() => groupAll(group, false)}>keine</button>
</div>
{#each list as t (t.id)}
<label class="choice">
<input
type="checkbox"
checked={chosenTasks.includes(t.id)}
disabled={running}
onchange={() => (chosenTasks = toggle(chosenTasks, t.id))}
/>
<span><strong>{t.id}</strong> {t.title}</span>
</label>
{/each}
</div>
{/each}
{#if tasks && tasks.errors.length > 0}
<details>
<summary class="error">{tasks.errors.length} Aufgabe(n) mit Fehlern</summary>
<ul>
{#each tasks.errors as e (e.dir)}
<li><code>{e.dir}</code>: {e.message}</li>
{/each}
</ul>
</details>
{/if}
</section>
<section class="card">
<h2>3. Starten</h2>
<div class="start">
<label>
Durchläufe je Aufgabe
<input type="number" min="1" max="20" bind:value={repeats} disabled={running} />
</label>
<p class="muted">
{#if totalRuns > 0}{totalRuns} Läufe: {chosenModels.length} Modell(e) × {chosenTasks.length} Aufgabe(n) × {repeats}.{:else}Wähle Modelle und Aufgaben.{/if}
Mehr Durchläufe machen die Prozentwerte verlässlicher.
</p>
<div class="buttons">
<button class="primary" onclick={start} disabled={!canStart}>Benchmark starten</button>
<button class="danger" onclick={() => api.cancelBatch()} disabled={!running}>Abbrechen</button>
</div>
</div>
{#if progress}
<div class="bar" role="progressbar" aria-valuenow={progress.done} aria-valuemax={progress.total}>
<div class="fill" style:width="{progress.total ? (100 * progress.done) / progress.total : 0}%"></div>
</div>
<p class="muted">{progress.done} von {progress.total} Läufen fertig</p>
{/if}
{#if current}<p>Läuft: <strong>{current}</strong></p>{/if}
{#if error}<p class="error">{error}</p>{/if}
{#if finishedBatch !== null}
<p>
{cancelled ? "Abgebrochen." : "Fertig."}
<button class="link" onclick={() => onfinished(finishedBatch!)}>Ergebnisse ansehen</button>
</p>
{/if}
{#if log.length > 0}
<ul class="log">
{#each log as l, i (i)}
<li class={l.cls}>{l.text}</li>
{/each}
</ul>
{/if}
</section>
{/if}
<style>
.choices {
display: grid;
gap: 0.4rem;
}
.choice {
display: flex;
align-items: baseline;
gap: 0.6rem;
padding: 0.25rem 0;
}
.choice .muted {
margin-left: 0.5rem;
font-size: 0.85rem;
}
.group {
margin-bottom: 0.9rem;
}
.group-head {
display: flex;
align-items: baseline;
gap: 0.8rem;
}
.group-head h3 {
flex: 1;
margin: 0;
}
.start label {
display: flex;
flex-direction: column;
gap: 0.2rem;
width: 12rem;
font-size: 0.85rem;
color: var(--muted);
}
.start input {
color: var(--text);
font-size: 1rem;
}
.buttons {
display: flex;
gap: 0.6rem;
margin-top: 0.6rem;
}
.bar {
height: 10px;
background: var(--surface-2);
border-radius: 999px;
overflow: hidden;
margin-top: 1rem;
}
.fill {
height: 100%;
background: var(--accent);
transition: width 0.3s;
}
.log {
list-style: none;
padding: 0.6rem;
margin: 0.8rem 0 0;
max-height: 18rem;
overflow-y: auto;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 8px;
font-family: ui-monospace, Menlo, monospace;
font-size: 0.85rem;
}
</style>