Skip to content

Function: decideBrowserAction()

decideBrowserAction(args, config?, env?, platform?): BrowserAction

Defined in: packages/aiui-util/src/browser.ts:334

Decide the browser sidecar's move — pure (env and platform are parameters) so every rung is unit-testable. The ladder, most explicit first, mirrors the aiui CLI's flag-beats-config ordering:

  1. Suppress flag → skip, silently. The user said no for this run.
  2. Force flag → open, even under CI or over SSH — the force flag exists precisely to overrule the defaults (e.g. the dev box is "headless" but its display is a forwarded port away).
  3. A browserUrl (the --aiui-browser-url flag) → open. The browser deliberately lives elsewhere (typically the user's local machine, reverse-tunneled — aiui remote), so this machine being headless is irrelevant: opening a tab there is exactly the point of the setup.
  4. CI or headless (see ./environment) → don't launch a browser nobody can see; hand back the reason so the caller can print the port-forwarding hint instead.
  5. Otherwise → open.

(The old chrome.enabled: false config rung retired with the browser-profiles redesign — opting out is flag-only now.)

Parameters

args

BrowserAutoOpenFlags

config?

BrowserAutoOpenConfig = {}

env?

ProcessEnv = process.env

platform?

Platform = process.platform

Returns

BrowserAction