Skip to main content

Tab Management

Otto tracks browser tabs as managed sessions identified by tabSessionId. Ownership metadata on each session enables safe cleanup when a controller disconnects.

Tab session lifecycle

Primitive tab actions

ActionDescription
primitive.tab.openOpen a new managed tab; returns tabSessionId
primitive.tab.closeExplicitly close a managed tab by tabSessionId
primitive.tab.navigateNavigate a managed tab to a new URL
primitive.tab.queryQuery managed tab state
primitive.tab.close_ownedInternal relay action: close all tabs owned by a controller identity

Ownership rules

  • Relay injects internal owner metadata when forwarding primitive.tab.open from a controller.
  • Owner metadata is relay-owned and not modifiable by the controller.
  • When a controller disconnects or heartbeat times out, relay dispatches primitive.tab.close_owned to connected nodes with the disconnected controller's clientId.
  • Node runtime closes only tabs owned by that controller identity. Tabs owned by other controllers are not affected.

Stale session causes and recovery

CauseRecovery
Manual tab close in browserOpen a new managed tab with primitive.tab.open
Extension reload or restartOpen a new managed tab; previous sessions are invalid
Cached tabSessionId after reconnectDiscard cached value; open a fresh session
Controller disconnect and cleanupOpen a new managed tab after reconnecting

After opening a new tab, always use the new tabSessionId for subsequent commands.

MV3 URL commit race

Chrome MV3 service-worker tabs may not expose a committed URL immediately after primitive.tab.open completes. Otto runtime uses bounded polling before strict site matching to avoid false site_mismatch or tab_url_not_ready outcomes.

If tab_url_not_ready is returned, retry after a short delay.

Tab automation groups

Otto tracks tabs opened through automation workflows in a Chrome tab group (automationGroupId). Initialization is single-flight guarded to prevent duplicate group creation under concurrent primitive.tab.open calls.

Next steps