Skip to content

fix(bridge): disable swap-and-bridge on the Hooks tab - #7696

Merged
fairlighteth merged 6 commits into
cowprotocol:developfrom
tenderdeve:fix/7490-disable-bridge-on-hooks-tab
Jun 26, 2026
Merged

fairlighteth merged 6 commits into
cowprotocol:developfrom
tenderdeve:fix/7490-disable-bridge-on-hooks-tab

Conversation

@tenderdeve

@tenderdeve tenderdeve commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #7490

Hooks orders are partially-fillable (PF), but bridge orders do not support partial fills. When a hook order is partially filled and the bridging step kicks in for the remaining amount, the order can get stuck in the 'Bridging' state indefinitely.

This PR restricts the bridging feature to the Swap route only. BridgingEnabledUpdater previously enabled bridging on both Routes.SWAP and Routes.HOOKS; the Hooks route is now excluded.

The Safe-widget feature flag (isBridgingInSafeWidgetEnabled), the disableCrossChainSwap widget param, and bridge-provider availability checks continue to apply on the Swap route.

To Test

  1. Hooks tab — bridging disabled

    • Navigate to /swap/hooks
    • Bridge / cross-chain destination UI is not shown
    • Placing a hooks order behaves as a regular swap order (no bridge entry points)
  2. Swap tab — bridging unchanged

    • Navigate to /swap
    • Bridge / cross-chain destination UI is shown when supported chains are configured
    • disableCrossChainSwap=true widget param still hides bridging
    • Inside Safe app widget without isBridgingInSafeWidgetEnabled flag, bridging remains hidden
  3. Limit / Yield / other routes

    • Bridging stays disabled (unchanged)

Background

The fix is in apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts, the sole producer of the global isBridgingEnabledAtom. Consumers of useIsBridgingEnabled (routes availability, supported tokens, swap-and-bridge UI) propagate the disabled state automatically.

A unit test BridgingEnabledUpdater.test.tsx covers:

  • Swap route → enabled
  • Hooks route → disabled (regression test for this issue)
  • Other routes → disabled
  • disableCrossChainSwap widget param respected
  • Bridge providers required
  • Safe-widget gating still applied

A code comment was added to explain why Hooks is excluded so the constraint isn't dropped by future refactors.

Summary by CodeRabbit

  • Changes

    • Cross-chain bridging is now available only on the Swap tab; it’s disabled on the Hooks tab to avoid order-related issues.
    • When bridging is active, the cross-chain URL parameter fallback now applies only for Swap, not other routes.
    • Bridging remains gated by widget configuration (e.g., cross-chain disable setting), Safe widget context, feature flag, and bridge provider availability.
  • Tests

    • Added coverage to verify bridging enablement/disablement across routes and widget/Safe/provided-bridge scenarios.

Hooks orders are partially-fillable (PF), but bridge orders do not
support partial fills. When a hook order is partially filled and the
remaining bridging step is triggered, the order can get stuck in the
'Bridging' state indefinitely.

Restrict the bridging feature to the Swap route only. The Safe-widget
flag, `disableCrossChainSwap` widget param, and bridge-provider
availability checks continue to apply.

Closes cowprotocol#7490
@vercel

vercel Bot commented Jun 22, 2026

Copy link
Copy Markdown

@tenderdeve is attempting to deploy a commit to the cow-dev Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1178483c-2e6a-447b-8f0c-709a43bff719

📥 Commits

Reviewing files that changed from the base of the PR and between 1ff4467 and 0e6ba18.

📒 Files selected for processing (1)
  • apps/cowswap-frontend/src/modules/trade/hooks/useGetTradeUrlParams.ts

Walkthrough

BridgingEnabledUpdater is updated to enable cross-chain bridging exclusively on the SWAP route, removing prior HOOKS route inclusion with explanatory comments. A separate update to useGetTradeUrlParams enforces Swap-only URL parameter fallback. A new test file covers all gating conditions: route, disableCrossChainSwap, Safe widget context, feature flag, and bridge provider presence.

Changes

Restrict bridging to Swap route

Layer / File(s) Summary
Swap-only bridging logic in updater
apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.ts
shouldEnableBridging now checks isSwapRoute only instead of isSwapRoute || isHooksRoute. Comments explain that Hooks is excluded due to partial-fill/order-stuck behavior. All other gates (disableCrossChainSwap, shouldEnableInWidgetSafe, hasBridgeProviders) are unchanged.
Enforce Swap-only URL parameter fallback
apps/cowswap-frontend/src/modules/trade/hooks/useGetTradeUrlParams.ts
Updated to restrict bridging-mode URL parameter fallback to the Swap tab only, changing the condition from "Swap or Hooks" to "Swap only". Cross-chain references are dropped when navigating to Hooks or other routes, returning default widget parameters instead.
Test coverage for updated gating conditions
apps/cowswap-frontend/src/modules/bridge/updaters/BridgingEnabledUpdater.test.tsx
New Jest/RTL suite mocks six hook dependencies and asserts setIsBridgingEnabled is called with true only on SWAP, and false on HOOKS, LIMIT_ORDERS, when disableCrossChainSwap is set, when no bridge providers exist, or inside a Safe widget without the feature flag.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • alfetopito
  • elena-zh
  • kernelwhisperer

Poem

🐰 Hippity-hop, the Hooks tab's sealed tight,
No bridging for orders that partial-fill at night!
The Swap page alone gets the cross-chain delight,
A flag and a Safe check keep the conditions right.
One small boolean, one big bug set to flight! 🌉

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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
Title check ✅ Passed The title accurately and concisely describes the main change: disabling the swap-and-bridge feature on the Hooks tab to resolve the partial-fill stuck order issue.
Description check ✅ Passed The description comprehensively covers all required sections: issue reference, clear explanation of the problem and solution, detailed testing steps with checkboxes, and background context. All template sections are properly filled.
Linked Issues check ✅ Passed The PR fully addresses issue #7490 by restricting bridging to the Swap route only, with comprehensive unit tests covering all scenarios mentioned in the issue and testing instructions validating the fix.
Out of Scope Changes check ✅ Passed All changes are directly scoped to disabling bridging on the Hooks tab: modifications to BridgingEnabledUpdater, useGetTradeUrlParams for proper URL state handling, and comprehensive test coverage. No out-of-scope changes detected.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@elena-zh elena-zh added the trigger-preview Add to a fork PR to trigger CF-pages preview. See https://github.com/cowprotocol/cowswap/pull/7615 label Jun 22, 2026
@github-actions

github-actions Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Cloudflare Pages preview mirror

Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7696
Mirror PR: #7698
Cloudflare Pages preview links will be posted on the mirror PR by the Cloudflare Pages GitHub integration once builds complete.

Source fork branch: tenderdeve/cowswap:fix/7490-disable-bridge-on-hooks-tab
Approval target SHA: 3bf8233dcd28
Last mirrored SHA: d4aad14e9623
Last comment update: @fairlighteth at 2026-06-26T17:09:12.022Z

  • Sync Cloudflare preview to approval target commit

@github-actions github-actions Bot removed the trigger-preview Add to a fork PR to trigger CF-pages preview. See https://github.com/cowprotocol/cowswap/pull/7615 label Jun 22, 2026
@vercel
vercel Bot temporarily deployed to Preview – storybook June 22, 2026 14:31 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 22, 2026 14:31 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 22, 2026 14:33 Inactive
@vercel
vercel Bot temporarily deployed to Preview – storybook June 23, 2026 10:06 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 23, 2026 10:06 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 23, 2026 10:07 Inactive
@elena-zh
elena-zh requested a review from a team June 23, 2026 10:43

@elena-zh elena-zh 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.

Hey @tenderdeve , thank you, it works fine.
However, there is 1 nitpick: it would be nice to reset URL parameters to deafult one and remove a cross-chain swap reference from there when navigating from Swap to the Hooks tab.

Image

Pls, compare it with navigation to limit orders page.

`useGetTradeUrlParams` only kept the cross-chain output token when the
target tab was Swap or Hooks. Since bridging is now disabled on the
Hooks tab, navigating from a bridging Swap to Hooks would carry over the
destination-chain token in the URL even though the Hooks form cannot use
it.

Restrict the "keep current trade context" branch to Swap only, so any
non-Swap navigation (Hooks included) falls back to default assets on the
current chain.

Addresses @elena-zh's review on cowprotocol#7696.
@vercel
vercel Bot temporarily deployed to Preview – storybook June 23, 2026 11:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 23, 2026 11:27 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 23, 2026 11:28 Inactive

@fairlighteth fairlighteth 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.

✅ AI Review (Codex GPT-5, worked 2m): no new findings

Review completed. I found no new non-duplicate comments worth posting.

Related context checked

  • Current head: d4aad14e96.
  • BridgingEnabledUpdater.ts:29: Hooks is excluded from bridge-enabled routes; Swap, Safe-widget, widget param, and provider gates remain covered by the same predicate.
  • useGetTradeUrlParams.ts:25: prior feedback is addressed; cross-chain URL state is dropped when leaving Swap, including Hooks.
  • Existing review context: the main behavior was manually confirmed, then approved after the URL-reset fix.
  • CI: BridgingEnabledUpdater.test.tsx passed; Test/Lint/Typecheck/Agent Harness passed. Cypress failed because INTEGRATION_TEST_PRIVATE_KEY is missing, so I did not treat it as PR-specific evidence.

Generated using the pr-review skill from the CoW Protocol skills repo.

@fairlighteth

Copy link
Copy Markdown
Contributor
🧪 Scoped browser QA passed: disconnected Hooks bridge gating; live bridge quote path not checked

Outcome

  • Checked scenarios:
    • ✅ Hooks route rendered the Hooks controls, including pre-hook and post-hook actions.
    • ✅ Hooks output token selector opened as a same-chain token list only; no Select network destination-chain panel was shown.
    • ✅ Swap output token selector still exposed the Select network panel with destination chains such as Base and Arbitrum, so the adjacent Swap bridge selector entry point remained available.
  • Primary evidence: Playwright browser run on PR head 0e6ba1875d25deadabcf828b73419d44318a102d; the recorded walkthrough and inspected screenshots show the Hooks-vs-Swap selector difference.
  • Not checked / follow-up:
    • ⚠️ Actual cross-chain destination token selection and bridge quote were not checked because the app showed the Near Intents impairment banner and bridge BFF destination-token calls returned 403 during the run.
    • ⚠️ Provider-injected, wallet-connected UI, signing-capable order placement, Safe widget behavior, and disableCrossChainSwap widget-param coverage were not exercised in this disconnected scoped pass.

Run details

  • Source: PR head 0e6ba1875d25deadabcf828b73419d44318a102d via local checkout.
  • Environment: macOS; Chromium 140.0.7339.16; Playwright.
  • Wallet: disconnected.
  • AI assistance: Codex orchestrated the Playwright browser execution, collected artifacts, and drafted this summary from the observed run.

Artifacts

How to retest

  • Start the app: pnpm start:cowswap
  • Enable the Hooks tab, then open route: #/1/swap/hooks/WETH/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
  • Open the output token selector and expect a same-chain token list without a Select network panel.
  • Open route: #/1/swap/WETH/0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48
  • Open the output token selector and expect the Select network panel to remain available on Swap.

Generated using the pr-qa skill from the CoW Protocol skills repo.

@fairlighteth
fairlighteth requested review from a team and fairlighteth June 23, 2026 20:48
@tenderdeve

Copy link
Copy Markdown
Contributor Author

@elena-zh updated in d4aad14 — useGetTradeUrlParams now drops the cross-chain output token whenever the user navigates from a bridging Swap to anywhere except Swap (Hooks included), so the URL is reset to default assets on the source chain.

@fairlighteth
fairlighteth enabled auto-merge (squash) June 26, 2026 17:09
@fairlighteth
fairlighteth merged commit 97cf3b5 into cowprotocol:develop Jun 26, 2026
12 of 18 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Disable swap and bridge on Hooks tab

3 participants