feat(spec): add explicit Action.order for deterministic action ordering (#2670)#2682
Merged
Merged
Conversation
…ng (#2670) The record-header renders the first visible `record_header` action as the primary button and pushes the rest into the `⋯` overflow menu. Which action wins was decided purely by cross-file `defineStack({ actions })` registration order, so system Approve/Reject decisions were appended after app actions and buried in the overflow menu — the approver's first-glance decision was hidden. Add an optional `Action.order` (number, lower = higher / more prominent, default 0) and stable-sort every action group by it in `mergeActionsIntoObjects()` — the single choke point for both `defineStack()` and `composeStacks()`. The sort is stable and treats unset `order` as 0, so groups where nobody sets `order` keep their exact registration order and array reference: the change is a no-op until an author opts in. A plugin (e.g. plugin-approvals) or app author can now give an action a low `order` to make it stably hold the primary-button slot, instead of hiding other actions to "make room". Includes schema tests, merge-sort regression tests, and Action Protocol docs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018H4wb2JGo68NggKiTh5Dag
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
📓 Docs Drift CheckThis PR changes 1 package(s): 94 hand-written doc(s) reference the affected code and may need an implementation-accuracy re-verification:
|
The spec property-liveness gate (check:liveness) requires every authorable property on a governed type to be classified. Classify the new `action/order` property as `live` (framework stable-sorts each action group by it in mergeActionsIntoObjects; objectui record_header consumes it for primary-button selection). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018H4wb2JGo68NggKiTh5Dag
os-zhuang
marked this pull request as ready for review
July 8, 2026 05:51
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.
Background
Closes the backend half of #2670. When a record is pending approval, the console injects Approve / Reject decision buttons for the approver — but the record-header primary button ends up being an app action (e.g. "申请关闭商机"), and Approve / Reject get buried in the
⋯overflow menu.Two root causes:
defineStack({ actions })merges actions in cross-file registration order with no explicit sort, and system Approve/Reject are appended after all app actions.record_headeraction as the primary button; the rest fall into overflow.The reporter's preferred fix (and the one implemented here) is the general one: give
Actionan explicit ordering field so priority is declarative instead of depending on fragile cross-file spread order.What this PR does (framework / backend)
Action.orderfield (packages/spec/src/ui/action.zod.ts) — optionalnumber, lower = higher / more prominent, treated as0when unset. Matches the repo's existingorderconvention (object-designer,plugin,settings-manifest).mergeActionsIntoObjects()(packages/spec/src/stack.zod.ts) — every action group (each object'sactionsand the top-levelactions) is stable-sorted byorder. This is the single choke point for bothdefineStack()andcomposeStacks(), so one change covers the single-stack (cross-file) case from the issue and multi-stack composition.orderis0, so groups where nobody setsorderkeep their exact registration order and array reference — a no-op until an author opts in.orderfield and an "Ordering & the Primary Button" section (content/docs/protocol/objectui/actions.mdx).order(action.test.ts) and merge-sort behaviour incl. stability, interleaving, backward-compat, and cross-stack composition (compose-stacks.test.ts).Because the current objectui bundle picks the primary button by array position, this framework-side sort already makes
ordertake effect for app-declared record-header actions today.Follow-up (objectui / frontend)
The Approve/Reject buttons are synthesized by the objectui record-header renderer at render time (they don't pass through framework's merge), so making those injected buttons outrank app actions needs a companion change in
objectstack-ai/objectui:order→variant:'primary'→ registration order (instead of naiveactions[0]);order+ primary variant.That change is being prepared separately and will bump
.objectui-sha.Verification
pnpm --filter @objectstack/spec test— 6713 passed (incl. new order tests), full suite, no regressions.pnpm --filter @objectstack/spec exec tsc --noEmit— clean.pnpm --filter @objectstack/spec check:api-surface— unchanged ✓ (additive optional field).Refs #2670
🤖 Generated with Claude Code
https://claude.ai/code/session_018H4wb2JGo68NggKiTh5Dag
Generated by Claude Code