← Commit history

demo: stop blaming the bridge when a verb simply outran the poll - distinguish 'finished in 2.5s' from 'never reported' (kicad-bridge#39 feedback)

John Lauer ·3070a38b09 ·2mo ago ·parent 2c8e932
1 file changed +14−3
web-control-demo.html+14−3
@@ -1035,6 +1035,7 @@ for (const w of mine) {       "on " + esc(who) + " - one slow verb, animated purely from its progress block");      var finished = false, frames = 0, sawMoving = false, lastLabel = null;+    var startedAt = Date.now();   // to tell 'too fast to poll' from 'never reported'     c._lastShotKey = null;   // fresh evidence stream per run      // ---- the poll leg: this is what animates -------------------------------@@ -1092,10 +1093,20 @@ for (const w of mine) {         clog(c, "terminal frame -> (this verb reported no progress block)");       }       var ok = res.s === 200 && res.j && res.j.success !== false;+      // Be honest about WHY a bar did not move, because the two reasons need+      // opposite responses and look identical from here. A verb that finished in+      // a couple of seconds simply outran a 1s poll - that is the bridge being+      // FAST, not the bridge being silent, and reporting it as "does not report+      // progress" sends a bridge author hunting a bug that is not there (the+      // kicad author caught exactly that wording, kicad-bridge#39).+      var ranMs = Date.now() - startedAt;       var note = frames + " live frame(s) polled" +-        (sawMoving ? ", bar animated" :-          ", none below 100% - this bridge does not populate active[] during this verb yet, " +-          "so the bar could only draw the terminal frame");+        (sawMoving ? ", bar animated"+          : frames > 0 ? ", all at 100% - the run finished before a poll caught it mid-flight"+          : ranMs < 6000 ? ", but the verb finished in " + (ranMs / 1000).toFixed(1) + "s - too fast for a 1s poll to " ++              "catch a frame, so only the terminal frame was drawn (not a bridge fault)"+          : ", and none arrived in " + (ranMs / 1000).toFixed(1) + "s - this bridge may not populate active[] " ++              "for this verb, so the bar could only draw the terminal frame");       setRes(c.res, ok ? "ok" : "err", ok ? "Allowed &amp; ran" : "Failed",         "on " + esc(who) + " - " + esc(note));       c.btn.disabled = false;