diff options
| author | Adam Soltys <[email protected]> | 2026-09-10 22:14:36 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-09-10 22:14:36 -0700 |
| commit | b19cf9672532a8f6c347dc8fe99d83492bd478fd (patch) | |
| tree | 740562a31a934415ba3c249b77e3eb1f23b0c05b /src/features | |
| parent | f0a5e0de3e68eee184b25ced2393329aec169f6d (diff) | |
| download | coinosv3-b19cf9672532a8f6c347dc8fe99d83492bd478fd.tar.gz coinosv3-b19cf9672532a8f6c347dc8fe99d83492bd478fd.zip | |
The wallet waits for its own state before painting, so nothing jumps.
The Spending balance and its history are read from the ark store, which is
IndexedDB: synchronous to read, asynchronous to OPEN. Boot didn't wait for
it, so every refresh painted a Spending wallet with nothing in it — no
balance, no history — and filled it in a beat later. On a phone that second
paint arrived as a change rather than an arrival: the balance counted itself
up from 0 in green, wearing the animation a received payment gets.
Boot now waits for the store (capped at 800ms — a store that won't open must
not hold the app hostage), and the shell stays up a moment longer instead of
a wrong balance going up. If the store does land past the cap, initArk
retries on it — so a Spending wallet whose state arrived late also connects,
which it previously didn't until something else happened to kick it — and
that catch-up paint forgets the last amounts first, so it reads as state
arriving rather than money.
Also: the zap tally chip loses its underline. In chat the chip is a reaction
chip too, and .chat-react.on still rings it; on a post row the underline just
read as an artifact.
tools/boot-balance-test.js pins the ordering, with IndexedDB slowed so it
can't pass by luck.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_019mrt228Upn9nNCwGixzSLx
Diffstat (limited to 'src/features')
| -rw-r--r-- | src/features/ark.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/features/ark.js b/src/features/ark.js index 8e74cc6..b70bafe 100644 --- a/src/features/ark.js +++ b/src/features/ark.js @@ -417,6 +417,16 @@ export function arkFeature(ctx) { stopArk(); ui.arkError = ''; lastAutoInit = Date.now(); + // The ark store is IndexedDB — asynchronous to OPEN, synchronous to read + // once it has. A boot that beats it open reads no state at all: no + // Spending balance, no Spending history, and nothing here that looks + // worth connecting for. Wait for it and run again, so what the store + // holds is on screen the moment it can be. + const store = wallet._arkStore; + if (store && !store.ready) { + store.open().then(() => { ctx.forgetAmountAnim && ctx.forgetAmountAnim(); render(); initArk(); }).catch(() => {}); + return; + } if (arkAvailable() && arkWanted()) connectArk().catch(() => {}); } @@ -2998,6 +3008,21 @@ export function arkFeature(ctx) { id: 'ark', init() { _autoSelected = false; ui.accountUserChosen = false; initArk(); }, stop() { stopArk(); }, + // Boot waits on this before opening a wallet: the Spending balance and + // its history live in the ark store, which is IndexedDB and therefore + // opens asynchronously. Painting first meant painting an empty Spending + // wallet and filling it in a beat later — a 0 that counted itself up, + // green, as if money had just arrived. Capped, because a store that + // won't open must not hold the whole app hostage; the retry in initArk + // catches up if it lands after the cap. + arkStoreReady() { + const store = wallet._arkStore; + if (!store || store.ready) return null; + return Promise.race([ + store.open().catch(() => {}), + new Promise((r) => setTimeout(r, 800)), + ]); + }, screenView() { return ui.arkCoinsPage ? arkCoinsPage() : ui.arkExitPage ? arkExitPage() : null; }, receiveTakeover() { const offboarded = arkOffboardedScreen(); |
