1- import { nativeImage } from "electron" ;
1+ import { app , nativeImage } from "electron" ;
22import type { NativeImage } from "electron" ;
33import type { GatewayState } from "@easyclaw/gateway" ;
44import { resolve , dirname } from "node:path" ;
55import { fileURLToPath } from "node:url" ;
66
77const __dirname = dirname ( fileURLToPath ( import . meta. url ) ) ;
8+ const DEV_TRAY_ICON_PATH = resolve ( __dirname , "../../panel/public/logo.png" ) ;
9+ const PACKAGED_TRAY_ICON_PATH = resolve ( __dirname , "../build/[email protected] " ) ; 10+ const TRAY_ICON_SIZE = 44 ;
811
912/**
1013 * Color palette for state indicator dot.
@@ -20,12 +23,14 @@ const STATE_COLORS: Record<GatewayState, [number, number, number]> = {
2023/**
2124 * Create a tray icon from the app logo PNG with a colored status dot overlay.
2225 *
23- * Uses build/[email protected] (64x64) as base, displayed at 32x32 on retina. 26+ * In dev, load the panel logo directly so icon tweaks are reflected immediately.
27+ * In packaged builds, use the bundled tray PNG.
2428 * Overlays a small colored circle in the bottom-right corner to indicate gateway state.
2529 */
2630export function createTrayIcon ( state : GatewayState ) : NativeImage {
27- const iconPath = resolve ( __dirname , "../build/[email protected] " ) ; 28- const base = nativeImage . createFromPath ( iconPath ) ;
31+ const iconPath = app . isPackaged ? PACKAGED_TRAY_ICON_PATH : DEV_TRAY_ICON_PATH ;
32+ const source = nativeImage . createFromPath ( iconPath ) ;
33+ const base = source . resize ( { width : TRAY_ICON_SIZE , height : TRAY_ICON_SIZE } ) ;
2934
3035 // Get the raw RGBA bitmap
3136 const size = base . getSize ( ) ;
@@ -36,7 +41,7 @@ export function createTrayIcon(state: GatewayState): NativeImage {
3641
3742 // Draw a state indicator dot in the bottom-right corner
3843 const [ r , g , b ] = STATE_COLORS [ state ] ;
39- const dotRadius = Math . round ( w * 0.18 ) ; // ~18% of icon size
44+ const dotRadius = Math . round ( TRAY_ICON_SIZE * 0.18 ) ; // ~18% of the visible icon size
4045 const cx = w - dotRadius - 1 ;
4146 const cy = h - dotRadius - 1 ;
4247
0 commit comments