runner: keep export handoffs nonterminal through recovery

This commit is contained in:
2026-10-20 21:19:26 +01:00
parent ca78b24f47
commit ec3eda9e05
28 changed files with 370 additions and 82 deletions
+5 -5
View File
@@ -1461,16 +1461,16 @@ func (a App) wait(ctx context.Context, pos []string, o *options, call callFunc)
return nil
}
// awaitRuns polls every run that active reports as unfinished until each is
// terminal, using the same GetRun reattachment the run --wait path uses, and
// calls onTerminal for each as it finishes (including runs already terminal at
// awaitRuns polls unfinished runs using GetRun reattachment. Export waits remain
// unfinished even for run --wait, whose status-only predicate intentionally stops
// at human decisions. It calls onTerminal for each as it finishes (including runs already terminal at
// entry, in the order supplied). A deadline that passes first returns a
// *waitLimitError naming the runs still active; ctx ending first returns
// ctx.Err(). It never cancels, retries or otherwise changes a run.
func (a App) awaitRuns(ctx context.Context, runs []protocol.Message, deadline <-chan time.Time, call callFunc, active func(string) bool, onTerminal func(protocol.Message) error) error {
remaining := make([]protocol.Message, 0, len(runs))
for _, r := range runs {
if active(r.RunDetail.Status) {
if active(r.RunDetail.Status) || (r.RunDetail.Status == protocol.RunStatusWaiting && r.RunDetail.ExportPendingSequence > 0) {
remaining = append(remaining, r)
continue
}
@@ -1495,7 +1495,7 @@ func (a App) awaitRuns(ctx context.Context, runs []protocol.Message, deadline <-
if refreshed.RunDetail == nil {
return fmt.Errorf("server did not return run detail for %d", r.RunDetail.ID)
}
if active(refreshed.RunDetail.Status) {
if active(refreshed.RunDetail.Status) || (refreshed.RunDetail.Status == protocol.RunStatusWaiting && refreshed.RunDetail.ExportPendingSequence > 0) {
next = append(next, refreshed)
continue
}