Add shared live run graphs, debugging, editor choice and draft cleanup
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/internal/runinspect"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
type debugClosedMsg struct{ err error }
|
||||
|
||||
func (m Model) selectedRunID() int64 {
|
||||
if !m.runOpen || m.runStartRequest != "" {
|
||||
return 0
|
||||
}
|
||||
if m.runDetail != nil {
|
||||
return m.runDetail.ID
|
||||
}
|
||||
if m.requestedRunID > 0 {
|
||||
return 0
|
||||
}
|
||||
runs := m.visibleRuns()
|
||||
if len(runs) > 0 {
|
||||
return runs[min(m.runIndex, len(runs)-1)].ID
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func (m Model) debugRun() (tea.Model, tea.Cmd) {
|
||||
id := m.selectedRunID()
|
||||
if id <= 0 {
|
||||
m.appendLine("Select a loaded run to debug.")
|
||||
return m, nil
|
||||
}
|
||||
cli, err := runinspect.CLIExecutable()
|
||||
if err != nil {
|
||||
m.appendLine("debug: pipelines CLI is unavailable: " + err.Error())
|
||||
return m, nil
|
||||
}
|
||||
cmd := exec.Command(cli, "--url", m.url, "debug", fmt.Sprint(id))
|
||||
return m, tea.ExecProcess(cmd, func(err error) tea.Msg { return debugClosedMsg{err} })
|
||||
}
|
||||
Reference in New Issue
Block a user