Skip to content

Fix qrcode copy button - #617

Merged
bordalix merged 4 commits into
masterfrom
fix_qrcode_copy_button
May 14, 2026
Merged

bordalix merged 4 commits into
masterfrom
fix_qrcode_copy_button

Conversation

@bordalix

@bordalix bordalix commented May 14, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #573

Supersede #579

Summary by CodeRabbit

  • Bug Fixes

    • Copy button in QR code receive screen now properly copies the unified address to clipboard and displays a confirmation notification.
  • Tests

    • Added test coverage for QR code copy functionality.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Rate limit exceeded

@bordalix has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 42 minutes and 22 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 87c1f9a6-1cf3-4a7c-afea-8bbd93fbcc88

📥 Commits

Reviewing files that changed from the base of the PR and between 9e94643 and c5f1b6f.

📒 Files selected for processing (1)
  • src/screens/Wallet/Receive/QrCode.tsx

Walkthrough

The PR updates the receive screen's copy button to automatically copy the unified BIP21 URI to the clipboard instead of only opening a sheet. A new handleCopyButton handler conditionally copies the QR code value with toast feedback. The behavior is tested to verify clipboard writes contain the expected Bitcoin-prefixed URI. A regtest submodule dependency is also updated.

Changes

BIP21 Copy Button Feature

Layer / File(s) Summary
Copy Button Handler and Wiring
src/screens/Wallet/Receive/QrCode.tsx
New handleCopyButton handler opens the copy sheet and copies qrCodeValue to clipboard with toast notification when not already copied. Bottom Copy button updated to call this handler instead of directly opening the sheet.
Copy Button Test
src/test/screens/wallet/receive-qrcode.test.tsx
Test case verifies that clicking the Copy button copies the unified BIP21 URI to clipboard, asserting the value starts with bitcoin: and contains the expected address.

Regtest Dependency Update

Layer / File(s) Summary
Submodule Revision Update
regtest
Git submodule commit pointer updated to a new revision.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • arkade-os/wallet#587: Both PRs update the regtest git submodule pointer to a new commit revision.
  • arkade-os/wallet#492: Both modify the regtest submodule reference for regtest environment integration.
  • arkade-os/wallet#533: Both PRs modify the QR code receive screen and tests to copy the unified BIP21 URI containing the expected Bitcoin-prefixed address to clipboard.

Suggested reviewers

  • arkanaai
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix qrcode copy button' directly relates to the main changeset which modifies the copy button behavior on the QR code receive screen to copy the unified BIP21 invoice.
Linked Issues check ✅ Passed The PR successfully implements the requirement from issue #573: the copy button now copies the unified BIP21 URI by default, with a new handler and corresponding test coverage.
Out of Scope Changes check ✅ Passed All changes are scoped to implementing the copy button fix: QrCode.tsx handler change, test coverage, and a regtest submodule update unrelated to core functionality.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix_qrcode_copy_button

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 and usage tips.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 Code Review — #617

🐛 Bug: !copied guard prevents re-copy after first use

src/screens/Wallet/Receive/QrCode.tsx — handleCopyButton

const handleCopyButton = async () => {
    if (!prefersReducedMotion) hapticSubtle()
    setShowCopySheet(true)
    if (qrCodeValue && !copied) {  // ← bug here
      await copyToClipboard(qrCodeValue)
      toast("Copied to clipboard")
      setCopied(qrCodeValue)
    }
  }

copied is a string (line 85: useState("")). After the first successful copy, copied becomes a non-empty string. !copied is then always false, so the auto-copy never fires again — even when qrCodeValue has changed (e.g., user edited the amount, or the QR was swapped to a different address type from the sheet).

This partially defeats the purpose of the fix. Scenario:

  1. User clicks Copy → copies BIP21 URI ✅
  2. User opens copy sheet, selects "Ark address" → copied = ark address
  3. User clicks Copy button again → !copied is false → nothing copied ❌

Fix: Replace !copied with copied !== qrCodeValue:

if (qrCodeValue && copied !== qrCodeValue) {

This correctly skips the copy only when the current value is already on the clipboard, and re-copies when the value has changed.

⚠️ Nit: Unrelated submodule bump

The regtest submodule pointer changed (6333e4b8 → dc23da2c). This is unrelated to the copy button fix and adds noise to the diff. Consider reverting unless intentional.

✅ What looks good

  • The new handleCopyButton correctly combines copy-to-clipboard with opening the sheet, matching issue #573 spec
  • Haptic feedback is consistent with the existing handleCopy pattern
  • Test covers the happy path (Copy button → clipboard gets BIP21 URI)
  • No protocol-critical code touched

📝 Suggestion for test coverage

Consider adding a test for the re-copy scenario: copy once, change qrCodeValue (via rerender), copy again → assert copyToClipboard was called a second time with the new value. The existing QR-tap test at line 357 does this for the QR button; the Copy button should have parity.


Verdict: Request changes — the !copied guard bug means the fix only works on the first click per session. One-line fix (!copied → copied !== qrCodeValue).

🤖 Reviewed by Arkana

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/test/screens/wallet/receive-qrcode.test.tsx (1)

343-355: ⚡ Quick win

Consider adding test cases for edge scenarios.

The current test verifies the happy path (first click), but additional test cases would improve coverage and catch potential regressions:

  1. Repeated clicks: Verify that clicking the Copy button multiple times behaves correctly (e.g., doesn't copy unnecessarily, or does re-copy if that's the intent)
  2. Address switching: Verify that after selecting a specific address (which changes qrCodeValue), clicking the Copy button copies the new value
  3. State management: Verify that the copied state is properly maintained across different user interactions

These test cases would have caught the conditional logic issue in handleCopyButton where !copied prevents re-copying when the QR code value changes.

📝 Example test cases
it('clicking Copy button after selecting a specific address copies the new value', async () => {
  const { rerender } = render(buildTree(tapFixture()))
  
  const copyButton = await screen.findByRole('button', { name: 'Copy' })
  
  // First click - copies unified BIP21
  await act(async () => { fireEvent.click(copyButton) })
  const firstCopy = copyToClipboardMock.mock.calls[0][0]
  expect(firstCopy).toMatch(/^bitcoin:/)
  
  // Simulate selecting a specific address (changes qrCodeValue)
  await act(async () => {
    rerender(buildTree(tapFixture({ off: 'ark1different', bd: 'bc1different' })))
  })
  
  // Second click - should copy the new value
  await act(async () => { fireEvent.click(copyButton) })
  expect(copyToClipboardMock).toHaveBeenCalledTimes(2)
  const secondCopy = copyToClipboardMock.mock.calls[1][0]
  expect(secondCopy).toContain('ark1different')
  expect(secondCopy).not.toBe(firstCopy)
})
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/test/screens/wallet/receive-qrcode.test.tsx` around lines 343 - 355, The
test only covers the first copy action; add tests that simulate repeated clicks
and address switching so the Copy button re-copies when qrCodeValue changes and
copied state is preserved correctly; specifically, extend
receive-qrcode.test.tsx to (1) click the Copy button multiple times and assert
copyToClipboardMock call count increments as expected, and (2) rerender or
dispatch the action that changes qrCodeValue (using tapFixture with a different
address) then click Copy again and assert the new URI (containing the new ark1
address) was copied and not equal to the previous value; if component logic
prevents re-copying, update handleCopyButton (and the copied state logic) to
reset or compare the current qrCodeValue so subsequent copies of a changed value
are allowed.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/screens/Wallet/Receive/QrCode.tsx`:
- Around line 332-340: The copy handler handleCopyButton uses a truthy check on
copied which prevents re-copying when qrCodeValue changes; update the condition
so it copies whenever qrCodeValue exists and is different from copied (e.g.,
compare qrCodeValue !== copied) — keep existing behaviors (hapticSubtle when
!prefersReducedMotion, setShowCopySheet(true)), call await
copyToClipboard(qrCodeValue), call toast('Copied to clipboard'), and then call
setCopied(qrCodeValue) so subsequent clicks with the same value do nothing but a
changed qrCodeValue will re-copy.

---

Nitpick comments:
In `@src/test/screens/wallet/receive-qrcode.test.tsx`:
- Around line 343-355: The test only covers the first copy action; add tests
that simulate repeated clicks and address switching so the Copy button re-copies
when qrCodeValue changes and copied state is preserved correctly; specifically,
extend receive-qrcode.test.tsx to (1) click the Copy button multiple times and
assert copyToClipboardMock call count increments as expected, and (2) rerender
or dispatch the action that changes qrCodeValue (using tapFixture with a
different address) then click Copy again and assert the new URI (containing the
new ark1 address) was copied and not equal to the previous value; if component
logic prevents re-copying, update handleCopyButton (and the copied state logic)
to reset or compare the current qrCodeValue so subsequent copies of a changed
value are allowed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 73b57c1f-8c74-4bf3-83b0-c1d2235549f7

📥 Commits

Reviewing files that changed from the base of the PR and between 0d98677 and 9e94643.

📒 Files selected for processing (3)
  • regtest
  • src/screens/Wallet/Receive/QrCode.tsx
  • src/test/screens/wallet/receive-qrcode.test.tsx

Comment thread src/screens/Wallet/Receive/QrCode.tsx Resolved
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented May 14, 2026 •

Copy link
Copy Markdown

Deploying tmp-boltz-upstream-mainnet-arkade-wallet with  Cloudflare Pages  Cloudflare Pages

Latest commit: c5f1b6f
Status: ✅  Deploy successful!
Preview URL: https://12da65c1.tmp-boltz-upstream-mainnet-arkade-wallet.pages.dev
Branch Preview URL: https://fix-qrcode-copy-button.tmp-boltz-upstream-mainnet-arkade-wallet.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying wallet-bitcoin with  Cloudflare Pages  Cloudflare Pages

Latest commit: c5f1b6f
Status: ✅  Deploy successful!
Preview URL: https://d0ba995c.wallet-bitcoin.pages.dev
Branch Preview URL: https://fix-qrcode-copy-button.wallet-bitcoin.pages.dev

View logs

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying wallet-mutinynet with  Cloudflare Pages  Cloudflare Pages

Latest commit: c5f1b6f
Status: ✅  Deploy successful!
Preview URL: https://026b9ad9.arkade-wallet.pages.dev
Branch Preview URL: https://fix-qrcode-copy-button.arkade-wallet.pages.dev

View logs

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Approved — Fix verified

The !copied → copied !== qrCodeValue fix from my previous review has been correctly applied. The copy button now properly re-fires when qrCodeValue changes (amount edit, address type switch from sheet).

No protocol-critical code touched. LGTM.

🤖 Reviewed by Arkana

@bordalix
bordalix merged commit e84af68 into master May 14, 2026
6 checks passed
@bordalix
bordalix deleted the fix_qrcode_copy_button branch May 18, 2026 16:12
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.

Copy button should copy unified BIP21 invoice by default

1 participant