Surfaces and Lifecycle
A ui.surface expose exports a mount function. The host calls it with a container owned by the current realm and a TapFederatedSurfaceMountContext for the exact package release, installation, contribution, and instance.
The generated document bounds html, body, and #tap-root to the webview
and disables body scrolling. A full-page miniapp must render one internal
vertical scroll owner. React surfaces should use
SurfaceViewport, which also
documents flex, grid, and nested horizontal overflow rules.
Mount Context
The context contains read-only identity and scope fields:
- package, namespace, release, installation, contribution, and instance IDs;
- the verified host origin and package asset base URL;
- the optional host-canonical control-plane
userIdfor interactive mounts; - optional workspace, channel, and conversation IDs;
- the declared package event publisher; and
- the live selected-owner snapshot; and
- the current host-authority snapshot.
userId is the same identity used to resolve trusted MCP {userId} storage
selectors; do not substitute an OAuth/OIDC profile subject. It is absent from
disposable activation-preflight mounts. Optional scope fields are absent when
the instance policy does not supply that scope. They are immutable for the
mounted realm. Read and subscribe to context.owner when behavior depends on
the currently selected workspace, channel, or conversation, because
per-workspace and singleton realms can change owner without remounting.
Validate required fields at mount and render a useful empty or unavailable
state instead of guessing an ID.
Selected Owner
The selected owner begins as null until the host projects the exact frame's
current owner. Subscribe for changes and release the listener during unmount:
Host Authority
A candidate realm can mount before it is allowed to perform host-backed work. Read context.hostAuthority.getSnapshot() and subscribe to changes:
Do not use a delay as a readiness signal. Disable privileged actions until authority is available, and handle authority being removed while the surface remains visible.
Package Events
Event names and schemas belong in manifest.tap.json. The host scopes delivery to the verified package session.
Validate received payloads even when you own both publisher and subscriber. Releases can overlap briefly during activation, and an older compatible release may use a previous payload version.
Package Assets
Use resolvePackageAssetUrl for files declared inside the target graph:
The helper rejects absolute paths, traversal, encoded separator aliases, query strings, fragments, credentials, and paths outside the target directory.
Cleanup
Make unmount idempotent because cleanup can follow user navigation, release activation, permission changes, or an error boundary. Unmount should:
- unsubscribe from package events and host-authority changes;
- remove global and DOM event listeners;
- abort pending work that your code owns;
- stop timers, observers, media, and workers; and
- remove rendered content.
SDK requests already accepted by the host can still settle during cleanup. Ignore their UI result after unmount rather than assuming every request can be cancelled.