desktop: clicking a Windows notification does not restore or focus the window
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 84/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- electron, typescript
- 領域
- desktop
調査の方向性
レンダラーの通知クリックハンドラーから開始し、WindowShow と WindowSetFocus をたどって、メインプロセスの BrowserWindow 呼び出しまで進みます。restore()、show()、focus() を呼び出す既存のディープリンクヘルパーを特定し、通知クリックのためにその動作を再利用するか揃えます。Windows で最小化ウィンドウとバックグラウンドウィンドウのケースを確認し、関連するデスクトップテストを実行するか、トーストからフォーカスへのフローを手動で再現します。
索引モデルが issue の本文から書いたものです。
説明
Summary
On Windows, clicking the desktop notification that fires when an agent response is ready (or an error occurs) does not bring the OpenCode window to the front. If the window is minimized it stays minimized; if it is only behind other windows it usually stays behind. The notification click handler only calls showWindow() + setWindowFocus(), which map to BrowserWindow.show() + BrowserWindow.focus(). Neither of those restores a minimized window, and show() is a no-op for an already-visible window, so nothing brings the window forward.
Environment
- opencode version:
opencode v2.0.32(desktop app,OpenCode.exeFileVersion 2.0.32) - OS: Windows 11 Enterprise LTSC,
Microsoft Windows NT 10.0.26100.0(win32 x64) - Terminal: N/A (desktop app)
- Shell:
C:\Windows\system32\cmd.exe - Install/channel: release build installed under
%LOCALAPPDATA%\Programs\@opencode-aidesktop - Runtime: Electron 44.4.5 (Chrome 152.0.7977.130)
- Active plugins: none
Reproduction
- Start a task in the desktop app and switch to another app (or minimize OpenCode) so the OpenCode window is not focused.
- Wait for the "agent response ready" notification.
- Click the notification in the Windows toast / Action Center.
- Notification disappears and the correct session is selected, but the OpenCode window is not brought forward — it stays minimized or stays behind the other windows.
Expected Behavior
Clicking the notification should restore (if minimized) and focus/raise the OpenCode window, showing the conversation the notification refers to.
Actual Behavior
The notification is dismissed and the session is switched, but the window either stays minimized or stays behind other windows.
Additional Context
The notification click path
Renderer (notification is created and clicked here):
function fde(e){return async(t,n,r)=>{
if(await e.getWindowFocused().catch(()=>document.hasFocus()))return;
let i=new Notification(t,{body:n??``,icon:`https://opencode.ai/favicon-96x96-v3.png`,silent:!0});
i.onclick=()=>{e.showWindow(),e.setWindowFocus(),r?.(),i.close()}
}}
Main process handlers:
WindowSetFocus:(t,n)=>I(()=>L.fromWebContents(Wp(e,n))?.focus()),
WindowShow:(t,n)=>I(()=>L.fromWebContents(Wp(e,n))?.show()),
So clicking a notification ends up as win.show(); win.focus(). There is no restore().
The same file already has the correct pattern for deep links
l=e=>{e&&(e.isMinimized()&&e.restore(),e.show(),e.focus())}
This confirms the authors know show() + focus() is not enough for a minimized window; the notification path just doesn't use it.
Verified on Windows 11 (Win32 P/Invoke against the live OpenCode main window)
Electron's BrowserWindow.focus() is SetForegroundWindow on Windows, and show() early-returns for a visible window, so:
opencode hwnd=79169172 IsIconic(iconic)=True
SetForegroundWindow(hwnd) -> True, IsIconic after = True # foreground set, window NOT restored
ShowWindow(hwnd, SW_RESTORE) -> True, IsIconic after = False # this is what actually restores it
Control test (window not minimized): a background process calling SetForegroundWindow on the OpenCode window correctly raises it, so the system's foreground lock is not the blocker here (ForegroundLockTimeout is 0 on this machine).
Suggested fix
Restore before showing/focusing in the notification path, e.g. reuse the deep-link helper:
l = win => { if (win.isMinimized()) win.restore(); win.show(); win.focus() }
If notification activation is sometimes not delivered to the renderer at all on Windows (this is the suspicion for the "visible but behind" case), consider emitting the notification from the main process with Electron's Notification (main-process click is reliable on Windows) and running the same restore/show/focus sequence there before telling the renderer to select the session.
Related
- #18133 — "Desktop: Clicking Windows notification doesn't open conversation window" (same symptom; auto-closed as not planned by the stale bot)
- #11786 — "Better notifications on Desktop" (Windows deeplink / protocol activation tracking; closed)
- 主要言語
- TypeScript
- スター
- 215k
- フォーク
- 28.9k
- 平均マージ
- 7時間 53分
- マージ済み PR(30日)
- 278
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
anomalyco/opencode のほかの issue
-
pending close triaging
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
anomalyco/opencode#56765 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
anomalyco/opencode#56735 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
pending close triaging
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
anomalyco/opencode#56625 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
anomalyco/opencode#56624 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 半日 初心者へのやさしさ 72/100
anomalyco/opencode#56602 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
anomalyco/opencode の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
paperclipai/paperclip#16785 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
code-yeongyu/senpi#3661 ·
メンテナーはふだん 1 日以内に返信
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
lingdojo/kana-dojo#32731 · コメント 1 件 · リアクション 5 件 ·
メンテナーはふだん 1 日以内に返信
-
bug status: needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
mastra-ai/mastra#27538 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
Yeachan-Heo/oh-my-codex#3822 ·
メンテナーはふだん 1 日以内に返信