Skip to content

fix(components): a related-list tab badge keeps following its list after a row action - #36953

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-36922-related-tab-badge-after-action
Nov 24, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/issue-36922-related-tab-badge-after-action

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread

Fixes #36922

Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户在记录页的关联列表里先执行一次行操作(如「标记完成」)后,再删除或新建子记录,页签上的数量角标现在会随列表一起更新,不再停在旧数字直到刷新。
  • 属于记录页关联列表体验修复,替在记录页上处理关联子表的用户解决角标与列表数字对不上的问题。
  • 出错时影响的是角标数字:最坏是多发一次计数请求或角标短暂不更新,不改任何数据,可直接撤回。
  • 无

What changes

RelatedCountStore.fetch (@object-ui/components) now settles on a count the store holds. When a change overtakes the read a fetch joined (an invalidation, invalidateAll, a newer seeded read, or a rail card's releaseRows), the read is marked overtaken and the fetch takes the count a newer read installed, joins the read now in flight, or reads again. A read that fails without being overtaken still answers 0 with nothing cached.

Why

Measured on main (4f19091) in a browser, showcase app, Projects → open a project in the drawer → Tasks related tab:

  1. A row action (Mark Done, a flow-free update) reaches the data-change bus twice, a beat apart: the dataSource write's own mutation event, then notifyRelatedChanged from RelatedRecordActionsBridge.runRowAction once the runner returns.
  2. The first change makes useRelatedCounts (the record page's tab-badge reader, plugin-detail) send a re-count. The second change overtakes it while it is out: invalidate drops the in-flight entry, so the read installs no count when it answers.
  3. fetch still resolved with that read's number. useRelatedCounts reads "resolved and nothing cached" as a failed read and adds the key to its per-parent failed set. A failed key is never asked again for the record open, and the badge draws its last known number.
  4. Every later write (delete, create) invalidates the store, but the reader skips the failed key: the badge stays on the old number until a reload.

A plain delete reaches the bus once, so no read is overtaken; that is why the control in the issue refreshes. The page-tabs badge (page:tabs, an authored page) is not affected: it re-fetches on every store version and keeps no failed set.

Fixed at the store, not the reader: fetch answering with a number for data that has changed, without caching it, is the contract gap; with it closed, the reader's inference ("resolved and nothing cached" = failed) is true again. No public type or accept set changes.

Tests

  • ui/packages/plugin-detail/src/__tests__/useRelatedCounts-27056.test.tsx, new top-level describe (objectstack#36922): drives the real bus (notifyDataChanged) through the store into useRelatedCounts. Row action (two changes, the second while the re-count is out) then delete → re-counted to 8; row action then create → re-counted to 10; plain-delete control → 8.
  • ui/packages/components/src/__tests__/related-count-store.test.ts, new top-level describe: an overtaken fetch reads again and resolves with the installed count; it joins a newer caller's read instead of sending a third; a non-overtaken failure still answers 0 with nothing cached.
Red on main, green with the fix, ablation
  • On main (pins only, commit 3bd578e): Tests 2 failed | 9 passed (11) — both row-action pins AssertionError: expected 2 to be greater than 2 (no read after the delete/create); the plain-delete control passes.
  • With the fix: Test Files 6 passed (6), Tests 48 passed (48) (the hook file plus all five related-count-store* suites).
  • Head: tests ran at 0227fb6; the head 6d5352d adds only the changeset on top of it (no source byte differs). type-check of @object-ui/components and @object-ui/plugin-detail (both programs, source and tsconfig.test.json): exit 0 after building their dependency closure.
  • Ablation through scripts/ablation-replace.mjs (anchor if (!pending.overtaken) return total; → return total;, anchor x1 → x0, blob da95bc4e → a2897c4f): Tests 4 failed | 18 passed (22) — the four new overtaking pins red, both controls green; restored blob == HEAD, git diff HEAD empty. Both suites import the store from source (the hook suite went red → green on a components/src-only change), so no build sits between the mutation and the run.

Acceptance notes

  • Create after a row action (unchecked in the issue): on main it is missed the same way (the create reaches the bus as a change to the child, and the failed key is skipped). Pinned above, and checked in the browser with the fix.
  • A header (record-level) action was not checked; it reaches the bus through the same store, and an overtaken re-count there would have taken the same path.
  • useRelatedCounts still never re-asks a key whose read really failed, for the rest of the record open, and draws its last known count meanwhile. That is unchanged and out of this card (no measured repro).
  • 相关列表:重新加载后结果为 0 条时,数量角标会短暂消失,而不是显示 0 #36822 (badge blanking on a zero-row refetch) is a different defect and is untouched.

Verification

Browser, showcase on its own port (objectstack dev --seed-admin --fresh), Console from ui/ source through Vite, drawer on a project's Tasks tab, the issue's exact sequence:

Readings
Run Tree Sequence Badge after List rows Server total
repro main Mark Done on one row, then Delete another, read 7 s later Tasks 5 4 4
control main fresh load, Delete one row Tasks 1 1 1
fix branch Mark Done, then Delete Tasks 3 3 3
fix, create branch Mark Done, then Add → save Tasks 3 3 3
fix, control branch fresh load, Delete one row Tasks 2 2 2

On main the row action sent one count read (the overtaken one) and the delete sent none; with the fix the row action sends two (the overtaken one, then the re-read) and the delete one more. Time from the tab drawing to its badge on a fresh load is unchanged (170–600 ms with the fix, 230–450 ms with the fetch loop ablated, dev-server Vite on a shared box).

Read first: ui/packages/components/src/hooks/related-count-store.ts — the fetchCount loop and the overtake call sites (the seed and releaseRows ones change behaviour too: a fetch that joined a replaced read now follows the newer read instead of answering with the old one).

Two-minute check: open a project in the drawer on its Tasks tab, run Mark Done on one row, then delete another row — the tab badge drops by one with the list.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (eslint run on the changed files; the repo-wide run is CI's).
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (not touched)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 24, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzesUz1Y8VZuKJRhVL8

席位核对 — ACCEPT · repo:objectstack#3 · head 6d5352d · 2026-11-24T11:19Z

L1 read of #36953 (card #36922, p1) at 6d5352daddc66b69880289bd7ab6346879306bb0. Clause-② no and Metadata-protocol none, both true: the change is internal to the store and alters no public type or accept set. NOT governed (0 of 4 paths), 225 changed lines. No contract review is owed.

The cause holds against the code. startRead installs a count only while inflight.get(k) === entry. On main, invalidate, invalidateAll, seed and releaseRows dropped the in-flight entry, yet fetchCount still answered with that entry's total. So a fetch resolved with nothing cached, which useRelatedCounts reads as failed, and it never asks that key again. A row action reaches the bus twice (the write's mutation event, then notifyRelatedChanged), which produces exactly this overtake. A plain delete reaches the bus once, which is why the card's control refreshes.

The fix. overtake(k) marks the dropped entry before deleting it, at all four drop sites. fetchCount loops: a cached count returns at once, otherwise it joins or starts the in-flight read, and it returns that read's answer only if the read was not overtaken. On an overtake it takes the count a newer read installed, joins the newer read, or reads again. A failure that was not overtaken still answers 0 with nothing cached, so the reader's "resolved and nothing cached = failed" inference is true again rather than loosened. The loop terminates: each extra lap needs an overtake that happened while the read was out, so it stops once the writes stop. In seed, overtake(k) runs before inflight.set(k, entry), so only the replaced entry is marked.

Tests. The hook suite drives the real bus through the store into useRelatedCounts: row action then delete re-counts to 8, row action then create re-counts to 10, and the plain-delete control reaches 8. The store suite covers an overtaken fetch that re-reads, a fetch that joins a newer caller's read instead of sending a third, and a non-overtaken failure that answers 0. The pins fail on main (2 failed). The ablation (return total; unguarded) reds 4 and leaves both controls green. Both suites import the store from source.

Card coverage. Expected: badge and list agree after a row action, delete or create. Delete and create are pinned and live-checked (the readings table, main vs branch). A header action is not checked and is stated as such. It goes through the same store path, which is acceptable.

Changeset. It names @object-ui/components at patch, and each sentence holds. The l1-face flag on @object-ui/plugin-detail concerns one test under src/__tests__/. The package ships files: ["dist", …], its tsconfig excludes **/__tests__/**, and its vite entry is src/index.tsx, so no entry is owed.

Mechanical. All-checks: 45 success · 13 expected skips · 0 failed · 0 pending. Floor checks are green, mergeable_state is clean, and Fixes #36922 delivers the card.

No open finding. ACCEPT, ordinary queue landing.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufziG2t1d9cfRQJDrHkB

Landing: 2026-11-24T11:20Z · area ux-C · p1 · head 6d5352daddc66b69880289bd7ab6346879306bb0

Probe Reading
L1 席位核对 ACCEPT at this head, comment 7129955141 (no open finding)
L2 not owed: Clause-②: no, Metadata-protocol: none, no packages/spec/src/**, no governed path
Checks 45 success, 13 skipped, 0 failed on this head
mergeable_state clean
check-governed-merges NOT governed, 225 changed lines ≤ 3000; one PR on the card
landing-k CAN'T ANSWER (UI-only, Test Core planner skipped); K read via merge-base: git rev-list --count --first-parent 4f190919..origin/main = 14 (< 15), no translations/ file in the PR

State: ready + auto-merge (merge queue).

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 24, 2026 11:21
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 24, 2026
Merged via the queue into main with commit 0212714 Nov 24, 2026
59 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/issue-36922-related-tab-badge-after-action branch November 24, 2026 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants