File tree Expand file tree Collapse file tree 5 files changed +54
-1
lines changed
Expand file tree Collapse file tree 5 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ import {
3232 binPath ,
3333} from './toolhive-manager'
3434import log from './logger'
35+ import { getAppVersion } from './util'
3536
3637Sentry . init ( {
3738 dsn : import . meta. env . VITE_SENTRY_DSN ,
@@ -440,3 +441,7 @@ ipcMain.handle('shutdown-store:clear-history', () => {
440441 clearShutdownHistory ( )
441442 return { success : true }
442443} )
444+
445+ ipcMain . handle ( 'get-app-version' , ( ) => {
446+ return getAppVersion ( )
447+ } )
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ import path from 'node:path'
33import { getAutoLaunchStatus , setAutoLaunch } from './auto-launch'
44import { createApplicationMenu } from './menu'
55import log from './logger'
6+ import { getAppVersion } from './util'
67
78///////////////////////////////////////////////////
89// Tray icon
@@ -136,6 +137,15 @@ const createStatusMenuItem = (toolHiveIsRunning: boolean) => ({
136137 enabled : false ,
137138} )
138139
140+ const getCurrentAppVersion = ( ) => {
141+ const appVersion = getAppVersion ( )
142+ return {
143+ label : `Current version: v${ appVersion } ` ,
144+ type : 'normal' as const ,
145+ enabled : false ,
146+ }
147+ }
148+
139149const startOnLoginMenu = ( currentTray : Tray , toolHiveIsRunning : boolean ) => {
140150 const isStartOnLogin = getAutoLaunchStatus ( )
141151 return {
@@ -180,6 +190,7 @@ const createSeparator = () => ({ type: 'separator' as const })
180190
181191const createMenuTemplate = ( currentTray : Tray , toolHiveIsRunning : boolean ) => [
182192 createStatusMenuItem ( toolHiveIsRunning ) ,
193+ getCurrentAppVersion ( ) ,
183194 createSeparator ( ) ,
184195 startOnLoginMenu ( currentTray , toolHiveIsRunning ) ,
185196 createSeparator ( ) ,
Original file line number Diff line number Diff line change 1+ import { app } from 'electron'
2+ import { execSync } from 'node:child_process'
3+
4+ function getVersionFromGit ( ) : string {
5+ try {
6+ const exactTag = execSync ( 'git describe --exact-match --tags HEAD' , {
7+ encoding : 'utf8' ,
8+ stdio : 'pipe' ,
9+ } ) . trim ( )
10+
11+ return exactTag . replace ( / ^ v / , '' )
12+ } catch {
13+ try {
14+ const describe = execSync ( 'git describe --tags --always' , {
15+ encoding : 'utf8' ,
16+ stdio : 'pipe' ,
17+ } ) . trim ( )
18+
19+ return describe . replace ( / ^ v / , '' )
20+ } catch {
21+ return app . getVersion ( )
22+ }
23+ }
24+ }
25+
26+ export function getAppVersion ( ) : string {
27+ if ( process . env . SENTRY_RELEASE ) {
28+ return process . env . SENTRY_RELEASE
29+ }
30+
31+ return getVersionFromGit ( )
32+ }
Original file line number Diff line number Diff line change @@ -16,6 +16,9 @@ contextBridge.exposeInMainWorld('electronAPI', {
1616 hideApp : ( ) => ipcRenderer . invoke ( 'hide-app' ) ,
1717 quitApp : ( ) => ipcRenderer . invoke ( 'quit-app' ) ,
1818
19+ // App version
20+ getAppVersion : ( ) => ipcRenderer . invoke ( 'get-app-version' ) ,
21+
1922 // ToolHive port
2023 getToolhivePort : ( ) => ipcRenderer . invoke ( 'get-toolhive-port' ) ,
2124 // ToolHive is running
@@ -88,6 +91,7 @@ contextBridge.exposeInMainWorld('electronAPI', {
8891} )
8992
9093export interface ElectronAPI {
94+ getAppVersion : ( ) => Promise < string >
9195 getAutoLaunchStatus : ( ) => Promise < boolean >
9296 setAutoLaunch : ( enabled : boolean ) => Promise < boolean >
9397 showApp : ( ) => Promise < void >
Original file line number Diff line number Diff line change @@ -76,10 +76,11 @@ export const Route = createRootRouteWithContext<{
7676 queryKey : [ 'is-toolhive-running' ] ,
7777 queryFn : async ( ) => {
7878 const res = await window . electronAPI . isToolhiveRunning ( )
79+ const appVersion = await window . electronAPI . getAppVersion ( )
7980 if ( ! res ) {
8081 log . error ( 'Error ToolHive is not running' )
8182 }
82- log . info ( ' ToolHive is running' )
83+ log . info ( ` ToolHive version ${ appVersion } is running` )
8384 return res
8485 } ,
8586 retry : 3 ,
You can’t perform that action at this time.
0 commit comments