Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
fix(desktop): show git-described version in dev instead of stale 0.1.0 (#1867)
Bohan Jiange024ab12320b
diff --git a/apps/desktop/src/main/app-version.ts b/apps/desktop/src/main/app-version.tsnew file mode 100644index 0000000000..fd079c8677--- /dev/null+++ b/apps/desktop/src/main/app-version.ts@@ -0,0 +1,33 @@+import { app } from "electron";+import { execSync } from "node:child_process";++/**+ * Resolve the running app version. In packaged builds this is the value+ * `electron-builder` baked into package.json via `extraMetadata.version`+ * (driven by `git describe` — see `apps/desktop/scripts/package.mjs`), so+ * `app.getVersion()` matches the GitHub Release tag exactly.+ *+ * In dev (`pnpm dev:desktop`) `app.getVersion()` only sees the static+ * `apps/desktop/package.json` value, which is "0.1.0" and never bumped —+ * the Settings → Updates panel and any other UI surfacing the version+ * would mislead developers into thinking they're running ancient builds.+ * Fall back to `git describe --tags --always --dirty` (same source the+ * packager uses) so dev shows e.g. `0.2.19-14-gabcdef-dirty`. If git is+ * unavailable for whatever reason, we just return the package.json value.+ */+export function getAppVersion(): string {+ if (app.isPackaged) {+ return app.getVersion();+ }+ try {+ const raw = execSync("git describe --tags --always --dirty", {+ cwd: app.getAppPath(),+ encoding: "utf-8",+ stdio: ["ignore", "pipe", "ignore"],+ }).trim();+ if (!raw) return app.getVersion();+ return raw.replace(/^v/, "");+ } catch {+ return app.getVersion();+ }+}diff --git a/apps/desktop/src/main/index.ts b/apps/desktop/src/main/index.tsindex d29470e5d1..395dc2673a 100644--- a/apps/desktop/src/main/index.ts+++ b/apps/desktop/src/main/index.ts@@ -7,6 +7,7 @@ import { setupAutoUpdater } from "./updater";import { setupDaemonManager } from "./daemon-manager";import { openExternalSafely } from "./external-url";import { installContextMenu } from "./context-menu";+import { getAppVersion } from "./app-version";// Bundled icon used for dev-mode dock/taskbar branding. In production the// app bundle icon (from electron-builder) wins; this path is only consumed@@ -203,7 +204,7 @@ if (!gotTheLock) {ipcMain.on("app:get-info", (event) => {const p = process.platform;const os = p === "darwin" ? "macos" : p === "win32" ? "windows" : p === "linux" ? "linux" : "unknown";- event.returnValue = { version: app.getVersion(), os };+ event.returnValue = { version: getAppVersion(), os };});// IPC: toggle immersive mode — hides the macOS traffic lights so full-screen