macos: default to showing the window on every launch

Replaces the narrow LAN_MOUSE_RELAUNCHED signal with an inverted
opt-out: present the main window on every macOS launch unless
LAN_MOUSE_HIDDEN=1 is in the environment.

User feedback: on any manual launch (Dock, Finder, `open`, post-
grant relaunch) the window should come up so the user has a visible
confirmation the app is alive and can see its current state. A
hidden-to-menu-bar-only launch should be opt-in for a LaunchAgent /
login-item configuration, not the default.

LaunchAgent plists can set the env via `EnvironmentVariables` and
`RunAtLoad=true` for a quiet boot launch.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Jon Kinney
2026-04-24 10:45:24 -05:00
committed by Ferdinand Schober
parent 99344a3104
commit 10fd728804
2 changed files with 9 additions and 11 deletions

View File

@@ -144,11 +144,7 @@ pub fn relaunch_bundle() {
// Trailing `&` backgrounds the sleep+open so our shell call returns
// immediately; the spawned shell is adopted by launchd once we exit.
// `--env LAN_MOUSE_RELAUNCHED=1` sets an env var on the new process
// so `build_ui` can present the main window on this specific launch
// (confirming to the user that the grant + relaunch worked) while
// still starting hidden in the menu bar on normal fresh launches.
let cmd = format!("(sleep 1 && open --env LAN_MOUSE_RELAUNCHED=1 {bundle:?}) &");
let cmd = format!("(sleep 1 && open {bundle:?}) &");
let _ = Command::new("sh").arg("-c").arg(cmd).spawn();
}