Skip to content

fix(showcase): CRM Workbench KPI cards read adapter.find().data not .records#2632

Merged
os-zhuang merged 1 commit into
mainfrom
claude/showcase-chrome-extension-test-tm32mm
Jul 5, 2026
Merged

fix(showcase): CRM Workbench KPI cards read adapter.find().data not .records#2632
os-zhuang merged 1 commit into
mainfrom
claude/showcase-chrome-extension-test-tm32mm

Conversation

@os-zhuang

Copy link
Copy Markdown
Contributor

What

The CRM Workbench KPI strip (Total projects / Active) rendered 0 even though the <ListView> beside it — backed by the same showcase_project object — showed all 5 rows. This fixes the count so the cards show the real totals.

Before → After (same page, freshly-built showcase):

Total projects Active
before 0 0
after 5 2

Why

The stats callback read all.records from adapter.find('showcase_project', …):

const all = await adapter.find('showcase_project', { limit: 200 });
const rows = Array.isArray(all) ? all : (all && all.records) || [];

But useAdapter() in the console is the ObjectStackAdapter, whose find() normalizes its result to a QueryResult with a data array — not the REST envelope's records. (normalizeQueryResult in @object-ui/data-objectstack returns { data, total, … }.) So all.records was always undefined, rows fell back to [], and both counts stuck at 0. The empty catch never fired because the promise resolved fine — it was a shape mismatch, not a rejection.

The fix reads .data first, keeping .records/array fallbacks for robustness across adapter shapes:

const rows = Array.isArray(all) ? all : (all && (all.data || all.records)) || [];

Note: the earlier attempt at this in #2621 changed the query param toplimit. That was not the cause — the result-shape mismatch was. This corrects it.

Verification

  • Booted a freshly-built showcase (objectstack dev --ui --seed-admin), logged in as admin, drove the CRM Workbench in a real browser (Chromium): cards now read Total 5 / Active 2; selecting a row still updates Editing without disturbing the counts.
  • pnpm --filter @objectstack/example-showcase test53 passed.

Scope

One-line behavioral fix in a single private example page (examples/app-showcase), so no changeset (consistent with prior showcase-only commits).

Out of scope — belong in objectui, not this repo

While re-verifying the #2616 findings against latest main, I confirmed #2621 already resolved the REST fields crash, the /ai/agents 404 spam, the unbound page-header Mark Done, and the offline (picsum) seed images. The following remain and are objectui-side (vendored console / SDUI renderer), not fixable in framework metadata — filing separately:

  • Sidebar nav labels show the singular object label (Project, Setting) instead of the app-nav's own label (Projects, Settings) — UnifiedSidebar/useObjectLabel treats the nav label as fallback and the i18n object label wins.
  • Record detail START DATE renders Overdue Nd for any past date — formatRelativeDate applies the "Overdue" wording to every past date, ignoring the dueLike flag it already computes for the red color.
  • Wizard post-submitsubmitBehavior: { kind: 'thank-you' } is a valid spec prop but the in-console object-form block doesn't consume it (only public-forms' EmbeddableForm does), so the wizard still resets in place after Create.
  • Command Center chart panels collapse to ~135px on the left third — the SDUI flex block renders items-start and a region-root component's responsiveStyles (incl. alignItems) is stripped at build, so a column's children can't be made to stretch from metadata. The integerYAxis config (yAxis:[{stepSize:1}]) is also not honored by object-chart (axis still shows 0.5/1.5).

🤖 Generated with Claude Code

https://claude.ai/code/session_0192Bo4EN62r2kgM35FsBiCp


Generated by Claude Code

…records

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0192Bo4EN62r2kgM35FsBiCp
@vercel

vercel Bot commented Jul 5, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
spec Ready Ready Preview, Comment Jul 5, 2026 9:12am

Request Review

@github-actions github-actions Bot added the size/s label Jul 5, 2026
@os-zhuang os-zhuang marked this pull request as ready for review July 5, 2026 09:14
@os-zhuang os-zhuang merged commit 059d68e into main Jul 5, 2026
15 checks passed
@os-zhuang os-zhuang deleted the claude/showcase-chrome-extension-test-tm32mm branch July 5, 2026 09:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants