Repository navigation
Commit a1d0b1e
fix(console): a settings action whose handler declares confirmText asks before invoking (#30470)
<!-- claude-projects-attribution: {"github_login":"os-sales"} -->
_Requested by **Sales** · [project
thread](https://claude.ai/code/project/chan_01D5bWFY3rFzgJcytD5gD4Uu?thread=cmsg_01D5bWFY3rFzgJcytD5gD4UuXpPPZiBKyj1HzrdQ6La3ZH)_
domain:ui#6 · os-sales · session_01L6bhgUR8Nu4M7tbtgES7q2
Fixes #30419
Clause-②: no
Metadata-protocol: none
## 维护者速读
- 改了什么:设置页的操作按钮(`action_button`)若在 manifest 里声明了
`confirmText`,点击后先弹出确认框显示该文字;取消则什么都不执行,确认才执行一次。未声明的按钮行为不变。
- 为什么改:spec 早已声明「执行前确认」(`SpecifierHandlerSchema` 的 `http` / `action`
两臂),但控制台从不读取,作者标记为需确认的危险操作一点就跑(声明 ≠ 兑现)。
- 风险与回滚:仅改控制台一个渲染分支,复用现有 `AlertDialog` 原语与已有 `actionConfirm.*`
文案键,不加新组件、不加新 locale 键;回滚即 revert 本 PR。
- 先看:`ui/apps/console/src/pages/settings/SettingsField.tsx` 的
`action_button` 分支(`declaredConfirm` 一段);其次新测试
`SettingsField.actionConfirm.test.tsx`。
- 两分钟验证:`pnpm --dir ui exec vitest run
apps/console/src/pages/settings/__tests__/SettingsField.actionConfirm.test.tsx`,预期
11 passed。
- 需要你做的:无,席位落地。
## What changes
- `SettingsField`'s `action_button` row reads the handler's declared
`confirmText` (the spec's `SpecifierHandlerSchema` `http` / `action`
arms: "Confirm dialog text before invoking (omit = no confirm)").
- Declared (judged `confirmText != null`, the same test the spec's
action resolver applies when it decides an action opens a dialog): the
button becomes the trigger of the console's existing `AlertDialog`
primitive from `@object-ui/components` (the one the Approvals Inbox
confirms with). The dialog body is the text resolved the way this file
resolves the row's other manifest copy: `labels.actionConfirm(actionId,
resolveLabel(confirmText))`, i.e. the already-existing, until now unread
`settings.NAMESPACE.actions.ID.confirmText` slot with the manifest
literal as fallback. Title / Cancel / Continue reuse the shared
`actionConfirm.*` keys `ActionConfirmDialog` uses, so no locale key is
added. Cancel invokes nothing; Continue invokes `onAction` once.
- Not declared, and a `navigate` handler (which has no such key): the
button is rendered exactly as before, `onClick={onAction}`, no dialog.
- Outside the source-badge / reset-to-default region; no `packages/**`
change; no change to the `types.ts` mirror.
## Tests
New
`ui/apps/console/src/pages/settings/__tests__/SettingsField.actionConfirm.test.tsx`
(11 tests):
- for an `http` and an `action` handler with `confirmText`: click opens
an alertdialog carrying the text and invokes nothing; Cancel closes it
and invokes nothing; Continue invokes exactly once;
- the `actions.ID.confirmText` translation is what the dialog shows, and
the helper is asked with the manifest literal as fallback;
- no `confirmText` (`http`, `action`), a `navigate` handler, and no
handler: click invokes once, no dialog.
## Acceptance notes
- The settings mirror (`types.ts`) types `confirmText` as a plain string
while the spec declares an `I18nLabel` (string or inline locale map).
The same mirror gap already holds for every specifier `label` here
(`resolveLabel` reads a string or a `defaultValue`/`key` object, not an
inline locale map). This PR keeps that resolution unchanged; because the
dialog opens on the declaration, not on the resolved text, an inline-map
`confirmText` still asks (with the generic title) rather than running
unasked. Not filed: observation, no reach measured.
## Verification
All readings on `objectstack-ai/objectstack`, branch head `470a4eb5`
(tests run at `21978cf3`; the only later commit adds the changeset).
<details><summary>Positive control: the declared-confirm tests fail on
main's SettingsField</summary>
`git restore --source=677ac3bb --
ui/apps/console/src/pages/settings/SettingsField.tsx` (trap-restored
from HEAD, hash re-compared after), then `pnpm --dir ui exec vitest run
--reporter=verbose
apps/console/src/pages/settings/__tests__/SettingsField.actionConfirm.test.tsx`:
```
Tests 7 failed | 4 passed (11)
os-verify-lock: VERDICT command-exit 1
```
The 7 failures are exactly the declared-confirm cases (http x3, action
x3, translation); the 4 undeclared cases pass on main, as they must.
</details>
<details><summary>With the fix</summary>
```
pnpm --dir ui exec vitest run --reporter=verbose apps/console/src/pages/settings/__tests__/SettingsField.actionConfirm.test.tsx
Test Files 1 passed (1)
Tests 11 passed (11)
os-verify-lock: VERDICT command-exit 0
pnpm --dir ui exec vitest run apps/console/src/pages/settings/__tests__/
Test Files 32 passed (32)
Tests 262 passed (262)
os-verify-lock: VERDICT command-exit 0
```
(The settings directory run includes
`settingsPage.noBareLiterals-12821.test.ts`, which reads
`SettingsField.tsx` for bare rendered literals.)
</details>
<details><summary>Lint</summary>
`cd ui && pnpm exec eslint
apps/console/src/pages/settings/SettingsField.tsx
apps/console/src/pages/settings/__tests__/SettingsField.actionConfirm.test.tsx`
→ exit 0, `0 errors, 2 warnings` (both pre-existing `no-explicit-any`
lines outside this diff). `pnpm --dir ui run check:new-line-citations` →
`VERDICT new-cross-file-line-citations: 0 new citation(s)`.
</details>
<details><summary>Derived gates (`node scripts/pm/dispatch-gates.mjs
--commands`, 34 commands)</summary>
- `node scripts/check-adr-0087-registration.mjs --base origin/main` →
exit 0
- `node scripts/check-adr-0087-registration.mjs --self-test` → exit 0
- `node scripts/check-changeset-no-major.mjs --base origin/main` → exit
0
- `node scripts/check-closing-keyword-parity.mjs` → exit 0
- `node scripts/check-closing-keyword-parity.mjs --self-test` → exit 0
- `node scripts/check-comment-mask-corpus.mjs` → exit 0
- `node scripts/check-empty-changeset.mjs --base origin/main` → exit 0
- `node scripts/check-empty-changeset.mjs --self-test` → exit 0
- `node scripts/check-sdui-manifest.mjs` → exit 0
- `node scripts/check-sdui-manifest.mjs --self-test` → exit 0
- `node scripts/pm/release-rehearsal-clone.mjs --self-test` → exit 0
- `node scripts/release-pending-publish.mjs --self-test` → exit 0
- `pnpm --filter @objectstack/spec run check:duration-unit-keys` → exit
0
- `pnpm check:changeset-gate-self-tests` → exit 0
- `pnpm check:closed-ceremony-text` → exit 0
- `pnpm check:cross-package-test-inputs` → exit 0
- `pnpm check:dispatcher-error-vocabulary` → exit 0
- `pnpm check:driver-memory-census` → exit 0
- `pnpm check:engine-double-contract` → exit 0
- `pnpm check:gitlink-declared` → exit 0
- `pnpm check:nul-bytes` → exit 0
- `pnpm check:published-files` → exit 0
- `pnpm check:query-options-erasure` → exit 0
- `pnpm check:refd-timer-probe` → exit 0
- `pnpm check:registry-log-declared` → exit 0
- `pnpm check:rest-log-spy-declared` → exit 0
- `pnpm check:test-source-alias` → exit 0
- `pnpm check:tier-file-adoption` → exit 0
- `pnpm check:type-check-coverage` → exit 0
- `pnpm check:type-check-debt` → exit 3
- `pnpm check:undeclared-dep-imports` → exit 0
- `pnpm check:watch-hint-literal` → exit 0
- `pnpm check:where-matcher` → exit 0
- `pnpm check:changeset-fixed` → exit 0
`pnpm check:type-check-debt` exit 3 is the gate's PREREQUISITE NOT MET
(it refused to measure), read as NOT MEASURED, not a finding; this diff
touches no package ledger. `pnpm --dir ui exec vitest run scripts/` not
run locally (scripts tree untouched); CI runs it.
</details>
<details><summary>NOT MEASURED</summary>
- Console type-check (`pnpm --filter @object-ui/console run
type-check`): NOT MEASURED, reason: it needs the `@object-ui/*` dist
closure built; the shared verify lock queue-timed out twice (exit 99, 9
min each) behind another run, and an unlocked attempt without that build
answers only TS2307 missing-module noise. CI's `Type Check UI` measures
it.
</details>
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent cd7f785 commit a1d0b1e
3 files changed
Lines changed: 177 additions & 7 deletions
File tree
- .changeset
- ui/apps/console/src/pages/settings
- __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 | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
30 | 39 | | |
31 | 40 | | |
32 | 41 | | |
| |||
485 | 494 | | |
486 | 495 | | |
487 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
| 515 | + | |
| 516 | + | |
| 517 | + | |
| 518 | + | |
| 519 | + | |
| 520 | + | |
| 521 | + | |
| 522 | + | |
| 523 | + | |
488 | 524 | | |
489 | 525 | | |
490 | 526 | | |
491 | 527 | | |
492 | 528 | | |
493 | 529 | | |
494 | 530 | | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
499 | | - | |
500 | | - | |
501 | | - | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
| 538 | + | |
| 539 | + | |
| 540 | + | |
| 541 | + | |
| 542 | + | |
| 543 | + | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
502 | 548 | | |
503 | 549 | | |
504 | 550 | | |
| |||
| 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 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
0 commit comments