Add shared live run graphs, debugging, editor choice and draft cleanup
This commit is contained in:
@@ -167,18 +167,61 @@ func (r *runner) start(request protocol.Message, retryOf ...int64) (*protocol.Ru
|
||||
r.run(ctx, id, d, workspace, request)
|
||||
}()
|
||||
}
|
||||
return r.store.GetRun(r.ctx, id)
|
||||
detail, err := r.store.GetRun(r.ctx, id)
|
||||
if detail != nil {
|
||||
_, detail.Executing = r.active[id]
|
||||
}
|
||||
return detail, err
|
||||
}
|
||||
|
||||
func (r *runner) getRun(id int64) (*protocol.RunDetail, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
d, err := r.store.GetRun(r.ctx, id)
|
||||
if d != nil {
|
||||
_, d.Executing = r.active[id]
|
||||
for _, s := range d.Steps {
|
||||
if s.AgentActive {
|
||||
d.Executing = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return d, err
|
||||
}
|
||||
|
||||
func (r *runner) listRuns() ([]protocol.RunSummary, error) {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
items, err := r.store.ListRuns(r.ctx)
|
||||
for i := range items {
|
||||
_, items[i].Executing = r.active[items[i].ID]
|
||||
if items[i].Status == "failed" && !items[i].Executing {
|
||||
d, err := r.store.GetRun(r.ctx, items[i].ID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, step := range d.Steps {
|
||||
if step.AgentActive {
|
||||
items[i].Executing = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return items, err
|
||||
}
|
||||
|
||||
func (r *runner) retry(request protocol.Message) (*protocol.RunDetail, error) {
|
||||
if request.RunID <= 0 {
|
||||
return nil, fmt.Errorf("retry requires a positive run ID")
|
||||
}
|
||||
original, err := r.store.GetRun(r.ctx, request.RunID)
|
||||
original, err := r.getRun(request.RunID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if original.Status != "failed" {
|
||||
if original.Executing {
|
||||
return nil, fmt.Errorf("run %d is still executing; wait for it to stop completely before retrying", original.ID)
|
||||
}
|
||||
if original.Status != "failed" || original.FinishedAt == "" {
|
||||
return nil, fmt.Errorf("only failed runs can be retried (run %d is %s)", original.ID, original.Status)
|
||||
}
|
||||
return r.start(protocol.Message{PipelineID: original.PipelineID, Version: original.Version, RequestKey: request.RequestKey, Workspace: original.Workspace, Input: original.Input, AllowTools: original.AllowTools, WritePaths: original.WritePaths}, original.ID)
|
||||
|
||||
Reference in New Issue
Block a user