Uh oh!
There was an error while loading. Please reload this page.
fix(grid): a legacy string row action runs instead of green-toasting a no-op (#2960) - #2996
Merged
Merged
Conversation
…a no-op (#2960) A list view declaring `rowActions: ['convert_lead']` rendered a menu item that performed zero network requests and reported success. Where the object also declared the same action with `locations: ['list_item']`, the row menu showed a working entry and a dead duplicate of it side by side. The name never became an action: ObjectGrid dispatched the legacy form as `{ type: <action name>, params: { record } }` — the action NAME landing in the runner's `type` slot, never resolved against the object's action defs. It matches no built-in type and (absent a handler registered under that exact name) no handler either, so it fell through to `ActionRunner.executeActionSchema`, which returned `{success: true, reload: true, close: true}` for a schema with nothing in it. `handlePostExecution` then fired the green "Action completed successfully" toast. Two changes, either of which would have surfaced the bug: 1. ObjectGrid resolves legacy names against `objectDef.actions` (`resolveLegacyRowActions`). A name matching a declared action is promoted to that def and dispatched through the same path as a `list_item` action — so it actually runs, and picks up the def's label, visible/disabled predicates, param dialog and capability gate, none of which the string form could carry. A name matching an action already rendered as a def is dropped, which removes the dead twin. Names that resolve to nothing are still dispatched by name, since a consumer may have registered a runner handler under exactly that name. ObjectGrid is the chokepoint for all three callers (app-shell ObjectView, plugin-view ObjectView, plugin-list ListView). 2. ActionRunner's empty-schema fallthrough fails loudly. It no longer reports success for an action it never ran: a dispatch with no registered handler and no api/endpoint/navigate/redirect/onClick returns a failure naming the action. Schema-only shapes that do declare something — a bare `redirect`, an explicit `reload`/`close` — run exactly as before. The sibling bulk-action path carries the same `{type: <name>}` shape, but `bulkActionDefs` is never derived from `objectDef.actions`, so there is nothing to resolve against; change 2 makes it fail honestly rather than green-toast. Verified: stashing only the two source files makes all four new behavioral assertions fail — success:true where it should be false, the green toast firing, fetch called 0 times, and 2 menu entries where there should be 1. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
✅ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
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 freeto 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.
Fixes#2960.
症状
列表视图声明
rowActions: ['convert_lead']时,行菜单里的这一项点下去零网络请求却报成功。如果同一个 action 还声明了locations: ['list_item'],菜单里会并排出现一个能用、一个是死的同名项。根因
名字从来没变成 action。
ObjectGrid把 legacy 形式派发成{ type: <action 名>, params: { record } }—— action 的名字落进了 runner 的type槽位,从未拿去和对象的 action def 做解析。它匹配不到任何内建类型,也匹配不到 handler(除非恰好有人用这个名字注册过),于是落到ActionRunner.executeActionSchema:对一个什么都没声明的 schema,它返回{success: true, reload: true, close: true},接着handlePostExecution弹出绿色的 "Action completed successfully"。改动
两处,任意一处都能让这个 bug 暴露出来:
①
ObjectGrid把 legacy 名字解析到objectDef.actions(新增纯函数resolveLegacyRowActions):list_itemaction 完全相同的派发路径。于是它真的会执行,并且拿到 def 的 label、visible/disabled谓词、参数弹窗和 capability gate —— 这些字符串形式一个都带不了。ObjectGrid是三个调用方(app-shellObjectView、plugin-viewObjectView、plugin-listListView)的唯一收敛点,改一处即可覆盖。没有提升发生时该函数按引用返回原数组,RowActionMenu的useMemo不会被打散。②
ActionRunner的空 schema 兜底改为响亮失败:不再为一个从未执行过的 action 报成功——没有注册 handler、也没有api/endpoint/navigate/redirect/onClick的派发,返回一条点名该 action 的失败。仅声明 schema 但确实有内容的形态(裸redirect、显式reload/close)行为完全不变,已注册 handler 的路径也未触碰。未处理(有意)
同一文件里的批量 action 路径是同样的
{type: <name>}形状,但bulkActionDefs从来不是由objectDef.actions推导出来的,没有可解析的对象;给它加推导是新功能而不是修这个 bug。改动 ② 让这条路径至少诚实地失败,而不是弹绿 toast。验证
success: true(应为 false)、绿色 toast 触发、fetch调用 0 次、菜单里出现 2 项(应为 1 项)。packages/core/src/actions/+packages/plugin-grid/src/→ 50 文件 / 506 测试全通过。types、data-objectstack、i18n、plugin-kanban、plugin-markdown、plugin-list、metadata-admin的@objectstack/specdist 陈旧问题)。加不加本改动,失败文件集合完全一致,且都不在core/actions或plugin-grid。新增测试:
resolveLegacyRowActions.test.ts(7 条纯函数)、legacyRowActionDispatch.test.tsx(4 条,驱动真实 grid + runner)、ActionRunner.test.ts(4 条)。🤖 Generated with Claude Code