File tree Expand file tree Collapse file tree
apps/code/src/main/platform-adapters Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,13 @@ import type { ElectronMainWindow } from "./electron-main-window";
66
77@injectable ( )
88export class ElectronNotifier implements INotifier {
9+ // Retain shown notifications so V8 doesn't GC the JS wrapper (and its
10+ // `click` listener) before the user interacts. Without this, the OS still
11+ // shows the notification and macOS will even focus the app on click, but
12+ // the JS click handler never fires — so any in-app routing tied to it
13+ // (e.g. switching to the task the notification was about) silently breaks.
14+ private readonly active = new Set < Notification > ( ) ;
15+
916 constructor (
1017 @inject ( MAIN_TOKENS . MainWindow )
1118 private readonly mainWindow : ElectronMainWindow ,
@@ -21,6 +28,11 @@ export class ElectronNotifier implements INotifier {
2128 body : options . body ,
2229 silent : options . silent ,
2330 } ) ;
31+ this . active . add ( notification ) ;
32+ const release = ( ) => this . active . delete ( notification ) ;
33+ notification . once ( "close" , release ) ;
34+ notification . once ( "click" , release ) ;
35+ notification . once ( "failed" , release ) ;
2436 if ( options . onClick ) {
2537 notification . on ( "click" , options . onClick ) ;
2638 }
You can’t perform that action at this time.
0 commit comments