The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): bundle skew decides by runtime content, not commit count
Teknium427c2132951a
diff --git a/apps/desktop/electron/bundle-skew.test.ts b/apps/desktop/electron/bundle-skew.test.tsindex 16a06107c62..ecfdce6385a 100644--- a/apps/desktop/electron/bundle-skew.test.ts+++ b/apps/desktop/electron/bundle-skew.test.ts@@ -340,6 +340,38 @@ describe('detectBundleSkew against a real git repo', () => {expect(result).toEqual(expected)})+ // A change and its revert in one update range: `hermes update` reuses the packaged app because+ // its inputs are byte-identical, so a commit count alone would warn until some later desktop+ // change happened to rebuild it.+ it('is quiet when runtime commits since the stamp net to no change', async () => {+ const { repoRoot } = makeScratchRepo()+ const git = scratchGit(repoRoot)++ writeFiles(repoRoot, ['apps/desktop/src/app/shell.tsx'])+ git('add', '.')+ git('commit', '-q', '-m', 'built')+ const stamp = git('rev-parse', 'HEAD')+ writeFileSync(join(repoRoot, 'apps/desktop/src/app/shell.tsx'), 'export const broken = true\n')+ git('commit', '-q', '-am', 'renderer change')+ git('revert', '--no-edit', 'HEAD')++ const runGit = realGitRun(repoRoot)++ expect(await detectBundleSkew({ commit: stamp, source: 'local' }, runGit, repoRoot)).toEqual({+ desktopCommitsBehind: 2,+ outOfSync: false+ })++ writeFiles(repoRoot, ['apps/desktop/src/app/new-feature.tsx'])+ git('add', '.')+ git('commit', '-q', '-m', 'real renderer change')++ expect(await detectBundleSkew({ commit: stamp, source: 'local' }, runGit, repoRoot)).toEqual({+ desktopCommitsBehind: 3,+ outOfSync: true+ })+ })+// The #92233 install, reproduced: the update rewrote the tree onto a fresh// orphan root, so the stamp resolves but is unreachable. Real git answers// `rev-list` with a positive count here — ancestry is the only thing thatdiff --git a/apps/desktop/electron/bundle-skew.ts b/apps/desktop/electron/bundle-skew.tsindex f0dcee05476..e38efb2b07c 100644--- a/apps/desktop/electron/bundle-skew.ts+++ b/apps/desktop/electron/bundle-skew.ts@@ -16,6 +16,11 @@** git merge-base --is-ancestor <stampCommit> HEAD* git rev-list --count <stampCommit>..HEAD -- <RUNTIME_PATHS>+ * git ls-tree <stampCommit> / HEAD -- <RUNTIME_PATHS> (only when the count is positive)+ *+ * The count is evidence and the endpoint content is the verdict: a change and its revert+ * inside one update range leave the runtime byte-identical, which is exactly when+ * `hermes update` reuses the packaged app (hermes_cli/desktop_build_reuse.py).** Ancestry has to come first, because `A..HEAD` only means "how far HEAD is* ahead of A" when A is an ancestor of HEAD. When it is not, the range@@ -82,6 +87,21 @@ export const RUNTIME_PATHS = [const NOT_STALE: BundleSkewResult = { desktopCommitsBehind: null, outOfSync: false }+type GitOptions = Parameters<RunGit>[1]++/**+ * True only on proof that every runtime path holds the same object at the stamp and at HEAD+ * (equal object ids are equal content). An empty or failed listing proves nothing, so the+ * commit count keeps the verdict.+ */+async function runtimeContentMatches(runGit: RunGit, stampCommit: string, options: GitOptions): Promise<boolean> {+ const [built, head] = await Promise.all(+ [stampCommit, 'HEAD'].map(commit => runGit(['ls-tree', commit, '--', ...RUNTIME_PATHS], options))+ )++ return built.code === 0 && head.code === 0 && built.stdout.trim() !== '' && built.stdout === head.stdout+}+/*** About/version polls share one check per checkout, including failed checks.* `isUpdating` may answer asynchronously (the marker's owner liveness is an@@ -196,7 +216,10 @@ export async function detectBundleSkew(return { desktopCommitsBehind: Number.isFinite(count) ? count : null, outOfSync: false }}- return { desktopCommitsBehind: count, outOfSync: true }+ // Commits are evidence, content is the verdict: a change and its revert in one update range+ // count 2 but leave the runtime byte-identical, and `hermes update` then rightly reuses the+ // packaged app instead of rebuilding it. Warning there would never clear.+ return { desktopCommitsBehind: count, outOfSync: !(await runtimeContentMatches(runGit, stamp.commit, options)) }} catch {return NOT_STALE}