Skip to content

Pass the activation token on to the browser - #16079

Open
dmkenney wants to merge 7 commits into
omacom:quattrofrom
dmkenney:browser-activation-token
Open

dmkenney wants to merge 7 commits into
omacom:quattrofrom
dmkenney:browser-activation-token

Conversation

@dmkenney

@dmkenney dmkenney commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

Part of #16078.

What changed

A link opened from a terminal or a notification carries an XDG_ACTIVATION_TOKEN, the compositor's proof that a click asked for focus. Both browser launch paths dropped it:

  • omarchy-cmd-browser-handoff writes the URL straight to the running browser's singleton socket. A browser process would have moved the token into --xdg-activation-token before handing off; the handoff didn't, so the running browser asked for focus with a token of its own, made from the last input it received.
  • omarchy-launch-browser starts a new browser in a systemd-run unit, which takes the user manager's environment, not the caller's.
  • omarchy-browser.desktop didn't set StartupNotify=true. GLib only hands a launched app the caller's token when it does, so links opened through the desktop portal's OpenURI (which carries the token as activation_token) reached omarchy-launch-browser without it.

Now the handoff passes --xdg-activation-token=$XDG_ACTIVATION_TOKEN when the variable is set, the launcher adds --setenv=XDG_ACTIVATION_TOKEN to the unit, and the link entry sets StartupNotify=true, with a migration to refresh the installed copy. omarchy-launch-webapp starts its browser with plain uwsm-app, which keeps the caller's environment, so it needs no change.

Edge needs one more fix for the token to get through. Its own handoff sends two more fields after the working directory, and when they're missing and there's more than one argument, Edge drops the first two. --xdg-activation-token=T URL then opened a blank tab. The handoff now sends Edge those fields, as reported with the fix in #16428. This also fixes Edge web apps launched with extra flags, such as the Sunshine admin app.

On Hyprland 0.56.2 this changes nothing visible, since every activation request is granted. It matters once Hyprland checks token serials (hyprwm/Hyprland#16427 and the follow-up in #16078): a real click then raises the browser, and an automated open doesn't. omarchy-launch-browser still focuses the browser itself after any URL launch; #14283 removes that for a running browser.

How it was verified

  • test/shell.d/browser-handoff-test.sh: new case checks the token is sent as --xdg-activation-token ahead of the arguments. Fails without the change.
  • test/shell.d/launch-browser-test.sh: new cases check --setenv=XDG_ACTIVATION_TOKEN is passed when a token is set and not otherwise. Fails without the change.
  • The migration, run against temporary homes: updates an old entry, is a no-op on a second run, and does nothing when the entry isn't installed.
  • Portal end to end on my desktop: OpenURI for an https URL with activation_token portal-e2e-token went through omarchy-browser.desktop and omarchy-launch-browser, and the running Brave called activate("portal-e2e-token").
  • With a real throwaway Chromium 154 (WAYLAND_DEBUG=1):
    • XDG_ACTIVATION_TOKEN=e2e-token bin/omarchy-cmd-browser-handoff chromium <url> made the running Chromium call activate("e2e-token").
    • A fresh Chromium started through systemd-run --setenv=XDG_ACTIVATION_TOKEN uwsm-app -- called activate("fresh-start-token").
  • Over the singleton socket, Brave 1.97 and Chrome 155 also activate with the token passed in --xdg-activation-token.
  • test/shell.d/browser-handoff-test.sh: new Edge case checks the two extra fields are sent. It runs only where /usr/bin/microsoft-edge-stable is installed and skips otherwise. I ran it with a stand-in binary in a private mount namespace: fails without the fix, passes with it.
  • With a throwaway Edge 156.0.4314.42, the patched handoff opened the right URL for --xdg-activation-token=T URL, --new-window --profile-directory=Default URL, a bare URL, and --app=URL --ignore-certificate-errors. Without the fix, the first two opened a blank tab. I didn't check whether the window and app-window switches took effect, only that the URL opened.

Not run: the full ./test/shell suite.

Fixes #16428

A link opened from a terminal or a notification comes with an
XDG_ACTIVATION_TOKEN that proves a click asked for focus. Both browser
launch paths dropped it. The handoff writes straight to the browser's
singleton socket, so the running browser never saw the token a browser
process would have moved into --xdg-activation-token, and asked for
focus with a token of its own instead. The fallback starts the browser
in a systemd unit, which takes the user manager's environment and not
the caller's.

Pass the token as --xdg-activation-token over the socket, and carry it
into the unit with --setenv.
@greptile-apps

greptile-apps Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no outstanding issues were found.

Summary

The PR carries the caller's activation token through browser launches and fixes Edge's socket message.

  • Browser links carry the opener’s focus token into the browser.
  • Edge opens handed-off URLs after its extra socket fields are sent.

Both earlier findings are fixed: the tests clear inherited tokens and skip cases when system flags could change the result. No new issues were found in the latest test change.

Reviews (7) · Last reviewed commit: "Run the Edge handoff case where Edge isn..." · Reviewed by Greptile

Comment thread test/shell.d/launch-browser-test.sh Resolved
GLib only hands a launched app the caller's activation token when the
app's entry sets StartupNotify=true. Links opened through the desktop
portal's OpenURI, which carries the token as its activation_token
option, reached omarchy-launch-browser without it.
@omarchybot omarchybot added bug Something isn't working verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 21, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at 3d919ac and nothing found to change. All three paths really did drop the token, and this fixes each one.

What ran, on a disposable Omarchy worker (Hyprland 0.56.2, Chromium 154, xdg-desktop-portal 1.22.1, glib2 2.90.1):

  • Handoff to a running browser. I ran a real Chromium with WAYLAND_DEBUG=1. After a handoff from base, it called xdg_activation_v1.activate with a UUID token of its own. After a handoff from this head, it used the token passed in XDG_ACTIVATION_TOKEN.
  • Fresh start. With no browser running, this head's omarchy-launch-browser put the token in the omarchy-browser-*.service environment; base left it out. The same systemd-run --setenv plus uwsm-app pipeline made the new Chromium activate with the passed token.
  • Portal. An OpenURI call with an activation_token reached Chromium's activate only after the installed entry had StartupNotify=true. Before that, Chromium used its own token.
  • Migration. It updated the old installed entry to match the repository's copy, left the entry untouched on a second run, and did nothing in a home without the entry.
  • Tests. The three focused test files fail on base with these tests applied and pass on the head. ./test/cli passes. The full ./test/shell run fails the same 20 checks on base and on this head, mostly a missing node on the worker, so nothing new fails.

Codex Medium gave a second opinion. Its own reading agreed that the problem is real and the change is proportionate, and its independence is not guaranteed. It also checked the order of the singleton arguments, how --setenv=NAME takes the caller's value, and the empty-array expansion under set -u, and found nothing wrong. It raised one point: the migration replaces the whole installed entry when the entry lacks StartupNotify=true, so a hand edit would be lost. I don't count that as a defect. omarchy-refresh-applications already overwrites every Omarchy entry wholesale, and the earlier migration 1791934674.sh copied this same entry unconditionally, so this file has never been the user's to edit.

One thing to note: the description says "Part of #16078", but that number doesn't resolve in this repository, so nothing is linked as fixed.

This is waiting on the maintainer.

@joetossell

Copy link
Copy Markdown

On Microsoft Edge this makes links that carry a token open a blank tab. Edge drops the first two arguments of any handoff with more than one, so --xdg-activation-token=T URL loses both. Details and a patch for the handoff are in #16428.

Edge's own second process sends two more fields after the working
directory on the singleton socket: the time in microseconds since 1601,
then a number Edge doesn't check. A message without them is read
correctly only when it has a single argument. With more than one, Edge
takes the first two arguments as those fields and drops them, so a link
handed off with --xdg-activation-token opened a blank tab, as did a web
app launched with extra flags.

Reported with the fix in omacom#16428.
@dmkenney

Copy link
Copy Markdown
Contributor Author

Thanks, confirmed on Edge 156.0.4314.42: --xdg-activation-token=T URL opened a blank tab. I added your fix from #16428 to this PR (fbcb64c) with a test, and with it every case opens the right URL.

Comment thread test/shell.d/browser-handoff-test.sh Resolved
@omarchybot omarchybot added verified Omarchy Triage has verified that this issue is ready for final review and removed verified Omarchy Triage has verified that this issue is ready for final review ready Good to merge labels Oct 23, 2026
It re-reads the line the change adds to omarchy-browser.desktop, which AGENTS.md rules out under "Don't restate the implementation". Removing that line from the entry is what the test would catch, and that is an edit to the line itself; the portal behaviour it stands for was checked against a real OpenURI call instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 8a0e4a1 after the Edge commit. The Edge fix works, and I pushed one commit that removes a test.

Edge, on a disposable Omarchy worker (Hyprland 0.56.2, microsoft-edge-stable-bin 156.0.4314.42, a local HTTP server logging each request). I tried three launches with the Edge commit reverted (3d919ac) and at the head:

With Edge installed, the new Edge case in browser-handoff-test.sh runs. It passes at the head and fails with the commit reverted. Chromium, Chrome and Brave get the same bytes as before, so the Chromium token results from my review of 3d919ac still hold.

Edge itself ignores the token. After every handoff, Edge 156 called xdg_activation_v1.activate with a token it minted itself. It did the same when Edge's own second process was given the token in XDG_ACTIVATION_TOKEN or --xdg-activation-token. So on Edge this change fixes the blank tab but doesn't get the click's token used. The description doesn't claim it does, but whoever expects Edge to behave like Chromium once Hyprland checks serials should know.

Pushed: 8a0e4a1 removes the case in browser-link-handoff-test.sh that greps omarchy-browser.desktop for StartupNotify=true. AGENTS.md rules out a test that re-reads the line the change just added, and the portal behaviour it stood for was checked against a real OpenURI call in my earlier review. StartupNotify=true and its migration are unchanged. The description still lists that test, so it's now out of date.

Suite: ./test/cli passes. The full ./test/shell at fbcb64c fails the same five checks as base 3ac4365: block-art logo, Hi width, da/menu.json, the keepLoaded IPC fixture, and lock-view timing. Nothing new fails. After the push, the three browser test files and ./test/cli pass at 8a0e4a1.

Second opinion: Codex Medium and muse-spark-1.3 (thinking high) reviewed the Edge commit and then the removal, and found no defect. They checked the 1601-epoch arithmetic with both . and , separators, the Edge-only gating, the two callers and the test regex. Their independence is not guaranteed. Both agreed with Greptile that the Edge case fails falsely when /etc/microsoft-edge-stable-flags.conf carries an extra flag such as --new-window. The existing Chromium cases are exposed to /etc/chromium-flags.conf the same way, so I left it. Codex also noted that no committed test runs the new migration 1792514642.sh. It was checked by hand on a worker in my earlier review.

#16428 is now linked as fixed by this pull request.

This is waiting on the maintainer: when to land token plumbing that changes nothing visible until Hyprland checks token serials, and how it is ordered against #14283.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Oct 23, 2026
The handoff leaves any launch to the launcher when /etc/<browser>-flags.conf
carries a flag beyond Omarchy's own. The test points XDG_CONFIG_HOME at a
temp dir but can't swap out /etc, so on a machine with such a flag the
Chromium and Edge cases failed though the handoff did the right thing.
Skip them when the system flags file exists.
@greptile-apps

greptile-apps Bot commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Want your agent to iterate on Greptile's feedback? Try greploops.

@omarchybot omarchybot added the verified Omarchy Triage has verified that this issue is ready for final review label Nov 1, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at ea04ea2. The new commit fixes the false failure Greptile pointed out, and nothing else in the pull request changed.

On a disposable Omarchy worker with microsoft-edge-stable-bin 156.0.4314.58 installed, so the Edge case ran instead of skipping:

  • browser-handoff-test.sh, launch-browser-test.sh, browser-link-handoff-test.sh and ./test/cli pass at ea04ea2. They also pass with ea04ea2 merged into current quattro (48fcf5f), which has since changed omarchy-launch-browser. The merge is clean and the token still reaches both the handoff and the systemd-run launch.
  • With --disable-gpu in /etc/chromium-flags.conf and /etc/microsoft-edge-stable-flags.conf, the previous head's handoff test fails. At ea04ea2 it skips. With only the Edge file present, just the Edge case skips. A stock install has neither file, so CI and a default machine still run every case.
  • The full ./test/shell on the merge fails the same 8 checks as quattro alone (Hi width, block-art logo, HUP, first-run git setup, keepLoaded IPC, recorder INT, reconnect Ctrl-C, interrupted install). None of them involves the browser. Nothing new fails.

The handoff and launcher code is the same as at fbcb64c, so the real-Edge reproduction from my last review still stands. With the Edge commit reverted, a link and a web app with an extra flag open a blank tab; at the head they open the URL.

Second opinion: Codex Medium and muse-wonder (thinking high) reviewed ea04ea2 and the merge with current quattro, and found no defect. They agreed that a skip on the file's mere existence is right. Skipping based on what the file contains would mean copying the handoff's flag whitelist into the test. They also confirmed that no other /etc read is left in the test. Their independence is not guaranteed.

A competing fix: #16433 by @vitally makes the same Edge change to omarchy-cmd-browser-handoff, byte for byte, and fixes the same #16428. The Edge commit here was pushed first, so this pull request comes first. Codex, asked separately, agreed. #16433 has one thing this one lacks: its test stands in for type -P, so the Edge case runs where Edge isn't installed. Here that case skips, which on CI likely means always. That test is worth bringing across, and #16433's own review will hand it over.

This is waiting on the maintainer, as before: when to land token plumbing that changes nothing visible until Hyprland checks token serials, and how it is ordered against #14283.

The packaged path is what selects Edge's profile, so the test stands in for type -P rather than skipping wherever Edge is missing, which is everywhere the suite usually runs. Taken from omacom#16433.

Co-Authored-By: Vitally Tezhe <vitally@tezhe.eu>
Co-Authored-By: muse-wonder High <noreply@meta.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@omarchybot

Copy link
Copy Markdown
Collaborator

Re-reviewed at 3c8e8c4. I pushed one commit to this branch. It brings over the Edge test improvement from #16433 by @vitally, credited to them with a Co-Authored-By trailer. Nothing outside test/shell.d/browser-handoff-test.sh changed.

What it changes: the Edge case now stands in for type -P microsoft-edge-stable inside a subshell. It no longer skips wherever Edge isn't installed, which is most machines and CI. The packaged path only picks Edge's profile. The message the test checks is still the one the real handoff sends over the socket. The skip for /etc/microsoft-edge-stable-flags.conf stays.

On a disposable Omarchy worker without Edge installed:

  • At 3c8e8c4, browser-handoff-test.sh (4/0), launch-browser-test.sh (5/0), browser-link-handoff-test.sh (8/0) and ./test/cli pass.
  • With only Edge's two extra fields removed from omarchy-cmd-browser-handoff, the Edge case fails. At ea04ea2 it would have skipped on this machine. So it now guards the Edge drops the first two arguments of a browser handoff that has more than one #16428 fix on machines where it never ran before.
  • The handoff and launcher code is the same as at fbcb64c, so the real-Edge reproduction and the full ./test/shell run from the earlier reviews still stand. quattro hasn't touched these files since, and the branch still merges cleanly.

Second opinion: Codex Medium and muse-wonder (thinking high) reviewed the commit and found no defect. They confirmed that the stand-in reaches the handoff and doesn't leak into later cases. I wrapped a long comment at muse-wonder's suggestion. Two other points are not taken. Running the Edge case ahead of the Chromium check isn't needed, because a stock install ships /usr/bin/chromium. A > 1601 comparison on the timestamp adds nothing, because a time missing the 1601 offset is 16 digits and already fails the 17-digit match. Their independence is not guaranteed.

#16433 now has nothing this pull request lacks.

This is waiting on the maintainer, as before: when to land token plumbing that changes nothing visible until Hyprland checks token serials, and how it is ordered against #14283.

@omarchybot omarchybot removed the verified Omarchy Triage has verified that this issue is ready for final review label Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Edge drops the first two arguments of a browser handoff that has more than one

3 participants