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:
@@ -18,6 +18,8 @@ import (
|
||||
type RunOverrides struct {
|
||||
Model string
|
||||
StageModels map[string]string
|
||||
// NotifyMode is auto, on or off for this run. Empty means auto.
|
||||
NotifyMode string
|
||||
}
|
||||
|
||||
// CreateRun inserts a run and derives its title from the prompt. It is the entry
|
||||
@@ -61,15 +63,15 @@ func (s *Store) CreateRunTitled(ctx context.Context, d *protocol.PipelineDetail,
|
||||
defer s.mu.Unlock()
|
||||
var id, pid int64
|
||||
var version int
|
||||
var oldInput, oldWorkspace, oldPaths, oldModel, oldStageModels string
|
||||
var oldInput, oldWorkspace, oldPaths, oldModel, oldStageModels, oldNotify string
|
||||
var oldTools bool
|
||||
err = s.db.QueryRowContext(ctx, "SELECT id,pipeline_id,version,input_json,workspace,write_paths,allow_tools,model,stage_models FROM pipeline_runs WHERE request_key=?", key).Scan(&id, &pid, &version, &oldInput, &oldWorkspace, &oldPaths, &oldTools, &oldModel, &oldStageModels)
|
||||
err = s.db.QueryRowContext(ctx, "SELECT id,pipeline_id,version,input_json,workspace,write_paths,allow_tools,model,stage_models,notify_mode FROM pipeline_runs WHERE request_key=?", key).Scan(&id, &pid, &version, &oldInput, &oldWorkspace, &oldPaths, &oldTools, &oldModel, &oldStageModels, &oldNotify)
|
||||
if err == nil {
|
||||
var oldParent int64
|
||||
if err := s.db.QueryRowContext(ctx, "SELECT COALESCE((SELECT original_run_id FROM run_retries WHERE run_id=?),0)", id).Scan(&oldParent); err != nil {
|
||||
return 0, false, err
|
||||
}
|
||||
if pid != d.ID || version != d.Version || oldInput != string(encoded) || oldWorkspace != workspace || oldPaths != string(writes) || oldTools != tools || oldParent != parent || oldModel != overrides.Model || oldStageModels != string(encodedModels) {
|
||||
if pid != d.ID || version != d.Version || oldInput != string(encoded) || oldWorkspace != workspace || oldPaths != string(writes) || oldTools != tools || oldParent != parent || oldModel != overrides.Model || oldStageModels != string(encodedModels) || oldNotify != notifyMode(overrides.NotifyMode) {
|
||||
return 0, false, fmt.Errorf("request key already used for a different run")
|
||||
}
|
||||
return id, false, nil
|
||||
@@ -82,7 +84,7 @@ func (s *Store) CreateRunTitled(ctx context.Context, d *protocol.PipelineDetail,
|
||||
return 0, false, err
|
||||
}
|
||||
defer tx.Rollback()
|
||||
result, err := tx.ExecContext(ctx, "INSERT INTO pipeline_runs(pipeline_id,version,request_key,workspace,allow_tools,write_paths,input_json,title,title_source,title_model,model,stage_models) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)", d.ID, d.Version, key, workspace, tools, string(writes), string(encoded), title.Text, title.Source, title.Model, overrides.Model, string(encodedModels))
|
||||
result, err := tx.ExecContext(ctx, "INSERT INTO pipeline_runs(pipeline_id,version,request_key,workspace,allow_tools,write_paths,input_json,title,title_source,title_model,model,stage_models,notify_mode) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?)", d.ID, d.Version, key, workspace, tools, string(writes), string(encoded), title.Text, title.Source, title.Model, overrides.Model, string(encodedModels), notifyMode(overrides.NotifyMode))
|
||||
if err != nil {
|
||||
return 0, false, err
|
||||
}
|
||||
@@ -101,6 +103,26 @@ func (s *Store) CreateRunTitled(ctx context.Context, d *protocol.PipelineDetail,
|
||||
return id, true, nil
|
||||
}
|
||||
|
||||
func notifyMode(value string) string {
|
||||
switch strings.ToLower(strings.TrimSpace(value)) {
|
||||
case "on", "off":
|
||||
return strings.ToLower(strings.TrimSpace(value))
|
||||
default:
|
||||
return "auto"
|
||||
}
|
||||
}
|
||||
|
||||
// RunNotifyMode returns the stored per-run notification override (auto, on or
|
||||
// off). It lets a restarted server honor an existing run's silence.
|
||||
func (s *Store) RunNotifyMode(ctx context.Context, id int64) (string, error) {
|
||||
var mode string
|
||||
err := s.db.QueryRowContext(ctx, "SELECT notify_mode FROM pipeline_runs WHERE id=?", id).Scan(&mode)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return notifyMode(mode), nil
|
||||
}
|
||||
|
||||
// resolveRunTitle guarantees a stored run title is never empty: a title supplied
|
||||
// by the caller (a model generation) is kept verbatim, and an absent one is
|
||||
// derived from the prompt's first line. The fallback is server-owned and never
|
||||
|
||||
@@ -12,7 +12,7 @@ func (s *Store) initRuns() error {
|
||||
id INTEGER PRIMARY KEY, pipeline_id INTEGER NOT NULL, version INTEGER NOT NULL,
|
||||
request_key TEXT NOT NULL UNIQUE, workspace TEXT NOT NULL, allow_tools INTEGER NOT NULL,
|
||||
title TEXT NOT NULL DEFAULT '', title_source TEXT NOT NULL DEFAULT '', title_model TEXT NOT NULL DEFAULT '',
|
||||
model TEXT NOT NULL DEFAULT '', stage_models TEXT NOT NULL DEFAULT '{}',
|
||||
model TEXT NOT NULL DEFAULT '', stage_models TEXT NOT NULL DEFAULT '{}', notify_mode TEXT NOT NULL DEFAULT 'auto',
|
||||
write_paths TEXT NOT NULL, input_json TEXT NOT NULL, output_json TEXT NOT NULL DEFAULT '{}',
|
||||
status TEXT NOT NULL DEFAULT 'queued', outcome TEXT NOT NULL DEFAULT '', current_stage TEXT NOT NULL DEFAULT '',
|
||||
diagnostic TEXT NOT NULL DEFAULT '', created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP, finished_at TEXT,
|
||||
@@ -62,6 +62,9 @@ CREATE TABLE IF NOT EXISTS retry_checkpoints (
|
||||
if err := s.migrateRunTitles(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.addColumnIfMissing("pipeline_runs", "notify_mode", "TEXT NOT NULL DEFAULT 'auto'"); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.dropResourceSchema(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user