fix(ui): restore turn/token counts on task reload

Turns/Tokens were never populated from history, so a reloaded terminal
task showed "0/max". Restore them from the latest task_run.
This commit is contained in:
mika kuns
2026-07-24 11:21:21 +02:00
parent b9b3053051
commit 0226c98076
@@ -536,6 +536,10 @@ public sealed partial class DetailsIslandViewModel : ViewModelBase, IDisposable
var latestRun = await runRepo.GetLatestByTaskIdAsync(row.Id, ct);
ct.ThrowIfCancellationRequested();
LatestRunSessionId = latestRun?.SessionId;
// Restore turn/token counts from the last run so a reloaded terminal task
// shows its real turns instead of "0/max".
Turns = latestRun?.TurnCount ?? 0;
Tokens = (latestRun?.TokensIn ?? 0) + (latestRun?.TokensOut ?? 0);
Monitor.ApplyOutcome(entity.Result, latestRun?.ErrorMarkdown);
Monitor.SetTaskId(row.Id);