Replace niche templates with simple starters and direct template submission
This commit is contained in:
@@ -90,7 +90,8 @@ are not approved. Warn explicitly before adding/changing schedules.
|
||||
Stage hooks use the global phone connection, never store credentials. Optional
|
||||
fenced `notify` block: `on=success,failure`, `artifacts=markdown`.
|
||||
The legacy destination field does not select a per-stage phone. For a native
|
||||
publisher, inspect the `anime-today` template's ntfy stage: `type=ntfy`,
|
||||
`destination=system`; its type-specific blocks differ from model stages.
|
||||
publisher, use `type=ntfy` and `destination=system`; its type-specific blocks
|
||||
differ from model stages. See the project's `docs/ntfy.md` for native publisher
|
||||
configuration and output fields. Bundled starters are generic and manual-only.
|
||||
Notification attachment/report support and model availability need real runtime
|
||||
tests; structural validation alone cannot confirm delivery.
|
||||
|
||||
@@ -91,7 +91,7 @@ func TestCLIStatusAndStatistics(t *testing.T) {
|
||||
|
||||
func TestCLIDraftValidateSubmitAndImmutableHistory(t *testing.T) {
|
||||
run, store, _ := setup(t)
|
||||
output, err := run("new", "example", "--template", "bug-fix", "--json")
|
||||
output, err := run("new", "example", "--template", "task", "--json")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -166,7 +166,7 @@ func TestCLIDraftValidateSubmitAndImmutableHistory(t *testing.T) {
|
||||
if items[0].Version != 3 {
|
||||
t.Fatal("invalid submission changed live version", items)
|
||||
}
|
||||
for _, command := range [][]string{{"list", "--json"}, {"show", "example", "--json"}, {"templates", "--json"}, {"template", "bug-fix", "--source"}, {"drafts", "--json"}, {"runs", "--json"}, {"connection", "--json"}, {"ping"}} {
|
||||
for _, command := range [][]string{{"list", "--json"}, {"show", "example", "--json"}, {"templates", "--json"}, {"template", "task", "--source"}, {"drafts", "--json"}, {"runs", "--json"}, {"connection", "--json"}, {"ping"}} {
|
||||
if _, err = run(command...); err != nil {
|
||||
t.Fatal(command, err)
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ Use pipelines help <command> for its flags. Names with spaces must be quoted.
|
||||
Examples:
|
||||
pipelines edit "bug fix" "Add a review step"
|
||||
pipelines new "release notes" "Summarize changes and notify my phone"
|
||||
pipelines new "weekly digest" --template scheduled-summary --no-open --json --yes
|
||||
pipelines new "Text summary" --template summary --no-open --json --yes
|
||||
pipelines validate /path/to/draft.md --json
|
||||
pipelines submit /path/to/draft.md
|
||||
pipelines run "bug fix" "Fix the layout" --json
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
)
|
||||
|
||||
func TestShowcaseDefinitions(t *testing.T) {
|
||||
for _, name := range []string{"bug-fix", "new-feature", "dashboard-screenshots", "dependency-upgrade", "incident-diagnosis", "scheduled-summary", "scheduled-web-research", "anime-digest", "notification-test", "anime-today"} {
|
||||
for _, name := range []string{"task", "summary", "review", "research", "three-stage"} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
source, err := os.ReadFile(filepath.Join("..", "..", "examples", name+".md"))
|
||||
if err != nil {
|
||||
@@ -19,12 +19,11 @@ func TestShowcaseDefinitions(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
success, failure, fork := false, false, false
|
||||
success, failure := false, false
|
||||
for _, stage := range graph.Stages {
|
||||
if stage.FallbackError {
|
||||
t.Fatalf("%s should declare its error route explicitly", stage.Key)
|
||||
}
|
||||
targets := map[string]bool{}
|
||||
for _, target := range stage.Edges {
|
||||
if target == protocol.SuccessEnd {
|
||||
success = true
|
||||
@@ -32,20 +31,11 @@ func TestShowcaseDefinitions(t *testing.T) {
|
||||
if target == protocol.FailureEnd {
|
||||
failure = true
|
||||
}
|
||||
if !protocol.IsTerminal(target) {
|
||||
targets[target] = true
|
||||
}
|
||||
}
|
||||
if len(targets) > 1 {
|
||||
fork = true
|
||||
}
|
||||
}
|
||||
if !success || !failure {
|
||||
t.Fatal("showcase must have both terminal outcomes")
|
||||
}
|
||||
if name == "new-feature" && !fork {
|
||||
t.Fatal("feature showcase must contain an exclusive route fork")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestNestedForkShowcaseIsForwardOnly(t *testing.T) {
|
||||
source, err := os.ReadFile("../../examples/nested-forks.md")
|
||||
source, err := os.ReadFile("testdata/nested-forks.md")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
# stage intake
|
||||
|
||||
```output
|
||||
{ request, audience, route_history: ["intake"] }
|
||||
Preserve the user's original request verbatim.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Read the user's runtime prompt and identify the intended audience. Preserve the
|
||||
request verbatim and initialize route_history with intake. This is a text-only
|
||||
explanation workflow: do not edit files, run commands, or claim unobserved facts.
|
||||
Return success with the request and audience, or error if the request is empty.
|
||||
```
|
||||
|
||||
```edges
|
||||
success -> format_router
|
||||
error -> #failure
|
||||
```
|
||||
|
||||
```configs
|
||||
type=model
|
||||
provider=opencode-go
|
||||
model=deepseek-v4.1-flash
|
||||
retries=0
|
||||
```
|
||||
|
||||
# stage format_router
|
||||
|
||||
```output
|
||||
{ request, audience, format: "brief" | "detailed", route_history }
|
||||
Append format_router to route_history and preserve the original request.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Choose exactly one format. If the request explicitly asks for a detailed,
|
||||
in-depth, step-by-step, walkthrough, tutorial, or reference explanation, choose
|
||||
detailed. Otherwise choose brief. Append format_router to route_history.
|
||||
Return brief or detailed to select one branch, not both; never send work backward.
|
||||
```
|
||||
|
||||
```edges
|
||||
brief -> brief_answer
|
||||
detailed -> detail_router
|
||||
error -> #failure
|
||||
```
|
||||
|
||||
```configs
|
||||
type=model
|
||||
provider=opencode-go
|
||||
model=deepseek-v4.1-flash
|
||||
retries=0
|
||||
```
|
||||
|
||||
# stage brief_answer
|
||||
|
||||
```output
|
||||
{ request, audience, format, content, route_history }
|
||||
content is a concise answer of no more than five sentences.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Write a concise answer to the request for the specified audience, no more than
|
||||
five sentences. Preserve all handoff fields and append brief_answer to
|
||||
route_history. Be honest about uncertainty; do not invent execution evidence.
|
||||
Return success to proceed directly to delivery, skipping the detailed branch.
|
||||
```
|
||||
|
||||
```edges
|
||||
success -> delivery
|
||||
error -> #failure
|
||||
```
|
||||
|
||||
```configs
|
||||
type=model
|
||||
provider=opencode-go
|
||||
model=deepseek-v4.1-flash
|
||||
retries=0
|
||||
```
|
||||
|
||||
# stage detail_router
|
||||
|
||||
```output
|
||||
{ request, audience, format, detail_kind: "walkthrough" | "reference", route_history }
|
||||
Preserve previous handoff fields and append detail_router to route_history.
|
||||
```
|
||||
|
||||
```prompt
|
||||
This is the second fork, reached only through the detailed branch. Choose
|
||||
walkthrough for a how-to, tutorial, or step-by-step request. Choose reference for
|
||||
definitions, comparisons, a conceptual explanation, or an explicit reference
|
||||
request. If ambiguous, choose reference. Select exactly one outcome and append
|
||||
detail_router to route_history. Do not return to the first router or brief branch.
|
||||
```
|
||||
|
||||
```edges
|
||||
walkthrough -> walkthrough
|
||||
reference -> reference
|
||||
error -> #failure
|
||||
```
|
||||
|
||||
```configs
|
||||
type=model
|
||||
provider=opencode-go
|
||||
model=deepseek-v4.1-flash
|
||||
retries=0
|
||||
```
|
||||
|
||||
# stage walkthrough
|
||||
|
||||
```output
|
||||
{ request, audience, format, detail_kind, content, route_history }
|
||||
content contains an ordered explanation with steps and a clearly labeled example.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Write an ordered walkthrough answering the original request. Adapt the level to
|
||||
the audience, explain each step, and include a clearly labeled illustrative
|
||||
example. Instructions are not evidence that commands or actions were executed.
|
||||
Preserve all handoff fields and append walkthrough to route_history. Return
|
||||
success to proceed to delivery, without entering the reference branch.
|
||||
```
|
||||
|
||||
```edges
|
||||
success -> delivery
|
||||
error -> #failure
|
||||
```
|
||||
|
||||
```configs
|
||||
type=model
|
||||
provider=opencode-go
|
||||
model=deepseek-v4.1-flash
|
||||
retries=0
|
||||
```
|
||||
|
||||
# stage reference
|
||||
|
||||
```output
|
||||
{ request, audience, format, detail_kind, content, route_history }
|
||||
content contains definitions, key distinctions, and a clearly labeled example.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Write a structured reference answer to the original request, using definitions,
|
||||
key distinctions, and a clearly labeled illustrative example. Adapt it to the
|
||||
audience and state uncertainty rather than inventing sources or observations.
|
||||
Preserve all handoff fields and append reference to route_history. Return success
|
||||
to proceed to delivery, without entering the walkthrough branch.
|
||||
```
|
||||
|
||||
```edges
|
||||
success -> delivery
|
||||
error -> #failure
|
||||
```
|
||||
|
||||
```configs
|
||||
type=model
|
||||
provider=opencode-go
|
||||
model=deepseek-v4.1-flash
|
||||
retries=0
|
||||
```
|
||||
|
||||
# stage delivery
|
||||
|
||||
```output
|
||||
{ answer, selected_format, selected_detail_kind?, route_history }
|
||||
answer contains the selected branch's content; route_history includes delivery.
|
||||
```
|
||||
|
||||
```prompt
|
||||
Deliver the preceding stage's content without doing another rewrite or routing
|
||||
decision. Append delivery to route_history. Return success with answer,
|
||||
selected_format, selected_detail_kind when present, and the exact traversed path.
|
||||
If content is missing, return error. Do not claim that unused branches executed.
|
||||
```
|
||||
|
||||
```edges
|
||||
success -> #success
|
||||
error -> #failure
|
||||
```
|
||||
|
||||
```configs
|
||||
type=model
|
||||
provider=opencode-go
|
||||
model=deepseek-v4.1-flash
|
||||
retries=0
|
||||
```
|
||||
@@ -44,7 +44,7 @@ func TestTemplatesDoNotSeedDatabaseAndCreateOnlyPreservesExisting(t *testing.T)
|
||||
if err := wsjson.Read(ctx, conn, &response); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if response.Type != protocol.Templates || len(response.Templates) != 11 {
|
||||
if response.Type != protocol.Templates || len(response.Templates) != 5 {
|
||||
t.Fatal("missing catalog", response.Type, len(response.Templates))
|
||||
}
|
||||
items, err := store.List(ctx)
|
||||
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
func TestShowcaseGraphsRender(t *testing.T) {
|
||||
for _, name := range []string{"bug-fix", "new-feature", "dashboard-screenshots", "dependency-upgrade", "incident-diagnosis"} {
|
||||
for _, name := range []string{"task", "summary", "review", "research", "three-stage"} {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
source, err := os.ReadFile(filepath.Join("..", "..", "examples", name+".md"))
|
||||
if err != nil {
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func nestedForkGraph(t *testing.T) protocol.Graph {
|
||||
t.Helper()
|
||||
source, err := os.ReadFile("../../examples/nested-forks.md")
|
||||
source, err := os.ReadFile("../pipeline/testdata/nested-forks.md")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ func (k keyMap) ShortHelp() []key.Binding {
|
||||
return []key.Binding{k.enter, k.cancel}
|
||||
}
|
||||
if k.templates {
|
||||
return []key.Binding{key.NewBinding(key.WithKeys("n", "p"), key.WithHelp("n/p", "template")), key.NewBinding(key.WithKeys("v"), key.WithHelp("v", "render/source")), key.NewBinding(key.WithKeys("enter"), key.WithHelp("Enter", "use template")), k.cancel}
|
||||
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}
|
||||
}
|
||||
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"))}
|
||||
|
||||
@@ -301,7 +301,14 @@ func (m Model) updateConfirm(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
m.submitNotice = "Name must be 1–200 bytes without line breaks or NUL."
|
||||
return m, nil
|
||||
}
|
||||
if m.pendingDraft.path != "" {
|
||||
if m.pendingDraft.path == "" {
|
||||
d, err := draft.Create(name, m.pendingDraft.source, m.url, m.pendingDraft.createOnly, m.pendingDraft.baseVersion)
|
||||
if err != nil {
|
||||
m.submitNotice = "Could not retain draft: " + err.Error()
|
||||
return m, nil
|
||||
}
|
||||
m.pendingDraft.path = d.Path
|
||||
} else {
|
||||
if err := draft.SetName(m.pendingDraft.path, name); err != nil {
|
||||
m.submitNotice = "Could not save draft name: " + err.Error()
|
||||
return m, nil
|
||||
@@ -352,7 +359,11 @@ func (m Model) confirmView(height int) string {
|
||||
field.Focus()
|
||||
}
|
||||
field.Width = max(1, min(60, m.width-12))
|
||||
return popup(m.width, height, 76, []string{"Name this pipeline", "", field.View(), m.submitNotice, "Enter save name and review · Esc keep draft"})
|
||||
hint := "Enter save name and review · Esc keep draft"
|
||||
if m.pendingDraft.path == "" {
|
||||
hint = "Enter save draft and review · Esc back"
|
||||
}
|
||||
return popup(m.width, height, 76, []string{"Name this pipeline", "", field.View(), m.submitNotice, hint})
|
||||
}
|
||||
lines := []string{"Submit edited pipeline", m.pendingDraft.name, "", "Creates a new immutable version.", "s submit · e edit again · Esc keep draft"}
|
||||
if m.pendingDraft.createOnly {
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
package tui
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http/httptest"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"git.a-wan.net/alan/pipelines/examples"
|
||||
"git.a-wan.net/alan/pipelines/internal/draft"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/server"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
)
|
||||
|
||||
func TestTemplateSubmitNamesRetainsAndExplicitlyPublishesSelectedTemplate(t *testing.T) {
|
||||
t.Setenv("PIPELINES_DRAFT_DIR", t.TempDir())
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
store, err := pipeline.Open(filepath.Join(t.TempDir(), "templates.db"))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer store.Close()
|
||||
srv := httptest.NewServer(server.Handler(ctx, store))
|
||||
defer srv.Close()
|
||||
url := "ws" + strings.TrimPrefix(srv.URL, "http") + "/connect"
|
||||
m := New(ctx, url)
|
||||
connected := m.connect()().(connectedMsg)
|
||||
defer connected.conn.CloseNow()
|
||||
updated, read := m.Update(connected)
|
||||
m = updated.(Model)
|
||||
updated, _ = m.Update(read())
|
||||
m = updated.(Model)
|
||||
m.templates = examples.Catalog()
|
||||
m.templateOpen, m.keys.templates = true, true
|
||||
m.defaultModel = "fixture/model"
|
||||
for i, item := range m.templates {
|
||||
if item.Key == "summary" {
|
||||
m.templateIndex = i
|
||||
}
|
||||
}
|
||||
m.renderTemplate()
|
||||
if !strings.Contains(m.templatesView(30), "Submit template") {
|
||||
t.Fatal("missing visible submit button")
|
||||
}
|
||||
stale, err := draft.Create("unrelated", "unrelated draft source", url, true, 0)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
m.pendingDraft = &editedMsg{name: stale.Name, source: "unrelated draft source", path: stale.Path, createOnly: true}
|
||||
updated, cmd := m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'s'}})
|
||||
m = updated.(Model)
|
||||
if cmd != nil || !m.confirmOpen || m.editorOpen || m.pendingDraft.name != "" || m.pendingDraft.path != "" || !m.pendingDraft.createOnly {
|
||||
t.Fatal("Submit button did not open naming flow without launching an editor", m.pendingDraft)
|
||||
}
|
||||
expected := pipeline.WithDefaultModel(m.templates[m.templateIndex].Source, m.defaultModel)
|
||||
if m.pendingDraft.source != expected {
|
||||
t.Fatal("selected template/model lost; unrelated draft reused")
|
||||
}
|
||||
updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyEsc})
|
||||
m = updated.(Model)
|
||||
drafts, _ := draft.List()
|
||||
if len(drafts) != 1 || !m.templateOpen || m.confirmOpen {
|
||||
t.Fatal("canceling template naming created a draft or left gallery")
|
||||
}
|
||||
updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyEnter})
|
||||
m = updated.(Model)
|
||||
updated, _ = m.Update(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune("Simple summary")})
|
||||
m = updated.(Model)
|
||||
updated, cmd = m.Update(tea.KeyMsg{Type: tea.KeyEnter})
|
||||
m = updated.(Model)
|
||||
items, _ := store.List(ctx)
|
||||
if cmd != nil || len(items) != 0 || !m.confirmOpen || m.pendingDraft.path == "" {
|
||||
t.Fatal("naming published before confirmation or failed to retain draft")
|
||||
}
|
||||
retained, err := draft.Load(m.pendingDraft.path)
|
||||
if err != nil || retained.Name != "Simple summary" || retained.Server != url || !retained.CreateOnly || retained.BaseVersion != 0 {
|
||||
t.Fatal("template draft metadata lost", retained, err)
|
||||
}
|
||||
text, err := draft.Read(retained.Path)
|
||||
if err != nil || text != expected {
|
||||
t.Fatal("template draft source lost", err)
|
||||
}
|
||||
updated, cmd = m.Update(tea.KeyMsg{Type: tea.KeyEnter})
|
||||
m = updated.(Model)
|
||||
if cmd == nil {
|
||||
t.Fatal("publication confirmation did not send")
|
||||
}
|
||||
if _, ok := cmd().(sentMsg); !ok {
|
||||
t.Fatal("publication send failed")
|
||||
}
|
||||
updated, _ = m.Update(m.read()())
|
||||
m = updated.(Model)
|
||||
items, _ = store.List(ctx)
|
||||
if len(items) != 1 || items[0].Name != retained.Name || items[0].Version != 1 || m.confirmOpen {
|
||||
t.Fatal("template submission failed", items, m.submitNotice)
|
||||
}
|
||||
detail, err := store.Get(ctx, items[0].ID, 0)
|
||||
if err != nil || detail.Source != expected {
|
||||
t.Fatal("published wrong template", err)
|
||||
}
|
||||
text, err = draft.Read(stale.Path)
|
||||
if err != nil || text != "unrelated draft source" {
|
||||
t.Fatal("template submission damaged unrelated draft", err)
|
||||
}
|
||||
if _, err := draft.Load(retained.Path); err != nil {
|
||||
t.Fatal("publication deleted retained draft", err)
|
||||
}
|
||||
}
|
||||
+20
-20
@@ -2,7 +2,7 @@ package tui
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"git.a-wan.net/alan/pipelines/internal/draft"
|
||||
"git.a-wan.net/alan/pipelines/internal/pipeline"
|
||||
"git.a-wan.net/alan/pipelines/internal/protocol"
|
||||
tea "github.com/charmbracelet/bubbletea"
|
||||
"github.com/charmbracelet/glamour"
|
||||
@@ -33,7 +33,8 @@ func (m *Model) renderTemplate() {
|
||||
return
|
||||
}
|
||||
t := m.templates[m.templateIndex]
|
||||
source := ansi.Strip(t.Source)
|
||||
display := ansi.Strip(pipeline.WithDefaultModel(t.Source, m.defaultModel))
|
||||
source := display
|
||||
if !m.templateRaw {
|
||||
renderer, err := glamour.NewTermRenderer(glamour.WithStandardStyle("dark"), glamour.WithWordWrap(max(1, m.width-8)))
|
||||
if err == nil {
|
||||
@@ -41,7 +42,7 @@ func (m *Model) renderTemplate() {
|
||||
}
|
||||
if err != nil {
|
||||
m.templateError = "Markdown rendering failed; showing source."
|
||||
source = t.Source
|
||||
source = display
|
||||
}
|
||||
}
|
||||
m.templateLines = strings.Split(source, "\n")
|
||||
@@ -49,16 +50,19 @@ func (m *Model) renderTemplate() {
|
||||
|
||||
func (m Model) updateTemplates(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
switch msg.String() {
|
||||
case "s":
|
||||
if m.pendingDraft != nil {
|
||||
m.confirmOpen = true
|
||||
m.keys.confirm = true
|
||||
case "s", "enter":
|
||||
if len(m.templates) == 0 || m.submitID != "" {
|
||||
return m, nil
|
||||
}
|
||||
m.pendingDraft = &editedMsg{source: pipeline.WithDefaultModel(m.templates[m.templateIndex].Source, m.defaultModel), createOnly: true}
|
||||
m.confirmOpen = true
|
||||
m.keys.confirm = true
|
||||
m.submitNotice = ""
|
||||
m.draftNameInput = newInput()
|
||||
return m, nil
|
||||
case "e":
|
||||
if m.pendingDraft != nil {
|
||||
return m.confirmMutation("Edit retained draft?", func() tea.Cmd {
|
||||
return editDraftMode(m.pendingDraft.name, m.pendingDraft.source, true, m.pendingDraft.createOnly, draft.Draft{Server: m.url, BaseVersion: m.pendingDraft.baseVersion})
|
||||
})
|
||||
if len(m.templates) > 0 {
|
||||
return m.newPipeline(m.templates[m.templateIndex].Source)
|
||||
}
|
||||
case "esc":
|
||||
m.templateOpen = false
|
||||
@@ -89,12 +93,8 @@ func (m Model) updateTemplates(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
||||
m.templateTop = 0
|
||||
case "end":
|
||||
m.templateTop = len(m.templateLines)
|
||||
case "enter":
|
||||
if len(m.templates) > 0 {
|
||||
return m.newPipeline(m.templates[m.templateIndex].Source)
|
||||
}
|
||||
}
|
||||
m.templateTop = max(0, min(m.templateTop, max(0, len(m.templateLines)-max(1, m.height-10))))
|
||||
m.templateTop = max(0, min(m.templateTop, max(0, len(m.templateLines)-max(1, m.height-11))))
|
||||
return m, nil
|
||||
}
|
||||
|
||||
@@ -108,17 +108,17 @@ func (m Model) templatesView(height int) string {
|
||||
mode = "Markdown source"
|
||||
}
|
||||
title := fmt.Sprintf("Templates · %d/%d · %s", m.templateIndex+1, len(m.templates), t.Name)
|
||||
note := "Preview only · Enter creates an editable draft, not a submission."
|
||||
note := "Preview only · choose a name, then confirm publication."
|
||||
if t.Scheduled {
|
||||
note = "SCHEDULED: submission activates its schedule; edit/remove settings first."
|
||||
}
|
||||
rows := max(0, height-6)
|
||||
rows := max(0, height-7)
|
||||
top := max(0, min(m.templateTop, max(0, len(m.templateLines)-rows)))
|
||||
end := min(len(m.templateLines), top+rows)
|
||||
headers := []string{bar(title, mode, max(1, m.width-4), true), lipgloss.NewStyle().Foreground(themeMuted).Render(note), bar("", fmt.Sprintf("%d–%d / %d", min(top+1, len(m.templateLines)), end, len(m.templateLines)), max(1, m.width-4), false)}
|
||||
headers := []string{bar(title, mode, max(1, m.width-4), true), action("s Submit template", true) + " " + action("e Customize", false), lipgloss.NewStyle().Foreground(themeMuted).Render(note), bar("", fmt.Sprintf("%d–%d / %d", min(top+1, len(m.templateLines)), end, len(m.templateLines)), max(1, m.width-4), false)}
|
||||
body := m.templateLines[top:end]
|
||||
if m.templateError != "" {
|
||||
body = append([]string{m.templateError}, body...)
|
||||
}
|
||||
return panel(m.width, height, headers, body, "n/p template · v rendered/source · j/k scroll · Enter use · Esc back", true)
|
||||
return panel(m.width, height, headers, body, "s/Enter submit · e customize · n/p template · v source · j/k scroll · Esc back", true)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func TestTemplateMarkdownPreviewDraftAndKeyboardScope(t *testing.T) {
|
||||
t.Fatal("raw Markdown not available")
|
||||
}
|
||||
m = press(m, "v")
|
||||
updated, cmd := m.updateTemplates(tea.KeyMsg{Type: tea.KeyEnter})
|
||||
updated, cmd := m.updateTemplates(tea.KeyMsg{Type: tea.KeyRunes, Runes: []rune{'e'}})
|
||||
m = updated.(Model)
|
||||
if cmd == nil || !m.editorOpen || !m.editorDraft.createOnly || m.editorDraft.source != m.templates[m.templateIndex].Source {
|
||||
t.Fatal("template should offer an editor without losing the selected source")
|
||||
|
||||
@@ -21,7 +21,7 @@ func TestUIUXReviewSnapshots(t *testing.T) {
|
||||
if err := os.MkdirAll(directory, 0700); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
source, err := os.ReadFile("../../examples/anime-today.md")
|
||||
source, err := os.ReadFile("../../examples/three-stage.md")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func TestUIUXReviewSnapshots(t *testing.T) {
|
||||
m.loaded = true
|
||||
m.status = "127.0.0.1:8080"
|
||||
m.notificationEndpoints = []protocol.NotificationEndpoint{{Destination: "system", ServerURL: "http://100.85.25.33:8090", Topic: "pipelines"}}
|
||||
m.pipelines = []protocol.PipelineSummary{{ID: 8, Name: "anime episodes today", Version: 1, Stages: 4, CreatedAt: "2026-10-08T20:00:00Z", UpdatedAt: "2026-10-08T20:00:00Z"}}
|
||||
m.pipelines = []protocol.PipelineSummary{{ID: 8, Name: "Plan, implement, review", Version: 1, Stages: 3, CreatedAt: "2026-10-08T20:00:00Z", UpdatedAt: "2026-10-08T20:00:00Z"}}
|
||||
save := func(name string) {
|
||||
t.Helper()
|
||||
view := ansi.Strip(m.View())
|
||||
@@ -62,12 +62,12 @@ func TestUIUXReviewSnapshots(t *testing.T) {
|
||||
}
|
||||
save("scrolled-stage")
|
||||
m = press(m, "tab")
|
||||
m = press(m, "4")
|
||||
save("delivery-stage")
|
||||
m = press(m, "3")
|
||||
save("review-stage")
|
||||
m.runOpen = true
|
||||
m.keys.runs = true
|
||||
m.runDetail = &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 1, Name: "anime episodes today", PipelineID: 8, Version: 1, Status: "succeeded", CreatedAt: "2026-10-08T20:00:00Z", FinishedAt: "2026-10-08T20:01:00Z"}, Steps: []protocol.RunStep{{Sequence: 1, Stage: "discover", Status: "completed", Outcome: "success", Target: "verify"}, {Sequence: 2, Stage: "verify", Status: "completed", Outcome: "success", Target: "report"}, {Sequence: 3, Stage: "report", Status: "completed", Outcome: "success", Target: "notify", Output: map[string]any{"markdown": "# Anime episodes today\n\n[Source](https://www.livechart.me/schedule)"}}, {Sequence: 4, Stage: "notify", Status: "completed", Outcome: "success", Target: protocol.SuccessEnd, Output: map[string]any{"delivery": map[string]any{"attachment_url": "http://100.85.25.33:8090/file/report.md"}}}}}
|
||||
m.runStepIndex = 4
|
||||
m.runDetail = &protocol.RunDetail{RunSummary: protocol.RunSummary{ID: 1, Name: "Plan, implement, review", PipelineID: 8, Version: 1, Status: "succeeded", CreatedAt: "2026-10-08T20:00:00Z", FinishedAt: "2026-10-08T20:01:00Z"}, Graph: graph, Steps: []protocol.RunStep{{Sequence: 1, Stage: "planner", Status: "completed", Outcome: "success", Target: "implementer"}, {Sequence: 2, Stage: "implementer", Status: "completed", Outcome: "success", Target: "reviewer"}, {Sequence: 3, Stage: "reviewer", Status: "completed", Outcome: "success", Target: protocol.SuccessEnd, Output: map[string]any{"summary": "Fixture review report", "findings": "Fixture findings"}}}}
|
||||
m.runStepIndex = 3
|
||||
save("run")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user