Skip to content

fix: handle clipboard copy failures in transaction card#131

Open
Atharva0506 wants to merge 1 commit intoStabilityNexus:mainfrom
Atharva0506:fix/clipboard-copy-error-handling
Open

fix: handle clipboard copy failures in transaction card#131
Atharva0506 wants to merge 1 commit intoStabilityNexus:mainfrom
Atharva0506:fix/clipboard-copy-error-handling

Conversation

@Atharva0506
Copy link
Copy Markdown

@Atharva0506 Atharva0506 commented Mar 16, 2026

Addressed Issues:

Fixes #130

Screenshots/Recordings:

N/A for this change (no layout/styling changes).
Behavioral change only:

  • Before: copy action could fail silently while still showing a success toast.
  • After: copy action awaits result, handles failures, and uses a fallback copy path before showing an error toast.

Additional Notes:

This PR improves transaction hash copy UX by:

  • adding async clipboard handling
  • adding error handling for blocked/unsupported clipboard contexts
  • adding a fallback copy mechanism when primary clipboard API is unavailable
  • Scope is intentionally small and limited to a single issue.

AI Usage Disclosure:

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

Checklist

  • My PR addresses a single issue, fixes a single bug or makes a single improvement.
  • My code follows the project's code style and conventions
  • If applicable, I have made corresponding changes or additions to the documentation
  • If applicable, I have made corresponding changes or additions to tests
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contribution Guidelines
  • Once I submit my PR, CodeRabbit AI will automatically review it and I will address CodeRabbit's comments.
  • I have filled this PR template completely and carefully, and I understand that my PR may be closed without review otherwise.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Enhanced transaction hash copy functionality with improved error handling and clearer user feedback when copy operations fail.

Add async clipboard copy flow with error handling and fallback when Clipboard API is unavailable or blocked. Show accurate success/error toasts so users are not told copy succeeded when it failed.
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 16, 2026

Walkthrough

The handleCopyHash function in TransactionCard.tsx was refactored to properly handle the async clipboard API. Changed from ignoring the returned Promise to awaiting navigator.clipboard.writeText() with try-catch error handling, displaying success or error toasts accordingly.

Changes

Cohort / File(s) Summary
Clipboard Promise Handling
src/lib/components/blocks/TransactionCard.tsx
Converted synchronous clipboard handler to async with proper Promise awaiting and error handling. Success toast displays only after confirmed write; error toast appears on failure with console logging.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

Typescript Lang

Poem

🐰 A clipboard that promised but never delivered,
Now properly awaits, no truth unshivered,
Catch those errors, toast them right,
Success and failure, both in sight! ✨

🚥 Pre-merge checks | ✅ 4
✅ 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 accurately describes the main change: converting synchronous clipboard copy to async with error handling in the transaction card.
Linked Issues check ✅ Passed The PR fully addresses issue #130 by making handleCopyHash async, awaiting clipboard.writeText(), showing success toast only after confirmation, and displaying error toasts on failures.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the async clipboard handling issue; no unrelated modifications to layout, styling, or other components are present.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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.

@Atharva0506 Atharva0506 marked this pull request as ready for review March 16, 2026 09:29
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/lib/components/blocks/TransactionCard.tsx`:
- Around line 42-44: Replace the inline toast strings in TransactionCard.tsx
with i18n resource lookups: change the success and error messages used in the
try/catch where toast.success("Transaction hash copied!") and
toast.error("Failed to copy transaction hash.") are called to use the
localization function (e.g., t('transaction.hashCopied') and
t('transaction.hashCopyFailed')) so the messages come from your i18n resources;
update or add corresponding keys in the translation files and ensure the
component imports/uses the i18n hook or translator method (the toast calls
inside the copy handler in TransactionCard) instead of hard-coded literals.
🪄 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: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: eabd162d-da96-44e8-a423-d2b669598b16

📥 Commits

Reviewing files that changed from the base of the PR and between 57aba3e and c3405e9.

📒 Files selected for processing (1)
  • src/lib/components/blocks/TransactionCard.tsx

Comment thread src/lib/components/blocks/TransactionCard.tsx
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.

[BUG]: Unhandled Async Clipboard Promise in TransactionCard.tsx

1 participant