Files
pipelines/internal/tui/run_progress.go
T

47 lines
1.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package tui
import (
"git.a-wan.net/alan/pipelines/internal/protocol"
"github.com/charmbracelet/lipgloss"
)
// Animation is driven by a local timer, never by extra server requests.
func (m Model) progress(status string) string {
marker := "○"
color := themeMuted
switch status {
case "running":
return m.runSpinner.View() + " running"
case "completed", "succeeded", "done":
marker = "✓"
color = themeSuccess
case "failed":
marker = "✗"
color = themeError
case "interrupted":
marker = "!"
color = themeError
case "canceled":
marker = "−"
}
return lipgloss.NewStyle().Foreground(color).Render(marker + " " + status)
}
func (m Model) stepProgressStatus(step protocol.RunStep) string {
status := step.Status
if status == "completed" {
if step.Outcome == "error" || step.Target == protocol.FailureEnd {
return "failed"
}
return "done"
}
// Never animate stale execution state in a terminal run.
if status == "running" && m.runDetail != nil && m.runDetail.Status != "running" && m.runDetail.Status != "queued" {
if m.runDetail.Status == "canceled" {
return "canceled"
}
return "interrupted"
}
return status
}