Skip to content

suppressWhenFocused does not suppress notifications in WSL2 with Windows Terminal #155

Todo

Description

@Nicholas-hosein-pw

Description

With "suppressWhenFocused": true, I still receive completion notifications while the Windows Terminal window running OpenCode is focused.

Notifications themselves work correctly. The problem is that they are not suppressed while I am looking at the terminal.

Environment

  • Windows with WSL2
  • Distribution: Ubuntu 24.04
  • Terminal: Windows Terminal
  • OpenCode: 1.18.35, running inside WSL
  • opencode-notifier: 1.2.0
  • No tmux, Zellij, or WezTerm

Configuration

Global OpenCode configuration:

{
  "plugin": ["@mohak34/opencode-notifier@latest"]
}

~/.config/opencode/opencode-notifier.json:

{
  "sound": false,
  "notification": true,
  "showIcon": false,
  "suppressWhenFocused": true
}

Steps to reproduce

  1. Start OpenCode inside WSL using Windows Terminal.
  2. Keep the Windows Terminal window and the OpenCode tab focused.
  3. Send a short prompt and wait for completion.
  4. Observe that a Windows notification appears.

I also tried quitting and restarting OpenCode, and running wsl --shutdown before reopening Ubuntu and OpenCode. The behavior persisted.

Expected behavior

No completion popup while the OpenCode terminal window is focused.

A popup should appear when another application window is focused.

Actual behavior

A popup appears in both cases.

Possible cause

OpenCode helped me investigate this, and the upstream code appears to handle WSL differently for notification delivery and focus detection:

  • Notification delivery explicitly recognizes WSL and selects Windows notifications.
  • Focus detection selects the Windows backend only when process.platform === "win32".
  • Inside WSL, the runtime reports linux, so focus detection follows the Linux desktop path rather than checking the Windows Terminal window.

I could not find a documented configuration option that enables Windows focus detection under WSL. Please let me know if I have missed a supported configuration or requirement.

I do not yet have an upstream OPENCODE_NOTIFIER_DEBUG=1 trace to attach, so the code-path explanation above is based on source inspection rather than captured debug output.

Fork with a possible fix

I have a fork with a possible fix implemented using OpenCode:

Nicholas-hosein-pw@af3a1c8

The proposed change adds a WSL Windows Terminal focus backend, captures the terminal window at startup, and checks Windows foreground-window state through asynchronous PowerShell queries. Failed or ambiguous checks keep notifications enabled.

I loaded the fork’s built plugin directly and confirmed on OpenCode 1.18.35 that:

  • No popup appears while the OpenCode terminal window is focused.
  • A popup appears when another application window is focused.

This is window-level detection only; it does not distinguish tabs within the same Windows Terminal window. OpenCode 2 was not manually tested.

The possible fix was implemented with OpenAI gpt-6.1-sol via OpenCode.

Comment

It made a bigger change than I was expecting so I am opening this issue to check if I should submit a PR.

Activity

  1. mohak34 commented on Dec 1, 2026

    @mohak34
    Owner

    @Nicholas-hosein-pw You can submit a PR if your fork works with the fixes if you don't mind. I'll look into it and then merge it if it doesn't break anything else.

  2. Nicholas-hosein-pw commented on Dec 1, 2026

    @Nicholas-hosein-pw
    ContributorAuthor

    Ok, thanks. It is working for me so I have added the PR. #156

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions