fix: persist bridge recipient across preview - #222
Conversation
Fixes EXP-302.
WalkthroughBridge form persistence now stores and restores a recipient value tied to the connected address, and disconnect cleanup removes all persisted bridge form keys through a shared helper. ChangesBridge recipient persistence
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant BridgeForm
participant useDefaultValues
participant localStorage
participant clearPersistedBridgeFormValues
BridgeForm->>useDefaultValues: useDefaultValues(address)
useDefaultValues->>localStorage: read BRIDGE_RECIPIENT
BridgeForm->>localStorage: persist recipient and bridge fields
BridgeForm->>clearPersistedBridgeFormValues: disconnect cleanup
clearPersistedBridgeFormValues->>localStorage: remove bridge form keys
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Deploying interwovenkit-testnet with
|
| Latest commit: |
4d634d5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://cd96d4fe.interwovenkit-testnet.pages.dev |
| Branch Preview URL: | https://fix-exp-302-recipient-reset.interwovenkit-testnet.pages.dev |
Deploying interwovenkit-staging with
|
| Latest commit: |
4d634d5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f2ea697d.interwovenkit-staging.pages.dev |
| Branch Preview URL: | https://fix-exp-302-recipient-reset.interwovenkit-staging.pages.dev |
Deploying interwovenkit with
|
| Latest commit: |
4d634d5
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://c2551128.interwovenkit.pages.dev |
| Branch Preview URL: | https://fix-exp-302-recipient-reset.interwovenkit.pages.dev |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
packages/interwovenkit-react/src/data/constants.tspackages/interwovenkit-react/src/pages/bridge/BridgeForm.tsxpackages/interwovenkit-react/src/pages/bridge/data/form.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Autofix Details
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.
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.
…-reset # Conflicts: # packages/interwovenkit-react/src/pages/bridge/data/form.ts
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Stale recipient after wallet switch
- I removed bridge recipient persistence so remounts after an in-widget wallet switch fall back to the current wallet's default destination address again.
Or push these changes by commenting:
@cursor push 73573e9510
Preview (73573e9510)
diff --git a/packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx b/packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx
--- a/packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx
+++ b/packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx
@@ -100,7 +100,6 @@
localStorage.setItem(LocalStorageKey.BRIDGE_DST_DENOM, dstDenom)
localStorage.setItem(LocalStorageKey.BRIDGE_QUANTITY, quantity)
localStorage.setItem(LocalStorageKey.BRIDGE_SLIPPAGE_PERCENT, slippagePercent)
- localStorage.setItem(LocalStorageKey.BRIDGE_RECIPIENT, recipient)
}, [
srcChainId,
srcDenom,
@@ -108,7 +107,6 @@
dstDenom,
quantity,
slippagePercent,
- recipient,
isSrcDenomValid,
isDstDenomValid,
])
diff --git a/packages/interwovenkit-react/src/pages/bridge/data/form.ts b/packages/interwovenkit-react/src/pages/bridge/data/form.ts
--- a/packages/interwovenkit-react/src/pages/bridge/data/form.ts
+++ b/packages/interwovenkit-react/src/pages/bridge/data/form.ts
@@ -72,7 +72,6 @@
slippagePercent: normalizePersistedSlippage(
localStorage.getItem(LocalStorageKey.BRIDGE_SLIPPAGE_PERCENT),
),
- recipient: localStorage.getItem(LocalStorageKey.BRIDGE_RECIPIENT),
})
return {You can send follow-ups to the cloud agent here.
Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3b2572b. Configure here.
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx (1)
26-30: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winRehydrate the saved recipient when
addressarrives
useFormonly readsdefaultValueson the first render, so ifuseAddress()is still empty during mount, the saved recipient fromuseDefaultValues(address)never gets applied. The form then falls back to the chain default instead of the persisted recipient on reconnect/hydration. Re-run recipient initialization whenaddresschanges (for example withreset(...)or a targetedsetValue("recipient", ...)effect).🤖 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 `@packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx` around lines 26 - 30, The BridgeForm form initialization only applies useDefaultValues(address) on first render, so the persisted recipient is missed when useAddress() resolves later. Update BridgeForm to rehydrate the recipient when address changes by adding an effect around useForm/reset or a targeted setValue("recipient", ...) keyed off address, and keep the recipient in sync with the saved default instead of falling back to the chain default.
🤖 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.
Outside diff comments:
In `@packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsx`:
- Around line 26-30: The BridgeForm form initialization only applies
useDefaultValues(address) on first render, so the persisted recipient is missed
when useAddress() resolves later. Update BridgeForm to rehydrate the recipient
when address changes by adding an effect around useForm/reset or a targeted
setValue("recipient", ...) keyed off address, and keep the recipient in sync
with the saved default instead of falling back to the chain default.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e95c5a50-6fb4-4ae6-ae11-b6fcf933d428
📒 Files selected for processing (3)
packages/interwovenkit-react/src/pages/bridge/BridgeForm.tsxpackages/interwovenkit-react/src/pages/bridge/data/form.test.tspackages/interwovenkit-react/src/pages/bridge/data/form.ts


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_RECIPIENTlocalStorage 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
eslint --fix --max-warnings=0andprettier --write.Fixes EXP-302.
Note
Low Risk
Client-side form persistence and disconnect cleanup only; recipient restore is scoped to the connected address to avoid cross-wallet reuse.
Overview
Fixes EXP-302: a custom bridge recipient was dropped when leaving the form for preview and returning, because only chains, denoms, quantity, and slippage were persisted.
The bridge form now saves
BRIDGE_RECIPIENTwith the other fields. Values are stored as JSON tying connected address to recipient, and are only restored when the same wallet reconnects (case-insensitive); legacy or malformed entries are ignored.Disconnect clears all bridge form keys (including recipient) via shared
clearPersistedBridgeFormValues, replacing inlinelocalStorageremovals inuseDisconnect.useDefaultValuestakes the connected address so the recipient can be rehydrated on remount.Reviewed by Cursor Bugbot for commit 4d634d5. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit