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

136
src/app.css Normal file
View File

@ -0,0 +1,136 @@
:root {
--bg: #f4f5f7;
--surface: #ffffff;
--surface-2: #eef0f3;
--text: #1b1f24;
--muted: #5d6673;
--border: #d8dce2;
--accent: #2b6cb0;
--accent-text: #ffffff;
--danger: #b3261e;
--ok: #2e7d32;
--radius: 10px;
font-family: Inter, "Segoe UI", system-ui, -apple-system, sans-serif;
font-size: 15px;
line-height: 1.5;
color: var(--text);
background: var(--bg);
-webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
:root {
--bg: #14171b;
--surface: #1d2127;
--surface-2: #272c34;
--text: #e6e9ed;
--muted: #98a2b0;
--border: #353b45;
--accent: #5b9bd5;
--accent-text: #0e1218;
--danger: #ff8a80;
--ok: #7bc47f;
}
}
* {
box-sizing: border-box;
}
body {
margin: 0;
background: var(--bg);
color: var(--text);
}
h1, h2, h3 {
line-height: 1.25;
margin: 0 0 0.6rem;
}
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
button {
font: inherit;
padding: 0.45rem 0.9rem;
border-radius: 8px;
border: 1px solid var(--border);
background: var(--surface-2);
color: var(--text);
cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button.primary {
background: var(--accent);
color: var(--accent-text);
border-color: var(--accent);
font-weight: 600;
}
button.danger { color: var(--danger); }
button.link {
background: none;
border: none;
padding: 0;
color: var(--accent);
text-decoration: underline;
}
input, select, textarea {
font: inherit;
padding: 0.4rem 0.55rem;
border-radius: 8px;
border: 1px solid var(--border);
background: var(--surface);
color: var(--text);
min-width: 0;
}
input:focus, select:focus, textarea:focus {
outline: 2px solid var(--accent);
outline-offset: -1px;
}
code, pre {
font-family: ui-monospace, "JetBrains Mono", Menlo, monospace;
font-size: 0.88em;
}
.card {
background: var(--surface);
border: 1px solid var(--border);
border-radius: var(--radius);
padding: 1rem 1.2rem;
margin-bottom: 1rem;
}
.muted { color: var(--muted); }
.error { color: var(--danger); }
.ok { color: var(--ok); }
.chip {
display: inline-block;
padding: 0.05rem 0.55rem;
border-radius: 999px;
font-size: 0.8rem;
background: var(--surface-2);
border: 1px solid var(--border);
}
table {
width: 100%;
border-collapse: collapse;
}
th, td {
text-align: left;
padding: 0.45rem 0.6rem;
border-bottom: 1px solid var(--border);
vertical-align: middle;
}
th {
font-size: 0.8rem;
font-weight: 600;
color: var(--muted);
text-transform: uppercase;
letter-spacing: 0.03em;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }

View File

@ -1,10 +1,10 @@
<!doctype html>
<html lang="en">
<html lang="de">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>Tauri + SvelteKit + Typescript App</title>
<title>coding-bench</title>
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">

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>

352
src/lib/ResultsPanel.svelte Normal file
View File

@ -0,0 +1,352 @@
<script lang="ts">
import { onMount, untrack } from "svelte";
import {
api,
fmtDuration,
fmtPct,
groupLabel,
pctColor,
type BatchInfo,
type Ranking,
type RunRow,
type StepRow,
} from "$lib/api";
let { selected = $bindable(null) }: { selected: number | null } = $props();
let batches = $state<BatchInfo[]>([]);
let ranking = $state<Ranking | null>(null);
let rows = $state<RunRow[]>([]);
let error = $state("");
let loading = $state(false);
let detail = $state<{ run: RunRow; steps: StepRow[] } | null>(null);
let showRuns = $state(false);
async function loadBatches() {
try {
batches = await api.batches();
if (selected === null && batches.length > 0) selected = batches[0].id;
} catch (e) {
error = String(e);
}
}
async function loadBatch(id: number | null) {
ranking = null;
rows = [];
detail = null;
if (id === null) return;
loading = true;
error = "";
try {
[ranking, rows] = await Promise.all([api.ranking(id), api.results(id)]);
} catch (e) {
error = String(e);
} finally {
loading = false;
}
}
onMount(loadBatches);
// Beim Wechsel des Batches neu laden. Neue Batches erscheinen nach dem Lauf in der Liste.
$effect(() => {
const id = selected;
untrack(() => {
loadBatch(id);
if (id !== null && !batches.some((b) => b.id === id)) loadBatches();
});
});
async function showSteps(run: RunRow) {
if (selected === null) return;
detail = { run, steps: await api.steps(selected, run) };
}
function cell(model: string, task: string) {
return ranking?.cells.find((c) => c.model === model && c.task_id === task);
}
function batchLabel(b: BatchInfo): string {
return `Batch ${b.id} · ${b.created_at.slice(0, 16)} · ${b.runs} Läufe`;
}
// Bereiche mit wenigen Aufgaben sind nur grobe Hinweise.
const FEW_TASKS = 3;
</script>
<section class="card">
<div class="head">
<h2>Bewertung</h2>
{#if batches.length > 0}
<select bind:value={selected} aria-label="Batch wählen">
{#each batches as b (b.id)}
<option value={b.id}>{batchLabel(b)}</option>
{/each}
</select>
{/if}
</div>
{#if error}<p class="error">{error}</p>{/if}
{#if batches.length === 0 && !error}
<p class="muted">Noch keine Ergebnisse. Starte im Reiter „Benchmark“ einen Lauf.</p>
{/if}
{#if loading}<p class="muted">Lade …</p>{/if}
{#if ranking && ranking.models.length > 0}
<div class="scroll">
<table class="rank">
<thead>
<tr>
<th class="num">#</th>
<th>Modell</th>
<th class="total">Gesamt</th>
{#each ranking.groups as g (g)}
<th class="grp" title={groupLabel(g)}>{g}<br /><span class="gl">{groupLabel(g)}</span></th>
{/each}
<th>Schwächster Bereich</th>
<th class="num">Bestanden</th>
<th class="num">Median-Dauer</th>
</tr>
</thead>
<tbody>
{#each ranking.models as m (m.model)}
<tr>
<td class="num">{m.rank}</td>
<td><strong>{m.model}</strong></td>
<td class="total">
<div class="pct big" style:color={pctColor(m.total_percent)}>{fmtPct(m.total_percent)}</div>
<div class="meter"><div style:width="{m.total_percent}%" style:background={pctColor(m.total_percent)}></div></div>
</td>
{#each m.groups as g (g.group)}
<td class="grp">
{#if g.percent === null}
<span class="muted">–</span>
{:else}
<div class="pct" style:color={pctColor(g.percent)}>{fmtPct(g.percent)}</div>
<div class="meter small"><div style:width="{g.percent}%" style:background={pctColor(g.percent)}></div></div>
<div class="n" class:few={g.tasks < FEW_TASKS} title={g.tasks < FEW_TASKS ? "Wenige Aufgaben: der Wert ist nur ein grober Hinweis." : ""}>
{g.tasks} Aufg.{g.tasks < FEW_TASKS ? " (grob)" : ""}
</div>
{/if}
</td>
{/each}
<td>
{#if m.weakest_group}
{m.weakest_group} · {groupLabel(m.weakest_group)}
{:else}
<span class="muted">–</span>
{/if}
</td>
<td class="num">{m.successes} / {m.runs}</td>
<td class="num">{fmtDuration(m.median_duration_ms)}</td>
</tr>
{/each}
</tbody>
</table>
</div>
<details class="how">
<summary>So wird bewertet</summary>
<ul>
<li>
Die Bewertung ist <strong>absolut</strong>, nicht im Vergleich zu einem Referenzmodell. 100 % heißt: alle
Prüfungen der Aufgaben bestanden.
</li>
<li>
Je Aufgabe zählt der Mittelwert der Durchläufe. Teilpunkte aus <code>check.sh</code> gehen anteilig ein.
</li>
<li>
Wert je Bereich: gewichteter Mittelwert der Aufgaben im Bereich. Gesamt: gewichteter Mittelwert über alle
Aufgaben des Batches. Die Gewichte stehen als <code>weight</code> in <code>task.toml</code>.
</li>
<li>Fehlt einem Modell ein Bereich, bleibt das Feld leer und zählt nicht in die Gesamtnote.</li>
<li>Die Reihenfolge richtet sich nach der Gesamtnote. Bei Gleichstand gewinnt die kürzere Median-Dauer.</li>
<li>Bereiche mit weniger als {FEW_TASKS} Aufgaben sind nur grobe Hinweise.</li>
</ul>
</details>
<h3>Aufgaben im Detail</h3>
<div class="scroll">
<table class="matrix">
<thead>
<tr>
<th>Modell</th>
{#each ranking.tasks as t (t.id)}
<th class="num" title={groupLabel(t.group)}>{t.id}</th>
{/each}
</tr>
</thead>
<tbody>
{#each ranking.models as m (m.model)}
<tr>
<td>{m.model}</td>
{#each ranking.tasks as t (t.id)}
{@const c = cell(m.model, t.id)}
<td
class="num"
style:background={c ? `color-mix(in srgb, ${pctColor(c.mean_score * 100)} 28%, transparent)` : ""}
title={c ? `${Math.round(c.mean_score * 100)} %, ${c.successes} von ${c.runs} bestanden` : "keine Läufe"}
>
{c ? `${Math.round(c.mean_score * 100)} %` : "–"}
</td>
{/each}
</tr>
{/each}
</tbody>
</table>
</div>
<h3>
Einzelne Läufe
<button class="link" onclick={() => (showRuns = !showRuns)}>{showRuns ? "ausblenden" : `anzeigen (${rows.length})`}</button>
</h3>
{#if showRuns}
<div class="scroll">
<table>
<thead>
<tr>
<th>Modell</th>
<th>Aufgabe</th>
<th class="num">Durchlauf</th>
<th>Ergebnis</th>
<th class="num">Score</th>
<th class="num">Schritte</th>
<th class="num">Dauer</th>
<th></th>
</tr>
</thead>
<tbody>
{#each rows as r (`${r.model}|${r.task_id}|${r.repeat_idx}`)}
<tr>
<td>{r.model}</td>
<td>{r.task_id}</td>
<td class="num">{r.repeat_idx}</td>
<td class={r.error_class === "ok" ? "ok" : "error"}>{r.error_class === "ok" ? "bestanden" : r.error_class}</td>
<td class="num">{Math.round(r.score * 100)} %</td>
<td class="num">{r.steps}</td>
<td class="num">{fmtDuration(r.duration_ms)}</td>
<td><button onclick={() => showSteps(r)}>Schritte</button></td>
</tr>
{/each}
</tbody>
</table>
</div>
{/if}
{#if detail}
<div class="detail">
<h3>
Schritte: {detail.run.model} · {detail.run.task_id} · Durchlauf {detail.run.repeat_idx}
<button class="link" onclick={() => (detail = null)}>schließen</button>
</h3>
{#if detail.run.check_output}
<p class="muted">Prüfung (<code>check.sh</code>):</p>
<pre>{detail.run.check_output}</pre>
{/if}
<ol class="steps">
{#each detail.steps as st (st.idx)}
<li>
<strong>{st.role}</strong>
{#if st.tool_name}<span class="chip">{st.tool_name}</span> <code>{st.tool_args_json ?? ""}</code>{/if}
{#if st.content}<pre>{st.content}</pre>{/if}
</li>
{/each}
</ol>
</div>
{/if}
{:else if ranking && !loading}
<p class="muted">Dieser Batch hat noch keine fertigen Läufe.</p>
{/if}
</section>
<style>
.head {
display: flex;
gap: 1rem;
align-items: center;
flex-wrap: wrap;
margin-bottom: 0.8rem;
}
.head h2 {
margin: 0;
flex: 1;
}
.head select {
max-width: 100%;
}
.scroll {
overflow-x: auto;
margin-bottom: 1rem;
}
.rank td,
.rank th {
vertical-align: top;
}
.matrix th {
text-transform: none;
}
.rank .total {
min-width: 7.5rem;
}
.rank .grp {
min-width: 6rem;
}
.gl {
font-weight: 400;
text-transform: none;
letter-spacing: 0;
}
.pct {
font-weight: 700;
font-variant-numeric: tabular-nums;
}
.pct.big {
font-size: 1.6rem;
line-height: 1.1;
}
.meter {
height: 7px;
background: var(--surface-2);
border-radius: 999px;
overflow: hidden;
margin: 0.25rem 0;
}
.meter.small {
height: 5px;
}
.meter > div {
height: 100%;
}
.n {
font-size: 0.75rem;
color: var(--muted);
}
.n.few {
color: var(--danger);
}
.how {
margin: 0.5rem 0 1.2rem;
color: var(--muted);
}
.how summary {
cursor: pointer;
}
.detail {
margin-top: 1rem;
border-top: 1px solid var(--border);
padding-top: 1rem;
}
.steps pre,
.detail > pre {
white-space: pre-wrap;
overflow-wrap: anywhere;
max-height: 12rem;
overflow-y: auto;
background: var(--bg);
border: 1px solid var(--border);
border-radius: 6px;
padding: 0.5rem;
margin: 0.3rem 0;
}
</style>

View File

@ -0,0 +1,232 @@
<script lang="ts">
import { api, type ModelEntry, type ModelInfo, type ModelTest, type Paths, type RuntimeStatus } from "$lib/api";
let {
models,
paths,
runtime,
onsaved,
}: {
models: ModelInfo[];
paths: Paths | null;
runtime: RuntimeStatus | null;
onsaved: (m: ModelInfo[]) => void;
} = $props();
const ADAPTERS = [
{ id: "ollama", label: "Ollama", hint: "http://host:11434" },
{ id: "openai", label: "OpenAI-kompatibel", hint: "http://host:8082/v1" },
];
function toEntry(m: ModelInfo): ModelEntry {
return { name: m.name, adapter: m.adapter, url: m.url, model: m.model, api_key_env: m.api_key_env };
}
// Bearbeitungsstand: Kopie beim Öffnen, bewusst vom Original gelöst. Gilt erst nach „Speichern“.
// svelte-ignore state_referenced_locally
let draft = $state<ModelEntry[]>(models.map(toEntry));
let dirty = $state(false);
let saveError = $state("");
let saving = $state(false);
let tests = $state<Record<string, ModelTest | "läuft">>({});
function markDirty() {
dirty = true;
saveError = "";
}
function addModel() {
draft.push({ name: "", adapter: "ollama", url: "", model: "", api_key_env: "" });
markDirty();
}
function removeModel(i: number) {
draft.splice(i, 1);
markDirty();
}
function hintFor(adapter: string): string {
return ADAPTERS.find((a) => a.id === adapter)?.hint ?? "";
}
async function save() {
saving = true;
saveError = "";
try {
const saved = await api.saveModels($state.snapshot(draft));
draft = saved.map(toEntry);
dirty = false;
onsaved(saved);
} catch (e) {
saveError = String(e);
} finally {
saving = false;
}
}
async function test(name: string) {
tests[name] = "läuft";
try {
tests[name] = await api.testModel(name);
} catch (e) {
tests[name] = { ok: false, duration_ms: 0, message: String(e) };
}
}
function savedInfo(name: string): ModelInfo | undefined {
return models.find((m) => m.name === name);
}
</script>
<section class="card">
<h2>Modelle</h2>
<p class="muted">
Jedes Modell hat einen Adapter. Er bestimmt, wie coding-bench mit dem Server spricht. Ein Schlüssel steht nie in der
Konfiguration: Trage nur den Namen der Umgebungsvariable ein, aus der die App ihn beim Start liest.
</p>
{#if draft.length === 0}
<p class="muted">Noch kein Modell angebunden.</p>
{/if}
{#each draft as m, i (i)}
<div class="model">
<div class="grid">
<label>
Name
<input bind:value={m.name} oninput={markDirty} placeholder="z. B. Qwen3 lokal" />
</label>
<label>
Adapter
<select bind:value={m.adapter} onchange={markDirty}>
{#each ADAPTERS as a (a.id)}
<option value={a.id}>{a.label}</option>
{/each}
</select>
</label>
<label class="wide">
Server-URL
<input bind:value={m.url} oninput={markDirty} placeholder={hintFor(m.adapter)} />
</label>
<label>
Modell-ID beim Server
<input bind:value={m.model} oninput={markDirty} placeholder="leer = Name" />
</label>
<label>
Schlüssel-Variable
<input bind:value={m.api_key_env} oninput={markDirty} placeholder="leer = kein Schlüssel" />
</label>
</div>
<div class="row">
{#if m.api_key_env && savedInfo(m.name)}
{#if savedInfo(m.name)?.api_key_set}
<span class="chip ok">Schlüssel gefunden</span>
{:else}
<span class="chip error">Variable {m.api_key_env} ist nicht gesetzt</span>
{/if}
{/if}
<span class="spacer"></span>
{#if tests[m.name] === "läuft"}
<span class="muted">teste …</span>
{:else if tests[m.name]}
{@const t = tests[m.name] as ModelTest}
<span class={t.ok ? "ok" : "error"}>
{t.ok ? "Verbunden" : "Fehler"}: {t.message}
{#if t.duration_ms}({(t.duration_ms / 1000).toFixed(1)} s){/if}
</span>
{/if}
<button onclick={() => test(m.name)} disabled={dirty || !savedInfo(m.name)} title={dirty ? "Erst speichern" : ""}>
Verbindung testen
</button>
<button class="danger" onclick={() => removeModel(i)}>Entfernen</button>
</div>
</div>
{/each}
<div class="row">
<button onclick={addModel}>Modell hinzufügen</button>
<span class="spacer"></span>
{#if saveError}<span class="error">{saveError}</span>{/if}
{#if dirty}<span class="muted">Ungespeicherte Änderungen</span>{/if}
<button class="primary" onclick={save} disabled={!dirty || saving}>Speichern</button>
</div>
</section>
<section class="card">
<h2>System</h2>
<dl>
<dt>Container</dt>
<dd>
{#if runtime}
{#if runtime.available}
<span class="ok">{runtime.program} bereit, {runtime.detail}</span>
{:else}
<span class="error">{runtime.program} nicht nutzbar: {runtime.detail}</span>
{/if}
{:else}
<span class="muted">Prüfe …</span>
{/if}
</dd>
{#if paths}
<dt>Konfiguration</dt>
<dd><code>{paths.config_file}</code></dd>
<dt>Datenordner</dt>
<dd><code>{paths.data_dir}</code></dd>
<dt>Aufgabenordner</dt>
<dd><code>{paths.tasks_dir}</code></dd>
{/if}
</dl>
</section>
<style>
.model {
border: 1px solid var(--border);
border-radius: 8px;
padding: 0.8rem;
margin-bottom: 0.8rem;
background: var(--bg);
}
.grid {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 0.6rem 0.8rem;
}
.grid .wide {
grid-column: 1 / -1;
}
label {
display: flex;
flex-direction: column;
gap: 0.2rem;
font-size: 0.85rem;
color: var(--muted);
}
label input,
label select {
color: var(--text);
font-size: 1rem;
}
.row {
display: flex;
align-items: center;
gap: 0.6rem;
margin-top: 0.7rem;
flex-wrap: wrap;
}
.spacer {
flex: 1;
}
dl {
display: grid;
grid-template-columns: max-content 1fr;
gap: 0.4rem 1.2rem;
margin: 0;
}
dt {
color: var(--muted);
}
dd {
margin: 0;
overflow-wrap: anywhere;
}
</style>

127
src/lib/api.ts Normal file
View File

@ -0,0 +1,127 @@
import { invoke } from "@tauri-apps/api/core";
export type Paths = { config_file: string; data_dir: string; tasks_dir: string };
export type TaskInfo = { id: string; title: string; group: string; dir: string; weight: number };
export type TaskError = { dir: string; message: string };
export type LoadReport = { tasks: TaskInfo[]; errors: TaskError[] };
export type ModelEntry = {
name: string;
adapter: string;
url: string;
model: string;
api_key_env: string;
};
export type ModelInfo = ModelEntry & { api_key_set: boolean };
export type ModelTest = { ok: boolean; duration_ms: number; message: string };
export type RuntimeStatus = { program: string; available: boolean; detail: string };
export type BatchInfo = {
id: number;
created_at: string;
note: string;
repeats: number;
runs: number;
models: string;
};
export type BatchSummary = { batch_id: number; completed: number; skipped: number; cancelled: boolean };
export type RunRow = {
model: string;
task_id: string;
repeat_idx: number;
error_class: string;
score: number;
steps: number;
prompt_tokens: number;
completion_tokens: number;
duration_ms: number;
tps: number | null;
summary: string | null;
check_output: string;
};
export type StepRow = {
idx: number;
role: string;
content: string;
tool_name: string | null;
tool_args_json: string | null;
tool_result: string | null;
};
export type GroupScore = { group: string; percent: number | null; tasks: number; runs: number };
export type ModelRank = {
rank: number;
model: string;
total_percent: number;
groups: GroupScore[];
weakest_group: string | null;
runs: number;
successes: number;
median_duration_ms: number;
mean_completion_tokens: number;
};
export type MatrixCell = { model: string; task_id: string; runs: number; successes: number; mean_score: number };
export type TaskColumn = { id: string; group: string };
export type Ranking = {
batch_id: number;
groups: string[];
models: ModelRank[];
cells: MatrixCell[];
tasks: TaskColumn[];
};
export type BatchEvent =
| { kind: "run_started"; model: string; task: string; repeat: number }
| { kind: "run_finished"; model: string; task: string; repeat: number; class: string; score: number }
| { kind: "run_skipped"; model: string; task: string; repeat: number }
| { kind: "model_unavailable"; model: string; reason: string }
| { kind: "progress"; done: number; total: number };
export const api = {
paths: () => invoke<Paths>("get_paths"),
tasks: () => invoke<LoadReport>("load_tasks"),
runtime: () => invoke<RuntimeStatus>("runtime_status"),
models: () => invoke<ModelInfo[]>("list_models"),
saveModels: (models: ModelEntry[]) => invoke<ModelInfo[]>("save_models", { models }),
testModel: (name: string) => invoke<ModelTest>("test_model", { name }),
startBatch: (models: string[], taskIds: string[], repeats: number, note: string) =>
invoke<BatchSummary>("start_batch", { models, taskIds, repeats, note }),
cancelBatch: () => invoke<boolean>("cancel_batch"),
batches: () => invoke<BatchInfo[]>("list_batches"),
results: (batchId: number) => invoke<RunRow[]>("batch_results", { batchId }),
ranking: (batchId: number) => invoke<Ranking>("batch_ranking", { batchId }),
steps: (batchId: number, r: RunRow) =>
invoke<StepRow[]>("run_steps", { batchId, model: r.model, taskId: r.task_id, repeatIdx: r.repeat_idx }),
};
/** Namen der Bereiche (Gruppen aus SPEC 11). */
export const GROUP_LABELS: Record<string, string> = {
A: "Tool-Calling",
B: "Kleine Coding-Aufgaben",
C: "Agent im Repo",
D: "Demos",
"?": "Unbekannt",
};
export function groupLabel(g: string): string {
return GROUP_LABELS[g] ?? g;
}
/** Farbe für einen Prozentwert: rot bei 0, gelb in der Mitte, grün bei 100. */
export function pctColor(p: number): string {
const hue = Math.max(0, Math.min(100, p)) * 1.2;
return `hsl(${hue} 60% 42%)`;
}
export function fmtPct(p: number | null): string {
return p === null ? "–" : `${Math.round(p)} %`;
}
export function fmtDuration(ms: number): string {
const s = ms / 1000;
return s < 90 ? `${s.toFixed(1)} s` : `${Math.floor(s / 60)} min ${Math.round(s % 60)} s`;
}

View File

@ -0,0 +1,6 @@
<script lang="ts">
import "../app.css";
let { children } = $props();
</script>
{@render children()}

View File

@ -1,483 +1,123 @@
<script lang="ts">
import { onMount, onDestroy } from "svelte";
import { invoke } from "@tauri-apps/api/core";
import { listen, type UnlistenFn } from "@tauri-apps/api/event";
import { onMount } from "svelte";
import { api, type LoadReport, type ModelInfo, type Paths, type RuntimeStatus } from "$lib/api";
import BenchPanel from "$lib/BenchPanel.svelte";
import ResultsPanel from "$lib/ResultsPanel.svelte";
import SettingsPanel from "$lib/SettingsPanel.svelte";
type Paths = {
config_file: string;
data_dir: string;
tasks_dir: string;
};
type TaskInfo = { id: string; title: string; group: string; dir: string };
type TaskError = { dir: string; message: string };
type LoadReport = { tasks: TaskInfo[]; errors: TaskError[] };
type BatchEvent =
| { kind: "run_started"; model: string; task: string; repeat: number }
| { kind: "run_finished"; model: string; task: string; repeat: number; class: string; score: number }
| { kind: "run_skipped"; model: string; task: string; repeat: number }
| { kind: "model_unavailable"; model: string; reason: string }
| { kind: "progress"; done: number; total: number };
type RunRow = {
model: string;
task_id: string;
repeat_idx: number;
error_class: string;
score: number;
steps: number;
duration_ms: number;
tps: number | null;
};
type Tab = "bench" | "results" | "settings";
let tab = $state<Tab>("bench");
let loaded = $state(false);
let loadError = $state("");
let models = $state<ModelInfo[]>([]);
let tasks = $state<LoadReport | null>(null);
let paths = $state<Paths | null>(null);
let error = $state("");
let report = $state<LoadReport | null>(null);
let taskError = $state("");
let modelsText = $state("qwen3:0.6b");
let selected = $state<string[]>([]);
let repeats = $state(1);
let running = $state(false);
let log = $state<string[]>([]);
let progress = $state<{ done: number; total: number } | null>(null);
let batchId = $state<number | null>(null);
let rows = $state<RunRow[]>([]);
type ModelRank = {
rank: number;
model: string;
total_score: number;
runs: number;
successes: number;
median_duration_ms: number;
mean_completion_tokens: number;
};
type MatrixCell = { model: string; task_id: string; runs: number; successes: number; mean_score: number };
type Ranking = { batch_id: number; models: ModelRank[]; cells: MatrixCell[]; tasks: string[] };
let ranking = $state<Ranking | null>(null);
type RuntimeStatus = { program: string; available: boolean; detail: string };
type StepRow = {
idx: number;
role: string;
content: string;
tool_name: string | null;
tool_args_json: string | null;
tool_result: string | null;
};
let runtime = $state<RuntimeStatus | null>(null);
let detail = $state<{ model: string; task_id: string; repeat_idx: number; steps: StepRow[] } | null>(null);
let batchError = $state("");
let unlisten: UnlistenFn | null = null;
let selectedBatch = $state<number | null>(null);
onMount(async () => {
try {
paths = await invoke<Paths>("get_paths");
[models, tasks, paths] = await Promise.all([api.models(), api.tasks(), api.paths()]);
runtime = await api.runtime();
// Ohne Modell beginnt man bei den Einstellungen.
if (models.length === 0) tab = "settings";
} catch (e) {
error = String(e);
}
try {
runtime = await invoke<RuntimeStatus>("runtime_status");
} catch (e) {
runtime = { program: "?", available: false, detail: String(e) };
}
try {
report = await invoke<LoadReport>("load_tasks");
} catch (e) {
taskError = String(e);
}
unlisten = await listen<BatchEvent>("batch-event", (ev) => onEvent(ev.payload));
});
onDestroy(() => {
if (unlisten) unlisten();
});
function onEvent(e: BatchEvent) {
if (e.kind === "progress") {
progress = { done: e.done, total: e.total };
return;
}
if (e.kind === "model_unavailable") {
log = [...log, `Modell ${e.model} nicht nutzbar: ${e.reason}`];
return;
}
const label = `${e.model} · ${e.task} · Wdh. ${e.repeat}`;
if (e.kind === "run_started") log = [...log, `läuft: ${label}`];
if (e.kind === "run_skipped") log = [...log, `übersprungen: ${label}`];
if (e.kind === "run_finished")
log = [...log, `fertig: ${label} → ${e.class}, Score ${e.score.toFixed(2)}`];
}
function toggleTask(id: string) {
selected = selected.includes(id)
? selected.filter((x) => x !== id)
: [...selected, id];
}
function parseModels(): string[] {
return modelsText
.split(/[\n,]/)
.map((m) => m.trim())
.filter((m) => m.length > 0);
}
async function start() {
batchError = "";
rows = [];
ranking = null;
log = [];
progress = null;
batchId = null;
running = true;
try {
const summary = await invoke<{ batch_id: number; cancelled: boolean }>("start_batch", {
models: parseModels(),
taskIds: selected,
repeats,
note: "",
});
batchId = summary.batch_id;
rows = await invoke<RunRow[]>("batch_results", { batchId: summary.batch_id });
ranking = await invoke<Ranking>("batch_ranking", { batchId: summary.batch_id });
if (summary.cancelled) log = [...log, "Batch abgebrochen."];
} catch (e) {
batchError = String(e);
loadError = String(e);
} finally {
running = false;
loaded = true;
}
});
function showResults(batchId: number) {
selectedBatch = batchId;
tab = "results";
}
async function showSteps(r: RunRow) {
if (batchId === null) return;
const steps = await invoke<StepRow[]>("run_steps", {
batchId,
model: r.model,
taskId: r.task_id,
repeatIdx: r.repeat_idx,
});
detail = { model: r.model, task_id: r.task_id, repeat_idx: r.repeat_idx, steps };
}
async function cancel() {
await invoke<boolean>("cancel_batch");
}
const tabs: { id: Tab; label: string }[] = [
{ id: "bench", label: "Benchmark" },
{ id: "results", label: "Ergebnisse" },
{ id: "settings", label: "Einstellungen" },
];
</script>
<main class="container">
<h1>coding-bench</h1>
<header>
<div class="inner">
<span class="logo">coding-bench</span>
<nav>
{#each tabs as t (t.id)}
<button class="tab" class:active={tab === t.id} onclick={() => (tab = t.id)}>{t.label}</button>
{/each}
</nav>
</div>
</header>
<section>
<h2>Setup: Pfade</h2>
{#if error}
<p class="fehler">Fehler: {error}</p>
{:else if paths}
<dl>
<dt>Konfiguration</dt>
<dd><code>{paths.config_file}</code></dd>
<dt>Datenordner</dt>
<dd><code>{paths.data_dir}</code></dd>
<dt>Aufgabenordner</dt>
<dd><code>{paths.tasks_dir}</code></dd>
<dt>Container</dt>
<dd>
{#if runtime}
{#if runtime.available}
<span class="ok">{runtime.program} verfügbar, {runtime.detail}</span>
{:else}
<span class="fehler">{runtime.program} nicht nutzbar: {runtime.detail}</span>
{/if}
{:else}
Prüfe …
{/if}
</dd>
</dl>
{:else}
<p>Lade Pfade …</p>
{/if}
</section>
<section>
<h2>Aufgaben</h2>
{#if taskError}
<p class="fehler">Fehler: {taskError}</p>
{:else if report}
<p>{report.tasks.length} gültig, {report.errors.length} mit Fehlern.</p>
<ul class="tasks">
{#each report.tasks as t (t.dir)}
<li>
<label>
<input
type="checkbox"
checked={selected.includes(t.id)}
onchange={() => toggleTask(t.id)}
disabled={running}
/>
<strong>{t.id}</strong> · {t.title} <span class="gruppe">Gruppe {t.group}</span>
</label>
</li>
{/each}
</ul>
{#if report.errors.length > 0}
<h3>Fehler</h3>
<ul class="fehler">
{#each report.errors as e (e.dir)}
<li><code>{e.dir}</code>: {e.message}</li>
{/each}
</ul>
{/if}
{:else}
<p>Lade Aufgaben …</p>
{/if}
</section>
<section>
<h2>Batch starten</h2>
<label class="feld">
Modelle (Komma oder Zeilenumbruch)
<textarea rows="2" bind:value={modelsText} disabled={running}></textarea>
</label>
<label class="feld">
Wiederholungen
<input type="number" min="1" max="20" bind:value={repeats} disabled={running} />
</label>
<div class="knöpfe">
<button onclick={start} disabled={running || selected.length === 0 || parseModels().length === 0}>
Starten
</button>
<button onclick={cancel} disabled={!running}>Abbrechen</button>
<main>
{#if loadError}
<section class="card"><p class="error">Start fehlgeschlagen: {loadError}</p></section>
{:else if !loaded}
<p class="muted">Lade …</p>
{:else}
<!-- Reiter bleiben gemountet, damit ein laufender Batch beim Wechsel nicht abreißt. -->
<div hidden={tab !== "bench"}>
<BenchPanel {models} {tasks} ongotosettings={() => (tab = "settings")} onfinished={showResults} />
</div>
<div hidden={tab !== "results"}>
<ResultsPanel bind:selected={selectedBatch} />
</div>
<div hidden={tab !== "settings"}>
<SettingsPanel {models} {paths} {runtime} onsaved={(m) => (models = m)} />
</div>
{#if progress}
<p>Fortschritt: {progress.done} von {progress.total}</p>
{/if}
{#if batchError}
<p class="fehler">Fehler: {batchError}</p>
{/if}
{#if log.length > 0}
<ul class="log">
{#each log as line, i (i)}
<li>{line}</li>
{/each}
</ul>
{/if}
</section>
{#if ranking && ranking.models.length > 0}
<section>
<h2>Rangliste, Batch {ranking.batch_id}</h2>
<table>
<thead>
<tr>
<th>Rang</th>
<th>Modell</th>
<th>Score</th>
<th>Erfolge</th>
<th>Median-Dauer</th>
<th>Ø Completion-Tokens</th>
</tr>
</thead>
<tbody>
{#each ranking.models as m (m.model)}
<tr>
<td>{m.rank}</td>
<td>{m.model}</td>
<td>{m.total_score.toFixed(2)}</td>
<td>{m.successes} / {m.runs}</td>
<td>{(m.median_duration_ms / 1000).toFixed(1)} s</td>
<td>{m.mean_completion_tokens.toFixed(0)}</td>
</tr>
{/each}
</tbody>
</table>
<h3>Matrix: Erfolge je Aufgabe</h3>
<table class="matrix">
<thead>
<tr>
<th>Modell</th>
{#each ranking.tasks as t (t)}
<th>{t}</th>
{/each}
</tr>
</thead>
<tbody>
{#each ranking.models as m (m.model)}
<tr>
<td>{m.model}</td>
{#each ranking.tasks as t (t)}
{@const cell = ranking.cells.find((c) => c.model === m.model && c.task_id === t)}
<td
class="zelle"
style={cell ? `background: color-mix(in srgb, #2e7d32 ${Math.round(cell.mean_score * 100)}%, transparent)` : ""}
title={cell ? `Score ${cell.mean_score.toFixed(2)}` : "keine Läufe"}
>
{cell ? `${cell.successes}/${cell.runs}` : "–"}
</td>
{/each}
</tr>
{/each}
</tbody>
</table>
</section>
{/if}
{#if batchId !== null && rows.length > 0}
<section>
<h2>Ergebnisse, Batch {batchId}</h2>
<table>
<thead>
<tr>
<th>Modell</th>
<th>Aufgabe</th>
<th>Wdh.</th>
<th>Klasse</th>
<th>Score</th>
<th>Schritte</th>
<th>Dauer</th>
<th></th>
</tr>
</thead>
<tbody>
{#each rows as r (`${r.model}|${r.task_id}|${r.repeat_idx}`)}
<tr>
<td>{r.model}</td>
<td>{r.task_id}</td>
<td>{r.repeat_idx}</td>
<td>{r.error_class}</td>
<td>{r.score.toFixed(2)}</td>
<td>{r.steps}</td>
<td>{(r.duration_ms / 1000).toFixed(1)} s</td>
<td><button onclick={() => showSteps(r)}>Schritte</button></td>
</tr>
{/each}
</tbody>
</table>
{#if detail}
<h3>Schritte: {detail.model} · {detail.task_id} · Wdh. {detail.repeat_idx}</h3>
<ol class="schritte">
{#each detail.steps as st (st.idx)}
<li>
<strong>{st.role}</strong>
{#if st.tool_name}
· Tool <code>{st.tool_name}</code> <code>{st.tool_args_json ?? ""}</code>
{/if}
{#if st.content}
<pre>{st.content}</pre>
{/if}
{#if st.tool_result}
<pre class="ergebnis">{st.tool_result}</pre>
{/if}
</li>
{/each}
</ol>
{/if}
</section>
{/if}
</main>
<style>
:root {
font-family: Inter, Avenir, Helvetica, Arial, sans-serif;
font-size: 16px;
line-height: 24px;
color: #0f0f0f;
background-color: #f6f6f6;
-webkit-text-size-adjust: 100%;
header {
background: var(--surface);
border-bottom: 1px solid var(--border);
position: sticky;
top: 0;
z-index: 5;
}
@media (prefers-color-scheme: dark) {
:root {
color: #f6f6f6;
background-color: #2f2f2f;
}
}
.container {
.inner {
max-width: 62rem;
margin: 0 auto;
padding: 2rem 1rem;
max-width: 48rem;
padding: 0 1rem;
display: flex;
align-items: center;
gap: 2rem;
}
section {
margin-bottom: 2rem;
.logo {
font-weight: 700;
letter-spacing: 0.01em;
}
dl {
display: grid;
grid-template-columns: max-content 1fr;
gap: 0.4rem 1rem;
nav {
display: flex;
gap: 0.2rem;
}
dt {
.tab {
border: none;
border-bottom: 3px solid transparent;
border-radius: 0;
background: none;
padding: 0.9rem 1rem 0.75rem;
color: var(--muted);
}
.tab:hover:not(:disabled) {
color: var(--text);
border-color: transparent;
}
.tab.active {
color: var(--text);
border-bottom-color: var(--accent);
font-weight: 600;
}
dd {
margin: 0;
overflow-wrap: anywhere;
main {
max-width: 62rem;
margin: 0 auto;
padding: 1.2rem 1rem 3rem;
}
.tasks {
list-style: none;
padding: 0;
}
.feld {
display: flex;
flex-direction: column;
gap: 0.3rem;
margin-bottom: 0.8rem;
}
.knöpfe {
display: flex;
gap: 0.6rem;
margin-bottom: 0.8rem;
}
.log {
max-height: 16rem;
overflow-y: auto;
font-family: monospace;
font-size: 0.85rem;
}
table {
width: 100%;
border-collapse: collapse;
}
th,
td {
text-align: left;
padding: 0.3rem 0.5rem;
border-bottom: 1px solid #8884;
}
.fehler {
color: #c62828;
}
.ok {
color: #2e7d32;
}
.schritte pre {
white-space: pre-wrap;
overflow-wrap: anywhere;
max-height: 12rem;
overflow-y: auto;
background: #8881;
padding: 0.4rem;
margin: 0.3rem 0;
font-size: 0.85rem;
}
.matrix .zelle {
text-align: center;
font-variant-numeric: tabular-nums;
[hidden] {
display: none !important;
}
</style>