Skip to content

Hand browser and web app launches to the running browser directly - #13530

Merged
dhh merged 2 commits into
quattrofrom
browser-singleton-handoff
Sep 28, 2026
Merged

dhh merged 2 commits into
quattrofrom
browser-singleton-handoff

Conversation

@dhh

@dhh dhh commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

With Chromium already running, every web app and Super+Shift+B launch started a second Chromium process. It loaded the whole binary only to pass its command line to the running one over the profile's singleton socket (~/.config/chromium/SingletonSocket) and exit. That throwaway process lived ~200ms, ~165ms of it before the running browser heard anything.

omarchy-cmd-browser-handoff sends the same message itself, START\0<cwd>\0<argv…>, with socat (already a base package) and waits for Chromium's ACK. omarchy-launch-webapp and omarchy-launch-browser try it first and launch the browser exactly as before when it declines.

Measured, from dispatch through Hyprland to the window mapping. Medians over two interleaved rounds against unchanged quattro:

before after
Web app (omarchy-launch-webapp) 432ms 207ms
Super+Shift+B (omarchy-launch-browser) 483ms 250ms
Web app, Brave Origin 345ms 158ms
Super+Shift+B, Brave Origin 538ms 311ms
Web app launch, Chrome (browser start vs handoff alone) 371ms 164ms
Web app launch, Brave (browser start vs handoff alone) 326ms 145ms
Web app launch, Edge (browser start vs handoff alone) 351ms 161ms

What's left is mostly Chromium creating and drawing the window.

When it hands off. It only does so when it can reproduce exactly what the second process would have done. Otherwise it declines and the browser launches normally:

  • The command resolves to the packaged binary: /usr/bin/chromium, google-chrome-stable, brave, brave-origin or microsoft-edge-stable. All five were checked on real installs: a cold start falls back to a normal launch, and both a web app and a plain new window open in the running browser. A wrapper in its place may pick a profile or add flags, so it gets run.
  • The flags files (/etc and ~/.config) hold nothing beyond the five process flags Omarchy ships. The running browser already has those. Any other flag might be meant for each launch (--new-window, --incognito, --profile-directory…), and this allow-list keeps us from having to know which.
  • No other data directory is asked for, by --user-data-dir or CHROME_USER_DATA_DIR/CHROME_CONFIG_HOME.
  • The socket is owned by the user. It lives in a /tmp dir that another user could recreate after a crashed browser's dir is cleaned away, and they would then receive the URLs.
  • The browser answers ACK. A stale socket, no browser, or Firefox gets a normal launch.

Tests. The new browser-handoff-test.sh runs a fake browser on a real socket. It checks the exact bytes sent, and the fallback for a stale socket, a non-Chromium browser, a PATH wrapper, --user-data-dir, the env override, and flags files with --new-window or a quoted --profile-directory. Each fallback assertion was checked to fail without its guard. It skips where /usr/bin/chromium isn't installed. launch-browser-test.sh now keeps XDG_CONFIG_HOME inside the test home. Before that fix, running it on a desktop with Chromium open handed its test URLs to the real browser. It also covers a handed-off URL starting no browser. The shell suite has the same 9 failing files as unchanged quattro here, plus the known VS Code theme failure in ./test/cli. manifest-entrypoints-test.sh failed once in a full run and passed on three reruns; it loads the shell against the live compositor and doesn't touch these launchers.

Review. Codex review caught several things, and the first attempts at them grew into reimplementing the launcher's flags parsing. That was replaced by the allow-list rule above. Its findings, all fixed:

  • a caller's --user-data-dir
  • flags from the flags files being dropped
  • Edge's --inprivate
  • a /tmp socket another user could take over
  • desktop entries whose Exec is a wrapper

Its final pass found nothing.

🤖 Generated with Claude Code

dhh and others added 2 commits September 28, 2026 12:42
With a Chromium-based browser already running, each launch started a second
browser process only to pass its command line over the profile's singleton
socket and exit, ~165ms before the running browser even heard of it.
omarchy-cmd-browser-handoff sends that message itself with socat and waits
for the ACK, so a web app opens in ~210ms instead of ~430ms.

It hands off only what it can do exactly as the browser would: the packaged
browser binary rather than a wrapper, a flags file holding nothing beyond the
process flags Omarchy ships, no other data directory, and a socket we own.
Anything else, or no answer, launches the browser as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
/usr/bin/brave-origin is the package's own launcher, reading
brave-origin-flags.conf, with the profile in BraveSoftware/Brave-Origin.
A web app now opens in ~158ms instead of ~345ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@dhh
dhh merged commit 97a9fce into quattro Sep 28, 2026
@dhh
dhh deleted the browser-singleton-handoff branch September 28, 2026 12:15
sgruendel pushed a commit to sgruendel/omarchy that referenced this pull request Oct 3, 2026
…acom#13530)

* Hand browser and web app launches to the running browser directly

With a Chromium-based browser already running, each launch started a second
browser process only to pass its command line over the profile's singleton
socket and exit, ~165ms before the running browser even heard of it.
omarchy-cmd-browser-handoff sends that message itself with socat and waits
for the ACK, so a web app opens in ~210ms instead of ~430ms.

It hands off only what it can do exactly as the browser would: the packaged
browser binary rather than a wrapper, a flags file holding nothing beyond the
process flags Omarchy ships, no other data directory, and a socket we own.
Anything else, or no answer, launches the browser as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hand Brave Origin launches to the running browser too

/usr/bin/brave-origin is the package's own launcher, reading
brave-origin-flags.conf, with the profile in BraveSoftware/Brave-Origin.
A web app now opens in ~158ms instead of ~345ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
omarchybot added a commit to Raj-Jagadeesh-A-P/omarchy that referenced this pull request Oct 7, 2026
Resolves the conflict with omacom#13520 and omacom#13530: the default browser now comes from omarchy-cmd-default-browser, and the parsed Exec command goes to omarchy-cmd-browser-handoff before falling back to a fresh launch.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
ryanrhughes pushed a commit that referenced this pull request Oct 16, 2026
…3530)

* Hand browser and web app launches to the running browser directly

With a Chromium-based browser already running, each launch started a second
browser process only to pass its command line over the profile's singleton
socket and exit, ~165ms before the running browser even heard of it.
omarchy-cmd-browser-handoff sends that message itself with socat and waits
for the ACK, so a web app opens in ~210ms instead of ~430ms.

It hands off only what it can do exactly as the browser would: the packaged
browser binary rather than a wrapper, a flags file holding nothing beyond the
process flags Omarchy ships, no other data directory, and a socket we own.
Anything else, or no answer, launches the browser as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* Hand Brave Origin launches to the running browser too

/usr/bin/brave-origin is the package's own launcher, reading
brave-origin-flags.conf, with the profile in BraveSoftware/Brave-Origin.
A web app now opens in ~158ms instead of ~345ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 97a9fce)
@emirb emirb added this to the 4.0.5 milestone Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants