Expose recorded background task timing and progress metadata

This commit is contained in:
2026-11-06 15:08:34 +00:00
parent c9a4cd0bf6
commit 6421554bfe
16 changed files with 688 additions and 31 deletions
+13 -1
View File
@@ -51,7 +51,19 @@ func (c *Chat) recordCommand(thread string, i item, emit bool) {
status = protocol.ChatShellRunning
}
snapshot := old
snapshot.shell = protocol.ChatShell{ID: id, Command: i.Command, Status: status, Exit: i.ExitCode}
snapshot.shell.ID, snapshot.shell.Status = id, status
snapshot.shell.Command, snapshot.shell.Exit = i.Command, i.ExitCode
snapshot.shell.TaskType = "command"
if i.startedAtMS > 0 && i.startedAtMS <= 8640000000000000 && snapshot.shell.StartedAt == 0 {
snapshot.shell.StartedAt = i.startedAtMS
}
if i.completedAtMS > snapshot.shell.UpdatedAt && i.completedAtMS <= 8640000000000000 {
snapshot.shell.UpdatedAt = i.completedAtMS
}
if i.DurationMS != nil && *i.DurationMS >= 0 && (snapshot.shell.DurationMS == nil || *i.DurationMS >= *snapshot.shell.DurationMS) {
duration := *i.DurationMS
snapshot.shell.DurationMS = &duration
}
if snapshot.shell.Command == "" {
snapshot.shell.Command = old.shell.Command
}