← Back to PRs

#9156: fix(status): refresh version/commit on gateway restart

by gavinbmoore open 2026-02-04 23:07 View on GitHub →
stale
## Summary The `session_status` tool now shows updated version and commit hash after `git pull + SIGUSR1` restart, instead of cached values from process start. ## The Problem After updating OpenClaw via `git pull`, the `session_status` tool (and `/status` command) continued showing the old version/commit even after gateway restart via `SIGUSR1`. This happened because: 1. `VERSION` constant is computed once at module load time 2. `resolveCommitHash()` caches the commit hash after first call 3. On SIGUSR1 restart, the gateway loop restarts but the process doesn't, so module-level caches persist ## The Fix - Add `clearCommitHashCache()` function to `git-commit.ts` - Add `resolveVersion()` function with cache clearing support to `version.ts` - Update `status.ts` to use `resolveVersion()` instead of `VERSION` constant - Clear both caches in `gateway-daemon.ts` on restart (SIGUSR1) The `VERSION` constant is preserved for backwards compatibility with code that doesn't need dynamic updates (e.g., CLI banner at startup). ## Testing - Added test file `git-commit.version-cache.test.ts` with 5 tests covering: - Cache clearing behavior - Consistent cached values - VERSION constant backwards compatibility All existing `status.test.ts` tests continue to pass. Fixes #9105 🤖 Generated by Claw overnight build <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR makes `/status`/`session_status` reflect updated version + commit after a SIGUSR1 gateway restart by introducing explicit cache clearing. Key changes: - `src/version.ts` adds `resolveVersion()` and `clearVersionCache()` alongside the existing `VERSION` constant. - `src/infra/git-commit.ts` adds `clearCommitHashCache()` for the cached commit hash. - `src/auto-reply/status.ts` switches from the module-level `VERSION` constant to `resolveVersion()`. - `src/macos/gateway-daemon.ts` clears both caches on restart so the next status call re-resolves values. - Adds a small vitest file covering cache-clear and caching behavior for version/commit. <h3>Confidence Score: 4/5</h3> - Generally safe to merge, but restart-time version/commit can still be stale in some packaging scenarios. - Changes are localized and straightforward (cache clear + dynamic resolver), and wiring in gateway restart is clear. Main concern is that build-info based version/commit still use `require()` caching, so SIGUSR1 restarts may not refresh those values even after clearing the new caches. - src/version.ts, src/infra/git-commit.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs