Skip to content

feat(core): a mechanism capability for Play/Stop and E on any kind (AK-09 1/2) - #954

Open
Aymericr wants to merge 3 commits into
mainfrom
fidelity/ak-09-mechanism-capability
Open

Aymericr wants to merge 3 commits into
mainfrom
fidelity/ak-09-mechanism-capability

Conversation

@Aymericr

@Aymericr Aymericr commented Sep 27, 2026 •

Copy link
Copy Markdown
Contributor

AK-09 first slice, part 1 of 2. Part 2 is #955 (GLB clip listing, baked viewer, walkthrough), stacked on this branch and targeting main.

What and why

Play/Stop and E were wired to node.type === 'item' | 'procedural-item' (nodes/src/shared/item-interactions.ts), so a plugin kind with moving parts (Articraft's joints) could not get either.

  • Core: capabilities.mechanism: { has, isOn, set, verb? } (MechanismCapability), plus nodeMechanism(node), toggleMechanism(mechanism, node) and toggleNodeMechanism(node). Operating state is transient: set writes useInteractive, never the node. Kinds with one switch use the new useInteractive.mechanisms map (setMechanism, removeMechanism). InteractiveState is exported.
  • Action menu: the Play/Stop button is generic (registry-action-contributions.tsx): the single selected node gets it when its kind declares the capability and has(node). The item/procedural contribution keeps only the light switch, so they show the same two buttons, in the same order, with the same classes.
  • E: runNodeInteraction(node): the kind's own keyboardActions.e, else its mechanism, else the door/window fallbacks as before.
  • Item and procedural-item declare the capability with their existing semantics (itemMechanism, proceduralMechanism). Their E still does mechanisms, else lights. Lights keep their kind checks; a lights capability is the next slice.
  • Wiki: node-definitions.md gains capabilities.mechanism.

Visible only once a plugin adopts it. The owner preview ships with the Articraft adoption (AK-ART).

Failing case first

690041dc4 (tests only), on main's code: core mechanism.test.ts 0 pass / 1 fail (no capability); nodes item-interactions.test.ts 0/1 (item and procedural declare none); editor use-keyboard.test.ts + registry-action-contributions.test.tsx fail (E does nothing for a capability-only kind; there is no Play for it).

Proof

  • bun run --cwd packages/core test: 2983 pass, 0 fail.
  • bun run --cwd packages/nodes test: 3506 tests, 0 fail. The item/procedural parity tests (item-interactions.test.ts, item/definition.test.ts, procedural-item/definition.test.ts) assert the same control values and part states as before.
  • bun run --cwd packages/editor test: 1117 pass, 0 fail.
  • bun run check: no errors (6 infos, all pre-existing). bun run check-types: every package passes. apps/editor fails on the missing local @webxr/plugin, as on main.
  • private-editor bun typecheck against these dists: 12/12.
Rule Check
R1 API v1 unchanged; the capability is optional. A kind without it behaves exactly as before.
R2 Play/Stop writes only transient useInteractive state: no scene write, no history step (test: running a mechanism is transient).
R6 Operating state stays out of the node; nothing persisted changes.
R8 No agent surface in this slice. MCP creation of plugin kinds is still parked with A-07 flag-on.

R3–R5, R7 and R9 are unaffected: no references, rooms, geometry or recipes change.

House effect: no change. /next has no plugin mechanisms, and item/procedural behave as before.

For Wassim (procedural items, #930)

  • nodes/src/shared/item-interactions.ts: proceduralMechanism wraps setProceduralParts(node.id, motionPartIds(node), on), with the same "any running → stop all, else start all" rule, now in toggleMechanism.
  • procedural-item/definition.ts: capabilities.mechanism: proceduralMechanism. E runs toggleMechanism(proceduralMechanism, n), else toggleItemLights(n).
  • shared/item-interaction-actions.tsx: the Play button moved to the editor's generic MechanismButton, with the same markup and order. The light button is unchanged.

🤖 Generated with Claude Code

Aymericr and others added 3 commits September 26, 2026 21:12
…rocedural parity (AK-09, failing first)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…tem and procedural adopt it (AK-09 1/2)

Capabilities.mechanism { has, isOn, set, verb? } with transient state in
useInteractive (mechanisms map for single-switch kinds). The action menu's
Play/Stop and the E fallback read it instead of item/procedural-item checks,
so a plugin kind gets both by declaring it. Item and procedural-item declare
it with their existing semantics; their light switch stays as it was.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@pascal

pascal Bot commented Sep 27, 2026

Copy link
Copy Markdown

I hit an error while handling your request (Model unavailable on AI Gateway free tier: Free tier users do not have access to this model. Upgrade to paid credits at https://vercel.com/d?to=%2F%5Bteam%5D%2F%7E%2Fai%3Fmodal%3Dtop-up for unrestricted…).

Please try again, rephrase, or reach out if it keeps failing.

Error id: 5e39e498-5714-421b-bd63-c5d1b0f52f7e

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant