Skip to content

fix(macos): parse lsappinfo report output - #144

Merged
mohak34 merged 1 commit into
mohak34:mainfrom
bhean:fix-macos-frontmost-app-parser
Oct 14, 2026
Merged

mohak34 merged 1 commit into
mohak34:mainfrom
bhean:fix-macos-frontmost-app-parser

Conversation

@bhean

@bhean bhean commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Problem

With suppressWhenFocused: true, notifications were still delivered while OpenCode was focused in a Ghostty/tmux popup on macOS 27.0.1 (build 26A434). This was reproduced with notifier 0.6.1; the same parser is present on the current main branch.

Run lsappinfo info -only name "$(lsappinfo front)" while Ghostty is frontmost. The exact output observed was:

"Ghostty" ASN:0x0-0x8d08d: (in front) 
    bundleID=[ NULL ] 
    bundle path=[ NULL ] 
    executable path=[ NULL ] 
 !cgsConnection !signalled type=[ NULL ]  flavor=[ NULL ]  Version=[ NULL ]  Arch=!!none 

The same report format was also observed when querying Finder. This establishes the reproduction, but does not establish why this macOS installation returns a report instead of the requested name=value field.

The current sed substitution leaves unmatched lines unchanged. The resulting report is nonempty, so the plugin accepts it as the app name and skips its System Events fallback. Comparing the report with the expected terminal name then reports the terminal as unfocused.

Change

Parse the raw output in TypeScript, supporting both name=value fields and the quoted application name in the report header. Reject empty, malformed, or unrecognized output so the existing System Events fallback can run. Add focused regression tests, a README clarification, and an Unreleased changelog entry.

OpenCode version and platforms

  • Both OpenCode versions use the shared macOS focus helper: V1 server delivery and V2 terminal delivery benefit from the fix. V2 server event commands remain independent of terminal focus.
  • The existing tmux, WezTerm, and Zellij pane checks, Linux and Windows backends, channel selection, and configuration defaults remain unchanged.
  • This also corrects the shared app-name lookup used by macOS terminal activation.
  • Tested on macOS 27.0.1 (build 26A434) with Ghostty/tmux. Other macOS terminals, Windows, and Linux were not tested on real hardware.

Evidence

  • macOS 27.0.1 with Ghostty/tmux: the equivalent fix in the installed notifier detected the open popup as focused; the user confirmed notification suppression after restarting OpenCode.
  • Parser tests cover name=value output, the exact multiline report above, spaces, escaped quotes, and invalid output.
  • Executed the four new parser tests with Node's TypeScript stripping and an assertion adapter; also checked fallback routing with a stubbed query and parsed the live Ghostty report. All passed. git diff --check passed.
  • Bun 1.4.2: bun test src/focus.test.ts passed (65 tests, 107 assertions); bun run typecheck passed. Dependencies were installed with bun install --frozen-lockfile.

Model: openai/gpt-6.1-sol. Harness: OpenCode.

Unmatched sed output was accepted as an app name, skipping the
System Events fallback and preventing focus suppression.
@mohak34
mohak34 merged commit 69d407a into mohak34:main Oct 14, 2026
1 check passed
@bhean
bhean deleted the fix-macos-frontmost-app-parser branch October 14, 2026 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants