Skip to content

Conversation

@fairlighteth
Copy link
Contributor

@fairlighteth fairlighteth commented Nov 11, 2025

Summary

Fixes #6508

  • Keep progress-bar state for any order still shown in the Surplus or confirmation modal by extending OrderProgressStateUpdater’s tracked IDs.
  • Expose useSurplusQueueOrderIds so other modules can reference the queued modal orders.
  • Strengthen unit tests to cover pruning interactions with pending orders, surplus queue, and confirmation modal to prevent future regressions.

To Test

  1. Place two market orders back-to-back in the Trade widget.

    • When the first order fills, its Surplus modal shows solver rankings without blinking/disappearing.
    • The second order continues solving in the background without affecting the first modal.
  2. Queue an order in the Surplus modal (e.g., via a fulfilled limit order) while leaving another order pending.

    • Solver info remains visible in the Surplus modal until it is dismissed, even though other orders are still pending.

Background

OrderProgressStateUpdater pruned solver data as soon as an order left the pending list, which happens before the Surplus modal finishes rendering. The new tracked-ID union ensures state lives until all relevant UIs release it.

Summary by CodeRabbit

  • New Features

    • Progress UI now preserves orders from the surplus queue, the confirmation modal, and cancellation-tracked orders so they remain visible during processing.
  • Bug Fixes

    • Favicon completion animations deduplicated and properly queued when orders cycle or others are in progress.
    • More robust handling when an order identifier is missing to prevent spurious state updates.
  • Tests

    • Added tests for animation queuing and progress-state retention across sources.

@vercel
Copy link

vercel bot commented Nov 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Updated (UTC)
cowfi Ready Ready Preview Nov 12, 2025 3:27pm
explorer-dev Ready Ready Preview Nov 12, 2025 3:27pm
swap-dev Ready Ready Preview Nov 12, 2025 3:27pm
widget-configurator Ready Ready Preview Nov 12, 2025 3:27pm
2 Skipped Deployments
Project Deployment Preview Updated (UTC)
cosmos Ignored Ignored Nov 12, 2025 3:27pm
sdk-tools Ignored Ignored Preview Nov 12, 2025 3:27pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 11, 2025

Walkthrough

Adds a derived atom and public hook to expose surplus-modal order IDs, refactors the favicon animation controller to track completed/in-progress orders and queue completion animations safely, makes orderId optional across several order-progress hooks and updaters, and updates order-progress pruning to preserve orders from surplus queue, trade confirmation, and cancellation tracking with tests.

Changes

Cohort / File(s) Summary
Surplus Modal Hook
apps/cowswap-frontend/src/entities/surplusModal/index.ts
Adds derived atom surplusModalOrderIdsAtom and exported hook useSurplusQueueOrderIds() returning surplus-queued order IDs.
Favicon Animation
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.ts
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts
Refactors FaviconAnimationController: adds private fields completedOrders and hasInProgress, introduces helpers updateCompletionCache, tryQueueCompletion, and cleanupCompletedOrders; updates update() to use them. Adds tests validating completion-queueing, idempotency, cycling behavior, and suppression while others are in progress.
Order Progress — State & Atoms
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.test.ts
Simplifies prune early-exit condition; adds and exports cancellationTrackedOrderIdsAtom which derives IDs with cancellationTriggered. Tests added/updated to validate the atom.
Order Progress — Updaters & Hooks
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
apps/cowswap-frontend/src/modules/orderProgressBar/hooks/useOrderProgressBarProps.ts
Makes orderId optional across several hooks and updaters, updates imports to include useSurplusQueueOrderIds, useTradeConfirmState, and cancellationTrackedOrderIdsAtom; builds a combined tracked-ID Set (market ∪ surplus ∪ trade ∪ cancellations) for pruning; adds tests ensuring preservation and deduplication of tracked orders and cancellation handling.

Sequence Diagram(s)

sequenceDiagram
    participant Updater as OrderProgressStateUpdater
    participant Surplus as useSurplusQueueOrderIds()
    participant Trade as useTradeConfirmState()
    participant Cancellations as cancellationTrackedOrderIdsAtom
    participant Pruner as pruneOrdersProgressBarState

    Updater->>Surplus: read surplus queue IDs
    Updater->>Trade: read active transaction hash
    Updater->>Cancellations: read cancellation-tracked IDs
    Updater->>Updater: combine tracked IDs (market ∪ surplus ∪ trade ∪ cancellations)
    Updater->>Pruner: pass combined IDs to prune/preserve state
    Note over Pruner,Updater: deduplicate and preserve tracked orders
Loading
sequenceDiagram
    participant State as OrderProgressBarState
    participant Controller as FaviconAnimationController
    participant Animator as FaviconAnimator

    State->>Controller: update(state)
    Controller->>Controller: compute hasInProgress, seenOrderIds
    Controller->>Controller: updateCompletionCache(orderId, step)
    alt success and conditions met (no in-progress, not completed, recent change)
        Controller->>Animator: enqueue completion animation (tryQueueCompletion)
        Controller->>Controller: mark order completed
    else suppress or ignore enqueue
    end
    Controller->>Controller: cleanupCompletedOrders(seenOrderIds)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Inspect favicon controller: correctness of completion queuing conditions, recent-change threshold, lifecycle of completedOrders, and hasInProgress updates.
  • Verify OrderProgressStateUpdater merges sources correctly, effect dependency list, and prune invocation.
  • Review tests for deterministic timing, Date.now manipulation, and mock resets.

Possibly related PRs

Suggested reviewers

  • elena-zh
  • shoom3301
  • alfetopito

Poem

🐰 I hopped through atoms, queues, and tiny signs,

Surplus IDs found their rightful lines.
Favicons blink when orders land,
No doubles kept, neat and planned.
A rabbit cheers the working minds.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main objective: keeping displayed orders in progress state and deduping favicon completions.
Description check ✅ Passed The description follows the template with Summary (including issue reference), To Test (with numbered steps and checkboxes), and Background sections provided.
Linked Issues check ✅ Passed The PR fully addresses issue #6508 by extending OrderProgressStateUpdater to track surplus and confirmation modal orders, exposing useSurplusQueueOrderIds, and strengthening tests to prevent regressions.
Out of Scope Changes check ✅ Passed All changes are in-scope: core changes to OrderProgressStateUpdater, FaviconAnimationController for favicon deduplication, atoms for tracking cancelled orders, and comprehensive test coverage for the linked issue requirements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/progress-solvers

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 and usage tips.

@elena-zh
Copy link
Contributor

Hey @fairlighteth , thank you! It works good in terms of solvers, but is not good in terms of favicon: it keeps shimmering with green when an order is filled (3-4 times instead of 1 time).
image

Could you please take a look at it?

@fairlighteth
Copy link
Contributor Author

Pushed a fix. Previously, every finished order sat in the queue, so you’d get multiple green flashes once the backlog cleared. Now, if order 1 finishes while order 2 is still solving, the favicon stays in the “progress” state for order 2, and when order 2 completes you get a single green flash for that order only. In other words, completion animations are skipped for any order that finishes while another is still in progress.

@fairlighteth fairlighteth requested a review from a team November 11, 2025 17:14
@fairlighteth fairlighteth self-assigned this Nov 11, 2025
@fairlighteth fairlighteth changed the title fix: add atom for surplus order IDs and integrate into OrderProgressS… fix: keep displayed orders in progress state and dedupe favicon completions Nov 11, 2025
@elena-zh elena-zh marked this pull request as ready for review November 12, 2025 09:17
@elena-zh elena-zh requested a review from a team November 12, 2025 09:17
Copy link
Contributor

@elena-zh elena-zh left a comment

Choose a reason for hiding this comment

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

Thank you, LGTM now!

Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.ts (1)

17-18: Consider documenting the completion deduplication behavior.

The new completedOrders Set and hasInProgress flag implement sophisticated logic to prevent duplicate favicon animations, as described in the PR comments. This addresses the issue where multiple green flashes occurred when clearing a backlog of finished orders.

Consider adding JSDoc comments explaining:

  • completedOrders: tracks which orders have shown a completion animation in their current success state
  • hasInProgress: suppresses completion animations while any order is still solving
+  /**
+   * Tracks orders that have already shown a completion animation in their current success state.
+   * Cleared when an order transitions out of success state, allowing re-animation if it succeeds again.
+   */
   private completedOrders = new Set<string>()
+  /**
+   * True if any order is currently in a solving/in-progress state.
+   * Suppresses completion animations until all orders finish to avoid multiple green flashes.
+   */
   private hasInProgress = false

Also applies to: 29-29

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 919043f and 6299cc0.

📒 Files selected for processing (5)
  • apps/cowswap-frontend/src/entities/surplusModal/index.ts (2 hunks)
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts (1 hunks)
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.ts (3 hunks)
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx (5 hunks)
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (5)
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
  • apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.ts
📚 Learning: 2025-08-05T14:27:05.023Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 5992
File: libs/wallet/src/web3-react/utils/switchChain.ts:36-38
Timestamp: 2025-08-05T14:27:05.023Z
Learning: In libs/wallet/src/web3-react/utils/switchChain.ts, the team prefers using Record<SupportedChainId, string | null> over Partial<Record<SupportedChainId, string>> for WALLET_RPC_SUGGESTION to enforce that all supported chain IDs have explicit values set, even if some might be null. This ensures compile-time completeness checking.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
📚 Learning: 2025-06-23T07:03:50.760Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5859
File: apps/cowswap-frontend/src/modules/tradeQuote/hooks/useTradeQuotePolling.ts:76-82
Timestamp: 2025-06-23T07:03:50.760Z
Learning: In the useTradeQuotePolling hook, there are two useLayoutEffect hooks that work together: one resets the counter to 0 when the confirmation modal closes, and another automatically triggers pollQuote(false, true) whenever the counter reaches 0. This creates an intentional chain reaction for immediate quote updates.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
📚 Learning: 2025-09-25T08:49:32.256Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
📚 Learning: 2025-09-25T08:48:53.495Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:58-60
Timestamp: 2025-09-25T08:48:53.495Z
Learning: In the cowswap-frontend codebase, when writing SWR tests, the team prefers maximum test isolation by using `provider: () => new Map()` in SWRConfig wrappers, even if it recreates cache on every render, to ensure tests don't share any state.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
🧬 Code graph analysis (4)
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts (2)
apps/cowswap-frontend/src/modules/orderProgressBar/types.ts (2)
  • OrderProgressBarState (15-24)
  • OrderProgressBarStepName (13-13)
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.ts (1)
  • FaviconAnimationController (9-218)
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (2)
apps/cowswap-frontend/src/modules/trade/hooks/useTradeConfirmState.ts (1)
  • useTradeConfirmState (7-9)
apps/cowswap-frontend/src/entities/surplusModal/index.ts (1)
  • useSurplusQueueOrderIds (58-60)
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx (3)
apps/cowswap-frontend/src/entities/surplusModal/index.ts (1)
  • useSurplusQueueOrderIds (58-60)
apps/cowswap-frontend/src/modules/trade/hooks/useTradeConfirmState.ts (1)
  • useTradeConfirmState (7-9)
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (1)
  • OrderProgressStateUpdater (22-61)
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.ts (2)
apps/cowswap-frontend/src/modules/orderProgressBar/types.ts (2)
  • OrderProgressBarStepName (13-13)
  • OrderProgressBarState (15-24)
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/logic.ts (2)
  • isSuccess (50-52)
  • isRecentStateChange (40-48)
🪛 GitHub Actions: CI
apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts

[error] 92-92: Test failure: FaviconAnimationController queues another completion when an order returns to solving and finishes again - Expected: 2, Received: 1.

🔇 Additional comments (5)
apps/cowswap-frontend/src/entities/surplusModal/index.ts (1)

14-15: LGTM! Clean Jotai pattern for derived state.

The derived atom and hook follow standard Jotai patterns, providing a clean public API for accessing surplus queue order IDs. This enables other modules to reactively track which orders are queued for the surplus modal.

Also applies to: 58-60

apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (1)

34-48: LGTM! Effective deduplication using Set.

The refactored effect correctly merges order IDs from three sources (pending market orders, surplus queue, and trade confirmation modal) using a Set for automatic deduplication. The logic properly handles the conditional inclusion of marketOrders (only when account/chainId present) while always including surplus queue IDs and transactionHash when available. The dependency array is complete and accurate.

apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx (1)

115-156: LGTM! Comprehensive test coverage for new tracking sources.

The three new test cases effectively validate the integration of surplus queue IDs and trade confirmation state:

  1. Orders queued for surplus modal are tracked even without wallet info
  2. The currently displayed order in the confirmation modal is tracked
  3. All three sources (pending, queued, displayed) are merged and deduplicated correctly

The test setup properly initializes mocks in beforeEach, following the team's preference for test isolation.

apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.test.ts (1)

85-93: Test setup issue: Mock animator callbacks never fire, preventing mode transitions.

The completion cache logic itself is correct. However, the test fails because the mockPlay mock never invokes the onComplete callback. This leaves the controller stuck in 'completing' mode after the first animation, causing processAnimationMode() to return early (line 36) for subsequent updates. This blocks both the queue processing and prevents the second completion from being queued or played.

The test needs to mock the animator such that onComplete callbacks execute synchronously, or use jest timers to simulate the animation sequence. The review comment's analysis of the cache logic is incorrect—the real issue is test infrastructure, not the controller's state management.

Likely an incorrect or invalid review comment.

apps/cowswap-frontend/src/modules/application/utils/faviconAnimation/controller.ts (1)

101-126: Fix suppressQueue logic to not suppress success-state completions on first update.

The root cause is different from what the review comment hypothesizes. The issue is that suppressQueue=true on the first update() call (when !isInitialized) prevents the initial FINISHED state from being queued in Update 1, not any blocking guard in Update 3.

Trace:

  • Update 1 (FINISHED, suppressQueue=true): Line 114 guard triggers, returns early → no queue
  • Update 2 (SOLVING): Deletes from completedOrders → no queue
  • Update 3 (FINISHED, suppressQueue=false): All guards pass → queues successfully

Result: 1 completion play (only Update 3), but test expects 2.

The suppressQueue logic suppresses ALL completions on app initialization to avoid spurious animations during state hydration. However, this also suppresses legitimate success-state completions. Either the test expectations are incorrect (should expect 1), or the suppressQueue logic should exclude success states that represent actual state transitions (not just initial load artifact).

#6511)

* refactor: streamline order progress state management and enhance tests

* feat: add cancellation tracking for order progress and improve related hooks and tests

* fix: update order ID handling to allow optional values in progress bar hooks

* fix: ensure consistent order ID usage in progress bar step name updates
Copy link
Contributor

@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: 0

🧹 Nitpick comments (1)
apps/cowswap-frontend/src/modules/orderProgressBar/hooks/useOrderProgressBarProps.ts (1)

363-371: Consider simplifying the orderId capture pattern.

After the early return on lines 363-365, TypeScript already knows that orderId is defined (not undefined). The ensuredOrderId variable on line 367 doesn't provide additional type safety—it's just a copy. Consider using orderId directly in the updateStepName function to reduce indirection.

Apply this diff if you prefer a more direct approach:

   useEffect(() => {
     if (!orderId) {
       return
     }

-    const ensuredOrderId = orderId
-
     function updateStepName(name: OrderProgressBarStepName): void {
-      setProgressBarStepName(ensuredOrderId, name || DEFAULT_STEP_NAME)
+      setProgressBarStepName(orderId, name || DEFAULT_STEP_NAME)
     }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b5b8e4f and f1c5b22.

📒 Files selected for processing (5)
  • apps/cowswap-frontend/src/modules/orderProgressBar/hooks/useOrderProgressBarProps.ts (7 hunks)
  • apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.test.ts (3 hunks)
  • apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts (2 hunks)
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx (5 hunks)
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (3 hunks)
🧰 Additional context used
🧠 Learnings (8)
📚 Learning: 2025-10-10T20:28:16.565Z
Learnt from: fairlighteth
Repo: cowprotocol/cowswap PR: 6347
File: apps/cowswap-frontend/src/modules/trade/pure/TradeConfirmation/index.tsx:49-49
Timestamp: 2025-10-10T20:28:16.565Z
Learning: In apps/cowswap-frontend/src/modules/trade, TradeConfirmation follows a two-layer architecture: TradeConfirmationView (pure/stateless) in pure/TradeConfirmation/index.tsx renders the UI, while TradeConfirmation (container) in containers/TradeConfirmation/index.tsx wraps it to freeze props during pending trades (via useStableTradeConfirmationProps), wire in signing state (useSigningStep), and inject trade confirmation state (useTradeConfirmState). Consuming modules should import the container TradeConfirmation from 'modules/trade' to preserve this stateful behavior.
<!-- [add_learning]
When reviewing component refactoring in apps/cowswap-frontend/src/modules/trade, recognize the pattern where a pure view component (e.g., TradeConfirmationView) is separated from a stateful container (e.g., TradeConfirmation) that wraps it. The container adds runtime state management (prop stabilization, signing state, etc.) while the view remains testable and composable. Do not flag usages that import th...

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.test.ts
  • apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
📚 Learning: 2025-08-08T13:56:18.009Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6125
File: libs/tokens/src/updaters/TokensListsUpdater/index.tsx:29-31
Timestamp: 2025-08-08T13:56:18.009Z
Learning: In libs/tokens/src/updaters/TokensListsUpdater/index.tsx, the project’s current Jotai version requires using `unstable_getOnInit` (not `getOnInit`) in atomWithStorage options; keep `{ unstable_getOnInit: true }` until Jotai is upgraded.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.test.ts
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
📚 Learning: 2025-06-23T07:03:50.760Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 5859
File: apps/cowswap-frontend/src/modules/tradeQuote/hooks/useTradeQuotePolling.ts:76-82
Timestamp: 2025-06-23T07:03:50.760Z
Learning: In the useTradeQuotePolling hook, there are two useLayoutEffect hooks that work together: one resets the counter to 0 when the confirmation modal closes, and another automatically triggers pollQuote(false, true) whenever the counter reaches 0. This creates an intentional chain reaction for immediate quote updates.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
📚 Learning: 2025-09-25T08:48:53.495Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:58-60
Timestamp: 2025-09-25T08:48:53.495Z
Learning: In the cowswap-frontend codebase, when writing SWR tests, the team prefers maximum test isolation by using `provider: () => new Map()` in SWRConfig wrappers, even if it recreates cache on every render, to ensure tests don't share any state.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
📚 Learning: 2025-09-25T08:49:32.256Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6299
File: apps/cowswap-frontend/src/entities/bridgeProvider/useBridgeSupportedNetworks.test.tsx:62-67
Timestamp: 2025-09-25T08:49:32.256Z
Learning: In the cowswap-frontend codebase, when testing hooks that use multiple bridge providers, both providers are always properly mocked as complete jest.Mocked<BridgeProvider<BridgeQuoteResult>> objects with all required methods stubbed, ensuring no undefined returns that could break the hook logic.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx
📚 Learning: 2025-08-08T13:55:17.528Z
Learnt from: shoom3301
Repo: cowprotocol/cowswap PR: 6125
File: libs/tokens/src/state/tokens/allTokensAtom.ts:78-78
Timestamp: 2025-08-08T13:55:17.528Z
Learning: In libs/tokens/src/state/tokens/allTokensAtom.ts (TypeScript/Jotai), the team prefers to wait for token lists to initialize (listsStatesListAtom non-empty) before returning tokens. No fallback to favorites/user-added/native tokens should be used when listsStatesList is empty.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
📚 Learning: 2025-08-05T14:27:05.023Z
Learnt from: alfetopito
Repo: cowprotocol/cowswap PR: 5992
File: libs/wallet/src/web3-react/utils/switchChain.ts:36-38
Timestamp: 2025-08-05T14:27:05.023Z
Learning: In libs/wallet/src/web3-react/utils/switchChain.ts, the team prefers using Record<SupportedChainId, string | null> over Partial<Record<SupportedChainId, string>> for WALLET_RPC_SUGGESTION to enforce that all supported chain IDs have explicit values set, even if some might be null. This ensures compile-time completeness checking.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx
📚 Learning: 2025-10-13T19:41:31.440Z
Learnt from: limitofzero
Repo: cowprotocol/cowswap PR: 6351
File: apps/cowswap-frontend/src/modules/erc20Approve/containers/TradeApproveModal/useTradeApproveCallback.ts:87-121
Timestamp: 2025-10-13T19:41:31.440Z
Learning: In apps/cowswap-frontend/src/modules/erc20Approve, useApproveCallback returns Promise<TransactionResponse | undefined> and is distinct from useApproveCurrency, which can return Promise<TransactionReceipt | SafeMultisigTransactionResponse>. When reviewing approval flows, verify which hook is actually being used before flagging Safe wallet concerns.

Applied to files:

  • apps/cowswap-frontend/src/modules/orderProgressBar/hooks/useOrderProgressBarProps.ts
🧬 Code graph analysis (4)
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.test.ts (1)
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts (2)
  • ordersProgressBarStateAtom (15-15)
  • cancellationTrackedOrderIdsAtom (217-223)
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx (6)
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts (1)
  • cancellationTrackedOrderIdsAtom (217-223)
libs/wallet/src/api/hooks.ts (1)
  • useWalletInfo (24-26)
apps/cowswap-frontend/src/legacy/state/orders/hooks.ts (1)
  • useOnlyPendingOrders (262-278)
apps/cowswap-frontend/src/entities/surplusModal/index.ts (1)
  • useSurplusQueueOrderIds (58-60)
apps/cowswap-frontend/src/modules/trade/hooks/useTradeConfirmState.ts (1)
  • useTradeConfirmState (7-9)
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (1)
  • OrderProgressStateUpdater (22-74)
apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (3)
apps/cowswap-frontend/src/modules/trade/hooks/useTradeConfirmState.ts (1)
  • useTradeConfirmState (7-9)
apps/cowswap-frontend/src/entities/surplusModal/index.ts (1)
  • useSurplusQueueOrderIds (58-60)
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts (1)
  • cancellationTrackedOrderIdsAtom (217-223)
apps/cowswap-frontend/src/modules/orderProgressBar/hooks/useOrderProgressBarProps.ts (3)
apps/cowswap-frontend/src/modules/orderProgressBar/types.ts (2)
  • OrderProgressBarState (15-24)
  • OrderProgressBarStepName (13-13)
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts (2)
  • ordersProgressBarStateAtom (15-15)
  • setOrderProgressBarCancellationTriggered (202-215)
apps/cowswap-frontend/src/modules/orderProgressBar/constants.ts (1)
  • DEFAULT_STEP_NAME (35-35)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Cypress
  • GitHub Check: Setup
🔇 Additional comments (12)
apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.test.ts (1)

130-141: LGTM! Comprehensive test coverage for cancellation tracking.

The test correctly validates that cancellationTrackedOrderIdsAtom filters orders with the cancellationTriggered flag set and returns their IDs.

apps/cowswap-frontend/src/modules/orderProgressBar/state/atoms.ts (2)

35-37: LGTM! Simplified pruning logic.

The refactored early-return condition correctly skips the state update only when no changes were made, removing the unnecessary check for tracked IDs existence.


217-223: LGTM! Clean derived atom for cancellation tracking.

The atom correctly derives the list of order IDs with cancellationTriggered set, enabling other components to reference cancellation-tracked orders for state retention.

apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.test.tsx (1)

126-180: LGTM! Excellent test coverage for multi-source tracking.

The four new test cases comprehensively validate:

  1. Surplus queue IDs are retained even without wallet context
  2. Transaction hash from confirmation modal is tracked
  3. Deduplication works correctly across pending, queued, and displayed orders
  4. Cancellation-triggered orders persist even after leaving pending state

This test coverage should prevent regressions and aligns perfectly with the PR objectives.

apps/cowswap-frontend/src/modules/orderProgressBar/updaters/OrderProgressStateUpdater.tsx (2)

36-52: LGTM! Clean Set-based deduplication of tracked IDs.

The refactored logic elegantly builds a union of order IDs from four sources (pending market orders, surplus queue, confirmation modal transaction hash, and cancellation-tracked orders) using a Set for automatic deduplication. The comment on lines 38-39 helpfully explains why pruning continues even without wallet context, directly addressing the previous review question.


53-61: LGTM! Comprehensive dependency array.

All tracked state sources are correctly included in the effect dependencies, ensuring pruning runs whenever any source changes.

apps/cowswap-frontend/src/modules/orderProgressBar/hooks/useOrderProgressBarProps.ts (6)

136-136: LGTM! Safe optional chaining for orderId.

The change to order?.id correctly handles cases where order may be undefined, aligning with the broader refactoring to support optional orderIds throughout the progress bar subsystem.


257-261: LGTM! Safe optional orderId handling.

The function correctly handles undefined orderId by conditionally accessing state and returning a default empty state.


284-313: LGTM! Proper guard for countdown updates.

The early return on line 292-294 correctly prevents countdown updates when orderId is undefined, ensuring safe access to the state atom.


315-325: LGTM! Clean cancellation guard.

The combined guard for both orderId and isCancelling correctly prevents unnecessary atom updates.


504-538: LGTM! Safe backend status updates with optional orderId.

The function correctly handles optional orderId by checking its presence before calling the atom setter on line 529.


544-554: LGTM! Proper conditional SWR key for optional orderId.

The SWR hook correctly returns null as the key when orderId is undefined or doNotQuery is true, preventing unnecessary API calls.

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.

Progress bar: Solvers info may become missing

4 participants