v160 · capabilities (fugu) · launch handling

WebAppLaunch: user activation on focus-existing launch delivery

An installed web app with "launch_handler": {"client_mode": "focus-existing"} receives every relaunch in its existing window through launchQueue.setConsumer(). Until now that consumer ran without user activation — even though the user had just clicked a shortcut, link, file or share — so it could not call window.open() or requestFullscreen(). Chrome 160 grants the existing document transient activation as the launch is delivered, exactly once per launch, the same way clicking a page’s own Notification activates that page.

How to run these demos: each concept is a small installable app. Install it (in-page button or the browser menu), keep its window open, then launch it again from an app shortcut, the OS launcher, a captured link, or (for the presenter) a file. Feature-detect with navigator.userActivation.isActive inside the consumer. It ships enabled by default with no enable flag; the kill switch --disable-features=WebAppLaunchHandlerUserActivation brings back the old behaviour for comparison. In a normal browser tab no launch is ever delivered, so the pages show only clearly labelled tab-side baselines there.

concepts

  1. Consumer activation probe

    The canonical check: navigator.userActivation.isActive read as the first line of the real consumer, logged per delivery with hasBeenActive, a +1-task re-read (as Chromium’s browser test does) and a +6 s re-read after expiry — plus the tab-side with/without-gesture baseline.

  2. Gated API matrix

    Choose which activation-gated calls the consumer attempts — window.open(), requestFullscreen(), showOpenFilePicker(), navigator.share() — and in what order. The results show the budget: one launch is one activation, and consuming calls spend it.

  3. Workspace router

    The motivating use case: a document app that uses focus-existing to avoid duplicate windows, yet opens a different notebook in its own window via window.open() — with the in-app prompt fallback older builds required and a loop guard for link capturing.

  4. When activation is withheld

    Edge and migration: real reload/re-delivery evidence across documents, plus a labelled path explorer showing why navigate-new, navigate-existing, no open window, an out-of-scope window, a non-user launch, the kill switch and re-delivery all get no grant.

  5. Launch to present

    Composition with File Handling and Fullscreen: open a .slides file or the Present from slide 3 shortcut and the already-open presenter loads the deck and goes fullscreen straight from the consumer — or offers a Present button when no activation arrived.

why it shipped

focus-existing exists so single-window apps (music players, editors with their own tab strips) never spawn duplicate windows. But every launch is a user action outside the app, and the consumer that receives it could do nothing a user gesture normally allows: no new window for a document that belongs elsewhere, no fullscreen, no picker. Developers reported it in manifest-incubations #141. The spec now runs the activation notification steps for the focused document — mirroring how a click on a page-created Notification activates that page — and limits it to one activation per user-initiated launch, never on navigating launches or re-delivery. Existing apps benefit without code changes.

the API

// manifest
"launch_handler": { "client_mode": "focus-existing" }

// page
launchQueue.setConsumer((params) => {
  if (navigator.userActivation.isActive) {        // Chrome 160+, focus-existing delivery
    window.open(params.targetURL);                // now allowed
  } else {
    showInAppPrompt(params.targetURL);            // older builds / non-user launch / kill switch
  }
});

references