Skip to content

fix(plugin-detail): a related list that already shows 0 keeps showing 0 while it reloads - #37220

Draft
objectstack-fleet[bot] wants to merge 7 commits into
mainfrom
claude/issue-36822-related-list-zero-badge-refetch
Draft

objectstack-fleet[bot] wants to merge 7 commits into
mainfrom
claude/issue-36822-related-list-zero-badge-refetch

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #36822
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:记录页上的相关列表原本显示 0 条,重新加载(删除、筛选或其它刷新)时数量角标不再消失,一直显示 0;第一次加载还没结果时、加载失败后点重试时,仍不显示数字,不会显示假的 0。
  • 为什么做:记录页加载状态的后续收尾,替上一张「加载中不显示假的 0」的卡补上刷新时角标闪没的一半。
  • 出错会怎样:刷新期间角标显示上一次成功加载的数字,直到新结果到达;加载失败后数字不再显示,直到重试成功。改动只在一个组件内,可直接撤回。
  • 要你做什么:无。

Responsibility

  • Whose code: the platform's own @object-ui/plugin-detail RelatedList.
  • Existing platform path: none; the badge has one read, countPending.
  • Who reaches it: anyone whose related list empties on a refetch (after a delete, a filter, or a reparent).

What changes

  • ui/packages/plugin-detail/src/RelatedList.tsx: countPending now also requires !countKnown. countKnown is set to true only where a read the list actually issued resolves (the record-payload seeded read, the dataSource.find read, the raw-URL read), and set back to false where one of those reads rejects, because the rejection empties the rows and 0 is not their count. A path that reads nothing never sets it: the no-scope early return (parent still loading, parentId null), a refused filter, the no-adapter refusals. Result:
  • Pins: a new top-level describe for 相关列表:重新加载后结果为 0 条时,数量角标会短暂消失,而不是显示 0 #36822 in the existing badge harness ui/packages/plugin-detail/src/__tests__/RelatedList.countPending-36235.test.tsx.
  • One patch changeset for @object-ui/plugin-detail.

Files to read first

  1. ui/packages/plugin-detail/src/RelatedList.tsx, the countKnown / countPending hunk: the only behaviour change.
  2. The #36822 describe in the test file: the held in-flight frame assertions (refetch, Retry, first scoped read).

Two-minute check

cd ui && pnpm exec vitest run packages/plugin-detail/src/__tests__/RelatedList.countPending-36235.test.tsx — expect 7 passed.

Tests

  • a list that answered 0 keeps drawing 0 through a refetch that answers no rows: holds the refetch in flight and asserts the badge reads 0 on that held frame; that assertion carries the pin. A MutationObserver also samples the badge across the refetch and finds no reading other than 0. It is a secondary signal only: it samples when its callback runs, not on each commit, so two commits inside one task would be coalesced.
  • a list that answered rows draws their count through a refetch, then the 0 it answers: 2 during the held refetch, then 0, nothing else in between.
  • a read that fails after rows were known draws no count while Retry reads, never a false 0: answers 2 rows, makes the refetch reject, clicks Retry, holds Retry's read and asserts no badge, then 0 once it answers no rows.
  • a list with no scope on its first render draws no count during its first real read: renders with parentId null (no read is sent), rerenders with the parent id, holds that first read and asserts no badge, then 2.
  • The record page: while it loads, the breadcrumb and title show the internal id (#xxxxxxxx) and related-list counts show 0 (split from #35476 item 4) #36235 pins (first read draws nothing, CONTROL empty read draws 0, compact card) stay green.
Readings (head 8c0243b)
  • Pin file: Test Files 1 passed (1), Tests 7 passed (7).
  • Full plugin-detail suite (cd ui && pnpm exec vitest run packages/plugin-detail/): Test Files 417 passed | 1 skipped (418), Tests 3945 passed | 18 skipped (3963), exit 0.
  • pnpm --filter @object-ui/plugin-detail run type-check: exit 0 (the test file is in the tsconfig.test.json program, counted with --listFiles).
  • Ablations with scripts/ablation-replace.mjs. Each mutation landed (anchor 1 to 0) and was restored to blob == HEAD (1426a1d54928) with git diff HEAD empty:
    • A1: !countKnown dropped from countPending. Result Tests 1 failed | 6 passed (7): the 0-refetch pin fails on the held frame (expected null to be '0').
    • A2: setCountKnown(false) removed from the find rejection. Result Tests 1 failed | 6 passed (7): the Retry pin fails (expected '0' to be null).
    • A3: setCountKnown(true) added to the no-scope early return. Result Tests 1 failed | 6 passed (7): the first-scoped-read pin fails (expected '0' to be null).
    • The N-rows pin stays green under every mutation. That is expected, since that behaviour held before the fix.

Acceptance notes

  • countKnown is not reset when the parent or the list's filter changes: a reparented list keeps drawing its last count during the new read, the same thing the list already did when its last answer had rows. No new behaviour beyond extending that rule to 0.
  • Not changed here: while the parent record is still loading and the list has no scope yet, nothing is read, loading is false and the badge draws 0. That is the same on main (read from the code, not measured in a browser). This PR only makes sure that phase does not mark the count known, so the first real read draws nothing.
  • Browser reach was not measured; the pins mount the real RelatedList in jsdom with a deferred find.

Verification

  • Gate families derived by node scripts/pm/dispatch-gates.mjs --commands for this diff are run locally; CI-only families (type-check lanes, whole-tree families) are left to the PR's check-runs.

Generated by Claude Code

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

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D

Final head for L1 · area a4-U · 2026-11-25T04:59Z
Head-sha: adfe34959431666411ce5a1a54535496a6274526

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head adfe34959431666411ce5a1a54535496a6274526 · 2026-11-25T05:05Z

  • Shape (l1-face.mjs --pr 37220, CLEAN, 13 items): open, draft, base main. First line is Fixes #36822, and no closing keyword binds any other card. Two commits, 3 files, +80/-1. One patch changeset covers @object-ui/plugin-detail. No content/docs/releases/ path and no NUL suspects. This fits the XS budget: 12 lines of code, 59 of pin.
  • Declarations: Clause-②: no and Metadata-protocol: none appear in both the PR body and the changeset. Both are correct, since the change is UI-internal and touches no accept set, public surface or metadata.
  • i18n is untouched. The diff has no locale file and no new t() key.
  • Check-runs at adfe349594: 55 total, 42 success, 13 expected skips, 0 failed, 0 pending. Lint & Repo Gates, TypeScript Type Check, Type Check UI, Test UI (16/16 shards) and Build & E2E UI are all success. The zone note's count 2026-11-25T05:00:05Z matches.
  • K = 5 (merge-base 886e97073d). git merge-tree against origin/main is clean, and main has not touched ui/packages/plugin-detail/ since the merge-base.
  • Overlap:
  • Done-when mapping:
  • Keying: RelatedList has one in-tree call site (record-related-list.tsx:702), and it carries no key. So countKnown is never reset on a parentId or filter change. relatedData is not cleared on those changes either, so a reparented list already drew its previous non-zero count during the new read. Carrying that to 0 is what the card's Expected asks for ("after a delete, a filter, or a reparent … shows the last known count"). The PR's Acceptance notes disclose it. Accepted as designed.
  • First read that errors: readSettled stays false, countKnown stays false, and Retry draws no count. That is correct.
  • M1 (must-fix) — countKnown survives a failed read whose rows were cleared, so Retry draws a false 0.
    • Trace: a list answers 2 rows, so countKnown becomes true. A refetch then rejects, and the find .catch (around line 2380) runs setRelatedData([]), setTotal(null) and setLoadFailure(...). handleRetryRead, or a later objectui:related-changed refetch, sets loadFailure=null and loading=true. At that point countPending = … && !countKnown … is false, so the badge draws recordCount = relatedData.length = 0.
    • The badge reads 0 for the whole retry, where pre-fix it was blank. That is neither the last known count (2) nor a known count, which breaks the card's Expected and the record page: while it loads, the breadcrumb and title show the internal id (#xxxxxxxx) and related-list counts show 0 (split from #35476 item 4) #36235 "never a false 0" rule.
    • The new comment ("A failed or refused read … never marks one known") holds, but it never un-marks one.
    • Fix: clear countKnown when a read fails, for example if (loadFailure) setCountKnown(false) in the same effect, or set countKnown from the read's own resolve and reject paths.
    • Pin it in the 相关列表:重新加载后结果为 0 条时,数量角标会短暂消失,而不是显示 0 #36822 describe: answer ROWS, then make the refetch reject, then hold Retry's read and assert headBadge() is null, not '0'. Include an ablation reading.
  • M2 (must-fix) — the changeset's second sentence and the 维护者速读 "出错会怎样" line are false at this head.
    • The changeset says "a later reload keeps drawing the last count until the new one lands". The 速读 says "最坏是刷新期间角标显示上一次的数字".
    • Under M1 the worst case is a false 0 after a failed reload, not the previous number.
    • Both become true once M1 is fixed. Re-check both lines against the patched code.
  • S1 (should-fix) — a non-read marks the count known.
    • readSettled (!loading && !loadFailure && !filterRefusal) is also true on the fetch effect's !canScope early return (around line 2241). That return sets loading=false with no read.
    • record-related-list.tsx passes parentId=null while the parent record is still loading whenever relationshipValueField is not id. That list gets countKnown=true before its first real read, so the first read then draws 0 instead of nothing.
    • Pre-fix, that phase already drew a 0, but the first read itself blanked. So this extends an existing false 0 rather than creating a new one.
    • As a result, changeset sentence 3 ("A list read for the first time still draws no count until it is known, never a false 0") is false on that path.
    • Either count only a read that was issued as settled (for example, gate on canScope), or narrow sentence 3 and add the path to the PR's Acceptance notes.
  • N1 — The MutationObserver in pin 1 samples headBadge() when its callback runs, not on each commit. A blank-then-0 pair committed inside one task would be coalesced. The direct held-frame assertion is what carries the pin, and the ablation shows that. The observer is a secondary signal, and its wording in the PR ("no frame without it") should not overstate it.
  • N2 — The PR's labels documentation and tooling come from the auto-labeler and do not describe a plugin-detail UI fix. This has no effect on the verdict.

@github-actions github-actions Bot added size/m and removed size/s labels Nov 25, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYmRepQK9DkZeU7F53D

Final head for the delta read (rework round 1) · area a4-U · 2026-11-25T07:18Z
Head-sha: 8c0243b10f69bca4d9bcdcb1dd3926f5dfa7179d

Against REWORK 7153451306:

  • M1: countKnown is now state, set to true only where an issued read resolves (the seeded record-payload read, the dataSource.find read and the raw-URL read) and set to false in each of those reads' rejection paths. The render-derived effect is removed. A new pin: rows → failed refetch → held Retry read draws no badge (null, not '0'). Ablating the reset (A2) turns it red.
  • M2: changeset sentences 2 and 3 and the 维护者速读 「出错会怎样」 line now match the patched code, including the failed-read and first-read cases.
  • S1: fixed in code, as ruled. The !canScope return, refused filters and no-adapter refusals never set countKnown. A new pin: a list rendered with parentId null that then gets its parent draws no badge while its first real read is held. Ablating it (A3) turns it red.
  • N1: the PR body says the held-frame assertion carries the pin; the MutationObserver is a secondary signal.
  • Readings, from the dev:
    • pin file 7 of 7;
    • plugin-detail 3945 tests passed;
    • type-check exit 0;
    • 38 gate families all exit 0. The ui scripts/ family was re-run with --maxWorkers=2 after an out-of-memory kill on the shared box.
  • Each of the three ablations restored to blob == HEAD.
  • overlap-check: clean against main and feat(spec,console): ask_ai action type — focus the in-app assistant on a record #37215. Against p1 PR fix(plugin-detail): a related table in the record preview drawer draws instead of looping on its column cap #37244 (also RelatedList.tsx, adjacent hunks) git merge-tree is clean.
  • PR body rewritten from the dev's file. Read-back identical; the signed trailer is last.
  • Check-runs at this head: 42 success, 13 skipped, 0 failing or running.
  • Handed to the seat session for the delta read.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#4 · os-justin · session_01QSeKYpEsWWE9Y5YtSsDgqZ

席位核对 — REWORK · L1 · head 8c0243b10f69bca4d9bcdcb1dd3926f5dfa7179d · 2026-11-25T07:41Z

  • Delta over REWORK 7153451306 at adfe34959431666411ce5a1a54535496a6274526:
    • Two commits, each with one parent: 5743d468fc (fix) and 8c0243b10f (changeset). There are no merge commits, the old head is an ancestor, and the base is still merge-base 886e97073d.
    • The delta is 3 files, +87/-9.
  • Shape (l1-face.mjs --pr 37220, CLEAN, 13 items):
    • The PR is open, a draft, and based on main, with first line Fixes #36822. No closing keyword binds any other card.
    • One patch changeset covers @object-ui/plugin-detail. Clause-②: no and Metadata-protocol: none are unchanged and correct.
  • Check-runs at 8c0243b10f: 59 total, 44 success, 15 expected skips, 0 failed, 0 pending.
    • Lint & Repo Gates, TypeScript Type Check, Type Check UI, Test UI (aggregate plus shards 1–13) and Build & E2E UI are all success.
  • K = 17. git merge-tree against origin/main d7f299c0b1 is clean, and main has not touched RelatedList.tsx since the merge-base.
  • My own reading: in a throwaway worktree at this head, the pin file gives Tests 7 passed (7).
  • M1 — CLOSED.
    • The render-derived readSettled effect is gone, and countKnown is now state declared beside loadFailure (line 1524).
    • It is set to true in the three resolve paths: the seeded read, dataSource.find and the raw URL. It is set to false in all three reject paths, each after the cancelled check.
    • New pin: rows, then a failed refetch, then Retry held → headBadge() is null, then 0.
    • Ablation A1, all three setCountKnown(false) dropped: 1 failed | 6 passed, expected '0' to be null, on the Retry pin only.
  • S1 (old) — CLOSED as ruled.
    • The !canScope return, filterRefusal and the two no-adapter refusals never set countKnown. New pin: parentId null, then the parent → the held first read draws null, then 2.
    • Ablation A3, setCountKnown(true) added to the !canScope return: 1 failed | 6 passed, expected '0' to be null, on that pin only.
    • Ablation A2, the prior head's RelatedList.tsx (adfe349594) under the new pins: 2 failed | 5 passed. Both new pins go red, so they catch exactly the two prior findings.
    • The original pin still holds. Ablation A4 drops !countKnown from countPending and gives 1 failed | 6 passed, expected null to be '0', on the 0-refetch pin.
  • M2 — CLOSED, except on the S1 path below.
    • The changeset now says that once a read the list issued has answered, the count is known and a reload keeps drawing it. That is true except on the S1 path.
    • "A read that fails forgets the count, so its Retry draws no count until it answers" is true, per the A1 pin.
    • "A list's first read, including one that starts only once its parent record has loaded, still draws no count while it is in flight" is true, per the A3 pin.
    • The 速读 「第一次加载还没结果时、加载失败后点重试时,仍不显示数字」 is true. The pre-existing no-scope 0 before the first read is disclosed in the Acceptance notes.
  • N1 — CLOSED. The Tests section now says the held-frame assertion carries the pin, and that the MutationObserver is a secondary sampler that coalesces commits within one task.
  • S1 (should-fix) — a path that empties the rows without reading still leaves an earlier count "known". The next parent's in-flight read then draws a false 0, which main does not draw.
    • The !canScope early return (and, the same way, the two no-adapter refusal arms) runs setRelatedData([]) but not setCountKnown(false). This is the same reasoning the new comment gives for the reject paths: "the rejection empties the rows, and 0 is not their count".
    • It is reachable when a mounted list's parent reloads through no scope. record-related-list.tsx:308 resolves parentLinkValue to null while ctx.data loads whenever relationshipValueField is not id, and the list carries no key.
    • L1 probe (pr-37220/RelatedList.l1probe-37220.test.tsx): ACC-1 answers 2 rows (badge 2), then parentId null, then ACC-2 with its read held.
      • At head: {"duringNull":"0","inFlight":"0"}.
      • Main's RelatedList.tsx in the same tree: {"duringNull":"0","inFlight":null}.
    • That makes the Acceptance note "a reparented list keeps drawing its last count during the new read" false on this path. It also falsifies the changeset's "keeps drawing that count until the new one lands" and the 速读 「刷新期间角标显示上一次成功加载的数字」. The badge draws 0, not 2.
    • Fix: setCountKnown(false) next to setRelatedData([]) in the !canScope return and in both no-adapter refusal arms. Add a pin for the known → null → new-parent case with an ablation reading.
  • N2 — The zone note says check-runs are "42 success, 13 skipped" at this head. The live count is 44 success and 15 expected skips (the extra skips include Plan Test Core shards, Build Core and the queue verdicts). This is a copy slip in the note and has no effect on the verdict.
  • N3 — The labels documentation and tooling carry over from the auto-labeler (old N2), unchanged.
  • Overlap with fix(plugin-detail): a related table in the record preview drawer draws instead of looping on its column cap #37244 (head 1cb2c044f0), both touching RelatedList.tsx:
  • Test evidence: logs are under scratchpad/pr-37220/: test-head.log, the four abl-*.log files, probe-head.log, probe-base.log and test-combined.log.

This branch has not been deployed

No deployments
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 tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

相关列表:重新加载后结果为 0 条时,数量角标会短暂消失,而不是显示 0

2 participants