Skip to content

fix: refetch stale credits balance after two minutes - #231

Merged
RasulOs merged 1 commit into
developfrom
fix/credits-balance-max-age
Dec 3, 2026
Merged

RasulOs merged 1 commit into
developfrom
fix/credits-balance-max-age

Conversation

@RasulOs

@RasulOs RasulOs commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • PortalBalanceRepository reused a loaded balance for the whole process lifetime; only the refresh button or sign-in/out forced a refetch. With the accessibility service keeping the process alive, the credits card could show a weeks-old balance (a customer saw 690 credits remaining while task runs returned 402).
  • Non-forced loads now refetch when the cached state is older than MAX_AGE_MS (2 min). The old value stays visible with the existing "Refreshing" text while the request runs; concurrent callers still join one in-flight request.
  • Clock is injectable for tests and reset in resetForTest().

Tests

  • New: reuse just before max age, stale refetch keeps old value and coalesces callers, stale non-retryable error refetches.
  • ./gradlew testDebugUnitTest (JDK 17): all pass.

🤖 Generated with Claude Code

The balance cache never expired, so a long-lived Portal process kept
showing the first balance it fetched. Non-forced loads now refetch once
the cached state is older than MAX_AGE_MS, keeping the old value visible
while the refresh runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

🧪 Test Build Ready

APK for PR #231 is available for testing.

Download APK from workflow run

Artifacts expire after 30 days.

@RasulOs
RasulOs merged commit c0fb557 into develop Dec 3, 2026
2 checks passed
This was referenced Dec 3, 2026
@RasulOs
RasulOs deleted the fix/credits-balance-max-age branch December 3, 2026 16:16
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.

1 participant