From baf8acd55c3993312d2aeb006bed80c0ec136dcd Mon Sep 17 00:00:00 2001 From: Garry Tan Date: Sat, 14 Mar 2026 13:23:25 -0500 Subject: [PATCH] fix: update check ignores stale UP_TO_DATE cache after version change MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The UP_TO_DATE cache path exited immediately without checking if the cached version still matched the local VERSION. After upgrading (e.g. 0.3.3 → 0.3.4), the cache still said "UP_TO_DATE 0.3.3" and the script never re-checked against remote — so updates were invisible until the 24h cache expired. Now both UP_TO_DATE and UPGRADE_AVAILABLE verify cached version vs local before trusting the cache. Co-Authored-By: Claude Opus 4.6 --- bin/gstack-update-check | 7 ++++++- browse/test/gstack-update-check.test.ts | 13 +++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/bin/gstack-update-check b/bin/gstack-update-check index 79986ba1c8ed3e48512c69c1fe4623a653b6a09c..c9fad0c2ba9135623bfb87420a183819bfa80d8b 100755 --- a/bin/gstack-update-check +++ b/bin/gstack-update-check @@ -49,7 +49,12 @@ if [ -f "$CACHE_FILE" ]; then CACHED="$(cat "$CACHE_FILE" 2>/dev/null || true)" case "$CACHED" in UP_TO_DATE*) - exit 0 + # Verify local version still matches cached version + CACHED_VER="$(echo "$CACHED" | awk '{print $2}')" + if [ "$CACHED_VER" = "$LOCAL" ]; then + exit 0 + fi + # Local version changed — fall through to re-check ;; UPGRADE_AVAILABLE*) # Verify local version still matches cached old version diff --git a/browse/test/gstack-update-check.test.ts b/browse/test/gstack-update-check.test.ts index a0fefb73810639f75e817c19feb0fed020e3fecd..475f3e64c89ac8b4270a4fcc2a6f628107e051da 100644 --- a/browse/test/gstack-update-check.test.ts +++ b/browse/test/gstack-update-check.test.ts @@ -86,6 +86,19 @@ describe('gstack-update-check', () => { expect(stdout).toBe(''); }); + // ─── Path D1b: Fresh UP_TO_DATE cache, but local version changed ── + test('re-checks when UP_TO_DATE cache version does not match local', () => { + writeFileSync(join(gstackDir, 'VERSION'), '0.4.0\n'); + // Cache says UP_TO_DATE for 0.3.3, but local is now 0.4.0 + writeFileSync(join(stateDir, 'last-update-check'), 'UP_TO_DATE 0.3.3'); + // Remote says 0.5.0 — should detect upgrade + writeFileSync(join(gstackDir, 'REMOTE_VERSION'), '0.5.0\n'); + + const { exitCode, stdout } = run(); + expect(exitCode).toBe(0); + expect(stdout).toBe('UPGRADE_AVAILABLE 0.4.0 0.5.0'); + }); + // ─── Path D2: Fresh cache, UPGRADE_AVAILABLE ──────────────── test('echoes cached UPGRADE_AVAILABLE when cache is fresh', () => { writeFileSync(join(gstackDir, 'VERSION'), '0.3.3\n');