Skip to content

[COMMEX-2353] Let a dom-bundle UI extension request host actions - #1546

Open
jolinger-godaddy wants to merge 1 commit into
godaddy:mainfrom
jolinger-godaddy:ui-extensions-request-action
Open

jolinger-godaddy wants to merge 1 commit into
godaddy:mainfrom
jolinger-godaddy:ui-extensions-request-action

Conversation

@jolinger-godaddy

Copy link
Copy Markdown

Summary

A dom-bundle UI extension has no way to ask its host to do anything. The runtime already has an onActionRequest mount option, but nothing reaches it. This adds the channel, opt-in on both sides.

  • DomExtensionMountInput gets an optional requestAction({ action, input }). It resolves with the host's result. The same function stays valid for the life of the mount and always reaches the host's current committed handler.
  • Target and UiExtensionRuntimeHost take an optional onActionRequest(request, source). Changing it doesn't remount the extension.
  • The host gets a structured clone of the request (read once), and source.extension is built from the host's own record of the extension, so a bundle can't change what was checked or pass itself off as another extension. The extension gets a structured clone of the result.
  • A request rejects with an action_rejected runtime error when there's no handler, the host rejects, a value can't be cloned, the action name is missing, blank or has spaces around it, or the extension unmounts, including while a request is still waiting on the host. The host's own reason never goes back to the extension.
  • Requests stop as soon as a mount fails, so nothing from a bundle that's being cleaned up reaches the host.
  • A runtime mounted again before its earlier mount (or unmount) finishes now leaves the newer mount alone: the replaced bundle is unmounted once, its requests are refused, and its late cleanup doesn't clear the newer mount's handler.
  • The runtime's onActionRequest mount option gets an optional second source argument, so existing runtimes that call it with the request alone still compile.
  • A handler's failure only reaches the extension, as a generic rejection; hosts that want to log it catch inside the handler. Requests stop when unmount starts.
  • New getEnabledStoreUiExtensions({ storeId, target, apiHost }): the same discovery request useEnabledStoreUiExtensions sends, for hosts that pick a target's extensions before they render.
  • Backward compatible: older bundles never call requestAction, and older hosts don't pass a handler.

Changeset

  • Changeset added (docs): @godaddy/react minor.

Test Plan

  • dom-bundle-runtime.test.ts: request and source reach the handler; metadata comes from the host's record, taken at mount, after the bundle or the record changes; request read once and cloned; an unreadable action name; uncloneable input rejected without calling the host; result cloned; host rejection rebuilt without its reason; no handler; no action name; after unmount; pending request rejected at unmount; requests during a failed mount's cleanup never reach the host; uncloneable result; padded names; a newer mount during load, during a failed mount's cleanup, during an earlier unmount and during a queued update; one unmount when the host unmounts before or during a failed queued update's cleanup.
  • runtime-host.test.tsx (new): a new handler is used without a remount; no handler rejects.
  • discovery.test.ts (new): the non-hook read sends the hook's request, and sends nothing without a store id or target.
  • target.test.tsx: onActionRequest gets the request and the extension's metadata.
  • pnpm vitest run src/ui-extensions (48 passing), tsc --noEmit, and biome check on the changed files.

The mount input carries an optional requestAction. Target and UiExtensionRuntimeHost take an onActionRequest handler; without one, requests reject with action_rejected.
@jolinger-godaddy
jolinger-godaddy requested a review from a team as a code owner November 23, 2026 23:25
@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: f8451ed

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@godaddy/react Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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

⌂ Proxy