This repository was archived by the owner on Nov 4, 2026. It is now read-only.
Repository navigation
fix(actions): one placement rule for locations — declare it or it renders nowhere (#3142) - #3145
Merged
Merged
Conversation
…enders nowhere (#3142) Four renderers each answered "where does an action with no `locations` go?" differently: `action:bar` and metadata-admin showed it EVERYWHERE, `page:header` showed it on the header, `action:group` showed it for `undefined` but hid it for `[]`. Meanwhile ActionEngine, RecordDetailView, DeclaredActionsBar, the related-list bridge and the environment toolbar all showed it NOWHERE. The same action appeared or vanished depending on which component happened to draw it — and that is how an aggregate-only bulk action (#3139), which has no single-record placement by construction, minted a list-toolbar button whose dispatch could only fail. All of them now go through one exported predicate — `actionRendersAt(action, location)` in `@object-ui/types`: an action renders at a location only if it declares that location; a missing or empty `locations` places it nowhere. This is the platform's own reading — ADR-0078 lists "an `action` with no `locations`" as a verified inert shape, and buildDefaultPageSchema already documented "must include `locations: ['record_header']` to render". One named carve-out, now consistent across both bars: host-injected chrome (`systemActions` / `headerSystemActions`) is placed by the host, not authored, so it is never location-filtered. `page:header` used to filter it while `action:bar` exempted it, so the same `sys_delete` obeyed two rules. Selection placement is likewise declared elsewhere — an action named in a view's `bulkActions` / `bulkActionDefs` needs no `locations`. Authoring side, so the stricter rule cannot mint invisible actions: - Studio seeds `locations: ['record_header']` on a new action - the action inspector says so when no placement is ticked - the `ActionSchema.locations` JSDoc claimed a `['record_header']` default no renderer ever implemented — corrected Tests: the lenient pin in action-bar.test is deliberately inverted; the capability-gate fixtures gain the harness's location so their assertions stop passing vacuously; new pins cover metadata-admin and `action:group`, neither of which had any coverage of this rule before. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S9aiswZBzoVYsyLKRuGByE
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
❌ Console Performance Budget
📦 Bundle Size Report
Size Limits
|
app-shell's tsc rejected the call from MetadataTypeActions: the metadata-admin `/meta/types` feed types an action's `locations` as plain `string[]`, while the predicate asked for `readonly ActionLocation[]`. Widen the ACTION parameter to `readonly string[]` rather than casting at the call site — the whole point of the predicate is to serve every surface, and a narrow parameter would push a cast onto each caller whose action shape came off the wire, which is how a shared rule grows per-caller variants and stops being shared. An unrecognized string matches no location, so nothing is loosened semantically. The LOCATION parameter stays typed: that is the renderer's own identity, not wire data. `MetadataTypeActions.location` was `string` and is now `ActionLocation` — both call sites pass a literal, so it costs them nothing and a typo can no longer quietly match nothing. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01S9aiswZBzoVYsyLKRuGByE
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 free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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 #3142.
问题
「一个没有
locations的动作应该出现在哪」这个问题,仓内有 5 套答案:undefined和[]都到处显示action-bar.tsx:137、MetadataTypeActions.tsx:99(逐字节相同的两份拷贝)containers.tsx:984(page:header)undefined显示、[]隐藏action-group.tsx:192ActionEngine、RecordDetailView、DeclaredActionsBar、RelatedRecordActionsBridge、EnvironmentListToolbar、record:quick_actions同一个动作,由哪个组件渲染决定它出现还是消失。 这正是 #3139 聚合批量动作踩中的坑:一个按构造就没有单记录位置的动作,不写
locations后凭空长出一个列表工具栏按钮,而它的分发必然失败(实测 HTTP 400)。方案:一条规则 + 一个具名豁免
新增
actionRendersAt(action, location)(从@object-ui/types导出),上述八个表面全部共用这一份判定:动作只有声明了某位置才在该位置渲染;缺失或空数组 = 没有位置。这不是新发明,是回归平台自己的既定读法:
actionwith nolocations」列为已验证的 Tier-A inert 形态 —— 该结论只有在「不声明 = 没有位置」时才成立;buildDefaultPageSchema.ts:131早就把契约写成「must includelocations: ['record_header']to render」。宽松规则同时违背了这两条。
具名豁免:主机注入的 chrome(
systemActions/headerSystemActions)由主机放置、不参与位置过滤。这里顺带修掉一个今天就存在的不一致 ——action:bar一直豁免它,page:header却在过滤它,所以同一个sys_delete取决于谁渲染而有两种命运。选中集的放置同样来自别处:视图
bulkActions/bulkActionDefs里命名一个动作就是它的声明,这类动作可以不写locations(#3139 的聚合动作正是如此)。防「改严格反而造出隐形动作」
严格化若不配套授权侧,只会把问题挪到作者手上。三处一并修:
locations: ['record_header']—— 此前ObjectActionsPanel的骨架不写locations、Placement 复选框默认全不勾,即"每个 Studio 新建的动作都没有位置",靠宽松规则蒙混显示;ActionSchema.locations那句defaults to ['record_header']的 JSDoc —— 那是第三个从未被任何渲染器兑现的"默认值"。迁移
对元数据是破坏性的,但迁移是一行:
已声明位置的动作完全不受影响。核过的存量面:objectstack 侧示例 20/20、platform-objects 73 个动作全部已声明
locations;本仓内唯一未声明的 4 个(sys_share/sys_edit_mobile/sys_delete/sys_open_new_tab)全走systemActions豁免通道。测试
action-bar.test.tsx那条唯一以名字和注释断言宽松契约的 pin,并写清为何反转;page:headerfixture 按既定契约补声明(排除类用例list_item/record_more的语义原样保留);metadata-admin与action:group的严格 pin —— 这两处的宽松分支此前完全没有测试,正是两份拷贝能悄悄漂移的原因;action-group.test.tsx并登记进heavyDomTests(registry 渲染类,AGENTS.md 指定做法)。验证:仓根
pnpm test9266 项通过 / 0 失败(794 文件);改动文件 lint 0 error。🤖 Generated with Claude Code
https://claude.ai/code/session_01S9aiswZBzoVYsyLKRuGByE
Generated by Claude Code