From 058d67b459191a85275764eb81ebca54bbc43277 Mon Sep 17 00:00:00 2001 From: Svrnty Date: Sun, 24 May 2026 14:24:31 -0400 Subject: [PATCH] fix(adwright panel): map real {meta,woo} shape from adwright-mcp; connections tab now shows live status Bug: panel _ingestUpdate expected payload.connections array (mock shape). Real adwright_get_connections_status returns {meta:{...}, woo:{...}}. Resulted in connections tab always empty + Overview KPIs sourced from empty arrays even though backend was returning real data. Now ingest normalises both shapes (real + mock fallback) into the [{id, name, ok, status, detail}, ...] shape the renderer already expects. detail field plumbed through for future Connections card expansion. Verified via curl /api/adwright/last-panel-update?tool=adwright_get_connections_status returns real Plan B sandbox + Woo. Panel now displays them. Karpathy 4 rules: surfaced shape mismatch via real backend probe, smallest shim (one ingest branch), supports both old + new shape (no regression). --- static/adwright.js | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/static/adwright.js b/static/adwright.js index c724132..212ea76 100644 --- a/static/adwright.js +++ b/static/adwright.js @@ -694,7 +694,34 @@ } else if (tool === "adwright_list_recipes") { NS.state.data.recipes = payload.recipes || []; } else if (tool === "adwright_get_connections_status") { - NS.state.data.connections = payload.connections || []; + // Real adwright-mcp returns {meta:{connected,account_id,...}, woo:{connected,store_url,...}} + // Legacy mock returned {connections:[...]}. Support both. + if (Array.isArray(payload.connections)) { + NS.state.data.connections = payload.connections; + } else { + const out = []; + if (payload.meta) { + const m = payload.meta; + out.push({ + id: "meta", + name: m.account_name ? "Meta — " + m.account_name : "Meta (Facebook + Instagram)", + status: m.connected ? "ok" : "down", + ok: !!m.connected, + detail: m.connected ? `${m.account_id} · ${m.currency} · spent ${m.amount_spent || 0}` : (m.error || "not connected"), + }); + } + if (payload.woo) { + const w = payload.woo; + out.push({ + id: "woo", + name: "WooCommerce" + (w.store_url ? " — " + w.store_url.replace(/^https?:\/\//, "") : ""), + status: w.connected ? "ok" : "down", + ok: !!w.connected, + detail: w.connected ? `WC ${w.wc_version || "?"} · WP ${w.wp_version || "?"} · ${w.currency || ""}` : (w.error || "not connected"), + }); + } + NS.state.data.connections = out; + } } }