Skip to content

fix: persist bridge recipient across preview#222

Draft
tansawit wants to merge 3 commits intomainfrom
fix/exp-302-recipient-reset
Draft

fix: persist bridge recipient across preview#222
tansawit wants to merge 3 commits intomainfrom
fix/exp-302-recipient-reset

Conversation

@tansawit
Copy link
Copy Markdown
Contributor

@tansawit tansawit commented Apr 7, 2026

Summary

This fixes EXP-302, where a custom bridge recipient address was lost after navigating to the preview screen and back.

The bridge form already persisted the selected chains, denom, quantity, and slippage in localStorage, but it did not persist the recipient field. Because the form remounts when moving through the preview route, the missing recipient value was treated as invalid and the widget replaced it with the default wallet address.

This change adds a dedicated BRIDGE_RECIPIENT localStorage key, writes the recipient into storage alongside the other bridge form fields, and restores it as part of the default bridge form values. That keeps a user-entered recipient stable across the preview round-trip instead of resetting it to the connected wallet address.

Validation

  • Pre-commit hooks ran successfully on the touched files: eslint --fix --max-warnings=0 and prettier --write.

Fixes EXP-302.


Note

Low Risk
Low risk: small change to bridge form persistence/cleanup via localStorage, with a new key and a helper to clear bridge-specific fields.

Overview
Fixes bridge form state loss by persisting the recipient field alongside existing bridge selections in localStorage, and restoring it as part of useDefaultValues() when the form remounts.

Introduces LocalStorageKey.BRIDGE_RECIPIENT plus a shared clearPersistedBridgeFormValues() helper (with test coverage) and uses it on disconnect to clear all bridge form keys consistently.

Reviewed by Cursor Bugbot for commit 6b3a18e. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • New Features
    • Bridge form now saves and restores the recipient address from previous sessions.
  • Chores
    • Disconnect flow now clears any saved bridge form values so stale form data isn't reused.
  • Tests
    • Added tests verifying bridge form data is cleared on demand while unrelated persisted data remains intact.

@linear
Copy link
Copy Markdown

linear bot commented Apr 7, 2026

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 7, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6521af8e-8746-4b8a-81e6-2195fc3a2a0d

📥 Commits

Reviewing files that changed from the base of the PR and between edc35d3 and 6b3a18e.

📒 Files selected for processing (3)
  • packages/interwovenkit-react/src/data/bridge-form-storage.test.ts
  • packages/interwovenkit-react/src/data/bridge-form-storage.ts
  • packages/interwovenkit-react/src/data/ui.ts

Walkthrough

Added persistent storage and cleanup for the bridge form recipient: new BRIDGE_RECIPIENT key, BridgeForm writes recipient to localStorage, useDefaultValues() reads it, and a new clearPersistedBridgeFormValues() plus tests remove persisted bridge fields on disconnect.

Changes

Cohort / File(s) Summary
LocalStorage keys & form persistence
packages/interwovenkit-react/src/data/constants.ts, packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx, packages/interwovenkit-react/src/pages/bridge/data/form.ts
Added LocalStorageKey.BRIDGE_RECIPIENT; BridgeForm now persists recipient to localStorage (effect deps updated); useDefaultValues() reads recipient from storage and includes it in returned defaults.
Persistence cleanup module & tests
packages/interwovenkit-react/src/data/bridge-form-storage.ts, packages/interwovenkit-react/src/data/bridge-form-storage.test.ts
New bridge-form-storage.ts exporting clearPersistedBridgeFormValues() which removes all bridge-related localStorage keys (including recipient); tests added to verify bridge keys are cleared while unrelated keys remain.
Disconnect flow update
packages/interwovenkit-react/src/data/ui.ts
Replaced inline localStorage removals with a call to clearPersistedBridgeFormValues() and adjusted imports accordingly.

Sequence Diagram(s)

sequenceDiagram
  participant UI as "BridgeForm (UI)"
  participant Defaults as "useDefaultValues()"
  participant StorageModule as "bridge-form-storage"
  participant LS as "localStorage"

  UI->>LS: set BRIDGE_SRC_*, BRIDGE_DST_*, BRIDGE_QUANTITY, BRIDGE_SLIPPAGE_PERCENT, BRIDGE_RECIPIENT
  Defaults->>LS: read BRIDGE_* keys (including BRIDGE_RECIPIENT)
  Note right of Defaults: Compose defaults from network presets\nthen localStorage values\nthen location overrides
  UI->>StorageModule: onDisconnect -> clearPersistedBridgeFormValues()
  StorageModule->>LS: remove BRIDGE_SRC_*, BRIDGE_DST_*, BRIDGE_QUANTITY, BRIDGE_SLIPPAGE_PERCENT, BRIDGE_RECIPIENT
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I hopped through keys both near and far,

Saved a recipient like a tiny star,
Cleared the trail when the session ends,
Bridge form tidy — shared with friends,
A little rabbit cheers the change with a happy jar 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 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 (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: persist bridge recipient across preview' directly and accurately reflects the main change: adding persistence of the bridge recipient field across navigation to the preview screen. The change is concise, specific, and clearly communicates the primary objective.

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

✨ 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 fix/exp-302-recipient-reset

Comment @coderabbitai help to get the list of available commands and usage tips.

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 7, 2026

Deploying interwovenkit-testnet with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6b3a18e
Status: ✅  Deploy successful!
Preview URL: https://d15d20b1.interwovenkit-testnet.pages.dev
Branch Preview URL: https://fix-exp-302-recipient-reset.interwovenkit-testnet.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 7, 2026

Deploying interwovenkit-staging with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6b3a18e
Status: ✅  Deploy successful!
Preview URL: https://be6f1e4f.interwovenkit-staging.pages.dev
Branch Preview URL: https://fix-exp-302-recipient-reset.interwovenkit-staging.pages.dev

View logs

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 7, 2026

Deploying interwovenkit with  Cloudflare Pages  Cloudflare Pages

Latest commit: 6b3a18e
Status: ✅  Deploy successful!
Preview URL: https://dc418ce5.interwovenkit.pages.dev
Branch Preview URL: https://fix-exp-302-recipient-reset.interwovenkit.pages.dev

View logs

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 `@packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx`:
- Line 101: The disconnect handler inside useDisconnect currently clears
source/destination/quantity/slippage but omits the persisted recipient; update
the disconnect handler in useDisconnect to remove the stored recipient by
calling localStorage.removeItem for LocalStorageKey.BRIDGE_RECIPIENT so the
recipient address is cleared on wallet disconnect and cannot persist across
sessions.
🪄 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: b479c51d-df22-4a53-b292-a1632c6e2f9f

📥 Commits

Reviewing files that changed from the base of the PR and between fff8722 and edc35d3.

📒 Files selected for processing (3)
  • packages/interwovenkit-react/src/data/constants.ts
  • packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx
  • packages/interwovenkit-react/src/pages/bridge/data/form.ts

Comment thread packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Stale recipient not cleared on wallet disconnect
    • The disconnect cleanup now removes the persisted bridge recipient so a previous wallet address cannot be restored after reconnecting.

Create PR

Or push these changes by commenting:

@cursor push eb9ba7010a
Preview (eb9ba7010a)
diff --git a/packages/interwovenkit-react/src/data/ui.ts b/packages/interwovenkit-react/src/data/ui.ts
--- a/packages/interwovenkit-react/src/data/ui.ts
+++ b/packages/interwovenkit-react/src/data/ui.ts
@@ -80,5 +80,6 @@
     localStorage.removeItem(LocalStorageKey.BRIDGE_DST_DENOM)
     localStorage.removeItem(LocalStorageKey.BRIDGE_QUANTITY)
     localStorage.removeItem(LocalStorageKey.BRIDGE_SLIPPAGE_PERCENT)
+    localStorage.removeItem(LocalStorageKey.BRIDGE_RECIPIENT)
   }
 }

You can send follow-ups to the cloud agent here.

Reviewed by Cursor Bugbot for commit edc35d3. Configure here.

Comment thread packages/interwovenkit-react/src/pages/bridge/BridgeForm.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.

1 participant