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
+38 -1
View File
@@ -16,7 +16,7 @@ import (
)
func (r *runner) notifyStep(id int64, name, workspace string, policy *protocol.NotificationPolicy, step protocol.RunStep) {
if policy == nil {
if r.notifyMode(id) == "off" || policy == nil {
return
}
event := "success"
@@ -183,6 +183,40 @@ func (r *runner) attentionAlready(id int64, sequence int, event string) bool {
return r.attentionSent[id][fmt.Sprintf("%d:%s", sequence, event)]
}
func (r *runner) setNotifyMode(id int64, mode string) {
mode = strings.ToLower(strings.TrimSpace(mode))
if mode != "on" && mode != "off" {
mode = "auto"
}
r.notifyMu.Lock()
r.notifyModes[id] = mode
r.notifyMu.Unlock()
}
func (r *runner) notifyMode(id int64) string {
r.notifyMu.Lock()
mode := r.notifyModes[id]
r.notifyMu.Unlock()
if mode != "" {
return mode
}
if r.store != nil {
if stored, err := r.store.RunNotifyMode(r.ctx, id); err == nil && stored != "" {
r.notifyMu.Lock()
r.notifyModes[id] = stored
r.notifyMu.Unlock()
return stored
}
}
return "auto"
}
func (r *runner) forgetNotifyMode(id int64) {
r.notifyMu.Lock()
delete(r.notifyModes, id)
r.notifyMu.Unlock()
}
// forgetAttention drops a run's delivered-event set once it is terminal, so the
// registry is bounded by the runs still in flight.
func (r *runner) forgetAttention(id int64) {
@@ -206,6 +240,9 @@ func runAttentionClick(id int64) string {
// A run that needs nobody produces nothing, and a delivery failure is logged and
// never fails the run: this is a best-effort alert, not persisted run evidence.
func (r *runner) notifyRun(id int64, name, status string, sequence int, currentStage, diagnostic string) {
if r.notifyMode(id) == "off" {
return
}
event := runAttentionEvent(status)
if event == "" {
return
+13 -3
View File
@@ -70,6 +70,10 @@ type runner struct {
// default — so neither republishes the same genuine event.
attentionMu sync.Mutex
attentionSent map[int64]map[string]bool
// notifyMu guards notifyModes: the per-run auto/on/off override recorded at
// admission. It is separate from the stage's own notify policy.
notifyMu sync.Mutex
notifyModes map[int64]string
}
func newRunner(ctx context.Context, s *pipeline.Store) (*runner, error) {
@@ -97,7 +101,7 @@ func newRunner(ctx context.Context, s *pipeline.Store) (*runner, error) {
return nil, err
}
root := filepath.Join(s.Directory(), "artifacts")
return &runner{ctx: ctx, store: s, artifactsRoot: root, active: map[int64]activeRun{}, idents: map[int64]runIdentity{}, attentionSent: map[int64]map[string]bool{}, exportSession: stage.ExportSession}, nil
return &runner{ctx: ctx, store: s, artifactsRoot: root, active: map[int64]activeRun{}, idents: map[int64]runIdentity{}, attentionSent: map[int64]map[string]bool{}, notifyModes: map[int64]string{}, exportSession: stage.ExportSession}, nil
}
func (r *runner) start(request protocol.Message, retryOf ...int64) (*protocol.RunDetail, error) {
@@ -263,10 +267,11 @@ func (r *runner) start(request protocol.Message, retryOf ...int64) (*protocol.Ru
return nil, err
}
}
id, created, err := r.store.CreateRunTitled(r.ctx, d, request.RequestKey, workspace, request.AllowTools, request.WritePaths, request.Input, pipeline.RunOverrides{Model: request.Model, StageModels: request.StageModels}, runTitle, retryOf...)
id, created, err := r.store.CreateRunTitled(r.ctx, d, request.RequestKey, workspace, request.AllowTools, request.WritePaths, request.Input, pipeline.RunOverrides{Model: request.Model, StageModels: request.StageModels, NotifyMode: request.NotifyMode}, runTitle, retryOf...)
if err != nil {
return nil, err
}
r.setNotifyMode(id, request.NotifyMode)
// The run row now exists: read it once for its resolved identity (pipeline
// id/name, the store-derived title, the pinned version), so the queued frame
// and every later frame carry what a client needs to render a brand-new run
@@ -658,7 +663,11 @@ func (r *runner) retry(request protocol.Message) (*protocol.RunDetail, error) {
return nil, err
}
}
return r.start(protocol.Message{PipelineID: original.PipelineID, Version: version, RequestKey: request.RequestKey, RetryMode: mode, RetrySource: original.ID, RetryStage: request.RetryStage, RetryVisit: request.RetryVisit, RetryInput: request.RetryInput, Workspace: original.Workspace, Input: original.Input, AllowTools: original.AllowTools, WritePaths: original.WritePaths, Model: original.Model, StageModels: original.StageModels}, original.ID)
notifyMode := request.NotifyMode
if notifyMode == "" {
notifyMode, _ = r.store.RunNotifyMode(r.ctx, original.ID)
}
return r.start(protocol.Message{PipelineID: original.PipelineID, Version: version, RequestKey: request.RequestKey, RetryMode: mode, RetrySource: original.ID, RetryStage: request.RetryStage, RetryVisit: request.RetryVisit, RetryInput: request.RetryInput, Workspace: original.Workspace, Input: original.Input, AllowTools: original.AllowTools, WritePaths: original.WritePaths, Model: original.Model, StageModels: original.StageModels, NotifyMode: notifyMode}, original.ID)
}
func (r *runner) cancel(id int64) error {
@@ -1272,6 +1281,7 @@ func (r *runner) finishRunState(id int64, name, workspace, status, outcome, diag
r.notifyRun(id, name, status, sequence, currentStage, diagnostic)
// The run is terminal: nothing more can notify for it.
r.forgetAttention(id)
r.forgetNotifyMode(id)
}
// completedSteps counts the completed steps of a run detail; resume uses it to