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.
This commit is contained in:
2026-10-10 20:55:42 +01:00
parent a66d540125
commit c42a19f7d3
81 changed files with 5593 additions and 539 deletions
+150 -118
View File
@@ -51,6 +51,8 @@ type keyMap struct {
versions bool
confirm bool
runs bool
runInspect bool
runGraph bool
retryAvailable bool
templates bool
drafts bool
@@ -58,10 +60,10 @@ type keyMap struct {
func (k keyMap) ShortHelp() []key.Binding {
if k.confirm {
return []key.Binding{key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "submit")), key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "edit")), k.cancel}
return []key.Binding{key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "create/update pipeline")), key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "edit")), k.cancel}
}
if k.drafts {
return []key.Binding{key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "draft")), key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "edit")), key.NewBinding(key.WithKeys("v"), key.WithHelp("v", "validate")), key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "submit")), k.cancel}
return []key.Binding{key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "draft")), key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "edit")), key.NewBinding(key.WithKeys("v"), key.WithHelp("v", "validate")), key.NewBinding(key.WithKeys("s"), key.WithHelp("s", "create/update pipeline")), k.cancel}
}
if k.versions {
return []key.Binding{key.NewBinding(key.WithKeys("j", "k"), key.WithHelp("j/k", "select")), k.enter, k.cancel}
@@ -73,14 +75,17 @@ func (k keyMap) ShortHelp() []key.Binding {
return []key.Binding{k.enter, k.cancel}
}
if k.templates {
return []key.Binding{key.NewBinding(key.WithKeys("s", "enter"), key.WithHelp("s/Enter", "submit")), key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "customize")), key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "template")), key.NewBinding(key.WithKeys("v"), key.WithHelp("v", "render/source")), k.cancel}
return []key.Binding{key.NewBinding(key.WithKeys("s", "enter"), key.WithHelp("s/Enter", "create pipeline")), key.NewBinding(key.WithKeys("tab"), key.WithHelp("Tab", "pane")), key.NewBinding(key.WithKeys("e"), key.WithHelp("e", "customize")), key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "template")), k.cancel}
}
if k.runs {
bindings := []key.Binding{k.commands, key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "next/prev stage")), key.NewBinding(key.WithKeys("g"), key.WithHelp("g", "graph")), key.NewBinding(key.WithKeys("D"), key.WithHelp("D", "debug")), key.NewBinding(key.WithKeys("P"), key.WithHelp("P", "pipeline"))}
if k.retryAvailable {
bindings = append(bindings, key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "retry failed")))
if !k.runInspect {
return []key.Binding{k.commands, k.search, key.NewBinding(key.WithKeys("j", "k"), key.WithHelp("j/k", "select")), k.enter, key.NewBinding(key.WithKeys("esc"), key.WithHelp("Esc", "back"))}
}
return append(bindings, key.NewBinding(key.WithKeys("tab"), key.WithHelp("Tab", "pane")), key.NewBinding(key.WithKeys("j", "k"), key.WithHelp("j/k", "select/scroll")), key.NewBinding(key.WithKeys("esc"), key.WithHelp("Esc", "back")))
target, keys, action := "graph", "j/k", "scroll"
if k.runGraph {
target, keys, action = "details", "h/j/k/l", "pan"
}
return []key.Binding{k.commands, key.NewBinding(key.WithKeys("tab"), key.WithHelp("Tab", target)), key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "stage")), key.NewBinding(key.WithKeys(keys), key.WithHelp(keys, action)), key.NewBinding(key.WithKeys("esc"), key.WithHelp("Esc", "back"))}
}
if k.detail {
return []key.Binding{k.commands, k.search, key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "next/prev stage")), key.NewBinding(key.WithKeys("tab"), key.WithHelp("Tab", "pane")), key.NewBinding(key.WithKeys("r"), key.WithHelp("r", "runs")), key.NewBinding(key.WithKeys("j", "k"), key.WithHelp("j/k", "scroll")), key.NewBinding(key.WithKeys("esc"), key.WithHelp("esc", "home"))}
@@ -90,101 +95,108 @@ func (k keyMap) ShortHelp() []key.Binding {
func (k keyMap) FullHelp() [][]key.Binding { return [][]key.Binding{k.ShortHelp()} }
type Model struct {
editorCheckGeneration uint64
editorChecking bool
statusOpen bool
statusTop int
statusRequest, statusError string
systemStatus *protocol.SystemStatus
usage *protocol.UsageStats
draftOpen bool
draftItems []draft.Draft
draftIndex, draftTop int
draftError, draftSource string
ctx context.Context
url string
conn *websocket.Conn
status string
nextID uint64
lines []string
width int
height int
help help.Model
keys keyMap
pipelines []protocol.PipelineSummary
loaded bool
notificationEndpoints []protocol.NotificationEndpoint
logSeen []bool
unread int
logOpen bool
logTop int
paletteOpen bool
commandInput textinput.Model
commandIndex int
homeTop int
searchOpen bool
detail *protocol.PipelineDetail
detailRequest string
detailLoading bool
detailError string
pipelineTop int
graphPan int
versionsOpen bool
versionIndex int
confirmOpen bool
actionConfirm *protocol.Message
actionApproved bool
defaultModel string
mutationTitle string
mutationCommand func() tea.Cmd
pendingDraft *editedMsg
draftNameInput textinput.Model
submitID string
submitNotice string
stageIndex int
stageTop int
stageFocus bool
reconnecting bool
requestedPipelineID int64
requestedVersion int
runs []protocol.RunSummary
runDetail *protocol.RunDetail
runOpen bool
runForm int
runInput textinput.Model
runPrompt textarea.Model
runWorkspace string
cliRun, cliStarted, runPicker bool
cliOptions RunOptions
runPickerIndex int
runPickerInput textinput.Model
runTask string
runPaths []string
runIndex, runTop int
requestedRunID int64
runStartRequest string
runStepIndex int
runDetailFocus bool
runCollapsed map[string]bool
runError string
runPipelineID int64
runFailedOnly bool
runSearch textinput.Model
runSearchOpen bool
runGraphFocus bool
runGraphTop int
runGraphPan int
editorOpen bool
editorInput textinput.Model
editorIndex int
editorDraft *editedMsg
draftDeletingPath string
runSpinner spinner.Model
templates []protocol.Template
templateOpen, templateRaw bool
templateIndex, templateTop int
templateLines []string
templateRequest, templateError string
editorCheckGeneration uint64
editorChecking bool
statusOpen bool
statusTop int
statusRequest, statusError string
systemStatus *protocol.SystemStatus
usage *protocol.UsageStats
draftOpen bool
draftItems []draft.Draft
draftIndex, draftTop int
draftError, draftSource string
ctx context.Context
url string
conn *websocket.Conn
status string
nextID uint64
lines []string
width int
height int
help help.Model
keys keyMap
pipelines []protocol.PipelineSummary
loaded bool
notificationEndpoints []protocol.NotificationEndpoint
logSeen []bool
unread int
logOpen bool
logTop int
logPan int
paletteOpen bool
commandInput textinput.Model
commandIndex int
homeTop int
searchOpen bool
detail *protocol.PipelineDetail
detailRequest string
detailLoading bool
detailError string
pipelineTop int
graphPan int
versionsOpen bool
versionIndex int
confirmOpen bool
actionConfirm *protocol.Message
actionConfirmTop int
actionApproved bool
defaultModel string
mutationTitle string
mutationCommand func() tea.Cmd
mutationTop int
pendingDraft *editedMsg
draftNameInput textinput.Model
submitID string
submitNotice string
stageIndex int
stageTop int
stageFocus bool
stageConfigExpanded bool
reconnecting bool
requestedPipelineID int64
requestedVersion int
runs []protocol.RunSummary
runDetail *protocol.RunDetail
runOpen bool
runForm int
runInput textinput.Model
runPrompt textarea.Model
runWorkspace string
cliRun, cliStarted, runPicker bool
cliOptions RunOptions
runPickerIndex int
runPickerInput textinput.Model
runTask string
runPaths []string
runIndex, runTop int
requestedRunID int64
runStartRequest string
runStepIndex int
runDetailFocus bool
runCollapsed map[string]bool
runError string
runPipelineID int64
runFailedOnly bool
runSearch textinput.Model
runSearchOpen bool
runGraphFocus bool
runGraphTop int
runGraphPan int
editorOpen bool
editorInput textinput.Model
editorIndex int
editorDraft *editedMsg
draftDeletingPath string
draftDeletingTop int
runSpinner spinner.Model
templates []protocol.Template
templateOpen, templateRaw bool
templateGraphFocus, templateConfirm bool
templateGraphTop, templateGraphPan int
templateIndex, templateTop int
templateLines []string
templateRequest, templateError string
}
func New(ctx context.Context, url string) Model {
@@ -268,12 +280,15 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.help.Width = m.width
if m.runForm == 1 {
m.runPrompt.SetWidth(max(1, min(96, m.width-12)))
m.runPrompt.SetHeight(max(1, min(10, m.height-14)))
m.runPrompt.SetHeight(max(1, min(14, m.height-10)))
}
if m.templateOpen {
oldTop := m.templateTop
graphTop, graphPan := m.templateGraphTop, m.templateGraphPan
m.renderTemplate()
m.templateTop = oldTop
m.templateGraphTop, m.templateGraphPan = graphTop, graphPan
m = m.clampTemplateGraph()
}
if m.keys.detail {
m.clampPipelineScroll()
@@ -377,11 +392,16 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
}
}
} else if msg.Type == protocol.Submitted {
m.templateConfirm = false
m.draftOpen = false
m.keys.drafts = false
m.templateOpen = false
m.keys.templates = false
m.appendLine(fmt.Sprintf("Submitted %s: version %d", msg.Name, msg.Version))
verb := "Updated"
if msg.Version == 1 {
verb = "Created"
}
m.appendLine(fmt.Sprintf("%s pipeline %s: version %d", verb, msg.Name, msg.Version))
m.pipelines = msg.Pipelines
m.loaded = true
if msg.ID == m.submitID {
@@ -389,7 +409,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.pendingDraft = nil
m.confirmOpen = false
m.keys.confirm = false
m.submitNotice = fmt.Sprintf("Submitted version %d", msg.Version)
m.submitNotice = fmt.Sprintf("%s pipeline · version %d", verb, msg.Version)
}
if msg.Detail != nil {
m.detail = msg.Detail
@@ -444,6 +464,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
return m, nil
case sentMsg:
// Responses are displayed by the independent read loop.
case transferFinishedMsg:
m.transferResult(msg)
if msg.imported && m.conn != nil {
return m, m.send(protocol.Message{Type: protocol.List})
}
return m, nil
case editedMsg:
m.appendLine("Draft: " + msg.path)
if msg.err != nil {
@@ -462,7 +488,7 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.confirmOpen = false
m.keys.confirm = false
m.submitNotice = "No changes."
m.appendLine("No changes; nothing to submit.")
m.appendLine("No changes; nothing to update.")
return m, nil
}
// Editor completion is never approval to publish, for either new or existing drafts.
@@ -516,6 +542,12 @@ func (m Model) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
m.mutationCommand = nil
m.mutationTitle = ""
}
if msg.String() == "j" || msg.String() == "down" || msg.String() == "pgdown" {
m.mutationTop++
}
if msg.String() == "k" || msg.String() == "up" || msg.String() == "pgup" {
m.mutationTop = max(0, m.mutationTop-1)
}
return m, nil
}
if m.editorChecking {
@@ -657,17 +689,6 @@ func (m Model) View() string {
if m.conn == nil {
connection = m.loading(connection)
}
if len(m.notificationEndpoints) > 0 {
endpoint := m.notificationEndpoints[0]
address := endpoint.ServerURL
if address == "" {
address = "not configured"
}
connection += " · ntfy " + address + " · topic " + endpoint.Topic
if m.width < 100 {
connection = "Connected · ntfy " + address + "/" + endpoint.Topic
}
}
status := ansi.Truncate(connection, max(0, m.width-min(24, m.width/4)), "…")
title := ""
if titleWidth := m.width - lipgloss.Width(status) - 1; titleWidth > 0 {
@@ -693,6 +714,9 @@ func (m Model) View() string {
if m.draftOpen {
name = "Drafts"
}
if m.statusOpen {
name = "Status"
}
title = ansi.Truncate(name, titleWidth, "…")
}
gap := max(0, m.width-lipgloss.Width(title)-lipgloss.Width(status))
@@ -705,6 +729,7 @@ func (m Model) View() string {
}
bodyHeight := max(0, m.height-lipgloss.Height(header)-lipgloss.Height(footer))
lines := m.homeLines()
homeLength := len(lines)
top := m.homeTop
top = min(top, max(0, len(lines)-bodyHeight))
lines = lines[top:min(len(lines), top+bodyHeight)]
@@ -712,6 +737,9 @@ func (m Model) View() string {
for i, line := range lines {
body[i] = ansi.Truncate(line, m.width, "…")
}
if m.homePage() && len(body) > 0 && top+bodyHeight < homeLength {
body[len(body)-1] = bar("↓ More below", fmt.Sprintf("%d–%d / %d", top+1, top+bodyHeight, homeLength), m.width, false)
}
parts := []string{header}
if bodyHeight > 0 {
content := strings.Join(body, "\n")
@@ -752,7 +780,11 @@ func (m Model) View() string {
content = m.actionConfirmView(bodyHeight)
}
if m.mutationCommand != nil {
content = popup(m.width, bodyHeight, 76, []string{m.mutationTitle, "This opens a new session/editor and may modify a retained draft.", "Published definitions and previous run history are unchanged.", "y confirm · n / Esc cancel"})
paragraphs := []string{"This opens a new session/editor and may modify a retained draft.", "Published definitions and previous run history are unchanged."}
if strings.Contains(m.mutationTitle, "debugging") {
paragraphs = []string{"Opens OpenCode with the pinned definition and retained failure evidence.", "Debugging may propose or edit a retained draft. It does not retry the run or change published history."}
}
content = wrappedDialog(m.width, bodyHeight, 76, m.mutationTitle, paragraphs, "y confirm · n / Esc cancel", m.mutationTop)
}
if m.editorChecking {
content = popup(m.width, bodyHeight, 76, []string{"Checking published edits", m.loading("Refreshing pipeline information…"), "Local draft remains retained."})