Add shared live run graphs, debugging, editor choice and draft cleanup
This commit is contained in:
+15
-1
@@ -15,6 +15,7 @@ import (
|
||||
"git.a-wan.net/alan/pipelines/internal/draft"
|
||||
"git.a-wan.net/alan/pipelines/internal/opencode"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
"git.a-wan.net/alan/pipelines/internal/runinspect"
|
||||
)
|
||||
|
||||
type editedMsg struct {
|
||||
@@ -43,6 +44,10 @@ func editDraft(name, source string, confirm ...bool) tea.Cmd {
|
||||
}
|
||||
|
||||
func editDraftMode(name, source string, needsConfirm, fresh bool, metadata ...draft.Draft) tea.Cmd {
|
||||
return editDraftUsing("", name, source, needsConfirm, fresh, metadata...)
|
||||
}
|
||||
|
||||
func editDraftUsing(choice, name, source string, needsConfirm, fresh bool, metadata ...draft.Draft) tea.Cmd {
|
||||
var meta draft.Draft
|
||||
if len(metadata) > 0 {
|
||||
meta = metadata[0]
|
||||
@@ -57,7 +62,9 @@ func editDraftMode(name, source string, needsConfirm, fresh bool, metadata ...dr
|
||||
return func() tea.Msg { return editedMsg{name: name, path: path, err: err} }
|
||||
}
|
||||
var command *exec.Cmd
|
||||
if name != "" && (strings.TrimSpace(os.Getenv("VISUAL")) != "" || strings.TrimSpace(os.Getenv("EDITOR")) != "") {
|
||||
if choice == "nvim" {
|
||||
command = exec.Command("nvim", path)
|
||||
} else if choice == "" && name != "" && (strings.TrimSpace(os.Getenv("VISUAL")) != "" || strings.TrimSpace(os.Getenv("EDITOR")) != "") {
|
||||
editor, args, editorErr := draftEditor()
|
||||
if editorErr != nil {
|
||||
return func() tea.Msg { return editedMsg{name: name, path: path, err: editorErr} }
|
||||
@@ -68,6 +75,13 @@ func editDraftMode(name, source string, needsConfirm, fresh bool, metadata ...dr
|
||||
if exeErr != nil {
|
||||
return func() tea.Msg { return editedMsg{name: name, path: path, err: exeErr} }
|
||||
}
|
||||
if cli, lookupErr := runinspect.CLIExecutable(); lookupErr == nil {
|
||||
executable = cli
|
||||
} else if choice == "opencode" {
|
||||
return func() tea.Msg {
|
||||
return editedMsg{name: name, path: path, err: fmt.Errorf("pipelines CLI is required for OpenCode editing: %w", lookupErr)}
|
||||
}
|
||||
}
|
||||
cli := quoteCLI(executable) + " --url " + quoteCLI(meta.Server)
|
||||
command, err = author.Command(context.Background(), opencode.Executable(), d, "", cli)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user