web: run pipelines from the browser and quiet background chat

Add the Run pipeline dialog with prompt, server directory and a per-run
notification choice; add --notify auto/on/off to run and retry; move the live
tool call onto the tool-count line and tick the reasoning duration; stop chat
frames from repainting a different screen.
This commit is contained in:
2026-10-20 12:56:47 +01:00
parent f7a3a49f94
commit 0d7e81362f
17 changed files with 428 additions and 80 deletions
+22 -4
View File
@@ -37,7 +37,7 @@ type options struct {
harness string
url, name, prompt, title, template, workspace, paths, key, opencode, model string
retryMode, retryStage, retryInputFile string
option, feedback, evidence, actor string
option, feedback, evidence, actor, notifyMode string
output string
conflict string
kind string
@@ -146,6 +146,7 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
f.StringVar(&o.key, "request-key", "", "Idempotency key (default: generated unique key)")
f.IntVar(&o.version, "version", 0, "Version to run (default: latest)")
f.StringVar(&o.model, "model", "", "Override the model for every stage of this run (PROVIDER/MODEL)")
f.StringVar(&o.notifyMode, "notify", "auto", "Notifications for this run: auto (pipeline), on, or off")
o.stageModels = stageModelFlags{}
f.Var(o.stageModels, "stage-model", "Override one stage's model; repeatable (STAGE=PROVIDER/MODEL); beats --model")
f.BoolVar(&o.wait, "wait", false, "In JSON mode, wait for a terminal run state")
@@ -165,6 +166,7 @@ func (a App) flags(command string) (*flag.FlagSet, *options) {
f.IntVar(&o.retryVisit, "visit", 0, "1-based occurrence of --stage in the recorded execution")
f.IntVar(&o.version, "version", 0, "Explicit published version of the same pipeline (default: source version)")
f.StringVar(&o.retryInputFile, "input-file", "", "JSON object merged into the selected stage input; '-' reads stdin")
f.StringVar(&o.notifyMode, "notify", "auto", "Notifications for this retry: auto, on, or off")
case "cancel", "draft-delete":
f.BoolVar(&o.yes, "yes", false, "Confirm this action without an interactive prompt")
case "retention":
@@ -930,6 +932,14 @@ func (a App) Run(ctx context.Context, args []string) error {
if o.retryMode != "resume" && o.retryMode != "restart" {
return fmt.Errorf("--mode must be resume or restart")
}
switch strings.ToLower(strings.TrimSpace(o.notifyMode)) {
case "", "auto":
o.notifyMode = "auto"
case "on", "off":
o.notifyMode = strings.ToLower(strings.TrimSpace(o.notifyMode))
default:
return fmt.Errorf("--notify must be auto, on or off")
}
if key == "" {
key = fmt.Sprintf("retry-%d-%d", os.Getpid(), time.Now().UnixNano())
}
@@ -966,7 +976,7 @@ func (a App) Run(ctx context.Context, args []string) error {
if o.retryVisit < 0 {
return fmt.Errorf("--visit must be positive")
}
r, err := call(protocol.Message{Type: typeName, RunID: id, RequestKey: key, RetryMode: o.retryMode, RetryStage: o.retryStage, RetryVisit: o.retryVisit, RetryVersion: o.version, RetryInput: retryInput})
r, err := call(protocol.Message{Type: typeName, RunID: id, RequestKey: key, RetryMode: o.retryMode, RetryStage: o.retryStage, RetryVisit: o.retryVisit, RetryVersion: o.version, RetryInput: retryInput, NotifyMode: o.notifyMode})
if err != nil {
return err
}
@@ -1277,6 +1287,14 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
return err
}
}
switch strings.ToLower(strings.TrimSpace(o.notifyMode)) {
case "", "auto":
o.notifyMode = "auto"
case "on", "off":
o.notifyMode = strings.ToLower(strings.TrimSpace(o.notifyMode))
default:
return fmt.Errorf("--notify must be auto, on or off")
}
if o.yes && (o.name == "" || strings.TrimSpace(o.prompt) == "") {
return fmt.Errorf("--yes requires a pipeline and nonempty prompt")
}
@@ -1291,7 +1309,7 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
if o.wait || o.key != "" || o.version > 0 {
return fmt.Errorf("--wait, --request-key and --version require --json")
}
_, err := tea.NewProgram(tui.NewRun(ctx, o.url, tui.RunOptions{Pipeline: o.name, Prompt: o.prompt, Title: o.title, Workspace: workspace, Yes: o.yes, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels}), tea.WithContext(ctx), tea.WithAltScreen()).Run()
_, err := tea.NewProgram(tui.NewRun(ctx, o.url, tui.RunOptions{Pipeline: o.name, Prompt: o.prompt, Title: o.title, Workspace: workspace, Yes: o.yes, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels, NotifyMode: o.notifyMode}), tea.WithContext(ctx), tea.WithAltScreen()).Run()
return err
}
if o.name == "" || strings.TrimSpace(o.prompt) == "" {
@@ -1313,7 +1331,7 @@ func (a App) run(ctx context.Context, pos []string, o *options, call callFunc, r
if key == "" {
key = fmt.Sprintf("cli-%d-%d", os.Getpid(), time.Now().UnixNano())
}
r, err := call(protocol.Message{Type: protocol.RunPipeline, PipelineID: p.ID, Version: version, RequestKey: key, Workspace: workspace, Title: o.title, Input: map[string]any{"prompt": o.prompt}, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels})
r, err := call(protocol.Message{Type: protocol.RunPipeline, PipelineID: p.ID, Version: version, RequestKey: key, Workspace: workspace, Title: o.title, Input: map[string]any{"prompt": o.prompt}, AllowTools: o.allow, WritePaths: paths, Model: o.model, StageModels: o.stageModels, NotifyMode: o.notifyMode})
if err != nil {
return err
}