47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
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
|
||
}
|