android: poll the live wallet-child probe so the wallet sync line moves #134
Loading…
Reference in a new issue
No description provided.
Delete branch "wt/t_07542df0"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
The wallet screen's refresh loop now polls a real probe, so the
sync h/tsegment moves on its own.On
mainthe 2s loop calledWire::wallet_status, which is a cached read (Node::wallet_child_status— "cheap: no dial"): it re-reads the record the last probe left in the store, and that record is only written byNode::wallet_child_refresh, reachable over UniFFI today only insidestart_wallet_child. That is why tapping a chain-mode button looked like a refresh — it was the only thing that probed.How
WireViewModel.openWalletChild()now runswalletChildRefreshLoop(tickMs = 2_000, cached = ::paintWalletChildCached, live = ::refreshWalletChild).paintWalletChildCached()→Wire::wallet_status. Runs once, before the first tick: never dials, so the screen has a record to render immediately.refreshWalletChild()→Wire::wallet_child_refresh(). Runs on every tick (t = 2s, 4s, …).readWalletChild()that keeps the previous behaviour exactly:Dispatchers.IO,requireWire()called inside therunCatching(a locked node must land inwalletChildError, not crash the tick), and the stickywalletChildErrorfold.while (isActive) { delay; read }— the loop suspends on the read before it sleeps, so a probe slower than the tick delays the next tick instead of overlapping it. NoFlow, nocollectLatest, nolaunchper tick: two concurrentwallet_child_refreshcalls against one child is a racing probe.ui/WalletChildStatusText.kt's copy and thesync h/tformat are untouched. No new field, no percent, no progress bar, no "last updated".ui/WalletScreen.ktis not touched at all.The post-action call sites that already called
refreshWalletChild()afterset_chain_source/stop_wallet_childnow hit the live probe too. That is the same call, one hop more honest:stop_wallet_childleaves no live child, so the core short-circuits with the cached snapshot and the call is as cheap as it was.Tests
android/app/src/test/java/com/siriusdevops/onionwire/WalletChildRefreshLoopTest.kt(new, 3 tests).The loop's two reads are parameters for one reason: there is no seam to fake
Wirefrom a JVM unit test.requireWire()isNodeHost.requireOpen(), a process-global that onlyopenWire()— a real Arti bootstrap — populates, andNodeHost.wireis private.Wireitself is the generated UniFFI interface (≈40 methods), so "implement a fake" means a hand-written stub of the whole surface. Rather than invent a mock framework, the loop takescached/livelambdas and the new test drives those for real. The binding oflivetoWireViewModel.refreshWalletChild()(and ofcachedtopaintWalletChildCached()) is the two lines inWireViewModel.openWalletChild(), and the only honest evidence for it is the committed source:What the tests pin (virtual time, so the 2s cadence is asserted exactly):
cached == 1,live == 3,currentTime == 8000);maxInFlight == 1, three probes, the tick pushed out by the probe's own length;They have teeth: with
live()mutated tocached()in the loop, all three fail —Full suite green on this branch's tree (commit
4d2528351b6df2c54ce5506797722f37317047e5, the head that was pushed):(117 tests, 0 failures.
--no-build-cacheso aFROM-CACHEis not reported as a pass. The-xs skip the Rust tasks;:sdk:uniffiBindgenwas run first against this checkout to regenerateandroid/sdk/build/generated/uniffi/, which carriessuspend fun walletChildRefresh(): WalletChildStatuson theWireinterface. Note the recipe needs-x :sdk:verifyDynamicLibcas well — it depends oncargoBuildAndroid, so excluding the latter alone leaves the verifier to fail on a missing.so.)Base
base = main. The parent cardt_0a355a62(rust-dev: exportWire::wallet_child_refreshover UniFFI, PR #132) is merged intomainasfa0e4b2—git merge-base --is-ancestor origin/wt/t_0a355a62 origin/mainexits 0 andgit rev-list --count origin/main..origin/wt/t_0a355a62is 0 — so this branch is cut fromorigin/main, not stacked.crates/onionwire-sdk/**is untouched by this PR.Scope
Only
android/app/src/main/java/com/siriusdevops/onionwire/WireViewModel.ktand the new test.ui/WalletChildStatusText.kt,ui/WalletScreen.kt,.forgejo/**, everybuild.gradle.ktsand everything undersrc/**/crates/**are untouched.android/README.mdandandroid/CUPRATE_DAEMON.mdwere checked and neither describes the refresh cadence as a cached read (CUPRATE_DAEMON.md says "the blocks the chain daemon had at the last probe", which is now true rather than aspirational), so no doc change.android-ci / androidwill run on this PR (android/**is in itspull_requestpath filter) and builds the release APK path throughscripts/build-android-local.sh; it does not run these JVM tests, which is why the output above is pasted here.