Skip to content

[BUG] suppressWhenFocused does not work on macOS with WezTerm #63

@lindeberg

Description

@lindeberg

Bug

suppressWhenFocused: true (the default) has no effect when using WezTerm on macOS. Notifications fire even when the WezTerm window is the active/focused window.

Root cause

On macOS, focus detection works by calling:

osascript -e 'tell application "System Events" to return name of first application process whose frontmost is true'

System Events reports the CFBundleExecutable value from the app's Info.plist as the process name. For WezTerm, that value is wezterm-gui.

The plugin's MAC_TERMINAL_APP_NAMES set includes "wezterm", and when TERM_PROGRAM=WezTerm, getExpectedMacTerminalAppNames adds "wezterm" to the expected set. But "wezterm-gui" !== "wezterm", so isMacTerminalAppFocused always returns false.

This can be verified:

osascript -e 'tell application "System Events" to return name of first application process whose frontmost is true'
# => wezterm-gui

Scope

Affects all macOS WezTerm users regardless of install method. The CFBundleExecutable is wezterm-gui in the official .app bundle itself (confirmed in the Homebrew cask and WezTerm's own Info.plist). This is not installation-specific.

Fix

In src/focus.ts, change the expected process name for WezTerm from "wezterm" to "wezterm-gui":

- } else if (termProgram === "warpterminal") {
-   expected.add("warp");
- } else if (termProgram.length > 0) {
+ } else if (termProgram === "warpterminal") {
+   expected.add("warp");
+ } else if (termProgram === "wezterm") {
+   expected.add("wezterm-gui");
+ } else if (termProgram.length > 0) {

Or alternatively add "wezterm-gui" to MAC_TERMINAL_APP_NAMES.

Environment

  • macOS (Homebrew cask install, but affects all installs)
  • WezTerm 20240203-110809-5046fc22
  • TERM_PROGRAM=WezTerm
  • Frontmost app name from System Events: wezterm-gui

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions