feat: Podman-Status im Setup und Schritt-Ansicht je Lauf

Setup zeigt, ob der Container-Befehl läuft (Version). Ergebnistabelle hat
eine Schritte-Ansicht: Nachrichten, Tool-Aufrufe und Tool-Antworten eines
Laufs aus der Datenbank. Store-Test grün, 53 Unit-Tests insgesamt.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-07 11:55:56 +01:00
parent 668e690cda
commit 91a15baebc
4 changed files with 179 additions and 2 deletions

View File

@ -121,6 +121,49 @@ fn batch_results(paths: State<'_, AppPaths>, batch_id: i64) -> Result<Vec<RunRec
store.runs_for_batch(batch_id)
}
/// Schritte eines einzelnen Laufs für die Detailansicht.
#[tauri::command]
fn run_steps(
paths: State<'_, AppPaths>,
batch_id: i64,
model: String,
task_id: String,
repeat_idx: u32,
) -> Result<Vec<store::StepRow>, String> {
let store = Store::open(&paths.0.data_dir.join(DB_FILE))?;
store.steps_for_run(batch_id, &model, &task_id, repeat_idx)
}
/// Zustand der Container-Laufzeit (Podman) für das Setup.
#[derive(serde::Serialize)]
pub struct RuntimeStatus {
pub program: String,
pub available: bool,
pub detail: String,
}
#[tauri::command]
fn runtime_status(cfg: State<'_, Config>) -> RuntimeStatus {
let program = cfg.container_runtime.clone();
match std::process::Command::new(&program).args(["version", "--format", "{{.Client.Version}}"]).output() {
Ok(out) if out.status.success() => RuntimeStatus {
program,
available: true,
detail: format!("Version {}", String::from_utf8_lossy(&out.stdout).trim()),
},
Ok(out) => RuntimeStatus {
program,
available: false,
detail: String::from_utf8_lossy(&out.stderr).trim().to_string(),
},
Err(e) => RuntimeStatus {
program,
available: false,
detail: format!("nicht startbar: {e}"),
},
}
}
/// Rangliste und Matrix eines Batches. Gewichte kommen aus den Aufgaben.
#[tauri::command]
fn batch_ranking(paths: State<'_, AppPaths>, batch_id: i64) -> Result<ranking::Ranking, String> {
@ -164,7 +207,9 @@ pub fn run() {
start_batch,
cancel_batch,
batch_results,
batch_ranking
batch_ranking,
run_steps,
runtime_status
])
.run(tauri::generate_context!())
.expect("error while running tauri application");

View File

@ -50,6 +50,17 @@ CREATE TABLE IF NOT EXISTS step (
";
/// Ein abgeschlossener Lauf, so wie er gespeichert wird.
/// Ein Schritt eines Laufs, für die Anzeige.
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct StepRow {
pub idx: i64,
pub role: String,
pub content: String,
pub tool_name: Option<String>,
pub tool_args_json: Option<String>,
pub tool_result: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize)]
pub struct RunRecord {
pub batch_id: i64,
@ -217,6 +228,38 @@ impl Store {
rows.collect::<Result<Vec<_>, _>>().map_err(|e| e.to_string())
}
/// Schritte eines Laufs, identifiziert über Batch, Modell, Aufgabe und Wiederholung.
pub fn steps_for_run(
&self,
batch_id: i64,
model: &str,
task_id: &str,
repeat_idx: u32,
) -> Result<Vec<StepRow>, String> {
let mut stmt = self
.conn
.prepare(
"SELECT s.idx, s.role, s.content, s.tool_name, s.tool_args_json, s.tool_result
FROM step s JOIN run r ON s.run_id = r.id
WHERE r.batch_id = ?1 AND r.model = ?2 AND r.task_id = ?3 AND r.repeat_idx = ?4
ORDER BY s.idx",
)
.map_err(|e| e.to_string())?;
let rows = stmt
.query_map(params![batch_id, model, task_id, repeat_idx], |r| {
Ok(StepRow {
idx: r.get(0)?,
role: r.get(1)?,
content: r.get(2)?,
tool_name: r.get(3)?,
tool_args_json: r.get(4)?,
tool_result: r.get(5)?,
})
})
.map_err(|e| e.to_string())?;
rows.collect::<Result<Vec<_>, _>>().map_err(|e| e.to_string())
}
pub fn run_count(&self, batch_id: i64) -> Result<i64, String> {
self.conn
.query_row("SELECT COUNT(*) FROM run WHERE batch_id = ?1", params![batch_id], |r| r.get(0))
@ -301,6 +344,19 @@ mod tests {
assert!(s.runs_for_batch(99).unwrap().is_empty());
}
#[test]
fn schritte_eines_laufs_werden_gefunden() {
let mut s = Store::open_in_memory().unwrap();
let b = s.create_batch("", 1, "{}").unwrap();
let transcript = vec![Message::new("user", "Aufgabe"), Message::new("assistant", "ok")];
s.insert_run(&rec(b, "m1", "a-01", 1), &transcript).unwrap();
let steps = s.steps_for_run(b, "m1", "a-01", 1).unwrap();
assert_eq!(steps.len(), 2);
assert_eq!(steps[0].role, "user");
assert_eq!(steps[1].content, "ok");
assert!(s.steps_for_run(b, "m1", "a-01", 2).unwrap().is_empty());
}
#[test]
fn unbekannter_batch_existiert_nicht() {
let s = Store::open_in_memory().unwrap();