diff --git a/eslint.config.ts b/eslint.config.ts index f59be99063..b2635663ef 100644 --- a/eslint.config.ts +++ b/eslint.config.ts @@ -24,6 +24,7 @@ const extraFileExtensions = ['.vue'] const commonGlobals = { ...globals.browser, __COMFYUI_FRONTEND_VERSION__: 'readonly', + __COMFYUI_FRONTEND_COMMIT__: 'readonly', __DISTRIBUTION__: 'readonly', __IS_NIGHTLY__: 'readonly' } as const diff --git a/global.d.ts b/global.d.ts index 84171df1f7..e0a154c311 100644 --- a/global.d.ts +++ b/global.d.ts @@ -1,4 +1,5 @@ declare const __COMFYUI_FRONTEND_VERSION__: string +declare const __COMFYUI_FRONTEND_COMMIT__: string declare const __SENTRY_ENABLED__: boolean declare const __SENTRY_DSN__: string declare const __ALGOLIA_APP_ID__: string diff --git a/src/components/common/SystemStatsPanel.vue b/src/components/common/SystemStatsPanel.vue index 76389290e5..4c46fa9da7 100644 --- a/src/components/common/SystemStatsPanel.vue +++ b/src/components/common/SystemStatsPanel.vue @@ -59,6 +59,8 @@ import type { SystemStats } from '@/schemas/apiSchema' import { formatCommitHash, formatSize } from '@/utils/formatUtil' import { cn } from '@/utils/tailwindUtil' +const frontendCommit = __COMFYUI_FRONTEND_COMMIT__ + const props = defineProps<{ stats: SystemStats }>() @@ -77,6 +79,7 @@ type SystemInfoKey = keyof SystemStats['system'] type ColumnDef = { field: SystemInfoKey header: string + getValue?: () => string format?: (value: string) => string formatNumber?: (value: number) => string } @@ -104,6 +107,7 @@ const cloudColumns: ColumnDef[] = [ { field: 'comfyui_frontend_version', header: 'Frontend Version', + getValue: () => frontendCommit, format: formatCommitHash }, { field: 'workflow_templates_version', header: 'Templates Version' } @@ -119,7 +123,9 @@ function isOutdated(column: ColumnDef): boolean { } function getDisplayValue(column: ColumnDef) { - const value = systemInfo.value[column.field] + const value = column.getValue + ? column.getValue() + : systemInfo.value[column.field] if (column.formatNumber && typeof value === 'number') { return column.formatNumber(value) } diff --git a/vite.config.mts b/vite.config.mts index 9033ea16ab..f14d6d26d9 100644 --- a/vite.config.mts +++ b/vite.config.mts @@ -1,6 +1,7 @@ import { sentryVitePlugin } from '@sentry/vite-plugin' import tailwindcss from '@tailwindcss/vite' import vue from '@vitejs/plugin-vue' +import { execSync } from 'child_process' import { config as dotenvConfig } from 'dotenv' import type { IncomingMessage, ServerResponse } from 'http' import { Readable } from 'stream' @@ -55,6 +56,21 @@ const DISTRIBUTION: 'desktop' | 'localhost' | 'cloud' = // Can be overridden via IS_NIGHTLY env var for testing const IS_NIGHTLY = process.env.IS_NIGHTLY === 'true' +// Resolve the frontend git commit hash at build time. +// Priority: FRONTEND_COMMIT_HASH env var → git rev-parse HEAD → 'unknown' +// FRONTEND_COMMIT_HASH is an escape hatch for non-git environments (e.g. Docker +// build containers without .git) where the commit hash can be injected externally. +let GIT_COMMIT = process.env.FRONTEND_COMMIT_HASH || '' +if (!GIT_COMMIT) { + try { + GIT_COMMIT = execSync('git rev-parse HEAD', { timeout: 5000 }) + .toString() + .trim() + } catch { + GIT_COMMIT = 'unknown' + } +} + // Disable Vue DevTools for production cloud distribution const DISABLE_VUE_PLUGINS = process.env.DISABLE_VUE_PLUGINS === 'true' || @@ -586,6 +602,7 @@ export default defineConfig({ __COMFYUI_FRONTEND_VERSION__: JSON.stringify( process.env.npm_package_version ), + __COMFYUI_FRONTEND_COMMIT__: JSON.stringify(GIT_COMMIT), __SENTRY_ENABLED__: JSON.stringify( !(process.env.NODE_ENV === 'development' || !process.env.SENTRY_DSN) ),