Files
alan c42a19f7d3 Improve workflow UI, retain stage diffs, and add portable pipeline transfers
Make OpenCode authoring responsive and expand the managed skill references. Add conflict-aware import/export, real-provider reference workflows, and tracked V2 generation for reliable budget accounting.
2026-10-10 20:55:42 +01:00

54 lines
1.3 KiB
Go

package tui
import (
"fmt"
"git.a-wan.net/alan/pipelines/internal/runinspect"
tea "github.com/charmbracelet/bubbletea"
"os/exec"
"path/filepath"
"time"
)
type transferFinishedMsg struct {
path string
imported bool
err error
}
func (m Model) transferPipelines(imported bool) (tea.Model, tea.Cmd) {
executable, err := runinspect.CLIExecutable()
if err != nil {
m.appendLine(err.Error())
return m, nil
}
command := "export"
path := ""
args := []string{"--url", m.url}
if imported {
command = "import"
} else {
path, err = filepath.Abs("pipelines-export-" + time.Now().Format("20060102-150405.000000000") + ".zip")
if err != nil {
m.appendLine(err.Error())
return m, nil
}
}
args = append(args, command)
if path != "" {
args = append(args, "--output", path)
}
return m, tea.ExecProcess(exec.Command(executable, args...), func(err error) tea.Msg { return transferFinishedMsg{path: path, imported: imported, err: err} })
}
func (m *Model) transferResult(msg transferFinishedMsg) {
if msg.err != nil {
m.appendLine(fmt.Sprintf("Pipeline transfer canceled or failed: %v", msg.err))
return
}
if msg.imported {
m.appendLine("Pipeline import completed; conflicts resolved and version history retained.")
} else {
m.appendLine("Export saved: " + msg.path)
}
}