fix(app-shell): stop double-firing action error/success toasts in RecordDetailView & delete handler#2253
Merged
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
RecordDetailView's serverActionHandler (script actions) and useObjectActions' delete handler each toasted an error/success themselves AND returned it to the ActionRunner, whose post-execution hook toasts again when onToast is wired — so the same message fired twice (the reported RECORD_LOCKED double-toast, plus a double on delete success/failure). - RecordDetailView: drop the self toast.error in both failure branches; return the error and let the runner surface it once (mirrors #2177's twin fix in useConsoleActionRuntime). - useObjectActions.delete: keep the richer localized toast, return without `error` on failure and mark successful deletes `silent` so the runner doesn't re-toast. - Add useObjectActions.test.tsx asserting a single toast on delete success/failure/partial-bulk-failure.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #2252
问题
Console 记录详情页点一个会失败的 script 动作(如「分配线索」触发后端
RECORD_LOCKED)时,同一条错误 toast 弹两次。后端只抛一次,是纯 UI 重复。排查中一并发现 删除动作 同类重复:失败弹两条、成功也弹两条。根因
ActionRunner.handlePostExecution已负责把结果error弹成 toast(成功则按showOnSuccess弹)。若某 handler 自己又调toast.*且 返回{success:false, error}(成功时未标silent),而 runner 又设了onToast,就会被弹第二遍。RecordDetailView.serverActionHandler(script):失败分支与 catch 分支各自toast.error后又返回 error。fix(app-shell): stop double-toasting failed script/modal action errors #2177 只修了孪生副本useConsoleActionRuntime(interface page),记录详情页这份没修 → 仍双弹。也解释了「两天前修过还在」「同事没 clone objectui 也复现」(都吃同一份已发布的@objectstack/console)。useObjectActions.delete(ObjectView 装配onToast):失败自弹+返回 error → 双弹;成功自弹+未标silent→ runner 追加通用「Action completed successfully」;批量部分失败同理。改动
RecordDetailView.tsx:两个失败分支去掉自toast.error,返回 error 交给 runner 弹一次(对齐 fix(app-shell): stop double-toasting failed script/modal action errors #2177)。useObjectActions.ts:保留更友好的本地化文案(label+description / 批量汇总),失败返回不带error、成功标silent:true,避免 runner 重复。测试
① 单元测试 — 新增
useObjectActions.test.tsx,把onToast接到与真实 ObjectView 相同的 sonner sink,断言用户实际所见:got 2 times,揪出了成功路径的第 3 处双弹)3 新增 + 83 相关回归(含 #2177 的用例)全绿。② 产物级证据 — 从本分支构建 console,grep 打包后的
RecordDetailViewchunk,对照当初坐实 bug 的同一签名:.error(X),{success:!1,error:X}@objectstack/console@12.1.0发货代码里两处自弹已消失。