Repository navigation
Description
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
- Start OpenCode inside WSL using Windows Terminal.
- Keep the Windows Terminal window and the OpenCode tab focused.
- Send a short prompt and wait for completion.
- 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:
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
mohak34 commentedon Dec 1, 2026
@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.
Nicholas-hosein-pw commentedon Dec 1, 2026
Ok, thanks. It is working for me so I have added the PR. #156