(s)
| 520 | |
| 521 | // Live status strip for an Autopilot run, shown above the active tab body. |
| 522 | function autopilotStrip(s) { |
| 523 | const a = s && s.autopilot; |
| 524 | if (!a) return ""; |
| 525 | if (a.running) { |
| 526 | const scopeLabel = a.scope === "all" ? "all phases" : "this phase"; |
| 527 | const now = a.current |
| 528 | ? "Working: " + esc(a.current.title) + (a.current.section ? ' <span class="smuted">' + esc(a.current.section) + "</span>" : "") |
| 529 | : "Selecting the next step…"; |
| 530 | return ( |
| 531 | '<div class="banner banner-auto"><span class="spin"></span>' + |
| 532 | "<span><b>Autopilot running</b> · " + esc(scopeLabel) + " · " + now + |
| 533 | ' <span class="apc">' + a.completed.length + " done</span></span>" + |
| 534 | '<span class="spacer"></span>' + |
| 535 | btn("■ Stop", "autopilot_stop", {}) + |
| 536 | "</div>" + autopilotLog(a) |
| 537 | ); |
| 538 | } |
| 539 | const labels = { |
| 540 | completed: "finished — every eligible step is done", |
| 541 | phase_done: "finished this phase", |
| 542 | stuck: "paused — a step needs your input", |
| 543 | cancelled: "stopped", |
| 544 | capped: "reached its step limit", |
| 545 | error: "stopped on an error", |
| 546 | }; |
| 547 | const label = labels[a.status] || "finished"; |
| 548 | const bad = a.status === "error" || a.status === "stuck"; |
| 549 | let note = "Review the changes (nothing was committed), then continue."; |
| 550 | if (a.stuck) note = "Stuck on: " + esc(a.stuck) + ". Open it in Plan & Progress to finish it yourself, then resume."; |
| 551 | if (a.error) note = esc(a.error); |
| 552 | const more = |
| 553 | btn("▶ Continue (next phase)", "autopilot_start", { scope: "phase" }, { primary: true }) + |
| 554 | btn("Dismiss", "autopilot_dismiss", {}); |
| 555 | return ( |
| 556 | '<div class="banner ' + (bad ? "banner-red" : "banner-auto") + '">' + |
| 557 | "<span><b>Autopilot " + esc(label) + ".</b> Completed " + a.completed.length + " step(s). " + note + "</span>" + |
| 558 | '<span class="spacer"></span>' + more + |
| 559 | "</div>" + autopilotLog(a) |
| 560 | ); |
| 561 | } |
| 562 | |
| 563 | function autopilotLog(a) { |
| 564 | if (!a || !a.completed || !a.completed.length) return ""; |
no test coverage detected