ghost-os icon indicating copy to clipboard operation
ghost-os copied to clipboard

App lookup by substring picks the wrong app ("Finder" matches "NeoFinder")

Open djbclark opened this issue 1 month ago • 0 comments

App names are resolved with a case-insensitive substring match, and the first running application that matches wins:

$0.localizedName?.localizedCaseInsensitiveContains(appName) == true

This appears in Sources/GhostOS/Actions/FocusManager.swift, Sources/GhostOS/Perception/Perception.swift and Sources/GhostOS/Recipes/RecipeEngine.swift.

Repro (macOS, ghost-os from Homebrew):

  1. Run NeoFinder (localizedName "NeoFinder") alongside Finder.
  2. Call ghost_hotkey (or ghost_context) with app: "Finder".
  3. The action goes to NeoFinder's window, not Finder, whenever NeoFinder comes before Finder in NSWorkspace.runningApplications.

Other names that would collide in the same way: "Mail" vs "Mailspring", "Code" vs "Xcode".

Suggested fix: try matches in order of strictness, and stop at the first tier that finds something:

  1. Exact localizedName (case-insensitive).
  2. Exact bundleIdentifier (e.g. com.apple.finder).
  3. Substring, as the last resort. If more than one app matches at this tier, return an error that lists the candidates rather than picking one silently.

Ideally the three call sites would share one resolver.

I searched existing issues and PRs ("Finder", "app name", "substring", "wrong app", "NeoFinder") and found nothing related.

djbclark avatar Oct 11 '26 10:10 djbclark