Skip to content

Keep the refresh for extension wallets, and the other permanence cache review fixes - #2330

Merged
vilenarios merged 2 commits into
devfrom
permanence-cache-review
Oct 21, 2026
Merged

vilenarios merged 2 commits into
devfrom
permanence-cache-review

Conversation

@vilenarios

@vilenarios vilenarios commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

This follows #2326, which merged before its review fixes landed. It makes the permanence panel's cache keep the refresh button for extension wallets, and closes the other gaps an independent review found. The review found no path where a hook can break or stall an upload, transaction post or top-up.

Needs your judgement: the shorter AR re-check after a spend (1 minute, for 10 minutes after the app last spent). Both values are constants at the top of lib/permanence/permanence_cache.dart.

Measured in a browser on a production build, logged in, after a sync: before #2326, 11 requests on the first open and 4 on every open after. After #2326, 4 on the first open (2 GraphQL, price, rate), then 0, then 0.

Fixes

Fix Where Test
An extension wallet whose earlier reading was "none" or zero, with AR paid directly, lost the "Refresh credits used" button and the "as of" note. The AR-only tile now carries both. lib/permanence/permanence_panel.dart:652 (arOnly), :692, :703 permanence_panel_test.dart: "of none, beside AR paid directly, still offers a refresh"
A clock that moved backward counted as current. A negative age is now stale, for the price, rate, credits and AR count. permanence_cache.dart:36 (_within) permanence_cache_test.dart: "a clock that moved backward makes every kept figure stale"
Right after this app spends, the AR count was reused for 30 minutes even though a transaction posted here is not mined yet. For 10 minutes after a spend it is now re-checked after 1 minute. permanence_cache.dart:407, :433 "the AR count soon after spending" (two tests: 1 minute inside the window, 30 minutes after it)
An open joined a read that began before the last spend and showed its result as current. It now starts a new read, for the credits and for the AR count. permanence_cache.dart:308, :382 "a read that began before the app spent": not joined after a spend; still joined when nothing happened between
A logout while the store was opening could leave a stored copy. Both writers now check again after the store opens. permanence_cache.dart:351, :456 "logging out while the store opens leaves no stored copy of a read that finished"
A refused Turbo post must leave the cache alone. lib/turbo/services/upload_service.dart (unchanged) upload_service_test.dart: "leaves the credits used alone when the item is refused"

Fails before

Each new cache and panel test fails on dev without the fix: I put dev's versions of permanence_cache.dart and permanence_panel.dart back and reran. Five failed: backward clock, AR re-check after a spend, not joining a read from before a spend, logout while the store opens, and the extension-wallet refresh. The refused-post test and the "joined when nothing happened between" test pin behaviour that already held, so they pass before and after.

Not covered

Hooks without their own test: postTx, uploadTx, the upload repository's two completion callbacks, the manifest repository, and the card and crypto top-up blocs. Only the Turbo data item hook and logout are tested directly.

loadNetworkCost stays: the panel's tests still use it. The value types (SpendLookup, NetworkCost) stay in the widget file, so the cache file imports it; moving them is a separate change.

Not seen on screen: the "as of" text and the button layout.

Independent check

A separate agent checked each fix against the earlier review's findings and found them fixed. It reported nothing that blocks a merge. Known limits, not changed here:

  • If an older read finishes after a newer one, it still writes its result. That result is marked stale (credits) or unchecked (AR), so the next open reads again. It never shows a wrong figure, and costs at most one extra read.
  • After a tapped refresh fails for an extension wallet, the earlier reading shows with no retry button until the panel is reopened. This is how it worked before Keep the permanence panel's figures for the session #2326.

Two code comments were reworded to drop "just".

🤖 Generated with Claude Code

https://claude.ai/code/session_017ksUKnnC1PGwNoUh6JNwZt

…e review fixes

An extension wallet whose earlier credits reading was none or zero, with
AR paid directly, lost the "Refresh credits used" button and the "as of"
note. The AR-only tile now carries both.

Also: a clock that moved backward is stale, not current; the AR count is
re-checked after a minute, not half an hour, for ten minutes after this
app spends; an open no longer joins a read that began before the last
spend; and both writers to local storage check for a logout after the
store opens.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ksUKnnC1PGwNoUh6JNwZt
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: ardriveapp/ardrive-web/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4dd3c35a-bb02-4d83-8383-013e5853124d
📥 Commits

Reviewing files that changed from the base of the PR and between a881464 and 435eeef.

📒 Files selected for processing: 5
  • lib/permanence/permanence_cache.dart
  • lib/permanence/permanence_panel.dart
  • test/permanence/permanence_cache_test.dart
  • test/permanence/permanence_panel_test.dart
  • test/turbo/services/upload_service_test.dart
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_017ksUKnnC1PGwNoUh6JNwZt
@vilenarios
vilenarios merged commit 7b9c5d5 into dev Oct 21, 2026
5 of 7 checks passed
@vilenarios
vilenarios deleted the permanence-cache-review branch October 21, 2026 01:06
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