Conversation
…und app foreground_app_from_running_application() dropped the frontmost app entirely when app.bundleIdentifier() was nil — a real state for a bare Mach-O launched from a shell script or a QEMU front-end, which still becomes NSWorkspace's frontmost application normally. Its window could therefore never match a per-app profile, and it never appeared in the GUI's Recent picker section. Falls back to app.executableURL().path() in that case. ForegroundApp::id's own doc already documents the executable path as a legitimate identity namespace — it's what Windows always uses — so this reuses an existing contract instead of inventing a new one. Fixes AprilNEA#1404
|
| let id_string = match app.bundleIdentifier() { | ||
| Some(bundle_id) => bundle_id, | ||
| None => app.executableURL().and_then(|url| url.path())?, |
There was a problem hiding this comment.
This fallback makes executable paths valid macOS application IDs, but the shared ForegroundApp::id documentation still describes macOS IDs only as bundle identifiers, while the macOS backend documentation still says an app without a bundle identifier returns None. These conflicting contracts could lead callers or future refactors to treat the new path identity as unsupported. Please update both API descriptions to document the fallback.
Knowledge Base Used: Global input hooks
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
| let id_string = match app.bundleIdentifier() { | ||
| Some(bundle_id) => bundle_id, | ||
| None => app.executableURL().and_then(|url| url.path())?, |
There was a problem hiding this comment.
Fallback branch lacks coverage
This adds bundle-identifier precedence and an executable-path fallback, but no test exercises either branch. The decision is embedded in the AppKit calls even though comparable platform identity logic is extracted into testable code. Without focused coverage, a later refactor could restore the original bundle-less-app bug or reverse the precedence without CI detecting it.
Summary
NSRunningApplication.bundleIdentifier()return nil, soforeground_app_from_running_applicationdropped it entirely instead of returning aForegroundApp.Changes
crates/openlogi-hook/src/macos.rs: whenbundleIdentifier()is nil, fall back toapp.executableURL().path()as theForegroundApp::id.ForegroundApp::id's own doc already documents the executable path as a legitimate identity namespace (it's what Windows always uses), so this reuses an existing contract instead of inventing a new one.Testing
cargo check -p openlogi-hook --target x86_64-apple-darwin— cleanRUSTFLAGS="-D warnings" cargo clippy -p openlogi-hook --target x86_64-apple-darwin --all-targets -- -D warnings— cleancargo fmt --all -- --check— cleanRUSTFLAGS="-D warnings" cargo clippy -p openlogi-hook -p openlogi-agent -p openlogi-agent-core -p openlogi-desktop -p openlogi-overlay --all-targets -- -D warnings— cleanRUSTFLAGS="-D warnings" cargo test -p openlogi-hook -p openlogi-agent -p openlogi-agent-core -p openlogi-desktop -p openlogi-overlay— all greenNSWorkspacenotifications was not possible on this host.Fixes #1404