Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

desktop: clicking a Windows notification does not restore or focus the window

Abierto Apto para principiantes
#56,663 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
84/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
electron, typescript
Área
desktop

Línea de trabajo

Comienza por el controlador de clics de la notificación del renderer y sigue WindowShow y WindowSetFocus hasta las llamadas a BrowserWindow del proceso principal. Localiza el helper existente de enlaces profundos que llama a restore(), show() y focus(), y reutiliza su comportamiento o ajústalo al de los clics en notificaciones. Verifica los casos de ventanas minimizadas y en segundo plano en Windows y, después, ejecuta las pruebas de escritorio relevantes o reproduce manualmente el flujo de toast a foco.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.exe FileVersion 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

  1. Start a task in the desktop app and switch to another app (or minimize OpenCode) so the OpenCode window is not focused.
  2. Wait for the "agent response ready" notification.
  3. Click the notification in the Windows toast / Action Center.
  4. 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)
Lenguaje dominante
TypeScript
Estrellas
215k
Forks
28.9k
Merge medio
11 h 19 min
PR fusionados (30 d)
320

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de anomalyco/opencode

Todos los issues de anomalyco/opencode

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.