From bebf1b7e01a6a084a3e46bb2d679dee65af83048 Mon Sep 17 00:00:00 2001 From: emozilla Date: Fri, 29 May 2026 02:54:30 -0400 Subject: [PATCH] fix(desktop): branch-pin the CLI manual-update command card MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The 'Update from your terminal' card (shown to CLI installs with no staged updater) hardcoded bare `hermes update` — which defaults to main and would switch a bb/gui (or any non-main) checkout off-branch. Same bug we fixed for the GUI button, leaked into the card's copy text. Resolve the checkout's current branch and show `hermes update --branch ` for non-main checkouts; keep it bare for main so the card stays clean. Best-effort: bare fallback if branch detection fails. Matches the GUI button + installer --update contract; bare terminal/bot/TUI update paths still default to main, unchanged. --- apps/desktop/electron/main.cjs | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/apps/desktop/electron/main.cjs b/apps/desktop/electron/main.cjs index 39e4e93a708..7f4f9b22dd9 100644 --- a/apps/desktop/electron/main.cjs +++ b/apps/desktop/electron/main.cjs @@ -1065,14 +1065,22 @@ async function applyUpdates(opts = {}) { // `hermes desktop`, never the Tauri installer that self-copies // hermes-setup.exe into HERMES_HOME). They DO have a working `hermes` // on PATH / in the venv, so the correct path is the one-liner in their - // native medium: `hermes update`. We surface that as an intentional - // "manual update" outcome — NOT an error with a dead retry button. - // - // We resolve the most copy-pasteable command we can: prefer the bare - // `hermes update` (works if hermes is on PATH, which install.sh/ps1 - // both arrange), and include the resolved checkout dir as context. - const command = 'hermes update' + // native medium. We show the EXACT command, branch-pinned to the + // checkout they're on — bare `hermes update` defaults to main and would + // silently switch a bb/gui (or any non-main) install off-branch. Mirror + // the GUI button's contract: append --branch for non-main + // checkouts, keep it bare for main so the card stays clean. const updateRoot = resolveUpdateRoot() + let command = 'hermes update' + try { + const head = await runGit(['rev-parse', '--abbrev-ref', 'HEAD'], { cwd: updateRoot }) + const branch = (head.stdout || '').trim() + if (head.code === 0 && branch && branch !== 'HEAD' && branch !== 'main') { + command = `hermes update --branch ${branch}` + } + } catch { + // Best-effort: fall back to bare `hermes update` if branch detection fails. + } rememberLog(`[updates] no staged updater; surfacing manual \`${command}\` for CLI install at ${updateRoot}`) emitUpdateProgress({ stage: 'manual', message: command, percent: null }) return { ok: true, manual: true, command, hermesRoot: updateRoot }