Skip to content

Every agent's model. One place. Codex on DeepSeek, Claude Code on Kimi, from the menu bar.

update: the Mac relaunch opens a new instance (open -n), not a reopen of the gone one (Linka on Discord)

yetone27a8255fd793
diff --git a/internal/update/relaunch_open_test.go b/internal/update/relaunch_open_test.go
index 5d34851d8..115882532 100644
--- a/internal/update/relaunch_open_test.go
+++ b/internal/update/relaunch_open_test.go
@@ -6,12 +6,14 @@ import (
)
// A Mac restart by itself with no window up opens the app as a login launch
-// does, its menu bar icon only (#2096); one with the window opens it.
+// does, its menu bar icon only (#2096); one with the window opens it. Both
+// ask for a new instance (-n), so LaunchServices launches the bundle rather
+// than send a reopen to the magpie that has just exited (Linka's -600).
func TestRelaunchOpen(t *testing.T) {
- if got, want := relaunchOpen("/Applications/magpie.app", true), `open "/Applications/magpie.app"`; got != want {
+ if got, want := relaunchOpen("/Applications/magpie.app", true), `open -n "/Applications/magpie.app"`; got != want {
t.Errorf("window: %s, want %s", got, want)
}
- if got, want := relaunchOpen("/Applications/magpie.app", false), `open "/Applications/magpie.app" --args tray`; got != want {
+ if got, want := relaunchOpen("/Applications/magpie.app", false), `open -n "/Applications/magpie.app" --args tray`; got != want {
t.Errorf("no window: %s, want %s", got, want)
}
}
diff --git a/internal/update/relaunch_retry_test.go b/internal/update/relaunch_retry_test.go
index 05fe35c76..07e7784c1 100644
--- a/internal/update/relaunch_retry_test.go
+++ b/internal/update/relaunch_retry_test.go
@@ -14,8 +14,8 @@ import (
// fakeOpen puts an `open` first on PATH that fails its first fails tries
// as LaunchServices does while it still holds the old magpie as running
-// ("-600 procNotFound"), then writes its arguments to dir/opened. Each try
-// is counted in dir/tries.
+// ("-600 procNotFound"), then writes its arguments to dir/opened, -n
+// included. Each try is counted in dir/tries.
func fakeOpen(t *testing.T, fails int) string {
t.Helper()
dir := t.TempDir()
@@ -23,8 +23,10 @@ func fakeOpen(t *testing.T, fails int) string {
d='` + dir + `'
n=$(( $(cat "$d/tries" 2>/dev/null || echo 0) + 1 ))
echo $n > "$d/tries"
+app=
+for a in "$@"; do case "$a" in *.app) app=$a;; esac; done
if [ $n -le ` + strconv.Itoa(fails) + ` ]; then
- echo "_LSOpenURLsWithCompletionHandler() failed for the application $1 with error -600." >&2
+ echo "_LSOpenURLsWithCompletionHandler() failed for the application $app with error -600." >&2
exit 1
fi
echo "$@" > "$d/opened"
@@ -66,7 +68,8 @@ func TestRelaunchOpenTriedAgain(t *testing.T) {
opened := filepath.Join(dir, "opened")
for end := time.Now().Add(30 * time.Second); time.Now().Before(end); time.Sleep(50 * time.Millisecond) {
if b, err := os.ReadFile(opened); err == nil && len(b) > 0 {
- if got, want := strings.TrimSpace(string(b)), bundle+" --args tray"; got != want {
+ // -n: a new instance, not a reopen sent to the gone one
+ if got, want := strings.TrimSpace(string(b)), "-n "+bundle+" --args tray"; got != want {
t.Fatalf("opened %q, want %q", got, want)
}
if n := tries(dir); n != 3 {
diff --git a/internal/update/update.go b/internal/update/update.go
index e72007075..040d0235b 100644
--- a/internal/update/update.go
+++ b/internal/update/update.go
@@ -469,12 +469,21 @@ func runAfterExit(pid int, command string) error {
return cmd.Start()
}
-// relaunchOpen is the open command Relaunch runs for bundle.
+// relaunchOpen is the open command Relaunch runs for bundle. -n asks
+// LaunchServices for a new instance: without it, open looks the app up
+// among those running first, and just after magpie exits LaunchServices
+// can still have the gone process registered as magpie. open then sends
+// it a reopen Apple event (aevt/rapp) rather than launching the bundle,
+// and fails with -600, procNotFound ("Specified target process … does
+// not exist", "LAUNCH: Launch failed in CSUI"; Linka's log on Discord,
+// macOS 27.0.1, v0.1.1308), as often as it is tried. A magpie that is in
+// fact up still has the one instance: the new process finds the instance
+// lock held and hands over to it (runningAlready in internal/gui).
func relaunchOpen(bundle string, window bool) string {
if window {
- return fmt.Sprintf("open %q", bundle)
+ return fmt.Sprintf("open -n %q", bundle)
}
- return fmt.Sprintf("open %q --args tray", bundle)
+ return fmt.Sprintf("open -n %q --args tray", bundle)
}
// ReplaceBinary puts the release's build for this binary where the