Skip to content

feat(flashcard): show the Cashu card on the home screen - #750

Merged
islandbitcoin merged 5 commits into
mainfrom
jabariennis/flashcard-v2-home-row
Oct 4, 2026
Merged

islandbitcoin merged 5 commits into
mainfrom
jabariennis/flashcard-v2-home-row

Conversation

@islandbitcoin

@islandbitcoin islandbitcoin commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

The home screen's Flashcard row only ever showed a BoltCard: it renders only when a BoltCard lnurl is linked, so a Cashu card never appeared there. Now the Cashu card attached to the app gets its own Flashcard row. That's the card read last, until Remove card detaches it. The row is hidden when no card is attached.

  • flashcardV2.attachedPubkey: every signed-in read attaches the card it read, Remove card detaches it, and logout clears it. useKnownCashuCard returns the attached card. Other cards the phone has read stay on record without showing.

  • The row shows the balance the card held at that last read:

    • in the display currency once the price is in;
    • before that, in the card's own figure (e.g. 1289 sats) with no currency code after it;
    • as "… · unit unknown" when the mint hasn't named the card's unit.

    Pressing it opens the card read this session, or asks for a tap; the sync button taps. A linked BoltCard keeps its own row, unchanged.

  • Balance takes an optional testID.

Choices worth a look:

  • One attached card. The row shows only the attached card. After Remove card it's hidden even if the phone has read other cards, until the next read attaches one. The first version showed the most recently read card, so removing a card brought back an older one: on the test Pixel, the same card's pre-reinstall record (0.2, 149 sats).
  • Last read, not live. The balance is what the card held when this phone last read it, the same as the card screen's last read. A spend at a till isn't reflected until the next tap.

Tests: a new spec covers:

  • the row hidden with no card, and shown with the last-read balance;
  • a USD card read as cents;
  • the fallback before the price is in;
  • the unknown-unit text;
  • open vs. tap;
  • attachedCard, and the slice attaching on a read and detaching on Remove.

Each fails when the behaviour it names is removed. Three existing specs that mock @app/hooks add the new hook. Full suite: 155 suites, 1,830 tests.

Requested during the 2026-10-02 device test.

🤖 Generated with Claude Code

Dread and others added 5 commits October 2, 2026 15:11
The home screen's Flashcard row only ever showed a BoltCard: it is gated on
the BoltCard's lnurl, so a Cashu card never appeared there. The card this
phone read last now gets its own Flashcard row, with the balance it held at
that read, and the row is hidden when the phone remembers no card.

- `useKnownCashuCard`: the most recently read card from the flashcardV2
  slice (signed-in reads only; Remove card drops it, logout clears them).
- The row shows the balance in the display currency, and the card's own
  figure (no currency code) before the price is in or when the mint has not
  named the unit. Pressing it opens the card read this session, or asks for
  a tap.
- `Balance` takes an optional testID.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…akes its place

The home row showed the card this phone read most recently. Remove card
dropped that card, and the row then showed the next one on record: on the
test Pixel, the card's own pre-reinstall record (0.2, 149 sats), so the
card looked still attached.

The flashcardV2 slice now records the attached card: every signed-in read
attaches the card it read, Remove card detaches it, logout clears it. The
home row shows the attached card only, and other cards the phone has read
stay on record without showing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…'s taps

Review fixes for the Home Cashu card row.

- flashcard-tap-call-sites.spec.tsx renders the row with an attached card
  and no card read this session, and pins both of its controls: the body
  and the sync each route one tap through useTapFlashcard with no options,
  so a BoltCard tapped there opens Card. The Balance mock keys its test ids
  on the tile's testID where it has one, since both Home rows are titled
  Flashcard.
- wallet-overview-cashu-card.spec.tsx covers the empty card: no unit named,
  balance 0, shown as a Bitcoin zero in the display currency, never as
  "unit unknown".
- useKnownCashuCard is now useAttachedCashuCard (use-attached-cashu-card.ts),
  and the comments and test labels that still described the first commit's
  "remembered card" rule now say "attached".
- migrations.ts: a new flashcardV2 field that starts with a value needs its
  own version and migration; an optional field that starts absent, as
  attachedPubkey does, needs neither.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…session

Review fix for the Home Cashu card row. The sync test ran only with no card
read this session, where the sync (tapFlashcard) and the body
(openCashuCard) make the same tap, so a sync wired to openCashuCard passed
every suite. With a card read this session that sync would open the
session's read, a balance a spend at a till has since made stale, and ask
for no tap.

- flashcard-tap-call-sites.spec.tsx: the useFlashcard mock returns
  cashuCard from mockSessionCard, reset in beforeEach. New test: with a card
  attached and read this session, the row's sync still routes one tap.
- A companion test pins the body in that state: it opens FlashcardV2
  without a tap. It also proves the session's read reaches the row, so the
  sync test cannot pass for want of one.
- useNavigation's navigate is a shared mockNavigate, and expectTapped and
  expectOpened assert the call site navigates nowhere itself, so a control
  that navigates and taps fails too.

Mutation checks: the sync wired to openCashuCard fails the new sync test;
a sync that navigates and taps fails both sync tests; a body that always
taps fails the new body test.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The Home row is the first reader of the slice's unit together with
lastBalance. cardSeen kept the unit the mint named for an earlier read
even when the balance had moved, so a card spent to zero and reloaded in
USD on another phone would show on Home in sats whenever this phone's tap
lost the keyset split (latent while cashuCardUsdEnabled is off). A read now
keeps the unit only while its balance still stands, as recordCardOperation
already does; the unit returns when cardUnitResolved names it again.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@islandbitcoin
islandbitcoin merged commit 2f81dde into main Oct 4, 2026
8 of 9 checks passed
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