Skip to content

fix(plugin-grid): a grouping-field switch paints only the server's groups for the new field (objectui#11574) - #11579

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-11574-grouping-switch-headers
Oct 3, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/issue-11574-grouping-switch-headers

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #11574

Clause-②: no

Implemented by an os-dev run dispatched by the domain:ui seat 1 PM loop, session https://claude.ai/code/session_01FjqrwXPfSMkSfkKYDSRkN2, claim comment 5973674012.

What was wrong (measured)

Switching a server-grouped grid's grouping field painted phantom (empty) group headers stuck on "Loading grid…" beside the server's real groups, until a reload.

Mechanism. useServerGroupHeaders moved to its loading state with { ...prev, loading: true }, so between the switch and the new answer it returned the previous field's header rows under the new grouping fields. A header row carries only the fields it was grouped by, so useGroupedData read the new field's name off every old row as null: N (empty) groups, all on the composite key 0:. ObjectGrid keys each group subtree by that composite key, so React got N children with one key (it warns "Encountered two children with the same key, 0:"). When the real answer arrived, React's keyed reconcile kept one fiber per duplicated key and deleted only that one (react-dom 19.2.8 mapRemainingChildren collects the old children in a Map by key, last one wins, and only that map's entries are deleted); the other N-1 subtrees were never deleted and stayed in the DOM, unmanaged, frozen on their "Loading grid…" placeholder. Hence the phantom count is always the previous field's group count minus one, which is the card's 9 (Title 10 to Priority), 3 (Priority 4 to Status) and 4 (Status 5 to Priority).

Ruled out: a stale header response landing after the switch (the effect's cancelled flag already dropped it), and headers merged by index (the hook replaces the whole set).

The same stale render also asked a row query for the phantom leaf (priority is null), and each group's row page was held by composite key alone. So a page asked under the previous field, including one still in flight at the switch, could render under the next field's group whenever two fields share a key (0:high under both priority and impact).

The fix (only packages/plugin-grid/src/useServerGrouping.ts)

Per the triage ruling, both hooks hold what they hold against the question it answers, and read it only under that same question, in the render the question changes:

  • useServerGroupHeaders: the question is the object, the grouping fields and the header query they compile with (composed filter, search pair, summary columns). A different question reads as pending (headers undefined) at once, and the effect starts it with no headers, so ObjectGrid's existing first-load branch shows the loading state until the new answer. A refresh (reloadKey) re-asks the same question, so the answer in hand stays on screen while it reloads, as before. The reference-label inputs are not part of the question: they label the same answer.
  • useServerGroupRows: pages are held against the object, the grouping fields, the composed filter and the search pair. A page asked under another question is never read under this one, and an answer is written only while it still matches the held question and request signature, so a discarded header's in-flight row query is dropped on arrival. Sort, projection, page size and a refresh keep the page in hand while re-asking, as before.

No client-side filtering of headers, no reload-only path, and ObjectGrid.tsx is unchanged. Cancellation reuses the module's existing patterns (the effect's cancelled flag and the per-request signature): plugin-grid holds no AbortController, and DataSource.find takes no signal.

Visible behaviour change: a change of grouping field, filter or search on a server-grouped grid now shows the grid's loading state until the new groups arrive, instead of the previous groups (which answered a different question). The changeset says so.

Pins: serverGroupingFieldSwitch-11574.test.tsx

  1. Title, Priority, Status, Priority over a 10-task store (10 titles, 4 priorities, 5 statuses, the card's numbers). Each new field's header query answers after the grid has settled on the switch, as a network does. At every step the header list equals the server's group set, with no (empty) header and no group left on "Loading grid…". Every header list painted on the way (sampled by a MutationObserver) is one field's whole answer, and no row query is asked for a group the server did not answer.
  2. A row query in flight for a discarded header never renders. Grouped by priority with the priority = high page held in flight, switch to impact (same value set, so high has the same composite key). The held page answers after the switch, then Impact's headers answer: Impact's high group shows "Loading grid…" and none of Priority-high's rows, then exactly Impact-high's rows.

Red first on main 0903617 (the test was committed alone as 1f0610e): pin 1 failed with expected [ '(empty)', '(empty)', …(11) ] to deeply equal [ 'high', 'low', 'medium', 'urgent' ], which is 13 headers with 9 phantom, the card's number. Pin 2 failed with three phantoms beside Impact's three.

Ablations (one-shot, ⛔ no permanent test)

Each ran through objectstack's scripts/ablation-replace.mjs in wrap mode on the committed fix (blob 42a68861600c): the anchor must hit exactly once, the landed mutation is proven by anchor count and blob change, and the restore is proven by blob equal to HEAD and an empty git diff HEAD, with a trap on exit, INT and TERM. There is no build or dist leg, because the pins import ../ObjectGrid by relative source path.

Mutation Blob after Pin 1 Pin 2
A: the header effect keeps the old answer for a new question ({ ...PENDING, question } becomes { ...prev, loading: true, error: null, question }) e173e56dd1af red, 13 headers, 9 phantom red, 3 phantom
B: the header read-time guard is removed (return state;) 6ccd2257ed64 red: a row query asked for priority null; header counts green, since the effect's reset unmounts the stale render before it is sampled green
C: the row pages are not reset on a question change (const pages = prev.pages;) 61e3c370a222 green red: "Draft the brief" (priority high, impact low) renders under Impact's high group

All three were restored to blob 42a68861600c with an empty git diff HEAD. NOT MEASURED: the row hook's read-time guard on its own. Removing it alone leaves a stale page painted before the effect runs, and act() flushes that render and the next one together, so no pin holds it alone.

Verification (head 3861835)

  • pnpm --workspace-concurrency=2 --filter '@object-ui/plugin-grid^...' build: exit 0 (at c0f07c9; later commits touch only the new test file and the changeset).
  • pnpm --filter @object-ui/plugin-grid type-check (tsc --noEmit && tsc -p tsconfig.test.json): exit 0. --listFilesOnly lists the new test once in the test project and the hook once in the build project.
  • pnpm exec vitest run --maxWorkers=2 packages/plugin-grid/: 184 files, 1700 tests passed.
  • The pins plus the 7189, 11021, 11105 and 10881 grouping suites: 5 files, 33 tests passed.
  • Server-grouped consumers outside the package (6 ListView suites in plugin-list, 2 in app-shell): 8 files, 64 tests passed (at c0f07c9; nothing they import has moved since).
  • check:control-bytes, check:new-line-citations (0 new citations), check:changeset-claims, check:pending-changeset-literals, check:test-path-roots, check:vi-mock-specifiers, check:vi-mock-inherit, check:vi-mock-override-shape, check:unreferenced-sources, check-changeset-presence, check-changeset-no-major, check-changeset-fixed: all exit 0. check-governed-queue-guard --test answers NOT GOVERNED.
  • ESLint, narrowed to the two changed TypeScript files (--no-inline-config --format json): the JSON reports 2 files, 0 errors. The hook's 3 warnings are the same 3 rule ids as on the base blob (react-hooks/set-state-in-effect twice, plus the pre-existing disabled exhaustive-deps once inline config is off). The test has none. --print-config resolves a rule set for both files, so neither is ignored. The config enables no type-aware linting (no parserOptions.project or projectService), so this diff cannot move a verdict on an untouched file. The repo-wide pnpm lint is CI's.
  • Not measured live: no browser run against examples/app-showcase.

Acceptance notes

  • Observation, not filed: useGroupedData derives a group's composite key segment with extractValueKey, which maps both null and '' to the empty segment. If a header query ever answers a null group and an '' group for the same field, the two would share a key, which is the same React duplicate-key shape as above. That needs a driver that groups null and '' apart, which nobody has measured. Carrier: none.
  • Observation, not filed: the ObjectGrid comment above its unified load effect says it uses an AbortController; the code uses a cancelled flag.

Generated by Claude Code

claude added 4 commits October 3, 2026 21:39
…grid (objectui#11574)

Red on main 0903617: Title (10 groups) -> Priority paints 13 headers, 9
phantom "(empty)" ones beside the server's 4, and a Priority -> Impact
switch paints 3 phantoms beside Impact's 3. React warns "Encountered two
children with the same key, `0:`" on the way.

Claude-Session: https://claude.ai/code/session_01FjqrwXPfSMkSfkKYDSRkN2
Co-authored-by: Claude <noreply@anthropic.com>
…t their question (objectui#11574)

useServerGroupHeaders kept the previous answer across a grouping-field
change (`{ ...prev, loading: true }`) and returned it under the new
fields. A header row carries only the fields it was grouped by, so every
old header became an `(empty)` group on the composite key `0:`; React
keeps one fiber per duplicated key, and the other N-1 header subtrees
outlived the real answer as phantom headers stuck on "Loading grid...".

Both hooks now record what they hold with the question it answers
(object, grouping fields, composed filter, search pair; the summary
columns for the headers) and read a held answer only under that same
question, in the render the question changes. A refresh asks the same
question, so the answer in hand stays on screen while it reloads.

Claude-Session: https://claude.ai/code/session_01FjqrwXPfSMkSfkKYDSRkN2
Co-authored-by: Claude <noreply@anthropic.com>
…ing to any (objectui#11574)

Claude-Session: https://claude.ai/code/session_01FjqrwXPfSMkSfkKYDSRkN2
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

✅ Console Performance Budget

Metric Value Budget
Eager closure (gzip, 330 chunks) 3310.9 KB 3330.4 KB
Main entry chunk (gzip) 151.3 KB 350 KB
Entry file index-BT6IIsfH.js —
Status PASS —

The eager closure is every chunk the entry reaches through static imports — what the browser fetches and parses before the app renders. The entry chunk on its own is a small fraction of it.


📦 Bundle Size Report

Package Size Gzipped
app-shell (consoleActionDispatch.js) 0.20KB 0.19KB
app-shell (index.js) 17.22KB 6.37KB
app-shell (runtime-config.js) 20.68KB 7.36KB
app-shell (types.js) 0.01KB 0.04KB
app-shell (urlParams.js) 10.11KB 3.87KB
auth (ActiveOrganizationStorage.js) 27.95KB 10.04KB
auth (AuthContext.js) 0.31KB 0.24KB
auth (AuthGuard.js) 2.07KB 1.00KB
auth (AuthProvider.js) 40.22KB 10.61KB
auth (AuthShell.js) 3.49KB 1.40KB
auth (ForgotPasswordForm.js) 12.21KB 3.45KB
auth (LoginForm.js) 18.17KB 5.40KB
auth (PreviewBanner.js) 0.90KB 0.50KB
auth (RegisterForm.js) 6.72KB 2.24KB
auth (SocialSignInButtons.js) 9.70KB 3.93KB
auth (UserMenu.js) 3.39KB 1.21KB
auth (auth-gate-events.js) 1.29KB 0.66KB
auth (authStyles.js) 5.04KB 1.72KB
auth (createAuthClient.js) 40.70KB 10.94KB
auth (createAuthenticatedFetch.js) 8.54KB 3.46KB
auth (index.js) 3.63KB 1.64KB
auth (invitation-status.js) 1.22KB 0.70KB
auth (org-roles.js) 6.66KB 2.78KB
auth (phone-identifier.js) 1.11KB 0.66KB
auth (types.js) 0.59KB 0.35KB
auth (useAuth.js) 5.30KB 1.02KB
auth (useWorkspaceAdminStatus.js) 11.08KB 4.58KB
collaboration (CommentThread.js) 27.11KB 7.97KB
collaboration (LiveCursors.js) 3.17KB 1.27KB
collaboration (PresenceAvatars.js) 6.28KB 2.60KB
collaboration (PresenceProvider.js) 2.79KB 1.13KB
collaboration (index.js) 1.68KB 0.73KB
collaboration (useCollaborationTranslation.js) 6.50KB 2.52KB
collaboration (useCommentSearch.js) 1.98KB 0.88KB
collaboration (useConflictResolution.js) 7.75KB 1.86KB
collaboration (useMentionNotifications.js) 1.81KB 0.68KB
collaboration (usePresence.js) 6.33KB 1.84KB
collaboration (useRealtimeSubscription.js) 7.91KB 2.01KB
components (index.js) 572.97KB 137.34KB
core (index.js) 10.00KB 3.96KB
create-plugin (index.js) 27.94KB 9.51KB
data-objectstack (index.js) 232.57KB 64.51KB
fields (index.js) 261.62KB 66.20KB
i18n (LocalizationContext.js) 1.76KB 0.96KB
i18n (builtinAggregateLabels.js) 0.86KB 0.49KB
i18n (currency.js) 2.59KB 1.22KB
i18n (fallbackInterpolation.js) 6.25KB 2.77KB
i18n (i18n.js) 8.87KB 3.64KB
i18n (index.js) 5.24KB 2.27KB
i18n (pickLocalized.js) 9.86KB 3.95KB
i18n (provider.js) 39.35KB 12.88KB
i18n (translateFn.js) 0.20KB 0.18KB
i18n (useDisplayLocale.js) 3.52KB 1.76KB
i18n (useObjectLabel.js) 35.66KB 9.49KB
i18n (useSafeTranslation.js) 7.14KB 2.92KB
layout (index.js) 39.47KB 11.25KB
mobile (MobileProvider.js) 0.92KB 0.49KB
mobile (ResponsiveContainer.js) 0.94KB 0.38KB
mobile (breakpoints.js) 1.51KB 0.70KB
mobile (createOfflineDataSource.js) 5.61KB 1.75KB
mobile (index.js) 1.99KB 0.87KB
mobile (offlineQueue.js) 3.91KB 1.35KB
mobile (pwa.js) 0.97KB 0.49KB
mobile (serviceWorker.js) 1.48KB 0.62KB
mobile (serviceWorkerSource.js) 3.41KB 1.48KB
mobile (useBreakpoint.js) 1.54KB 0.65KB
mobile (useGesture.js) 6.96KB 1.98KB
mobile (useOfflineSync.js) 1.99KB 0.72KB
mobile (usePullToRefresh.js) 6.62KB 2.45KB
mobile (useResponsive.js) 0.72KB 0.42KB
mobile (useSpecGesture.js) 5.52KB 2.10KB
mobile (useTouchTarget.js) 1.01KB 0.54KB
permissions (MePermissionsProvider.js) 13.86KB 5.00KB
permissions (PermissionContext.js) 0.31KB 0.25KB
permissions (PermissionGuard.js) 0.89KB 0.45KB
permissions (PermissionProvider.js) 6.52KB 2.26KB
permissions (discardProofCache.js) 1.04KB 0.55KB
permissions (evaluator.js) 8.33KB 3.07KB
permissions (index.js) 0.93KB 0.41KB
permissions (store.js) 0.91KB 0.42KB
permissions (useFieldPermissions.js) 1.28KB 0.53KB
permissions (usePermissions.js) 4.83KB 2.27KB
plugin-ai (index.js) 16.04KB 3.92KB
plugin-calendar (index.js) 53.17KB 15.46KB
plugin-charts (index.js) 83.60KB 22.89KB
plugin-chatbot (index.js) 198.22KB 46.97KB
plugin-dashboard (index.js) 142.26KB 38.44KB
plugin-designer (index.js) 231.28KB 48.76KB
plugin-detail (index.js) 245.60KB 64.57KB
plugin-editor (index.js) 2.23KB 1.05KB
plugin-form (index.js) 175.44KB 45.28KB
plugin-gantt (index.js) 179.16KB 45.06KB
plugin-grid (index.js) 235.69KB 64.78KB
plugin-kanban (index.js) 49.59KB 15.58KB
plugin-list (index.js) 116.46KB 28.93KB
plugin-map (index.js) 25.60KB 8.62KB
plugin-markdown (index.js) 13.88KB 4.80KB
plugin-report (index.js) 44.12KB 12.29KB
plugin-timeline (index.js) 38.80KB 11.71KB
plugin-tree (index.js) 14.51KB 5.15KB
plugin-view (index.js) 90.23KB 22.73KB
providers (DataSourceProvider.js) 0.75KB 0.39KB
providers (MetadataProvider.js) 1.37KB 0.59KB
providers (ThemeProvider.js) 1.90KB 0.85KB
providers (UploadProvider.js) 11.81KB 3.58KB
providers (index.js) 0.45KB 0.23KB
providers (types.js) 0.01KB 0.04KB
react-runtime (index.js) 5.62KB 2.34KB
react (LazyPluginLoader.js) 4.47KB 1.63KB
react (SchemaRenderer.js) 120.63KB 39.56KB
react (data-invalidation.js) 5.05KB 2.08KB
react (index.js) 4.50KB 2.06KB
react (schema-input.js) 4.25KB 2.04KB
react (spec-input.js) 0.20KB 0.18KB
sdui-parser (body-dialect.js) 4.50KB 1.99KB
sdui-parser (codegen.js) 9.45KB 3.76KB
sdui-parser (dashboard-widget-options.js) 3.08KB 1.30KB
sdui-parser (index.js) 6.06KB 2.68KB
sdui-parser (input-type.js) 2.84KB 1.40KB
sdui-parser (parse.js) 25.28KB 7.80KB
sdui-parser (provenance.js) 3.84KB 1.90KB
sdui-parser (types.js) 0.28KB 0.23KB
sdui-parser (validate.js) 21.42KB 7.05KB
types (ai.js) 4.39KB 2.17KB
types (api-types.js) 0.20KB 0.18KB
types (app.js) 4.12KB 1.61KB
types (authoring-nodes.js) 0.20KB 0.19KB
types (base.js) 0.20KB 0.18KB
types (blocks.js) 0.20KB 0.18KB
types (cloud.js) 0.20KB 0.18KB
types (complex.js) 4.16KB 1.96KB
types (crud.js) 0.20KB 0.18KB
types (dashboard-filter-alias.js) 6.23KB 2.74KB
types (dashboard-widget-layout.js) 2.06KB 0.96KB
types (data-display.js) 3.75KB 1.85KB
types (data-protocol.js) 0.20KB 0.19KB
types (data.js) 0.20KB 0.18KB
types (designer.js) 1.85KB 0.85KB
types (disclosure.js) 0.20KB 0.18KB
types (error-code.js) 1.54KB 0.88KB
types (expression.js) 0.20KB 0.18KB
types (feedback.js) 0.20KB 0.18KB
types (field-types.js) 0.20KB 0.18KB
types (form.js) 0.20KB 0.18KB
types (http-inflight.js) 8.87KB 3.73KB
types (http-retry.js) 4.32KB 2.02KB
types (icon-key-migration.js) 4.26KB 1.63KB
types (index.js) 5.07KB 2.39KB
types (layout.js) 0.20KB 0.18KB
types (managed-by.js) 0.19KB 0.18KB
types (mobile.js) 5.00KB 2.39KB
types (navigation.js) 0.20KB 0.18KB
types (objectql.js) 0.20KB 0.18KB
types (overlay.js) 0.20KB 0.18KB
types (permissions.js) 2.52KB 1.31KB
types (plugin-scope.js) 0.20KB 0.18KB
types (record-components.js) 0.20KB 0.19KB
types (record-semantics.js) 1.28KB 0.67KB
types (registry.js) 0.20KB 0.18KB
types (reports.js) 0.20KB 0.18KB
types (select-option.js) 0.20KB 0.19KB
types (spec-report.js) 4.99KB 1.96KB
types (spec-ui-namespace.js) 0.20KB 0.19KB
types (strict-authoring-face.js) 19.93KB 7.25KB
types (system-fields.js) 3.33KB 1.54KB
types (theme.js) 6.28KB 2.87KB
types (ui-action.js) 8.11KB 3.32KB
types (views.js) 0.20KB 0.18KB
types (widget.js) 0.20KB 0.18KB

Size Limits

  • ✅ Core packages should be < 50KB gzipped
  • ✅ Component packages should be < 100KB gzipped
  • ⚠️ Plugin packages should be < 150KB gzipped

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 3, 2026 22:26
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 3, 2026 22:26
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 3, 2026
Merged via the queue into main with commit 2f54dca Oct 3, 2026
45 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-11574-grouping-switch-headers branch October 3, 2026 22:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant