You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 32dc5d8
Browse filesBrowse the repository at this point in the historyBrowse files
fix(runtime): a declarative update action answers the validation warnings its write raised, and the console toast shows them (#38076)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6Jao3VQSGvy9zYGn6FpGEZRCnJ)_Fixes#37867
repo:objectstack#3 · os-tesla · session_01L9qibyUSf2nKJWW6qBemSU
Clause-②: yes (widening)
Metadata-protocol: none
## 维护者速读
-
用户点「确认订单」这类改状态的按钮时,如果这次写入触发了警告型校验规则,现在会弹出一条警告样式的提示,规则作者写的话就在提示里,撤销按钮照样在;以前只弹成功提示。
- 替用按钮改状态的应用解决:警告规则以前只在编辑表单里生效,最常用的按钮路径静默通过(HotCRM 订单超出框架合同额度就是实例)。
- 写入本身不变,只是应答多带警告、提示换样式;如果有问题,最多是提示样式不对,可以直接撤回。
- 无
## What changes
- `packages/runtime/src/action-execution.ts`:
`executeDeclarativeUpdateAction` copies the `warnings` the data-plane
update answered (`protocol.updateData`, the data door's own
`ValidateDataIssue` elements) onto its result. `DeclarativeUpdateResult`
gains an optional `warnings`, present only when the write raised an
advisory rule hit, so a write that trips nothing answers byte-for-byte
as before. Both action doors (REST `POST /api/v1/actions/...` and MCP
`run_action`) go through this executor. The stale roll-up path
(`ERR_SUMMARY_RECOMPUTE`) composes from the same `written` answer, so it
carries them too.
- `ui/packages/core/src/actions/ActionRunner.ts`: for an `operation:
'update'` action only, the runner reads the answer's `warnings`
(distinct messages, in answer order). When there are any, the success
toast takes the `warning` variant, with the messages as its
`description` and the Undo affordance kept. This is one toast, the way a
record save raises one (`toastRecordSave`). When the author turned the
success toast off (`toast.showOnSuccess: false`, or a result dialog),
the warning is still shown, in the rule's own words, so no new runner
text is needed. `ToastHandler` options gain an optional `description`.
- `ui/packages/app-shell/src/hooks/useConsoleActionRuntime.tsx`,
`ui/packages/app-shell/src/views/RecordDetailView.tsx`: both console
toast handlers used to send every non-error toast to `toast.success`.
They now honour `type: 'warning'` and call `toast.warning(message, {
description, duration, action })` with the same Undo action.
- Changeset: `@objectstack/runtime`, `@object-ui/core`,
`@object-ui/app-shell` patch.
Not changed: `packages/spec` (the action answer has no zod declaration,
it is the runtime's TS interface), locale packs (no new text), HotCRM
(its `confirm_sales_order` and `framework_quota_exceeded` work as
authored).
## Tests
- `packages/runtime/src/action-declarative-update.test.ts`, a new
top-level `describe` in the shared harness. It puts a `protocol` slot in
front of the caller-honouring rig. REST: the 200 answer carries the
write's warnings, element for element, beside the record and the undo
anchor. MCP `run_action`: the same write gives the same warnings.
Control: a write that trips no rule has no `warnings` key. The file
gains a module-top `import '@objectstack/metadata'` so the dispatcher's
lazy load is paid at collection (`check:test-source-alias`).
-
`ui/packages/core/src/actions/__tests__/ActionRunner.updateOperation.test.ts`,
a new `describe` through the real `createServerActionHandler`: one
warning toast with the success message as title and the rule's words as
description; repeated messages said once and distinct ones one per line;
Undo kept on an undoable action; control with no warnings is a plain
success toast with no description; success toast off still warns;
reverse pin: a script action without `operation` never reads a
`warnings` key.
-
`ui/packages/app-shell/src/hooks/__tests__/useConsoleActionRuntime.undoLookupId-11122.test.tsx`
and
`ui/packages/app-shell/src/views/RecordDetailView.undoLookupId-11122.test.tsx`,
a new `describe` in each, down to `sonner`. On a grid row and on the
record page, the update's warnings raise `toast.warning` once with the
description and the Undo action, no success toast, and Undo restores the
stored value. Both harnesses' route stubs gained an optional answer
body. These two test files are a surface amendment to the claim,
reported to the seat.
## Acceptance notes
- Premise measured on `origin/main` `815e882b` before any edit. Through
the real `HttpDispatcher.handleActions` →
`executeDeclarativeUpdateAction` → `callData`, the protocol's
`updateData` answered `["object","id","record","warnings"]` and the
action's 200 body carried `warnings` 0 times.
- The same executor also drops the data door's `notice` (a hook's
message for the person) and `droppedFields`. Out of scope here; the seat
files them.
- `ToastHandler` and the action answer each gain one optional member.
Nothing is refused or narrowed.
## Verification
- Two-minute check: `pnpm --dir ui exec vitest run
packages/core/src/actions/__tests__/ActionRunner.updateOperation.test.ts`
shows 19 passed, 6 of them the new block.
- Read first: `executeDeclarativeUpdateAction`'s result block
(`action-execution.ts`), then the success-toast arm of
`handlePostExecution` (`ActionRunner.ts`).
<details><summary>Local readings at 40c5c82</summary>
- New and edited suites: `action-declarative-update.test.ts` 37 passed;
`ActionRunner.updateOperation.test.ts` 19 passed;
`useConsoleActionRuntime.undoLookupId-11122` 6 passed;
`RecordDetailView.undoLookupId-11122` 4 passed.
- Full: `pnpm --filter @objectstack/runtime test` Test Files 655 passed,
Tests 12316 passed, 25 skipped. ui vitest `packages/core/src/actions`:
58 files, 810 passed. app-shell `useConsoleActionRuntime*` +
`RecordDetailView*`: 128 files, 1104 passed.
- Typecheck exit 0: `@objectstack/runtime` (test layer 27 files / 183
errors held in the ledger, unchanged), `@object-ui/core` `type-check`,
`@object-ui/app-shell` `type-check`.
- Ablations through `scripts/ablation-replace.mjs`, each restore blob ==
HEAD: runtime `warnings` spread removed, 2 failed (REST, MCP); the
runner's warnings read emptied, 6 failed (4 core, 2 hosts); each host's
warning arm disabled, 1 failed each.
- `dispatch-gates --ran` with recorded exit codes: 73 derived, 71 exit
0, 2 NOT MEASURED (exit 3: `check-plugin-teardown-shape --self-test`,
fixture commit outside the shallow clone; `check:dual-build-cjs-loads`,
needs a full `pnpm build`), 0 unrun. `check:test-source-alias` exit 0 at
40c5c82.
- `overlap-check.mjs` VERDICT clean exit 0 against main and #37929,
#37924, #37896.
</details>
---
_Generated by [Claude
Code](https://claude.ai/code/session_01L9qiby3dfNfCgpXwPkB2Hf)_
<!-- signed: repo:objectstack#3 · os-tesla ·
session_01L9qiby3dfNfCgpXwPkB2Hf -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
0 commit comments