Repository navigation
Commit 47b6392
fix(core): a declared action's confirm dialog names the action (#26663)
<!-- claude-projects-attribution: {"github_login":"zhuangjianguo"} -->
_Requested by **Steedos** · [project
thread](https://claude.ai/code/project/chan_018ETKaNwMZCNRYD7D8Q9Ubb?thread=cmsg_018ETKaNwMZCNRYD7D8Q9UbbMRFuRAeCbsTfQZ2W3U1Pq6)_
Fixes #26580
Clause-②: no
Metadata-protocol: none
## 维护者速读
- **改了什么**:点一个声明了 `confirmText`
的动作时,确认框的标题和确认按钮现在显示动作自己的名字(如「标记为赢单」),`variant: 'danger'`
的动作确认按钮变成红色危险样式。以前一律是「确认操作」+ 中性的「继续」。
- **为什么改**:用户在确认框里看不出自己确认的是哪个动作,危险操作也没有危险提示;Record Delete 早已这样做,声明式动作没有。
- **风险与回滚**:低。只改 `ActionRunner` 的一个调用点,把已有的 `options`
参数传给已有的确认处理器;没有新键。另在 ui 门禁 `check-action-forward-parity` 的豁免表加四条(四个
action 渲染器的 `variant` 是按钮样式词表,不转给 runner)。回滚即 revert 本 PR。
- **先看**:`ui/packages/core/src/actions/ActionRunner.ts` 的确认调用点与新的
`confirmOptions`;`ui/packages/core/src/actions/__tests__/ActionRunner.confirmNamesAction-26580.test.ts`;`ui/scripts/check-action-forward-parity.mjs`
新增的四条 JUSTIFIED。
- **两分钟验证**:`cd ui && pnpm exec vitest run
packages/core/src/actions/__tests__/ActionRunner.confirmNamesAction-26580.test.ts`,预期
5 个用例全绿;或在控制台点一个带确认文案的危险动作,确认框标题是动作名、按钮是红色的动作名。
- **需要你做的**:无,席位落地。
## What changes
`ActionRunner` asked its `ConfirmationHandler` with the confirm message
alone, so the console's `ActionConfirmDialog` always fell back to its
generic `actionConfirm.title` / `actionConfirm.confirm` copy ("Confirm
Action" / "Continue", 「确认操作」 / 「继续」), and a `variant: 'danger'` action
confirmed through a neutral button.
The runner now fills the handler's existing `options` bag from what the
action already declares (no new key, per triage comment 6437776331):
- `title` and `confirmText` are the action's `label`. Every console
surface resolves the label against the locale's bundle before dispatch
(`useActionTextLocalizer`), so the runner receives the localized string.
- `destructive: true` when the action declares the spec's `variant:
'danger'` (`ActionSchema.variant`,
`packages/spec/src/ui/action.zod.ts`), the same flag the record Delete
passes, which paints the confirm button with `buttonVariants({ variant:
'destructive' })`.
- The cancel button keeps the host's copy. An action with neither a
label nor the danger variant is asked with the message alone, exactly as
before.
`ActionConfirmDialog.tsx` and `useConsoleActionRuntime` needed no
change: both already forward and render `title`, `confirmText` and
`destructive`. The `ConfirmationHandler` type is unchanged; its doc
comment now names the runner as one of the bag's producers.
Where the danger-to-destructive styling lives: the runner turns the
spec's `variant: 'danger'` into the handler's `destructive: true`
(`confirmOptions` in `ui/packages/core/src/actions/ActionRunner.ts`).
The dialog turns `destructive` into the style: `ActionConfirmDialog.tsx`
sets the confirm button's `className` to `buttonVariants({ variant:
'destructive' })` from `@object-ui/components` (unchanged since
objectui#11695). No other mapping is added.
**Gate table, one file outside the first claim (claim amended, comment
6440643307).** The runner now reads `action.variant`, so
`ui/scripts/check-action-forward-parity.mjs` owed `variant` on
`action:button`, `action:icon`, `action:group` and `action:menu`. Those
renderers' `variant` is `@object-ui/types`' `UIActionSchema.variant`,
the button-style vocabulary (`default | primary | secondary |
destructive | outline | ghost`), consumed at the renderer; the runner
reads the spec enum on `ActionDef` (`primary | secondary | danger |
ghost | link`). Forwarding it raw does not type-check and carries no
`danger`, so the four omissions are JUSTIFIED entries (issue 26580), not
forwards. The vocabulary gap itself is left open; see Acceptance notes.
## Tests
- New
`ui/packages/core/src/actions/__tests__/ActionRunner.confirmNamesAction-26580.test.ts`
(5 tests): a labelled action passes `{ title, confirmText }`; a labelled
danger action adds `destructive: true`; a labelless danger action passes
`{ destructive: true }` only; a CONTROL action with neither is called
with the message alone; a cancel still stops the run.
- Ablation (one-off, not kept): `scripts/ablation-replace.mjs` replaced
`this.confirmHandler(confirmMessage, confirmOptions)` with
`this.confirmHandler(confirmMessage)` (anchor 1 to 0, blob
`888cfb538c5d` to `926b95771ab6`). The new file went red: Tests 3
failed, 2 passed (the CONTROL and the cancel case stay green, as
expected). Restored to the HEAD blob with `git diff HEAD` empty.
- The test imports the runner from source (`../ActionRunner`), so no
`dist/` rebuild sits between the mutation and the run.
## Acceptance notes
- The existing one-argument pins (`ActionRunner.test.ts` "should show
confirmation", `ActionRunner.callContext-13063.test.ts`) use actions
with no label, so they still hold unchanged; that is the CONTROL path.
- The confirm button repeats the action's label, as triage asked. A
surface whose action reaches the runner without a label still shows the
generic chrome.
- Open, not built here: an `action:button` / `action:icon` /
`action:group` / `action:menu` node styled `variant: 'destructive'` (the
`UIActionSchema` spelling) gets a neutral confirm button, because the
runner reads only the spec's `danger`. Closing it needs a decision on
the two vocabularies (map one onto the other, or retire one); it is
reported to the seat as an open question. Declared actions dispatched by
the console's spread-based hosts (`DeclaredActionsBar`, `page:header`'s
`dispatchHeaderAction`) carry the declaration's own spec `variant` and
are covered.
## Verification
All readings at head `84482207` unless named. The core suite and
type-check ran at `88581363`; the later commit touches only
`ui/scripts/check-action-forward-parity.mjs`, so they still hold.
<details><summary>Touched package: @object-ui/core</summary>
- `bash scripts/pm/os-verify-lock.sh -c 'cd ui && pnpm exec vitest run
packages/core/ --maxWorkers=2'` (after `--filter '@object-ui/core^...'
build`): Test Files 214 passed (214), Tests 4105 passed, 27 skipped;
VERDICT command-exit 0.
- `pnpm --filter @object-ui/core run type-check` (`tsc --noEmit && tsc
-p tsconfig.test.json`, so the tests are covered): exit 0.
</details>
<details><summary>ui scripts suite and the forward-parity gate</summary>
- `node ui/scripts/check-action-forward-parity.mjs`: exit 0
(action:button owes 29, forwards 25; icon, group, menu owe 29, forward
23; payloads excess-property CHECKED).
- `pnpm --dir ui exec vitest run scripts/` under the lock, after
`--filter '@object-ui/app-shell^...' build`: Test Files 178 passed, 2
skipped (180); Tests 5065 passed, 2 skipped. Before the JUSTIFIED
entries it was red on `check-action-forward-parity.test.ts > the real
repository > is green` (the four `variant` drops); the run before the
closure build also failed `unit-registry-absence-collision.test.ts` on
unbuilt workspace packages, a prerequisite, green after the build.
</details>
<details><summary>Derived gates: 34 of 34, all exit 0</summary>
`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` at `84482207` derived 34 commands from 4
changed paths; each ran with its exit code captured before any pipe (the
PR-body gates read this body through `GITHUB_EVENT_PATH`;
`check:type-check-debt` under the lock). Reconciliation: `--ran`
answered "34 derived famil(ies) accounted for — 34 run, 0 NOT-MEASURED
(a DERIVED zero — all 34 recorded an exit code and none of them is 3)".
`check-partof-closing-keyword.mjs` on this body: exit 0.
</details>
Dogfood battery: not owed (no `!` in the title, no `(narrowing)` arm).
---
_Generated by [Claude
Code](https://claude.ai/code/session_01QsR2jSVZrd3f8WgEZrkUCu)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a71564f commit 47b6392
4 files changed
Lines changed: 152 additions & 8 deletions
File tree
- .changeset
- ui
- packages/core/src/actions
- __tests__
- scripts
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
547 | 547 | | |
548 | 548 | | |
549 | 549 | | |
550 | | - | |
551 | | - | |
552 | | - | |
553 | | - | |
554 | | - | |
555 | | - | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
| 555 | + | |
| 556 | + | |
| 557 | + | |
556 | 558 | | |
557 | | - | |
| 559 | + | |
558 | 560 | | |
559 | 561 | | |
560 | 562 | | |
| |||
1533 | 1535 | | |
1534 | 1536 | | |
1535 | 1537 | | |
| 1538 | + | |
| 1539 | + | |
| 1540 | + | |
| 1541 | + | |
| 1542 | + | |
1536 | 1543 | | |
1537 | 1544 | | |
1538 | | - | |
| 1545 | + | |
| 1546 | + | |
| 1547 | + | |
| 1548 | + | |
1539 | 1549 | | |
1540 | 1550 | | |
1541 | 1551 | | |
| |||
1865 | 1875 | | |
1866 | 1876 | | |
1867 | 1877 | | |
| 1878 | + | |
| 1879 | + | |
| 1880 | + | |
| 1881 | + | |
| 1882 | + | |
| 1883 | + | |
| 1884 | + | |
| 1885 | + | |
| 1886 | + | |
| 1887 | + | |
| 1888 | + | |
| 1889 | + | |
| 1890 | + | |
| 1891 | + | |
| 1892 | + | |
| 1893 | + | |
| 1894 | + | |
| 1895 | + | |
| 1896 | + | |
| 1897 | + | |
| 1898 | + | |
1868 | 1899 | | |
1869 | 1900 | | |
1870 | 1901 | | |
| |||
| 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 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
305 | 305 | | |
306 | 306 | | |
307 | 307 | | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
308 | 329 | | |
309 | 330 | | |
310 | 331 | | |
| |||
0 commit comments