Repository navigation
Commit dfdebfa
fix(plugin-detail): a related list that already shows 0 keeps showing 0 while it reloads (#37220)
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. The paths among those that empty the
rows without reading (the no-scope return and both no-adapter refusals)
also set it back to false, so an earlier count does not survive them.
Result:
- a refetch over a list that already answered 0 keeps drawing 0 instead
of blanking the badge;
- a failed read forgets the count, so Retry's read draws no count, never
a false 0;
- a parent that reloads through no scope forgets the count too, so the
new parent's read draws no count, never a false 0;
- a list's first real read, including one that starts only once the
parent has loaded, draws nothing while in flight (the #36235 rule);
- a list that answered rows behaves as before.
- Pins: a new top-level `describe` for #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, read after a scope loss).
## Two-minute check
`cd ui && pnpm exec vitest run
packages/plugin-detail/src/__tests__/RelatedList.countPending-36235.test.tsx`
— expect 8 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`.
- `a list whose parent reloads through no scope draws no count during
the new parent's read`: `ACC-1` answers 2 rows (badge `2`), then
`parentId` null (no read), then `ACC-2` with its read held: no badge on
that frame, then `1`.
- The #36235 pins (first read draws nothing, CONTROL empty read draws 0,
compact card) stay green.
<details><summary>Readings (head 8bfd2f7, origin/main merged at
83585e7)</summary>
- Pin file: `Test Files 1 passed (1)`, `Tests 8 passed (8)`.
- Full plugin-detail suite (`cd ui && pnpm exec vitest run
packages/plugin-detail/`): `Test Files 418 passed | 1 skipped (419)`,
`Tests 3951 passed | 18 skipped (3969)`, exit 0.
- `pnpm --filter @object-ui/plugin-detail run type-check`: exit 0 (the
test file is in the `tsconfig.test.json` program).
- Ablations with `scripts/ablation-replace.mjs`. Each mutation landed
(anchor 1 to 0) and was restored to blob == HEAD with `git diff HEAD`
empty.
- Round 1, at `1426a1d54928`:
- A1: `!countKnown` dropped from `countPending`. The 0-refetch pin fails
on the held frame (`expected null to be '0'`).
- A2: `setCountKnown(false)` removed from the `find` rejection. The
Retry pin fails (`expected '0' to be null`).
- A3: `setCountKnown(true)` added to the no-scope early return. The
first-scoped-read pin fails (`expected '0' to be null`).
- Each run read `1 failed | 6 passed (7)`.
- Round 2, at `c6a0a1451618`:
- A4: `setCountKnown(false)` removed from the no-scope early return. The
scope-loss pin fails (`expected '0' to be null`), `1 failed | 7 passed
(8)`.
- A1, re-run: the 0-refetch pin fails (`expected null to be '0'`), `1
failed | 7 passed (8)`.
- The N-rows pin stays green under every mutation. That is expected,
since that behaviour held before the fix.
</details>
## Acceptance notes
- `countKnown` is not reset when the parent or the list's filter changes
directly, from one scope to the next: such a list keeps drawing its last
count during the new read, as it already did when its last answer had
rows. A parent that reloads through no scope (`parentId` null while the
parent record loads) empties the rows without reading and forgets the
count, so the new parent's read draws nothing.
- 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](https://claude.ai/code/session_01QSeKYmRepQK9DkZeU7F53D)_
<!-- signed: repo:objectstack#4 · os-justin ·
session_01QSeKYmRepQK9DkZeU7F53D -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ff04943 commit dfdebfa
3 files changed
Lines changed: 197 additions & 1 deletion
File tree
- .changeset
- ui/packages/plugin-detail/src
- __tests__
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1515 | 1515 | | |
1516 | 1516 | | |
1517 | 1517 | | |
| 1518 | + | |
| 1519 | + | |
| 1520 | + | |
| 1521 | + | |
| 1522 | + | |
| 1523 | + | |
| 1524 | + | |
| 1525 | + | |
| 1526 | + | |
1518 | 1527 | | |
1519 | 1528 | | |
1520 | 1529 | | |
| |||
2249 | 2258 | | |
2250 | 2259 | | |
2251 | 2260 | | |
| 2261 | + | |
| 2262 | + | |
2252 | 2263 | | |
2253 | 2264 | | |
2254 | 2265 | | |
| |||
2280 | 2291 | | |
2281 | 2292 | | |
2282 | 2293 | | |
| 2294 | + | |
2283 | 2295 | | |
2284 | 2296 | | |
2285 | 2297 | | |
2286 | 2298 | | |
2287 | 2299 | | |
2288 | 2300 | | |
2289 | 2301 | | |
| 2302 | + | |
2290 | 2303 | | |
2291 | 2304 | | |
2292 | 2305 | | |
| |||
2380 | 2393 | | |
2381 | 2394 | | |
2382 | 2395 | | |
| 2396 | + | |
2383 | 2397 | | |
2384 | 2398 | | |
2385 | 2399 | | |
| |||
2389 | 2403 | | |
2390 | 2404 | | |
2391 | 2405 | | |
| 2406 | + | |
2392 | 2407 | | |
2393 | 2408 | | |
2394 | 2409 | | |
| |||
2406 | 2421 | | |
2407 | 2422 | | |
2408 | 2423 | | |
| 2424 | + | |
2409 | 2425 | | |
2410 | 2426 | | |
2411 | 2427 | | |
| |||
2432 | 2448 | | |
2433 | 2449 | | |
2434 | 2450 | | |
| 2451 | + | |
2435 | 2452 | | |
2436 | 2453 | | |
2437 | 2454 | | |
| |||
2451 | 2468 | | |
2452 | 2469 | | |
2453 | 2470 | | |
| 2471 | + | |
2454 | 2472 | | |
2455 | 2473 | | |
2456 | 2474 | | |
2457 | 2475 | | |
2458 | 2476 | | |
2459 | 2477 | | |
2460 | 2478 | | |
| 2479 | + | |
2461 | 2480 | | |
2462 | 2481 | | |
2463 | 2482 | | |
| |||
4032 | 4051 | | |
4033 | 4052 | | |
4034 | 4053 | | |
4035 | | - | |
| 4054 | + | |
| 4055 | + | |
| 4056 | + | |
| 4057 | + | |
| 4058 | + | |
4036 | 4059 | | |
4037 | 4060 | | |
4038 | 4061 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
134 | 134 | | |
135 | 135 | | |
136 | 136 | | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
0 commit comments