LearnNewsExamplesServices
Frontmatter
id18363
titleToolbar actions resolve by name, but two actions may share one name
stateClosed
labels
enhancementaicore
assigneesneo-opus-vega
createdAtSep 5, 2026, 3:41 PM
updatedAtSep 5, 2026, 11:31 PM
githubUrlhttps://github.com/neomjs/neo/issues/18363
authorneo-opus-vega
commentsCount0
parentIssuenull
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtSep 5, 2026, 11:31 PM

Toolbar actions resolve by name, but two actions may share one name

Closed v13.2.0/archive-v13-2-0-chunk-19 enhancementaicore
neo-opus-vega
neo-opus-vega commented on Sep 5, 2026, 3:41 PM

Context

Neo resolves collaborators by name: component.Base#getPlugin(name), getController(ntype), getReference(name). Toolbar actions already follow that model — toolbar.Base#getActionItem('close') returns the action instance, and the dock's header policy addresses close, pop-out, lock, pin and reload that way — but the model rests on an invariant nobody enforces: a name resolves to one action only if no two actions share it. Nothing in toolbar.Base refuses a duplicate, so a collision degrades silently to first-match. Operator direction (2026-09-05): the plugin lookup is the mental model for actions, and action names must be unique.

The Problem

getActionItem(action) is getActionItems().find(item => item.action === action) || null (src/toolbar/Base.mjs:577). Two actions carrying the same action name make the second unaddressable and route every intent by that name to the first. Both are host programming errors, and both are silent.

Two consumers already pay for the missing invariant:

  • The dock built it locally. src/dashboard/dock/projection/LayoutAdapter.mjs:1096-1120 walks the host's header actions and throws on a missing name, a duplicate name, and a name reserved by an engine flag — the comment says why: "getActionItem(name) returns the FIRST match … A duplicate makes one of them unaddressable". The duplicate half of that guard belongs to the toolbar, where it would also cover contributions and every non-dock toolbar.
  • HeaderActionPolicy.mjs:392-400 works around first-match semantics by hand: while the engine reload flag is off, a host may own the name reload, so the policy returns early rather than write into whatever getActionItem('reload') happens to find.

An unnamed action is a second, smaller hole: getActionItem(undefined) returns the first action that has no name, so "get by name" can hand back an action nobody named.

The Architectural Reality

  • The action set of one toolbar is closed. Every action instance is minted by createActionItemConfig (src/toolbar/Base.mjs:418), which stamps isToolbarAction: true; getActionItems() (:568) filters on exactly that flag. Three paths feed it: syncActions(actions) (:623, the reactive actions_ config), createActionItemConfigs, and addActionContribution(config) (:532, plugin-owned contributions kept across consumer rebuilds — tab/plugin/Overflow is the one contributor). A uniqueness check at syncActions and addActionContribution therefore covers the whole set.
  • createActionItemConfig already throws on malformed input — an unknown actionMap key, an icon-only action without a name (:428, :442). Throwing on a duplicate is the same idiom in the same method family.
  • String actions carry their name through the actionMap factory: dialog/header/Toolbar.mjs:18 resolves 'close' to {action: 'close', …}. Object actions carry action explicitly; the key is copied onto the instance by Neo.create, not declared as a config.
  • The lookup has one delegate, tab/Container.mjs:404 getActionItem(action), and eleven call lines in src/ (code/LivePreview.mjs:395,523, dashboard/dock/plugin/Maximize.mjs:757,966, dashboard/dock/interaction/RevealOverlay.mjs:499, HeaderActionPolicy.mjs:149,176,203,367,399), plus 105 lines across 20 spec files.
  • getPlugin has the same first-match shape and no uniqueness guard (component/Base.mjs:1471, beforeSetPlugins :1187). Out of scope here; noted so the symmetry is deliberate.

The Fix

  1. Uniqueness, enforced where the set is closed. A protected toolbar.Base helper collects the action names of a candidate config list plus the instances that will survive beside them and throws Neo.toolbar.Base: duplicate toolbar action "<name>" on a repeat. syncActions calls it with the new consumer configs against the surviving contributions before it removes or inserts anything; addActionContribution calls it with the one contribution against getActionItems() before the spacer or the contribution is inserted, so a refused contribution leaves the toolbar untouched. Unnamed configs are skipped — they cannot be addressed, so they cannot collide.
  2. The lookup takes the family's name. toolbar.Base#getAction(name) replaces getActionItem(action); tab.Container delegates under the same name; the eleven src/ call lines and the spec lines follow (a scripted rename, no behaviour change). getAction() with no name returns null: an unnamed action is not addressable. getActionItems() keeps its name — it is the instance collection, and getActions() would collide with the actions config accessor. Downstream callers outside this repository were not measured from this seat. The implementer greps the private consumer repositories before opening the PR: zero callers means a hard rename; any caller means getActionItem stays as a one-line @deprecated alias whose docblock names the consumer's migration as its removal trigger.
  3. The dock's copy retires. The host-vs-host duplicate branch in LayoutAdapter.mjs:1109-1111 (and its seen bookkeeping) goes; the toolbar now throws for the same collision when the projected header receives its actions. The name-required branch (:1105) and the reserved-name branch (:1113) stay — they are dock policy the toolbar cannot know (intents route by name; engine-owned names are reserved even while their flag is off). The spec arm pinning the deleted branch (test/playwright/unit/dashboard/DockLayoutAdapter.spec.mjs:331) is replaced by the toolbar arm below.
  4. Spec home: test/playwright/unit/toolbar/Actions.spec.mjs, beside ActionButton.spec.mjs, using the own(Neo.create(Toolbar, {…})) fixture idiom of unit/tab/HeaderActions.spec.mjs:71.

Contract Ledger Matrix

Target Surface Source of Authority Proposed Behavior Fallback Docs Evidence
toolbar.Base#getAction(name) this ticket; family precedent component.Base#getPlugin/getController/getReference returns the one action instance whose action === name; null when none matches or name is not a non-empty string getActionItem alias only if a downstream caller is measured (see Fix 2) method docblock AC-3, AC-4
toolbar.Base#actions assignment (syncActions) createActionItemConfig's throw-on-malformed idiom (toolbar/Base.mjs:428,442) a duplicate name among the resulting consumer actions, or against a surviving contribution, throws before any item is removed or inserted none — host programming error actions_ docblock states the invariant AC-1
toolbar.Base#addActionContribution(config) same a contribution whose name is already present throws before spacer or contribution insertion; the toolbar's items are unchanged none method docblock AC-2
tab.Container#getAction(name) delegate of the above delegates to the tab bar's getAction as above method docblock AC-3 (renamed existing arms)
dashboard/dock/projection/LayoutAdapter host-action validation ADR 0029 header projection (unchanged) host-vs-host duplicate branch removed; name-required and reserved-name branches unchanged n/a inline comment names the toolbar as the invariant's owner AC-5

Decision Record impact: none. ADR 0029's header-action projection is unchanged; the toolbar invariant is generic.

Acceptance Criteria

  • AC-1 — Constructing a toolbar.Base whose actions carry two entries with the same action name throws an error naming that action; re-assigning actions so a consumer action collides with a live contribution throws the same way, and the toolbar's items are unchanged after the throw. Unit arm, red on dev.
  • AC-2 — addActionContribution with a name already present among getActionItems() throws before inserting a spacer or the contribution; a distinct name still inserts ahead of consumer actions as today. Unit arm, red on dev.
  • AC-3 — toolbar.Base#getAction(name) and tab.Container#getAction(name) are the lookups; grep -rnw "getActionItem" src apps examples test returns zero lines (the word matcher: getActionItems, the collection, stays), or exactly the deprecated alias definition and its docblock when Fix 2's downstream measurement found a caller, with the measurement stated in the PR body.
  • AC-4 — getAction() called without a name, or with an empty string, returns null even when the toolbar holds an unnamed action. Unit arm, red on dev.
  • AC-5 — LayoutAdapter.mjs no longer throws its own "duplicate host header action" error; the name-required and reserved-name arms in DockLayoutAdapter.spec.mjs and DockLockAction.spec.mjs are unchanged and green.
  • AC-6 — A dialog.header.Toolbar resolves getAction('close') to the instance minted by its actionMap (the string-action path carries the name). Unit arm.
  • AC-7 — Full unit suite and the component/dashboard + component/tab component suites green at the PR head (--workers=1).

Out of Scope

  • Making action mandatory for text actions. Icon-only actions already require a name for their accessible label; a text action without a name keeps working and is simply not addressable.
  • A uniqueness guard on plugins / getPlugin. Same shape, different owner; a sibling ticket if wanted.
  • Declaring action as a config on toolbar.ActionButton; it stays the plain instance key it is today.
  • The actionsState / change-detection direction of D#18150 Option F. The guard lives in syncActions, which every actions re-assignment path runs through, so that later work cannot bypass it.

Avoided Traps

  • Log-and-skip (manager.Base#register precedent) rejected. A skipped action disappears from the toolbar silently — the exact defect shape this ticket removes. Throwing at config time matches how createActionItemConfig already treats malformed actions.
  • A permanent alias for getActionItem rejected. Two names for one lookup defeats the mental model the ticket exists for; an alias is admitted only against a measured downstream caller and carries its own removal trigger.
  • getActions() as the plural rejected. It would shadow the actions config accessor's meaning (configs) with instances.
  • Keeping the dock's duplicate branch "for the better message" rejected. One invariant, one owner; the toolbar's error names the toolbar class and the action, and the stack names the projection.

Related

  • #17418 — origin of the actions collection, actionMap and getActionItems
  • #17876 — host-authored header actions; the dock's local guard was built for them
  • #18241 — toolbar.ActionButton
  • #17874 — showOnFocus on actions
  • #18307 — header state; a consumer of name-based lookup
  • D#18150 — Option F (actionsState), adjacent work in the same file

Live latest-open sweep: latest 20 open issues read at 2026-09-05 13:30Z and re-read immediately before filing; no equivalent. A2A claim sweep (30 latest, all read-states): no overlapping claim. Memory Core sweep: no prior proposal of this invariant; D#18150 Option F is the adjacent thread.

Origin Session ID: 3711ad57-061d-43fb-b1f1-aa9dc21dedda

Retrieval Hint: query_raw_memories("toolbar action names unique getAction rename first match dock duplicate guard")