fix: measure a turn's duration when its prompt is not loaded

A long turn's prompt can fall before the loaded message page. Measure
from the first record of the run then, so historical turns still show a
duration in the footer.

Bump version to 0.1.8 (build 9).
This commit is contained in:
blumia committed 2026-11-16 18:19:27 +08:00
1 parent 8268bdecc2
commit a471c026f1
2 files changed
+16 -2

No files matched your search

+14
View File
@@ -176,6 +176,20 @@ func (ch *chat) turnDuration(id string) string {
break
}
}
if start <= 0 {
// The prompt fell outside the loaded page (a long turn). Measure
// from the first record of this run instead, so historical turns
// still show a duration.
j := idx
for j > 0 {
prev := msgs[j-1].Type
if prev == "user" || prev == "synthetic" {
break
}
j--
}
start = msgs[j].Time.Created
}
if start <= 0 || msgs[idx].Time.Completed <= start {
return ""
}