#9156: fix(status): refresh version/commit on gateway restart
stale
Cluster:
Gateway and System Fixes
## 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
#16016: fix: update systemd unit version on gateway restart
by jbold · 2026-02-14
78.7%
#20355: fix(gateway): enforce commands.restart guard for config.apply and c...
by Clawborn · 2026-02-18
76.6%
#23113: fix: show actual runtime version after update/restart when service ...
by BryanTegomoh · 2026-02-22
75.7%
#16170: fix: restart service manager after update.run
by Swader · 2026-02-14
75.4%
#12234: gateway: incident tracking, recover command, and ciao ERR_SERVER_CL...
by levineam · 2026-02-09
75.1%
#10034: Don't crash gateway on transient unhandled fetch failures
by gigq · 2026-02-06
75.0%
#5823: fix(config): exit cleanly on invalid config instead of high CPU loop
by gavinbmoore · 2026-02-01
74.8%
#8713: feat: gateway memory monitor, install linger, docs and failover
by quratus · 2026-02-04
74.6%
#13408: fix(gateway): skip SIGUSR1 restart in config.patch for noop reload ...
by rwmjhb · 2026-02-10
74.6%
#13881: fix: Address Greptile feedback - test isolation and channel resolution
by trevorgordon981 · 2026-02-11
74.4%