← Commit history

demo: fall back to a window screenshot when fusion_state returns no captures, so a good open is not scored unproven

John Lauer ·a17086d4ff ·2mo ago ·parent 491440c
1 file changed +29−2
web-control-demo.html+29−2
@@ -1901,6 +1901,34 @@ for (const w of mine) {     return probe();   } +  // fusion_state often returns NO captures (it is documented as "next release" in+  // fusion-bridge#28 and still returns an empty set here). The single-surface+  // path already falls back to asking the bridge which window is Fusion's and+  // screenshotting it; the proof card needs the same, or a perfectly good open+  // is scored as unproven because the STATE verb, not the SHOW verb, came back+  // empty. Measured: symbol reported success, zero shots, 0/3.+  function fusionCapture(c, label, expect) {+    return settleThenCapture(c, "fusion_state").then(function (sr) {+      if (sr.s === 200 && sr.j && appendPicked(c, sr.j, "", label, expect)) return true;+      clog(c, "  fusion_state returned no captures - falling back to a window screenshot");+      return postVerb("fusion_window_info", {}).then(function (wi) {+        var wd = (wi.j && (wi.j.data || wi.j)) || {};+        if (!wd.hwnd) { clog(c, "  no Fusion window reported"); return false; }+        return postVerb("desktop_screenshot_base64", { hwnd: wd.hwnd, maxWidth: 900 }).then(function (sh) {+          if (!(sh.s === 200 && sh.j && sh.j.image)) { clog(c, "  window screenshot failed"); return false; }+          var title = (wd.title || "") + "";+          if (expect && title.toLowerCase().indexOf(String(expect).toLowerCase()) < 0) {+            clog(c, "  WRONG WINDOW: asked for '" + expect + "' but the window is '" + title + "'");+            addShot(c.card, sh.j.image, "REJECTED " + label + " - " + title);+            return false;+          }+          addShot(c.card, sh.j.image, label + " - " + (title || "Fusion window"));+          return true;+        });+      }, function () { clog(c, "  fusion_window_info failed"); return false; });+    });+  }+   function showFusionLibraryProof(c) {     c.btn.disabled = true;     cardLog(c.card).textContent = "";@@ -1939,8 +1967,7 @@ for (const w of mine) {             }             // Fusion drives ONE window, so the part name in the title is the             // identity check available here - there is no LIB:NAME prefix.-            return settleThenCapture(c, "fusion_state").then(function (sr) {-              var got = sr.s === 200 && sr.j && appendPicked(c, sr.j, "", st.label, PART.name);+            return fusionCapture(c, st.label, PART.name).then(function (got) {               if (!got) {                 clog(c, "  " + st.label + ": reported success but the capture did not prove it");                 for (var i = results.length - 1; i >= 0; i--) {