Skip to content

The agent that grows with you

fix(webapp): point to --no-open when a private launch opened no visible browser

unsupportedpastels395c6737391c
diff --git a/hermes_cli/webapp_launcher.py b/hermes_cli/webapp_launcher.py
index b73b4f1e15a..d386542e5eb 100644
--- a/hermes_cli/webapp_launcher.py
+++ b/hermes_cli/webapp_launcher.py
@@ -108,7 +108,9 @@ def _open_privately(target: Path, url: str) -> bool:
user-only ``webapp`` folder, readable by this OS user alone, and open that page. Pages of earlier
launches go first, so at most one is left, and its link stops working within the link's lifetime.
False, leaving no page, on WSL (the Windows browser cannot read the page as this user only), when the
- folder or page cannot be kept user-only, or when no browser opens it."""
+ folder or page cannot be kept user-only, or when no browser opens it. On macOS ``webbrowser`` hands the
+ URL to ``osascript`` on stdin, never in argv, so the page mainly protects the BSDs and illumos, where
+ ``xdg-open`` or ``firefox`` gets the URL in argv."""
from gateway.webapp_listener import TOKEN_PATH, _close_to_other_users, _readable_by_other_users
from hermes_constants import is_wsl
if os.name == "nt" or is_wsl():
@@ -345,6 +347,7 @@ def cmd_webapp(args) -> int:
# carries it to the browser; failing that, the user opens it by hand.
if not args.no_open and _open_privately(target, link["url"]):
print("Opened the Webapp in your browser.")
+ print("If no browser opened, run `hermes webapp --no-open` for a link.")
return 0
print(f"Open this link in your browser within {link['expires_in_seconds']} seconds. It works "
"once and signs the browser in as you, so keep it private:")
diff --git a/tests/hermes_cli/test_webapp_private_launch.py b/tests/hermes_cli/test_webapp_private_launch.py
index a7662289a55..1a59e6c460b 100644
--- a/tests/hermes_cli/test_webapp_private_launch.py
+++ b/tests/hermes_cli/test_webapp_private_launch.py
@@ -53,6 +53,8 @@ def test_a_private_link_reaches_the_browser_in_a_page_only_the_user_can_read(pri
assert html.unescape(refresh[1]) == LINK
out = capsys.readouterr().out
assert "Opened the Webapp in your browser" in out and "ticket=" not in out
+ # macOS can report a browser that opened where the user never sees it (osascript over SSH).
+ assert "If no browser opened, run `hermes webapp --no-open` for a link." in out
@pytest.mark.platforms("posix")
diff --git a/website/docs/reference/cli-commands.md b/website/docs/reference/cli-commands.md
index 8534b2b1e03..22347b6b2fb 100644
--- a/website/docs/reference/cli-commands.md
+++ b/website/docs/reference/cli-commands.md
@@ -1942,8 +1942,9 @@ Windows it checks nothing, and the link travels only in the browser launcher's c
standard users cannot read. On macOS, the BSDs and illumos neither holds, so the command never passes
the link to a browser launcher: it writes it into a page only your OS user can read
(`webapp/launch-*.html` in the gateway home) and opens that page. Where it cannot open a browser, and
-on WSL, it prints the link for you to open. Until it is used it signs a browser in as you, so keep it
-private.
+on WSL, it prints the link for you to open. On macOS a browser can open where you don't see it (over
+SSH, on the Mac's own screen): if none did, run `hermes webapp --no-open` for the link. Until it is
+used it signs a browser in as you, so keep it private.
For a named profile served by the default gateway (`hermes -p work webapp`), the Webapp opens on that
profile.
diff --git a/website/docs/user-guide/desktop.md b/website/docs/user-guide/desktop.md
index 4172ae08534..118e98e5753 100644
--- a/website/docs/user-guide/desktop.md
+++ b/website/docs/user-guide/desktop.md
@@ -57,8 +57,10 @@ Linux the gateway checks that the browser's connection belongs to your OS user;
travels only in the browser launcher's command line, which other standard users cannot read. On macOS,
the BSDs and illumos neither holds, so the command writes the link into a page only your OS user can
read (in the gateway home's `webapp` folder) and opens that page: the launcher sees only its path.
-Where it cannot open a browser (`--no-open`, an SSH session) and on WSL (where the Windows browser
-reaches the gateway through WSL's relay), it prints the one-use link for you to open instead; until it
+On macOS a browser can open where you don't see it (over SSH, on the Mac's own screen): if none did,
+run `hermes webapp --no-open` for the link. Where it cannot open a browser (`--no-open`, an SSH session
+on the BSDs or illumos) and on WSL (where the Windows browser reaches the gateway through WSL's
+relay), it prints the one-use link for you to open instead; until it
is used it signs a browser in as you, so keep it private. `hermes webapp --sign-out` signs out every
tab at once: their open connections close, Bot Desktop viewers included, and each shows the sign-in
instructions. Behind the sign-in gate (below) it also signs out every browser that signed in with a