fix(adwright panel): map real {meta,woo} shape from adwright-mcp; connections tab now shows live status
Some checks failed
plugin-tests / test (push) Failing after 6s
Some checks failed
plugin-tests / test (push) Failing after 6s
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).
This commit is contained in:
parent
e9554fa051
commit
058d67b459
@ -694,7 +694,34 @@
|
|||||||
} else if (tool === "adwright_list_recipes") {
|
} else if (tool === "adwright_list_recipes") {
|
||||||
NS.state.data.recipes = payload.recipes || [];
|
NS.state.data.recipes = payload.recipes || [];
|
||||||
} else if (tool === "adwright_get_connections_status") {
|
} 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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user