Skip to content

Commit 35a317e

Browse files
fix(mac): use createFromBuffer for tray icon + add debug logs
Switch from createFromDataURL to createFromBuffer which is more reliable. Add detailed logging to diagnose whether the template icon is actually being used or falling back to the app icon. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 4b1cff0 commit 35a317e

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

electron/tray.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,18 @@ function loadIconFromPath(filePath: string): NativeImage | null {
6969
}
7070

7171
function createMacTrayIcon(): NativeImage {
72-
const trayIcon = nativeImage.createFromDataURL(`data:image/png;base64,${TRAY_TEMPLATE_BASE64}`)
73-
if (!trayIcon.isEmpty()) {
74-
trayIcon.setTemplateImage(true)
75-
console.log('[Tray] macOS: using dedicated template icon (32x32 sound-wave)')
76-
return trayIcon
72+
try {
73+
const buf = Buffer.from(TRAY_TEMPLATE_BASE64, 'base64')
74+
const trayIcon = nativeImage.createFromBuffer(buf)
75+
const size = trayIcon.getSize()
76+
console.log(`[Tray] macOS: template buffer ${buf.length} bytes, image ${size.width}x${size.height}, empty=${trayIcon.isEmpty()}`)
77+
if (!trayIcon.isEmpty() && size.width > 0) {
78+
trayIcon.setTemplateImage(true)
79+
console.log('[Tray] macOS: using dedicated template icon')
80+
return trayIcon
81+
}
82+
} catch (err) {
83+
console.error('[Tray] macOS: createFromBuffer failed:', err)
7784
}
7885
console.warn('[Tray] macOS: dedicated template icon failed, falling back to app icon')
7986
return nativeImage.createEmpty()

0 commit comments

Comments
 (0)