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.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
Stu Leak 2025-12-17 14:25:18 -05:00
parent aa64e64576
commit 27e038e1a1
3 changed files with 18 additions and 9 deletions

View File

@ -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

View File

@ -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

View File

@ -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())
}