Repository navigation
Commit 31eb2ae
fix(plugin-grid): report a rejected aggregate bulk action as one outcome and refresh the list (#34213)
<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi9FjkKnUT9gkJCgXLZMd3GkS)_
Fixes #34173
Clause-②: yes (widening) — optional member userMessage on ActionResult
(@object-ui/types) and ActionResponseOutcome (@object-ui/core); nothing
removed or renamed
Metadata-protocol: none
## 维护者速读
- **改了什么**:选择栏里「整体执行」(`execution:
'aggregate'`)的批量动作被拒时,结果框只说一次「操作未对所选记录全部完成」,并只显示一次处理器写给用户的提示(`userMessage`,没有就用
`message`);不再逐行重复同一句报错,也不再显示「成功 0 /
N」。关掉结果框后列表会重新读取,被改过的记录显示新值。逐条执行的批量动作显示完全不变。
- **为什么改**:HotCRM 实测:选两个商机批量改阶段,一个已赢单被拒、另一个其实改了,结果框却说
0/2、每行都是平台报错,列表也不刷新,销售看不出哪条动了。
- **风险与回滚**:只影响 aggregate
批量动作的结果框和关闭后的刷新;`ActionResult`(`@object-ui/types`)和
`ActionResponseOutcome`(`@object-ui/core`)各多一个可选字段 `userMessage`。回滚即
revert 本 PR。
-
**先看**:`ui/packages/plugin-grid/src/hooks/useBulkExecutor.ts`(aggregate
一次结算、一个结果);`ui/packages/plugin-grid/src/components/BulkActionDialog.tsx`(结果框的
aggregate 分支);`ui/packages/plugin-grid/src/ObjectGrid.tsx`(拒绝时带上
`userMessage`、关闭时刷新)。
- **两分钟验证**:`pnpm --dir ui exec vitest run
packages/plugin-grid/src/__tests__/objectBulkActionDispatch.test.tsx`,预期全绿,其中
`an aggregate rejection is one outcome for the selection` 组 5 条。
- **需要你做的**:无,席位落地。
## What changes
A rejected aggregate bulk run is ONE outcome for the selection. The one
call cannot say which rows it wrote before it stopped (a
non-transactional body can move some rows and then reject once), so the
result no longer pretends to a per-row count.
- `useBulkExecutor`: an `execution: 'aggregate'` def no longer rides the
bulk-first decision tree. It makes its one `runAggregate` call;
resolved, every row counts as covered (unchanged); rejected, the result
carries `aggregateRejection: { message }`, where `message` is
`declaredUserMessage(error)` (the producer-marked `userMessage`) else
the error's own message, and `errors` gets no per-row entry. A rejected
run also invalidates the resource's cached related counts, as a
successful one does. `BulkResult` is not exported from the package.
- `BulkActionDialog`: for a result with `aggregateRejection`, the panel
says the action did not complete for the selected records (new key
`grid.bulk.aggregateNotCompleted`) and shows the message once. No
"Succeeded x / N", no per-row list, no error CSV, no Retry. Every other
result renders exactly as before.
- `ObjectGrid`: the aggregate dispatcher rejects with an `Error` whose
`message` is `ActionResult.error` and which carries
`ActionResult.userMessage` when present. On dialog close, a result with
`aggregateRejection` bumps `refreshKey`, the same refresh path the
per-row run already takes when rows succeeded; the selection stays,
ready for a re-run. A resolved aggregate run keeps its existing refresh,
which happens once.
- The carrier: `interpretActionResponse` reads the refusal's
`error.userMessage` (ADR-0112 envelope; non-empty string only, verbatim)
onto `ActionResponseOutcome.userMessage`, and
`createServerActionHandler` relays it on the failed
`ActionResult.userMessage`. `error` stays the whole text, so every
existing reader of `error` (toasts, the per-row list) is unchanged. The
reader `refusalUserMessage` stays off the package's public entry.
- i18n: `grid.bulk.aggregateNotCompleted` in all eleven packs (`zh-Hant`
regenerated with `gen-zh-hant.mjs`). The sentence has no `{{count}}`, so
it is not a plural family.
- Docs: `content/docs/ui/views.mdx` says what the dialog shows for a
rejected aggregate run and when the list re-reads.
## Tests
- `objectBulkActionDispatch.test.tsx`, new top-level describe `an
aggregate rejection is one outcome for the selection
(objectstack#34173)`, driven through the real `script` dispatch
(`createServerActionHandler`) and the `/actions` door's refusal
envelope:
- the rejection's `userMessage` shows once; the platform `message` is
absent; zero `bulk-error-row-*`; no "Succeeded" and no "0 / 2" text;
- with no `userMessage`, the `message` shows once;
- the grid's `find` runs exactly once after Done following a rejection,
and exactly once following a resolve;
- CONTROL: a per-record dispatch (`bulkActions: ['mass_update_stage']`)
with one refused row still reads "Succeeded 1 / 2" and lists
`bulk-error-row-r2` with the row's error text.
- `useBulkExecutor.test.ts`: a rejection is one `aggregateRejection`
with `errors: []`; it reports `userMessage` over `message`; a resolved
call carries no rejection.
- `serverActionHandler.test.ts`, new describe `userMessage relay`:
relayed verbatim beside `error`; absent when unmarked; a blank, numeric
or object value is no marking.
- **Forced test edits** (each pinned the behaviour this card calls the
defect):
- `useBulkExecutor.test.ts` "attributes a failed aggregate call to every
id with the real error — no per-record re-dispatch" is now "a failed
aggregate call is one outcome for the selection — no per-id error, no
per-record re-dispatch".
- `useBulkExecutor.test.ts` "fails loudly when no runAggregate is
wired…" now reads the message from `aggregateRejection` instead of
`errors[0]`.
- `objectBulkActionDispatch.test.tsx` "attributes a failed aggregate
call to every record, with no per-row Retry" is now "reports a failed
aggregate call once for the selection, with no per-row list and no
Retry".
## Acceptance notes
- **File surface beyond the claim, declared:**
`ui/packages/plugin-grid/src/ObjectGrid.tsx` (the dialog's mount, and
the per-row refresh path the order says to reuse lives there);
`ui/packages/types/src/ui-action.ts` (`ActionResult.userMessage`, the
carrier from the script dispatch to the grid);
`content/docs/ui/views.mdx` (ui commandment 2, docs-driven); all eleven
locale packs, because `all-locales-key-parity.test.ts` requires every
pack to define every `en` key, so "let other locales fall back" is not
available in this pack.
- **Public face for the seat to judge:** two optional members on
published types, `ActionResult.userMessage` (`@object-ui/types`) and
`ActionResponseOutcome.userMessage` (`@object-ui/core`). No new exported
name. Precedent: `ActionResult.fieldErrors`, the same relay of the same
refusal envelope. The seat ruled the declaration `Clause-②: yes
(widening)` (a non-protocol widening, so the changeset stays `patch`);
the PR body and the changeset carry it since head 3f829b5.
- **Card ask 3 (a per-row result shape for aggregate handlers) is still
needed** for a truthful per-row count: with this PR the dialog no longer
states a false count, but it still cannot say which rows moved. That is
an action-contract change in `packages/spec`, out of scope here.
- **Same class, left unchanged as ordered:** a per-record bulk row
refused with a `userMessage` still lists the row's `error` (the platform
message), and the single-record action toast reads `error` too. With
`ActionResult.userMessage` now carried, preferring it there is a small
follow-up. The CONTROL pin above shows the current per-row text.
- The list re-reads when the dialog closes (the path the per-row run
uses), not at the instant the call settles; the dialog is modal over the
grid.
- Out of scope, as the card says: a script action body gets no locale in
`ctx.session` (the #34062 class).
## Verification
<details><summary>Measured on main 75ab117 before the fix: all three
symptoms, script dispatch</summary>
A probe test drove the real `ObjectGrid` with
`createServerActionHandler`; the `/actions` answer was `400 { success:
false, error: { code: 'HOOK_ABORTED', message: 'mass_update_stage: Plan
B is Closed Won', userMessage: 'Plan B is Closed Won and was not moved.'
} }`:
```text
PROBE[reject] dialog text: "Update StageSucceeded 0 / 2 · Failed 2 … Plan A: mass_update_stage: Plan B is Closed WonPlan B: mass_update_stage: Plan B is Closed Won Download error CSV Done"
PROBE[reject] actions POSTs: 1 error rows: 2
PROBE[reject] find calls on Done: 0
PROBE[resolve] dialog text: "Update StageSucceeded 2 / 2 … • Plan A• Plan B Done"
PROBE[resolve] find calls on Done: 1
```
The wire for both handler shapes, read from `actionsDoorAnswerOf`
(`@objectstack/types` dist on the same tree): a script body's sandboxed
throw and a server action's plain throw both answer `userMessage` beside
`message`:
```text
script-body {"status":400,"code":"HOOK_ABORTED","message":"Plan B is Closed Won","userMessage":"Plan B is Closed Won and was not moved."}
server-handler {"status":400,"code":"VALIDATION_ERROR","message":"Plan B is Closed Won","userMessage":"Plan B is Closed Won and was not moved."}
```
The client then dropped `userMessage` in `interpretActionResponse` /
`actionErrorDetail`, which read `error.message` only.
</details>
<details><summary>Ablation: five legs, each red, restored clean
(scripts/ablation-replace.mjs, anchors hit 1 → 0)</summary>
Committed fix first (7cf6c65); each leg mutated one line and ran the
three touched test files; the trap restored `git checkout HEAD --
ui/packages` and printed `RESTORED-CLEAN`. Tests resolve `@object-ui/*`
from source, so no dist rebuild was involved.
- `useBulkExecutor.ts` `declaredUserMessage(e)` → `null`: red "shows the
rejection's userMessage once…" and "the rejection reports its
producer-marked userMessage, not its message".
- `ObjectGrid.tsx` the rejection refresh branch disabled: red "re-reads
the grid once when the dialog closes after a rejection".
- `BulkActionDialog.tsx` per-row branch guard removed
(`!result.aggregateRejection`): red "shows the rejection's userMessage
once, with no per-row list and no "0 / N" count".
- `serverActionHandler.ts` `userMessage` relay removed: red "relays
error.userMessage verbatim…" and the dialog userMessage pin.
- `useBulkExecutor.ts` aggregate branch disabled: red across both
aggregate describes (11 tests).
</details>
<details><summary>Local runs on head 2ee839f (main 571cf90
merged)</summary>
Head 3f829b5 changes only the changeset's Clause-② line; on it
`check-changeset-no-major`, `check-empty-changeset`,
`check-adr-0087-registration` (each `--base origin/main`),
`check:changeset-gate-self-tests` and `check:nul-bytes` re-ran, exit 0
each.
- Type-check (`pnpm run type-check`, tsc echoed): `@object-ui/types`,
`@object-ui/core`, `@object-ui/i18n`, `@object-ui/plugin-grid` — each
exit 0.
- Whole packages: `pnpm exec vitest run packages/plugin-grid/
packages/types/ packages/i18n/ packages/core/src/actions/` — Test Files
830 passed (830), Tests 15603 passed, 13 skipped. Lock VERDICT
command-exit 0.
- Wider readers, narrowed by grep for the changed symbols and testids
under `ui/packages` and `ui/apps` (declared narrowing; CI's Test UI runs
everything): 12 files in components, app-shell and console — Test Files
12 passed, Tests 466 passed.
- `check:i18n-keys`, `check:i18n-drift`, `check:i18n-dead-keys` (ui):
exit 0 each.
- `node scripts/pm/dispatch-gates.mjs --commands`: 72 derived families,
all exit 0; `--ran` reconciliation: 72 derived, 72 run, 0 NOT-MEASURED,
0 UNRUN.
- Dogfood battery: not run — no `!` in the title and no `(narrowing)`
arm.
</details>
<!-- signed: domain:ui#1 · os-steve · session_01ADHkmRD9ZdCE9G3z9FgtCj
-->
---------
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>1 parent adccc24 commit 31eb2ae
22 files changed
Lines changed: 367 additions & 71 deletions
File tree
- .changeset
- content/docs/ui
- ui/packages
- core/src/actions
- __tests__
- i18n/src/locales
- plugin-grid/src
- __tests__
- components
- hooks
- types/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
262 | 274 | | |
263 | 275 | | |
264 | 276 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| |||
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| 134 | + | |
129 | 135 | | |
130 | 136 | | |
131 | 137 | | |
132 | 138 | | |
133 | 139 | | |
134 | 140 | | |
| 141 | + | |
135 | 142 | | |
136 | 143 | | |
137 | 144 | | |
138 | 145 | | |
139 | 146 | | |
140 | 147 | | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
141 | 164 | | |
142 | 165 | | |
143 | 166 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
308 | 309 | | |
309 | 310 | | |
310 | 311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
589 | 589 | | |
590 | 590 | | |
591 | 591 | | |
| 592 | + | |
592 | 593 | | |
593 | 594 | | |
594 | 595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
543 | 543 | | |
544 | 544 | | |
545 | 545 | | |
| 546 | + | |
546 | 547 | | |
547 | 548 | | |
548 | 549 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1039 | 1039 | | |
1040 | 1040 | | |
1041 | 1041 | | |
| 1042 | + | |
1042 | 1043 | | |
1043 | 1044 | | |
1044 | 1045 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
558 | 558 | | |
559 | 559 | | |
560 | 560 | | |
| 561 | + | |
561 | 562 | | |
562 | 563 | | |
563 | 564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
553 | 553 | | |
554 | 554 | | |
555 | 555 | | |
| 556 | + | |
556 | 557 | | |
557 | 558 | | |
558 | 559 | | |
| |||
0 commit comments