Skip to content

Chore/fix chain bug - #1069

Merged
lcamargof merged 2 commits into
masterfrom
chore/fix-chain-bug
Jul 28, 2026
Merged

Chore/fix chain bug#1069
lcamargof merged 2 commits into
masterfrom
chore/fix-chain-bug

Conversation

@lcamargof

@lcamargof lcamargof commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Added automatic wallet chain switching for supported routes when the active tab is focused and visible.
    • Background or hidden tabs remain passive and synchronize the wallet when focus or visibility returns.
  • Bug Fixes

    • Improved chain targeting to use the route’s provider identity.
    • Revalidated tab focus before wallet changes to prevent unintended switching.
  • Tests

    • Added coverage for focus, visibility, wallet-chain changes, and disabled switching scenarios.

@lcamargof
lcamargof requested a review from jgalat July 28, 2026 18:27
@coderabbitai

coderabbitai Bot commented Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

A new activity-aware chain-switching hook synchronizes wallets to active route chains only in focused, visible documents. Token context and Index DTF routes use the hook, with expanded effect dependencies and regression tests covering background and recovery states.

Changes

Focused-tab chain switching

Layer / File(s) Summary
Activity-aware switching hook
src/hooks/use-active-chain-switch.ts, src/hooks/tests/use-active-chain-switch.test.tsx, docs/wiki/project.md
Adds focus and visibility tracking, conditional wallet switching, lifecycle cleanup, and tests for active, background, recovery, stale-state, and disabled behavior.
Token route context integration
src/hooks/useRTokenContext.ts
Derives chain identity from URL parameters, expands effect dependencies, and delegates selected-token chain switching to useActiveChainSwitch.
Index DTF integration and records
src/views/index-dtf/index-dtf-container.tsx, docs/wiki/log.md, docs/wiki/progress.md
Replaces the local chain watcher with the shared hook and records the focused-tab switching stage and related regression notes.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Suggested reviewers: jgalat, juampirombola

Sequence Diagram(s)

sequenceDiagram
  participant Route as Index DTF or token route
  participant Hook as useActiveChainSwitch
  participant Document as Browser document
  participant Wallet as wagmi switchChain
  Route->>Hook: provide route chain
  Hook->>Document: check focus and visibility
  Hook->>Wallet: request route chain when active
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 inconclusive)

Check name Status Explanation Resolution
Title check ❓ Inconclusive The title is generic and does not clearly describe the main change, which is focused-tab chain switching and related hook/docs updates. Rename it to mention the focused-tab automatic chain switching fix, or the new useActiveChainSwitch hook, so the change is identifiable at a glance.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch chore/fix-chain-bug

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.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying register-app with  Cloudflare Pages  Cloudflare Pages

Latest commit: 3c8f1aa
Status: ✅  Deploy successful!
Preview URL: https://b1d09244.register-app.pages.dev
Branch Preview URL: https://chore-fix-chain-bug.register-app.pages.dev

View logs

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 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/hooks/use-active-chain-switch.ts`:
- Around line 36-50: Update the useEffect switch flow in
use-active-chain-switch.ts to use switchChainAsync and handle rejected or
unsupported chain switches. Resolve the target chain name and surface failures
through the existing wallet-error toast UX, following the pattern in
seamless-transaction.tsx, while preserving the current activation and
chain-mismatch conditions.
🪄 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 Plus

Run ID: 5dd55a62-e8cd-4505-8df3-e5800741bbdd

📥 Commits

Reviewing files that changed from the base of the PR and between b2fcf72 and 3c8f1aa.

📒 Files selected for processing (7)
  • docs/wiki/log.md
  • docs/wiki/progress.md
  • docs/wiki/project.md
  • src/hooks/tests/use-active-chain-switch.test.tsx
  • src/hooks/use-active-chain-switch.ts
  • src/hooks/useRTokenContext.ts
  • src/views/index-dtf/index-dtf-container.tsx

Comment thread src/hooks/use-active-chain-switch.ts
@lcamargof
lcamargof merged commit 45f7d16 into master Jul 28, 2026
5 checks passed
@lcamargof
lcamargof deleted the chore/fix-chain-bug branch July 28, 2026 18:42
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.

2 participants