Skip to content

fix(twap): stay on Signing tab after placing a TWAP order#7730

Merged
elena-zh merged 7 commits into
cowprotocol:developfrom
tenderdeve:fix/6864-twap-stay-on-signing-tab
Jul 7, 2026
Merged

fix(twap): stay on Signing tab after placing a TWAP order#7730
elena-zh merged 7 commits into
cowprotocol:developfrom
tenderdeve:fix/6864-twap-stay-on-signing-tab

Conversation

@tenderdeve

@tenderdeve tenderdeve commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Closes #6864

Problem

After placing a TWAP order, the user is navigated to the Open orders tab while signing is still in progress. The order is actually in WaitSigning status at that point — so the Open tab is empty/wrong and the order they just placed effectively disappears from view until signing completes.

See Loom in the issue.

Cause

useCreateTwapOrder branched the post-placement navigation on isSmartContractWallet:

navigateToOrdersTableTab(isSmartContractWallet ? OrderTabId.signing : OrderTabId.open)

A TWAP order goes through sendSafeTransactions regardless of the wallet path and lands in TwapOrderStatus.WaitSigning. Both branches should send the user to the Signing tab, not Open.

Fix

Always navigate to OrderTabId.signing. Once owners actually sign, the order moves to Open and the user can switch tabs themselves.

Testing

  1. Place a TWAP order in a multi-sig Safe
  2. After the placement modal closes, you stay on Signing tab while signing is in progress
  3. Once signed, the order moves to Open tab and is visible there

Summary by CodeRabbit

  • Bug Fixes
    • TWAP order creation now always takes you to the Orders Table Signing tab after submission, with consistent behavior across wallet types.
    • URL tab validation is now less aggressive, so the app only normalizes/resets the tab when no valid tab ID is present, avoiding unnecessary URL rewrites.

A freshly placed TWAP order is in WaitSigning until the Safe (or other
smart-account) owners sign it. Navigating to the Open tab right after
`sendSafeTransactions` resolves hides the order while it is still being
signed and confuses the user.

Always navigate to the Signing tab on placement; once signed the order
moves to Open and the user can switch tabs themselves.

Fixes cowprotocol#6864
@vercel

vercel Bot commented Jun 24, 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 24, 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: aea1f6e1-a09e-4af5-99e9-09010c5f8920

📥 Commits

Reviewing files that changed from the base of the PR and between 0a52445 and 88cdd9c.

📒 Files selected for processing (1)
  • apps/cowswap-frontend/src/modules/ordersTable/hooks/url/useValidatePageUrlParams.ts

Walkthrough

TWAP order placement now always navigates to the Orders Table signing tab after submission. Orders Table URL validation now resets the tab only when the parsed URL lacks a valid tabId, preserving the existing page reset behavior.

Changes

TWAP order placement

Layer / File(s) Summary
TWAP post-placement navigation
apps/cowswap-frontend/src/modules/twap/hooks/useCreateTwapOrder.tsx
Removes useIsSmartContractWallet usage, always redirects to OrderTabId.signing after order placement, and updates the callback dependencies accordingly.

Orders Table URL handling

Layer / File(s) Summary
Orders Table URL tab reset
apps/cowswap-frontend/src/modules/ordersTable/hooks/url/useValidatePageUrlParams.ts
Changes tab normalization to run only when the URL has no valid tabId, instead of when the current tab differs from the parsed tab.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • elena-zh
  • fairlighteth
  • kernelwhisperer

Poem

🐇 Hop to the signing tab, bright and clear,
No wallet guessing needed here.
The URL tabs now settle सही? no—just right,
A bunny fixed the path in one swift flight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main fix: keeping TWAP users on the Signing tab after placement.
Description check ✅ Passed The description covers the issue, root cause, fix, and test steps, which matches the template's core requirements.
Linked Issues check ✅ Passed The changes address #6864 by keeping TWAP placement on Signing and preventing URL normalization from forcing Open too early.
Out of Scope Changes check ✅ Passed The extra URL-guard change is directly supporting the TWAP navigation fix and is not unrelated scope.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ 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 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

Cloudflare Pages preview mirror

Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7730
Mirror PR: #7733
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/6864-twap-stay-on-signing-tab
Approval target SHA: 9ca92c3f7d81
Last mirrored SHA: 0c28d3734b4e
Last comment update: @elena-zh at 2026-07-07T09:07:25.580Z

  • Sync Cloudflare preview to approval target commit

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

The issue is still reproducible if follow exact steps described in #6864

…tly empty

A freshly placed TWAP order reaches the Signing list a few renders after
navigation. In that gap useCurrentTab falls back to the Open tab, and
useValidatePageUrlParams then rewrote the URL to open with replace:true,
permanently bouncing the user off Signing. Only normalize the tab when the
URL has no valid tab, so a valid explicitly-selected tab is preserved.
@tenderdeve

tenderdeve commented Jun 29, 2026

Copy link
Copy Markdown
Contributor Author

@elena-zh you're right, the first change wasn't enough.

The new TWAP order only shows up in the Signing list a few renders after we navigate there (it has to go through twapOrdersListAtom -> emulated orders -> store). While Signing is still empty, useCurrentTab falls back to Open, and then useValidatePageUrlParams rewrites the URL to open with replace: true. So even once the order does appear in Signing, the URL already says open and you're stuck there.

88cdd9c only normalizes the URL tab when there isn't a valid one in the URL, so a tab you explicitly selected that's briefly empty is left alone. With that the Signing navigation sticks.

Can you re-test the steps from #6864?

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

it has become better, there is no blinking between tabs after placing an order. So approving it.

@elena-zh elena-zh requested a review from Danziger June 30, 2026 11:30

@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): no new findings

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

Review scope and related context
  • Rechecked useCreateTwapOrder: the new TWAP order is created with TwapOrderStatus.WaitSigning and navigation now always targets OrderTabId.signing.
  • Rechecked useValidatePageUrlParams: a valid URL tabId is no longer overwritten while the Signing list is transiently empty.
  • Existing review context: the earlier “still reproducible” review was followed by approval after 88cdd9c, confirming the tab no longer blinks after placing the order.

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

@fairlighteth

fairlighteth commented Jul 2, 2026

Copy link
Copy Markdown
Contributor
⚠️ Browser QA follow-up: real Safe App reached; hybrid fixture covers Signing → Open UI reaction

Outcome

  • Verified PR head 9e7702987aaa098dd9412c188b1a5f9975f833ba in a local PR worktree.
  • Real browser/Safe setup: Safe.global old UI loaded CoW Swap as a Safe App, using the configured MetaMask profile and Safe App connector. CoW displayed the Safe account 0x7759...3bad.
  • The exact live first step, “place a TWAP order in a multi-sig Safe”, was not completed end-to-end in this VM: the configured Safe is a 1/1 Safe, not a true multi-owner threshold Safe, and it is unfunded (0 USDC / 0 GNO), so the form blocks before a placement/signing modal can complete.
  • Fixture-backed post-placement state: seeded the same Safe account with a TWAP order in WaitSigning; the Orders table stays on Signing (1) and shows the order with “Please sign order”.
  • Hybrid post-sign/indexer state: while still on ?tab=signing&page=1, updated that same in-memory fixture order from WaitSigning to Pending via the app's Jotai store. The route stayed on Signing before/after the mutation, and the Orders table selected Open (1) itself with the order visible.

Evidence

Real Safe App + connected Safe, but live placement blocked before modal:

Real Safe placement blocked

Fixture-backed WaitSigning state showing the order on the Signing tab:

Fixture Signing state

Hybrid fixture-backed post-sign Pending state: route stayed tab=signing, app selected Open (1):

Hybrid auto Open state

Structured capture for that mutation: mode=jotai-store, fallbackUsed=false, beforeUrl=...tab=signing&page=1, afterUrl=...tab=signing&page=1, finalUrl=...tab=signing&page=1.

Video walkthrough for the hybrid state mutation: https://github.com/cowprotocol/cowswap/releases/download/pr-qa-assets/prqa-7730-9e770-hybrid-auto-tab-walkthrough.webm

Not covered

  • Real funded Safe TWAP placement.
  • Real multi-owner Safe threshold signing.
  • Real Safe service / WatchTower / indexer transition from Signing to Open. The Signing → Open reaction above is fixture-backed by mutating local app state, not by a real Safe signature.

AI-assisted QA.

@fairlighteth fairlighteth self-requested a review July 3, 2026 09:53
@elena-zh elena-zh enabled auto-merge (squash) July 7, 2026 09:07
@elena-zh elena-zh merged commit 359591d into cowprotocol:develop Jul 7, 2026
12 of 20 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators Jul 7, 2026
@Danziger

Danziger commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

useValidatePageUrlParams is gone in #7673, and the navigate call change was not what was causing the issue anyway, as you say in the follow-up change in this PR, plus the previous logic will still be needed soon. Anyway, I've left that code in #7673 after resolving the conflicts, with the original one commented out.

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.

TWAP: user is navigated to the Open tab after placing an order

4 participants