Offer nvim or OpenCode when creating a pipeline

This commit is contained in:
2026-10-09 20:53:00 +01:00
parent a50e8648f6
commit dd50344170
10 changed files with 102 additions and 16 deletions
+22 -1
View File
@@ -8,6 +8,19 @@ import (
"github.com/sahilm/fuzzy"
)
func (m Model) openAuthorPicker(edit editedMsg) (tea.Model, tea.Cmd) {
m.editorOpen = true
m.editorIndex = 0
m.editorInput = newInput()
m.editorInput.Placeholder = "Search nvim or OpenCode…"
m.editorDraft = &edit
return m, m.editorInput.Focus()
}
func (m Model) newPipeline(source string) (tea.Model, tea.Cmd) {
return m.openAuthorPicker(editedMsg{source: source, createOnly: true})
}
func (m Model) editorChoices() []string {
choices := []string{"nvim", "OpenCode"}
if query := strings.TrimSpace(m.editorInput.Value()); query != "" {
@@ -45,7 +58,7 @@ func (m Model) updateEditorPicker(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
d := m.editorDraft
m.editorOpen = false
m.editorDraft = nil
return m, editDraftUsing(choice, d.name, d.source, true, false, draft.Draft{Server: m.url, BaseVersion: d.baseVersion})
return m, editDraftUsing(choice, d.name, d.source, true, d.createOnly, draft.Draft{Path: d.path, Name: d.name, Server: m.url, CreateOnly: d.createOnly, BaseVersion: d.baseVersion})
}
var cmd tea.Cmd
m.editorInput, cmd = m.editorInput.Update(msg)
@@ -57,9 +70,17 @@ func (m Model) editorPickerView(height int) string {
input := m.editorInput
input.Width = max(1, min(60, m.width-12))
lines := []string{"Edit pipeline with…", input.View(), "Tab/Shift+Tab choose · type to search · Enter open · Esc cancel", ""}
if m.editorDraft != nil && m.editorDraft.createOnly {
lines[0] = "New pipeline with…"
}
choices := m.editorChoices()
for i, choice := range choices {
lines = append(lines, menuOption(choice, i == m.editorIndex))
if choice == "nvim" {
lines = append(lines, " Write the pipeline Markdown in a retained draft file.")
} else {
lines = append(lines, " Open the OpenCode harness to write it together.")
}
}
if len(choices) == 0 {
lines = append(lines, "No matching editor.")