From 9aeb82dd2b940d27e7adf402b52f171677dec371 Mon Sep 17 00:00:00 2001 From: Stu Leak Date: Wed, 17 Dec 2025 14:25:18 -0500 Subject: [PATCH] Fix queue stats to properly distinguish cancelled from failed jobs The queue Stats() method was grouping cancelled and failed jobs together, causing cancelled jobs to be displayed as "failed" in the status bar. Updated Stats() to return a separate cancelled count and modified all callers (updateStatsBar, queueProgressCounts, showMainMenu) to handle the new return value. Also updated ConversionStatsBar to display cancelled jobs separately in the status bar. --- internal/queue/queue.go | 6 ++++-- internal/ui/components.go | 12 +++++++++--- main.go | 9 +++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/internal/queue/queue.go b/internal/queue/queue.go index 49f2b60..f341434 100644 --- a/internal/queue/queue.go +++ b/internal/queue/queue.go @@ -167,7 +167,7 @@ func (q *Queue) List() []*Job { } // Stats returns queue statistics -func (q *Queue) Stats() (pending, running, completed, failed int) { +func (q *Queue) Stats() (pending, running, completed, failed, cancelled int) { q.mu.RLock() defer q.mu.RUnlock() @@ -179,8 +179,10 @@ func (q *Queue) Stats() (pending, running, completed, failed int) { running++ case JobStatusCompleted: completed++ - case JobStatusFailed, JobStatusCancelled: + case JobStatusFailed: failed++ + case JobStatusCancelled: + cancelled++ } } return diff --git a/internal/ui/components.go b/internal/ui/components.go index 900f2fb..108d8ea 100644 --- a/internal/ui/components.go +++ b/internal/ui/components.go @@ -443,6 +443,7 @@ type ConversionStatsBar struct { pending int completed int failed int + cancelled int progress float64 jobTitle string fps float64 @@ -461,22 +462,24 @@ func NewConversionStatsBar(onTapped func()) *ConversionStatsBar { } // UpdateStats updates the stats display -func (c *ConversionStatsBar) UpdateStats(running, pending, completed, failed int, progress float64, jobTitle string) { +func (c *ConversionStatsBar) UpdateStats(running, pending, completed, failed, cancelled int, progress float64, jobTitle string) { c.running = running c.pending = pending c.completed = completed c.failed = failed + c.cancelled = cancelled c.progress = progress c.jobTitle = jobTitle c.Refresh() } // UpdateStatsWithDetails updates the stats display with detailed conversion info -func (c *ConversionStatsBar) UpdateStatsWithDetails(running, pending, completed, failed int, progress, fps, speed float64, eta, jobTitle string) { +func (c *ConversionStatsBar) UpdateStatsWithDetails(running, pending, completed, failed, cancelled int, progress, fps, speed float64, eta, jobTitle string) { c.running = running c.pending = pending c.completed = completed c.failed = failed + c.cancelled = cancelled c.progress = progress c.fps = fps c.speed = speed @@ -600,7 +603,7 @@ func (r *conversionStatsRenderer) Refresh() { r.statusText.Text = "⏸ " + formatCount(r.bar.pending, "queued") r.statusText.Color = color.NRGBA{R: 255, G: 200, B: 100, A: 255} // Yellow r.progressBar.Hide() - } else if r.bar.completed > 0 || r.bar.failed > 0 { + } else if r.bar.completed > 0 || r.bar.failed > 0 || r.bar.cancelled > 0 { statusStr := "✓ " parts := []string{} if r.bar.completed > 0 { @@ -609,6 +612,9 @@ func (r *conversionStatsRenderer) Refresh() { if r.bar.failed > 0 { parts = append(parts, formatCount(r.bar.failed, "failed")) } + if r.bar.cancelled > 0 { + parts = append(parts, formatCount(r.bar.cancelled, "cancelled")) + } statusStr += strings.Join(parts, " • ") r.statusText.Text = statusStr r.statusText.Color = color.NRGBA{R: 150, G: 150, B: 150, A: 255} // Gray diff --git a/main.go b/main.go index b1b1851..dade5fc 100644 --- a/main.go +++ b/main.go @@ -751,7 +751,7 @@ func (s *appState) updateStatsBar() { return } - pending, running, completed, failed := s.jobQueue.Stats() + pending, running, completed, failed, cancelled := s.jobQueue.Stats() // Find the currently running job to get its progress and stats var progress, fps, speed float64 @@ -794,14 +794,14 @@ func (s *appState) updateStatsBar() { } } - s.statsBar.UpdateStatsWithDetails(running, pending, completed, failed, progress, fps, speed, eta, jobTitle) + s.statsBar.UpdateStatsWithDetails(running, pending, completed, failed, cancelled, progress, fps, speed, eta, jobTitle) } func (s *appState) queueProgressCounts() (completed, total int) { if s.jobQueue == nil { return 0, 0 } - pending, running, completedCount, failed := s.jobQueue.Stats() + pending, running, completedCount, failed, cancelled := s.jobQueue.Stats() // Total includes all jobs in memory, including cancelled/failed/pending total = len(s.jobQueue.List()) // Include direct conversion as an in-flight item in totals @@ -812,6 +812,7 @@ func (s *appState) queueProgressCounts() (completed, total int) { _ = pending _ = running _ = failed + _ = cancelled return } @@ -1122,7 +1123,7 @@ func (s *appState) showMainMenu() { // Get queue stats - show completed jobs out of total var queueCompleted, queueTotal int if s.jobQueue != nil { - _, _, completed, _ := s.jobQueue.Stats() + _, _, completed, _, _ := s.jobQueue.Stats() queueCompleted = completed queueTotal = len(s.jobQueue.List()) }