From e36a8bc130ed1f3128768ab2be1673814cab76da Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 5 Jul 2026 09:06:05 +0000 Subject: [PATCH] fix(showcase): CRM Workbench KPI cards read adapter.find().data not .records MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The CRM Workbench KPI strip (Total projects / Active) rendered 0 even though the ListView beside it, backed by the same object, showed all rows. The stats callback read `all.records` from `adapter.find('showcase_project', …)`, but useAdapter() is the console's ObjectStackAdapter — its find() normalizes to a QueryResult with a `data` array, not the REST envelope's `records`. The lookup always missed, so `rows` was `[]` and both counts stuck at 0. Read `.data` first (with `.records`/array fallbacks for robustness across adapter shapes). Verified in a browser against a freshly-built showcase: the cards now show Total 5 / Active 2, and selecting a row still updates Editing without disturbing the counts. The prior attempt at this (#2621) changed the query param `top`→`limit`, which was not the cause — the result-shape mismatch was. Co-Authored-By: Claude Fable 5 Claude-Session: https://claude.ai/code/session_0192Bo4EN62r2kgM35FsBiCp --- .../app-showcase/src/ui/pages/crm-workbench.page.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/examples/app-showcase/src/ui/pages/crm-workbench.page.ts b/examples/app-showcase/src/ui/pages/crm-workbench.page.ts index 98de23e88..2024db350 100644 --- a/examples/app-showcase/src/ui/pages/crm-workbench.page.ts +++ b/examples/app-showcase/src/ui/pages/crm-workbench.page.ts @@ -31,11 +31,13 @@ function Page() { const refreshStats = React.useCallback(async () => { if (!adapter) return; try { - // Canonical QueryOptionsV2 keys only (limit, not the legacy top alias - // removed in 11.0) — the KPI cards silently stuck at 0 whenever adapter.find - // rejected on the unrecognized param, and the empty catch hid the failure. + // useAdapter() is the console's ObjectStackAdapter — its find() resolves to + // a normalized QueryResult with a "data" array, NOT the REST envelope with + // a "records" array. Reading .records here always missed, so the KPI cards + // silently stuck at 0 even though the ListView beside them showed the same + // rows. Read .data first, with .records/array fallbacks for robustness. const all = await adapter.find('showcase_project', { limit: 200 }); - const rows = Array.isArray(all) ? all : (all && all.records) || []; + const rows = Array.isArray(all) ? all : (all && (all.data || all.records)) || []; setStats({ total: rows.length, active: rows.filter((r) => r.status === 'active').length }); } catch (e) { console.warn('[CRM Workbench] failed to refresh stats', e); } }, [adapter]);