Skip to content

fix(grokbot): dim a reading past its reset, and find the active slot - #518

Merged
vinzdg merged 1 commit into
vinzdg:mainfrom
keepsilence233:fix/grokbot-stale-after-reset
Nov 5, 2026
Merged

vinzdg merged 1 commit into
vinzdg:mainfrom
keepsilence233:fix/grokbot-stale-after-reset

Conversation

@keepsilence233

Copy link
Copy Markdown
Contributor

Summary

Grok Bot only rewrites its weekly cache when it fetches. It can run for hours after a reset without doing that. The notch kept showing the finished week's percent as live, and the card stayed on "Resetting…" until Grok Bot's own day-long expiresAtMs ran out.

 GrokBotReading.isExpired
-  expiresAt <= now
+  expiresAt <= now || resetsAt <= now

The selected account also never matched its cache. The slot blob writes auth0|user_…, while the cache key writes the same slot URL-encoded as auth0%7Cuser_….

 GrokBotCache.load
   slot = key minus prefix/suffix
-  compare slot with activeSlot
+  compare slot.removingPercentEncoding with activeSlot

Evidence

Real cache on a Mac (local time): read 11-01 18:23, nextResetMs 11-01 19:10, expiresAtMs 11-02 18:23. That left the notch on "Resetting…" at 12% for about 23 hours.

  • Before:
    testAReadingPastItsResetReadsStale            FAILED  ("ok") is not equal to ("stale(since: …)")
    testTheActiveSlotMatchesItsURLEncodedCacheKey FAILED  (got the fresher neighbour's 90%)
    
    After:
    GrokBotUsageTests: Executed 15 tests, with 0 failures
    

The fixture's hard-coded nextResetMs (2026-10-13) is now in the past. It is now a parameter that defaults to three days out. The test that pins the recorded date passes that date explicitly.

Merge Danger

Door: two-way

Blast Radius: Grok Bot only

After a reset, Grok Bot's ring is dimmed and dated, not shown at full strength, until Grok Bot writes a fresh reading. With several signed-in accounts, the selected account's cache now wins over a fresher neighbour, as intended.

🤖 Generated with Claude Code

Grok Bot only rewrites its weekly cache when it fetches, and can run for
hours past a reset without doing so. The reading was only treated as stale
past Grok Bot's own day-long expiry, so the notch showed the finished
week's percent as live and sat on "Resetting…". A reading whose reset has
passed now reads stale too.

The slot blob names the account `auth0|user_…` while the cache key spells
it URL-encoded (`auth0%7Cuser_…`), so the active account never matched and
the freshest file always won. Decode the key's slot before comparing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vinzdg
vinzdg merged commit 6c2dfbd into vinzdg:main Nov 5, 2026
2 checks passed
vinzdg added a commit that referenced this pull request Nov 6, 2026
…panese

- Claude Code sessions named by their title (#510); the lone Claude ring
  named when Claude Desktop uses another account (#511).
- Cost indexer stats transcripts (#501) and acts only on changed readings
  (#514).
- Krea AI (#490), a Xiaomi MiMo preset (#503), Grok multi-account (#515),
  Japanese up to date (#492), deficit rings by soonest expiry (#496).
- Fixes: Claude weekly-only /usage (#527), remote Claude reuse (#522),
  remote Codex behind a proxy (#523), Kiro V2 engine and parsing (#528,
  #517), Kimi monthly quotas (#526), MiniMax China sk-api keys (#529),
  Grok Bot resets (#518), Developer ID team check (#491).
- Windows: the taskbar strip drawn as the notch (#506), Claude accounts as
  rows (#502), Antigravity through agy.exe (#507), a hook auth token (#525).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants