Skip to content

fix(account): show correct order amounts in Unfillable edit-approval modal - #7718

Merged
fairlighteth merged 6 commits into
cowprotocol:developfrom
tenderdeve:fix/7686-unfillable-allowance-widget-ui
Jun 26, 2026
Merged

fairlighteth merged 6 commits into
cowprotocol:developfrom
tenderdeve:fix/7686-unfillable-allowance-widget-ui

Conversation

@tenderdeve

@tenderdeve tenderdeve commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #7686.

Two UI bugs on the Account modal's "Unfillable" warning when opening Edit partial approval:

  1. The amount preview at the top of the modal was reading from `useDerivedTradeState()`, which reflects the current trade form — not the pending order being warned about. With another draft (e.g. a limit order) sitting on the form, the preview showed unrelated sell/buy amounts.
  2. The token symbol in the "Please top up X balance" copy could break across two lines.

Fix

  • Thread the order's `outputAmount` from `ActivityDetails` -> `OrderFillabilityWarning` -> `OrderPartialApprove` -> `PartialApproveAmountModal` -> `ChangeApproveAmountModal` / `Pure` down to `SwapAmountPreview`.
  • `SwapAmountPreview` now accepts optional `inputCurrencyAmount` / `outputCurrencyAmount` overrides and only falls back to the derived trade state when none are provided. Existing callers (trade-confirm flow) keep their old behaviour.
  • Wrap the token symbol in the not-enough-balance copy in a `NoWrap` span so it stays on one line.

Testing steps

  1. Pick a permittable token to sell, go to Limit orders and place a limit order with that token.
  2. Switch to Swap and enable the partial approval option.
  3. Place two market swap orders back-to-back with the same approval amount.
  4. After the first one fills, open the Account modal on the second order and expand the Unfillable warning.
  5. The amounts at the top of "Edit partial approval" should match the swap order (not the earlier limit order).
  6. The "Please, top up <symbol> balance" copy keeps the token symbol on a single line.

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced partial approval workflows to display expected output amounts alongside approval amounts.
    • Order fillability warnings now include and display expected output amounts for better visibility.
    • Swap amount preview now supports custom input and output amount display.
  • Bug Fixes

    • Improved text wrapping for currency symbols in order warning messages.

…modal

Two issues on the Account modal's "Unfillable" warning when the user
opened "Edit partial approval":

1. The amount preview at the top of the modal pulled from
   `useDerivedTradeState()`, which reflects the *current* trade form,
   not the pending order being warned about. With another (e.g. limit)
   order draft on the form, the preview showed the wrong sell/buy
   amounts.
2. The token symbol could wrap mid-line in the "Please top up X
   balance" copy.

Thread the order's `outputAmount` from `ActivityDetails` down through
`OrderFillabilityWarning` -> `OrderPartialApprove` ->
`PartialApproveAmountModal` -> `ChangeApproveAmountModal` /
`ChangeApproveAmountModalPure` to `SwapAmountPreview`, which now accepts
explicit `inputCurrencyAmount` / `outputCurrencyAmount` overrides and
only falls back to the derived trade state when none are provided.

Wrap the token symbol in the not-enough-balance copy in a `NoWrap` span
so it stays on a single line.

Closes cowprotocol#7686
@vercel

vercel Bot commented Jun 23, 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 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

An outputAmount field is threaded from ActivityDetails through OrderFillabilityWarning, OrderPartialApprove, PartialApproveAmountModal, ChangeApproveAmountModal, and ChangeApproveAmountModalPure into a refactored SwapAmountPreview that now accepts optional amount overrides instead of always deriving from trade state. A NoWrap styled span and overflow-wrap: anywhere on Subtitle fix currency symbol display.

Changes

Partial Approval Modal Output Amount Fix

Layer / File(s) Summary
SwapAmountPreview props-driven refactor
apps/cowswap-frontend/src/modules/erc20Approve/containers/SwapAmountPreview/SwapAmountPreview.tsx
SwapAmountPreview is changed from a zero-argument component to one accepting optional inputCurrencyAmount and outputCurrencyAmount override props, falling back to useDerivedTradeState() when omitted.
amountToBuy prop threading through approval modal chain
apps/cowswap-frontend/src/modules/erc20Approve/containers/ChangeApproveAmountModal/ChangeApproveAmountModal.tsx, apps/cowswap-frontend/src/modules/erc20Approve/containers/ChangeApproveAmountModal/ChangeApproveAmountModalPure.tsx, apps/cowswap-frontend/src/modules/erc20Approve/containers/PartialApproveAmountModal/PartialApproveAmountModal.tsx, apps/cowswap-frontend/src/modules/account/containers/OrderPartialApprove/OrderPartialApprove.tsx
Each modal in the chain gains an optional amountToBuy prop; each component destructures and forwards the value down to SwapAmountPreview as outputCurrencyAmount.
outputAmount origin, OrderFillabilityWarning wiring, and NoWrap styling
apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx, apps/cowswap-frontend/src/modules/account/pure/OrderFillabilityWarning/index.tsx, apps/cowswap-frontend/src/modules/account/pure/OrderFillabilityWarning/styled.ts
OrderSummaryType gains outputAmount populated from order data; OrderFillabilityWarning receives outputAmount and passes it as amountToBuy to OrderPartialApprove; a new NoWrap styled span and overflow-wrap: anywhere on Subtitle fix the currency symbol line-break bug.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested reviewers

  • Danziger
  • shoom3301
  • elena-zh
  • fairlighteth

Poem

🐰 A bunny once saw token names split in two,
"That symbol needs wrapping!" it knew what to do.
It threaded amountToBuy down every chain,
So swap previews show the right amounts again.
No more wrong limits where market should be—
The modal's as tidy as a rabbit hutch, see! 🐇

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 16.67% 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 clearly summarizes the main change: fixing order amounts display in the unfillable edit-approval modal.
Description check ✅ Passed The description covers the bugs fixed, implementation approach, and testing steps, matching the template's expectations.
Linked Issues check ✅ Passed The PR successfully addresses both issues from #7686: incorrect order amounts display and token symbol wrapping.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the identified UI issues; no out-of-scope modifications 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.

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

Actionable comments posted: 2

🤖 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
`@apps/cowswap-frontend/src/modules/account/containers/OrderPartialApprove/OrderPartialApprove.tsx`:
- Around line 20-25: The OrderPartialApproveProps in the OrderPartialApprove.tsx
file is currently declared as a type alias using export type syntax, but should
be converted to an exported interface instead to follow the coding guidelines.
Replace the type alias declaration with an interface declaration that has the
same name OrderPartialApproveProps and the same properties (amountToApprove,
amountToBuy, isPartialApproveEnabledBySettings, and orderId) with their
respective types, ensuring all properties maintain their optional status where
applicable.

In
`@apps/cowswap-frontend/src/modules/account/pure/OrderFillabilityWarning/index.tsx`:
- Line 12: The styled component NoWrap is currently being imported as a named
import from the styled module, but the codebase follows a namespace import
pattern for styled files. Change the import statement to use namespace style
import (import * as styledEl from the styled file path), then update all
references to NoWrap throughout the file to use the namespace prefix
(styledEl.NoWrap).
🪄 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: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: f4f18dd6-8b69-4831-8004-457860af43b1

📥 Commits

Reviewing files that changed from the base of the PR and between ead6958 and 6d22d89.

📒 Files selected for processing (8)
  • apps/cowswap-frontend/src/modules/account/containers/OrderPartialApprove/OrderPartialApprove.tsx
  • apps/cowswap-frontend/src/modules/account/containers/Transaction/ActivityDetails.tsx
  • apps/cowswap-frontend/src/modules/account/pure/OrderFillabilityWarning/index.tsx
  • apps/cowswap-frontend/src/modules/account/pure/OrderFillabilityWarning/styled.ts
  • apps/cowswap-frontend/src/modules/erc20Approve/containers/ChangeApproveAmountModal/ChangeApproveAmountModal.tsx
  • apps/cowswap-frontend/src/modules/erc20Approve/containers/ChangeApproveAmountModal/ChangeApproveAmountModalPure.tsx
  • apps/cowswap-frontend/src/modules/erc20Approve/containers/PartialApproveAmountModal/PartialApproveAmountModal.tsx
  • apps/cowswap-frontend/src/modules/erc20Approve/containers/SwapAmountPreview/SwapAmountPreview.tsx

Comment on lines 20 to 25
export type OrderPartialApproveProps = {
amountToApprove: CurrencyAmount<Currency>
amountToBuy?: CurrencyAmount<Currency>
isPartialApproveEnabledBySettings?: boolean
orderId?: string
}

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use an exported interface for component props.

Line 20 exports OrderPartialApproveProps as a type alias in a component file. Please switch this to an exported interface.

As per coding guidelines, component files should export only components and their interfaces.

Suggested change
-export type OrderPartialApproveProps = {
+export interface OrderPartialApproveProps {
   amountToApprove: CurrencyAmount<Currency>
   amountToBuy?: CurrencyAmount<Currency>
   isPartialApproveEnabledBySettings?: boolean
   orderId?: string
 }
🤖 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
`@apps/cowswap-frontend/src/modules/account/containers/OrderPartialApprove/OrderPartialApprove.tsx`
around lines 20 - 25, The OrderPartialApproveProps in the
OrderPartialApprove.tsx file is currently declared as a type alias using export
type syntax, but should be converted to an exported interface instead to follow
the coding guidelines. Replace the type alias declaration with an interface
declaration that has the same name OrderPartialApproveProps and the same
properties (amountToApprove, amountToBuy, isPartialApproveEnabledBySettings, and
orderId) with their respective types, ensuring all properties maintain their
optional status where applicable.

Source: Coding guidelines


import {
ApproveWrapper,
NoWrap,

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use namespace style imports for styled modules.

Line 12 extends a named import from the style file; this should use a namespace style import pattern.

As per coding guidelines, import styles as import * as styledEl from './X.styled'.

🤖 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
`@apps/cowswap-frontend/src/modules/account/pure/OrderFillabilityWarning/index.tsx`
at line 12, The styled component NoWrap is currently being imported as a named
import from the styled module, but the codebase follows a namespace import
pattern for styled files. Change the import statement to use namespace style
import (import * as styledEl from the styled file path), then update all
references to NoWrap throughout the file to use the namespace prefix
(styledEl.NoWrap).

Source: Coding guidelines

@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 23, 2026
@github-actions

github-actions Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Cloudflare Pages preview mirror

Preview branch URL: https://github.com/cowprotocol/cowswap/tree/cf-preview/pr-7718
Mirror PR: #7722
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/7686-unfillable-allowance-widget-ui
Approval target SHA: 1dcf662f3ef7
Last mirrored SHA: bc520d2d15c3
Last comment update: @fairlighteth at 2026-06-26T16:33:41.602Z

  • 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 23, 2026
@vercel
vercel Bot temporarily deployed to Preview – storybook June 23, 2026 14:58 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 23, 2026 14:59 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 23, 2026 15:00 Inactive
@vercel
vercel Bot temporarily deployed to Preview – storybook June 23, 2026 15:48 Inactive
@vercel
vercel Bot temporarily deployed to Preview – widget-configurator June 23, 2026 15:49 Inactive
@vercel
vercel Bot temporarily deployed to Preview – cowfi June 23, 2026 15:50 Inactive

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

Works as expected, thank you

@elena-zh
elena-zh requested review from a team, kernelwhisperer and limitofzero and removed request for a team June 23, 2026 15:59

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

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

Related context checked:

  • ActivityDetails now passes the order outputAmount through the unfillable-warning approval path, and SwapAmountPreview uses the passed order amounts for the Account modal edit-approval preview.
  • The existing trade-flow partial approval caller still keeps the previous derived trade-state behavior for the buy-side preview.
  • Existing open comments already cover the style issues around OrderPartialApproveProps and styled-module imports.
  • Existing human review says the repro scenario works as expected.

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

@fairlighteth

fairlighteth commented Jun 26, 2026 •

Copy link
Copy Markdown
Contributor
🧪 Scoped automated browser QA passed: mocked unfillable allowance modal states

Outcome

  • Primary evidence: the structured browser assertion result shows the modal rendered the order amounts 1.2345 DAI / 6.789 USDC while the separately seeded active trade draft amounts 987 WETH / 654 GNO were absent.
  • Supporting visual evidence: the embedded browser screenshot shows the final mocked UI state with the edit-approval modal open on the order amounts.
  • The balance-warning copy with long token symbol QA-LONG-SYMBOL-7718 stayed readable and nowrap in the mocked state.

Run details

  • Source under test: PR head 33707aa0a6b0ce88fe318d381f081e4ce9ca92b3 via local checkout.
  • Runtime: deterministic React Cosmos fixture around OrderFillabilityWarning, seeded with mocked order, fillability, active trade draft, and approval-modal state.
  • Browser: Chromium 140.0.7339.16, driven by Playwright 1.51.0 on macOS.
  • Wallet mode: mocked account/order state only; no signing-capable wallet was exercised.
  • AI usage: Codex orchestrated the Playwright browser run, collected artifacts, and drafted this summary from the observed results.

Artifacts

Primary assertion result JSON: https://github.com/cowprotocol/cowswap/releases/download/pr-qa-assets/prqa-7718-chromium-mocked-approval-modal-33707aa-result.json

Full MP4 recording: https://github.com/cowprotocol/cowswap/releases/download/pr-qa-assets/prqa-7718-chromium-mocked-approval-modal-33707aa.mp4

Inline evidence image, combining the browser screenshot with the mocked inputs and pass assertions:
PR 7718 Chromium QA evidence showing mocked order amounts, unrelated active draft amounts, pass assertions, and edit approval modal screenshot

How to retest

  • Check out PR head 33707aa0a6b0ce88fe318d381f081e4ce9ca92b3.
  • Seed an unfillable allowance order where the order amounts differ from the active trade draft, open Edit partial approval, and confirm the approval modal uses the order amounts.
  • Seed a balance warning with a long token symbol and confirm the warning copy remains readable/no-wrap.

Not checked / follow-up

  • Real wallet signing, approval transaction submission, or order placement.
  • Live orderbook/Safe-specific state, live allowance/balance reads, or chain RPC behavior.
  • The exact original live repro order state; this pass verifies the runtime UI logic with deterministic inputs.

Generated with the pr-qa workflow: Playwright browser execution and artifact collection were AI-orchestrated; results were verified against the captured browser state.

@fairlighteth
fairlighteth self-requested a review June 26, 2026 09:57
@fairlighteth

Copy link
Copy Markdown
Contributor
✅ Security Review (Codex GPT-5): no new PR-introduced finding; DeepSec surfaced pre-existing approval-state risk

Review completed on PR head 9fa16cc632d572523cf667b429dcc9c4568a5efd.

No new PR-introduced security finding worth blocking this change on. DeepSec did surface two reports in the touched approval path, but after code inspection they collapse to one pre-existing root cause already present on develop: the pending-order partial approval modal state is module-level, so isModalOpen / amountSetByUser are not scoped by orderId or token identity.

DeepSec triage

  • Source: DeepSec PR-mode output, verified against current code
  • DeepSec reports: other-unintended-token-approval and other-approval-state-confusion
  • Classification for this PR: pre-existing issue in touched code path, not introduced by the new amountToBuy / outputCurrencyAmount display threading
  • Evidence: develop already had OrderPartialApprove reading amountSetByUser from the shared pending approval atom and using it for finalAmountToApprove; this PR mainly adds display-only buy-amount threading into SwapAmountPreview
  • Security impact if addressed separately: stale pending approval state could make the account-modal approval path consume a previous order’s CurrencyAmount unless the state is scoped/reset by order/token

Suggested follow-up

Track or patch separately by scoping pending-order approval modal state to orderId and token identity, or by resetting/ignoring amountSetByUser when orderId, chain, token address, or required amount changes. Also consider making isModalOpen identify the selected order so only that row renders/consumes the modal state.

Review scope and related context
  • Checked: account unfillable warning approval path, OrderPartialApprove, PartialApproveAmountModal, ChangeApproveAmountModal, SwapAmountPreview, pending approval modal state, and approval callback path.
  • Existing PR QA: deterministic browser QA covered the display regression only; it did not exercise real signing or approval submission.
  • Confidence limits: no real wallet approval transaction was submitted in this pass.

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

@fairlighteth
fairlighteth enabled auto-merge (squash) June 26, 2026 16:33
@fairlighteth
fairlighteth merged commit fbad99b 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.

Unfillable market order: insufficient allowance widget UI issues

4 participants