diff --git a/src/main/windows.ts b/src/main/windows.ts index ffa9bd0..df8d39d 100644 --- a/src/main/windows.ts +++ b/src/main/windows.ts @@ -1,7 +1,28 @@ import { BrowserWindow, shell } from "electron"; +import { execFileSync } from "child_process"; + +import { isDevMode } from "../utils/devmode"; let mainWindow: BrowserWindow | null = null; +function getDevBranchSuffix(): string { + if (!isDevMode()) return ""; + + try { + const branch = execFileSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], { + encoding: "utf8", + }).trim(); + + if (branch && branch !== "master" && branch !== "main") { + return ` (${branch})`; + } + } catch { + // git not available or not a repo — ignore + } + + return ""; +} + export function getOrCreateWindow(): BrowserWindow { if (mainWindow) return mainWindow; @@ -18,6 +39,14 @@ export function getOrCreateWindow(): BrowserWindow { }, }); + const branchSuffix = getDevBranchSuffix(); + if (branchSuffix) { + mainWindow.on("page-title-updated", (event, title) => { + event.preventDefault(); + mainWindow?.setTitle(`${title}${branchSuffix}`); + }); + } + mainWindow.loadFile("./dist/static/index.html"); mainWindow.webContents.on("will-navigate", (event, url) =>