From 4f7202a6af2dfc767a0e9442128c80f2b9fdd9c5 Mon Sep 17 00:00:00 2001 From: "prompt.ac/@jeffrey" Date: Tue, 28 Apr 2026 12:55:54 -0700 Subject: [PATCH] slab/yergersnap: fix menu-click crash from showMenu recursion MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit showMenu was setting statusItem.menu then calling performClick(nil), which re-fired handleClick → showMenu in a loop until the main thread blew its stack and the app crashed with EXC_BAD_ACCESS. Replace with NSMenu.popUp(positioning:at:in:) which displays the menu synchronously without going back through the button's action. Co-Authored-By: Claude Opus 4.7 (1M context) --- slab/yergersnap/tap.swift | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/slab/yergersnap/tap.swift b/slab/yergersnap/tap.swift index 7757700ecc..61bc4275d7 100755 --- a/slab/yergersnap/tap.swift +++ b/slab/yergersnap/tap.swift @@ -649,9 +649,12 @@ class AppDelegate: NSObject, NSApplicationDelegate { } func showMenu() { - statusItem.menu = menu - statusItem.button?.performClick(nil) - DispatchQueue.main.async { self.statusItem.menu = nil } + guard let btn = statusItem.button else { return } + // Pop the menu directly. Setting `statusItem.menu` and calling + // `performClick(nil)` would re-fire our action handler and recurse + // until the stack overflows. + let origin = NSPoint(x: 0, y: btn.bounds.height + 2) + menu.popUp(positioning: nil, at: origin, in: btn) } @objc func tapFromMenu() { -- 2.51.2