Today WebView Bridge
Contract

Agent Name

Read the host-owned agent name and invalidate it after a rename.

Embed uses the current agent name to render Ask {agent_name} for ClientCards and the Widget host action slot. The native host owns the profile; Web owns the translated CTA. This additive WebView bridge contract does not add a Desktop WEI/CPI/NEI/SEI module.

Read

Web sends the following through the existing promise channel:

{ type: 'agent.getName', schemaVersion: 1 }

The host replies with its current account's name:

{
  name: 'Nova'
} // or { name: null } when no name is available

The host must return its current profile state and must not assemble Ask … or return unrelated profile fields. Whitespace-only names are treated as null. Serve this method only to the trusted Embed main frame. As with the existing Embed account contract, reload the document with the new uid on account switch.

No capability token is required: older hosts resolve unknown methods to undefined. Web treats that as an unavailable name and uses Today. bridge.getAgentName() validates replies and bounds each read to three seconds. Transport errors, timeouts, and malformed results preserve the last known name; a successful null response restores the default.

Change notification

After committing a rename to its profile state, the host dispatches:

window.dispatchEvent(
  new CustomEvent('todayWebViewBridge:nativeEvent', {
    detail: { type: 'agent.nameChanged', schemaVersion: 1 },
  }),
)

The event carries no name: it invalidates the Web projection and triggers agent.getName. This ensures reads and notifications use one source of truth. Send the notification to the mounted Embed document, including while hidden.

Embed refresh behavior

Embed V3 keeps one in-memory external store per mounted account scope and subscribes with React useSyncExternalStore. Both card kinds consume the same snapshot. It subscribes before the initial read and reads again on:

  • agent.nameChanged with schemaVersion: 1.
  • Every valid todayPage.exposureChanged with visible: true.
  • webView.visibilityChanged with visible: true.
  • Document visibilitychange when the document becomes visible.

Hidden events do not read. Invalidations arriving during a pending read are coalesced into a follow-up read; the old response cannot overwrite the newer state. Unmount removes listeners and ignores pending results. Names are not persisted, and reads do not delay feed loading or its render acknowledgements.

Native integration verification: return Nova on initial load, rename to Kuta and send agent.nameChanged, then rename again while hidden without sending that event. The next visible exposure must update both ClientCard and Widget CTAs, without reloading the document.

On this page