diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 44bc9383..31c451fc 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -23,6 +23,7 @@ - Session picker respects custom keybindings when using `--resume` ([#633](https://github.com/badlogic/pi-mono/pull/633) by [@aos](https://github.com/aos)) - Custom footer extensions now see model changes: `ctx.model` is now a getter that returns the current model instead of a snapshot from when the context was created ([#634](https://github.com/badlogic/pi-mono/pull/634) by [@ogulcancelik](https://github.com/ogulcancelik)) +- Footer git branch not updating after external branch switches. Git uses atomic writes (temp file + rename), which changes the inode and breaks `fs.watch` on the file. Now watches the directory instead. - Extension loading errors are now displayed to the user instead of being silently ignored ([#639](https://github.com/badlogic/pi-mono/pull/639) by [@aliou](https://github.com/aliou)) ## [0.42.5] - 2026-01-11 diff --git a/packages/coding-agent/src/core/footer-data-provider.ts b/packages/coding-agent/src/core/footer-data-provider.ts index 91317c38..41f7aea1 100644 --- a/packages/coding-agent/src/core/footer-data-provider.ts +++ b/packages/coding-agent/src/core/footer-data-provider.ts @@ -103,10 +103,17 @@ export class FooterDataProvider { const gitHeadPath = findGitHeadPath(); if (!gitHeadPath) return; + // Watch the directory containing HEAD, not HEAD itself. + // Git uses atomic writes (write temp, rename over HEAD), which changes the inode. + // fs.watch on a file stops working after the inode changes. + const gitDir = dirname(gitHeadPath); + try { - this.gitWatcher = watch(gitHeadPath, () => { - this.cachedBranch = undefined; - for (const cb of this.branchChangeCallbacks) cb(); + this.gitWatcher = watch(gitDir, (_eventType, filename) => { + if (filename === "HEAD") { + this.cachedBranch = undefined; + for (const cb of this.branchChangeCallbacks) cb(); + } }); } catch { // Silently fail if we can't watch