Skip to content

feat: improve maker UX when order is taken by counterpart#251

Merged
Catrya merged 1 commit into
mainfrom
orderTakenWaitingCounterpart
Aug 4, 2025
Merged

feat: improve maker UX when order is taken by counterpart#251
Catrya merged 1 commit into
mainfrom
orderTakenWaitingCounterpart

Conversation

@Catrya

@Catrya Catrya commented Aug 1, 2025

Copy link
Copy Markdown
Member
  • Prevent auto-navigation and show waiting message for makers when their orders are taken, while preserving original behavior for takers.
  • Add personalized message for makers waiting for counterpart response

Summary by CodeRabbit

  • New Features

    • Displayed customized messages based on whether the user is the order creator or taker during specific order states.
    • Improved navigation behavior to only redirect users to trade details when relevant to their role and order type.
  • Localization

    • Added new localized messages for English, Spanish, and Italian to inform users when their order is taken and awaiting a counterpart’s action.

Prevent auto-navigation and show waiting message for makers when their orders are taken, while preserving original behavior for takers.
@coderabbitai

coderabbitai Bot commented Aug 1, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

This update introduces user role-aware logic for both navigation and displayed messages in order-related flows. Conditional checks now determine navigation and message content based on whether the user is the creator (maker) or taker of an order, with corresponding updates to localization files to support new user-facing messages in English, Spanish, and Italian.

Changes

Cohort / File(s) Change Summary
Order Notifier Logic Update
lib/features/order/notfiers/abstract_mostro_notifier.dart
Added conditional navigation in handleEvent for certain actions, using a new private _isUserCreator() method to determine if the current user is the maker of the order and adjusting navigation accordingly.
Role-based Message Display
lib/features/trades/widgets/mostro_message_detail_widget.dart
Introduced logic to display different messages based on whether the user is the order creator or taker, with a new _isUserCreator helper method.
Localization: English
lib/l10n/intl_en.arb
Added a new key and message for "orderTakenWaitingCounterpart" with placeholder for expiration time, including metadata.
Localization: Spanish
lib/l10n/intl_es.arb
Added Spanish translation for "orderTakenWaitingCounterpart" with placeholder and metadata.
Localization: Italian
lib/l10n/intl_it.arb
Added Italian translation for "orderTakenWaitingCounterpart" with placeholder and metadata.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant UI
    participant Notifier
    participant Session

    User->>UI: Triggers order-related action
    UI->>Notifier: handleEvent(action, order)
    Notifier->>Session: Get user session and role
    Notifier->>Notifier: _isUserCreator(session, order)
    alt User is creator and action matches
        Notifier-->>UI: Skip navigation
    else User is not creator or action does not match
        Notifier-->>UI: Navigate to trade detail
    end
Loading
sequenceDiagram
    participant User
    participant UI
    participant MessageWidget
    participant Session

    User->>UI: Views order message
    UI->>MessageWidget: buildMessage(tradeState)
    MessageWidget->>Session: Get user session and role
    MessageWidget->>MessageWidget: _isUserCreator(session, tradeState)
    alt User is creator and action matches
        MessageWidget-->>UI: Show "orderTakenWaitingCounterpart" message
    else
        MessageWidget-->>UI: Show default waiting message
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • chebizarro
  • grunch

Poem

In the warren of code, a bunny did find
Roles and messages, carefully aligned.
Makers and takers, now see what’s true—
The screen shows a message just for you!
With hops and with checks, translations anew,
This rabbit says: “Great job, team—thank you!” 🐇✨

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch orderTakenWaitingCounterpart

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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

🧹 Nitpick comments (1)
lib/l10n/intl_en.arb (1)

78-86: Keep locale files in sync and fix seconds/minutes wording

Good addition, but please:

  1. Confirm orderTakenWaitingCounterpart is also present in intl_it.arb.
  2. Decide whether expiration_seconds should be expressed in seconds or minutes to avoid user-visible confusion.
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c6b682e and 3b26939.

📒 Files selected for processing (5)
  • lib/features/order/notfiers/abstract_mostro_notifier.dart (3 hunks)
  • lib/features/trades/widgets/mostro_message_detail_widget.dart (3 hunks)
  • lib/l10n/intl_en.arb (1 hunks)
  • lib/l10n/intl_es.arb (1 hunks)
  • lib/l10n/intl_it.arb (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
lib/**/*.dart

📄 CodeRabbit Inference Engine (CLAUDE.md)

lib/**/*.dart: Use S.of(context).yourKey for all user-facing strings
Always use localized strings instead of hardcoded text
Pass BuildContext to methods that need localization
Always use latest APIs (e.g., withValues() instead of withOpacity())
Always check mounted before using context after async operations

Files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/features/trades/widgets/mostro_message_detail_widget.dart
**/*.dart

📄 CodeRabbit Inference Engine (CLAUDE.md)

**/*.dart: Remove unused imports and dependencies
Use const constructors where possible

Files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/features/trades/widgets/mostro_message_detail_widget.dart
lib/l10n/*.arb

📄 CodeRabbit Inference Engine (CLAUDE.md)

lib/l10n/*.arb: Internationalization must use flutter_intl with ARB files in lib/l10n/
Use proper ARB metadata for parameterized strings

Files:

  • lib/l10n/intl_it.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_en.arb
lib/l10n/intl_{en,es,it}.arb

📄 CodeRabbit Inference Engine (CLAUDE.md)

Add new localization keys to all three ARB files (en, es, it)

Files:

  • lib/l10n/intl_it.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_en.arb
lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart

📄 CodeRabbit Inference Engine (CLAUDE.md)

Feature-based organization: features/{feature}/{screens|providers|notifiers|widgets}/

Files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
🧠 Learnings (17)
📚 Learning: in abstractmostronotifier, state updates occur for all messages regardless of timestamp to hydrate t...
Learnt from: chebizarro
PR: MostroP2P/mobile#127
File: lib/features/order/notfiers/abstract_mostro_notifier.dart:45-54
Timestamp: 2025-06-26T15:03:23.529Z
Learning: In AbstractMostroNotifier, state updates occur for all messages regardless of timestamp to hydrate the OrderNotifier from MostroStorage during sync, while handleEvent is only called for recent messages (within 60 seconds) to prevent re-triggering side effects like notifications and navigation for previously handled messages. This design prevents displaying stale notifications when the app is reopened or brought to the foreground.

Applied to files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in abstractmostronotifier, the handleevent method is synchronous and returns void, not future....
Learnt from: Catrya
PR: MostroP2P/mobile#215
File: lib/features/order/notfiers/order_notifier.dart:0-0
Timestamp: 2025-07-20T23:33:17.689Z
Learning: In AbstractMostroNotifier, the handleEvent method is synchronous and returns void, not Future<void>. Do not suggest adding await to super.handleEvent() calls as this would cause compilation errors.

Applied to files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
📚 Learning: applies to lib/core/mostro_fsm.dart : order state transitions must be managed by `core/mostro_fsm.da...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/core/mostro_fsm.dart : Order state transitions must be managed by `core/mostro_fsm.dart`

Applied to files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: mostroservice methods like takebuyorder() and takesellorder() return future and trigger side e...
Learnt from: chebizarro
PR: MostroP2P/mobile#110
File: test/notifiers/take_order_notifier_test.dart:72-74
Timestamp: 2025-06-04T19:35:20.209Z
Learning: MostroService methods like takeBuyOrder() and takeSellOrder() return Future<void> and trigger side effects through other mechanisms rather than direct return values. When testing these methods, focus on verifying method calls and testing state changes through the provider system rather than mocking return values.

Applied to files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in the mostro protocol, an order cannot be canceled unless it has a valid orderid, so null checks on...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:97-103
Timestamp: 2025-05-06T15:49:55.079Z
Learning: In the Mostro protocol, an order cannot be canceled unless it has a valid orderId, so null checks on orderId during cancel operations are unnecessary.

Applied to files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
📚 Learning: in the context of the mostro mobile app, the `tradestate` class is specifically constructed using th...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/features/trades/models/trade_state.dart:1-15
Timestamp: 2025-05-08T16:06:33.665Z
Learning: In the context of the Mostro Mobile app, the `TradeState` class is specifically constructed using the `tradeStateProvider`. While some fields are nullable (`lastAction` and `orderPayload`), they are still marked as required parameters to ensure they are explicitly considered during state construction.

Applied to files:

  • lib/features/order/notfiers/abstract_mostro_notifier.dart
  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/l10n/intl_{en,es,it}.arb : add new localization keys to all three arb files (en, es, ...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/l10n/intl_{en,es,it}.arb : Add new localization keys to all three ARB files (en, es, it)

Applied to files:

  • lib/l10n/intl_it.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_en.arb
📚 Learning: applies to lib/l10n/*.arb : use proper arb metadata for parameterized strings...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/l10n/*.arb : Use proper ARB metadata for parameterized strings

Applied to files:

  • lib/l10n/intl_es.arb
  • lib/l10n/intl_en.arb
📚 Learning: in the orderstate refactor, public keys should be accessed via `tradestate.peer?.publickey` from the...
Learnt from: chebizarro
PR: MostroP2P/mobile#110
File: lib/features/trades/widgets/mostro_message_detail_widget.dart:134-141
Timestamp: 2025-06-08T23:54:09.987Z
Learning: In the OrderState refactor, public keys should be accessed via `tradeState.peer?.publicKey` from the OrderState instance rather than through `session?.peer?.publicKey`, as the OrderState encapsulates peer information directly.

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in the mostro mobile codebase, riverpod code generation is used with `@riverpod` annotations. provid...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, Riverpod code generation is used with `@Riverpod` annotations. Providers like `eventStorageProvider` are generated in `.g.dart` files from annotated functions in the main provider files. These providers are accessible by importing the main provider file (e.g., `mostro_service_provider.dart`), not by importing a separate provider file.

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: use riverpod for all state management...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Use Riverpod for all state management

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: in the mostro mobile codebase, `eventstorageprovider` is exported from `package:mostro_mobile/shared...
Learnt from: chebizarro
PR: MostroP2P/mobile#74
File: lib/services/mostro_service.dart:70-76
Timestamp: 2025-05-06T15:49:26.443Z
Learning: In the Mostro Mobile codebase, `eventStorageProvider` is exported from `package:mostro_mobile/shared/providers/mostro_service_provider.dart` and not from a separate `event_storage_provider.dart` file.

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/data/models.dart : models must be exported through `data/models.dart`...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/data/models.dart : Models must be exported through `data/models.dart`

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/services/nostr_service.dart : all nostr protocol interactions must go through `servic...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/services/nostr_service.dart : All Nostr protocol interactions must go through `services/nostr_service.dart`

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/shared/providers/mostro_database_provider.dart : database initialization must occur i...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/shared/providers/mostro_database_provider.dart : Database initialization must occur in `shared/providers/mostro_database_provider.dart`

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart : feature-based organizati...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/features/*/{screens,providers,notifiers,widgets}/**/*.dart : Feature-based organization: `features/{feature}/{screens|providers|notifiers|widgets}/`

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
📚 Learning: applies to lib/features/*/providers/**/*.dart : providers are organized by feature in `features/{fea...
Learnt from: CR
PR: MostroP2P/mobile#0
File: CLAUDE.md:0-0
Timestamp: 2025-07-30T14:10:43.895Z
Learning: Applies to lib/features/*/providers/**/*.dart : Providers are organized by feature in `features/{feature}/providers/`

Applied to files:

  • lib/features/trades/widgets/mostro_message_detail_widget.dart
🔇 Additional comments (8)
lib/l10n/intl_it.arb (1)

78-86: LGTM! Well-formed localization entry.

The new Italian localization key follows proper ARB format with correct placeholder definition and appropriate message content for the maker waiting scenario.

lib/features/order/notfiers/abstract_mostro_notifier.dart (3)

162-177: Excellent implementation of role-aware navigation for waitingSellerToPay.

The conditional logic correctly identifies when the user is a maker of a buy order and prevents automatic navigation, keeping them on the current screen as intended. The logic flows well and maintains the original behavior for takers.


183-192: Good implementation of conditional navigation for waitingBuyerInvoice.

The logic properly checks if user is a maker of a sell order and skips navigation accordingly, while preserving the original navigation behavior for other scenarios.


248-255: Well-implemented helper method with proper null safety.

The _isUserCreator() method correctly determines if the current user is the order creator by matching session role with order kind. The null checks ensure robust behavior when session or order data is unavailable.

lib/features/trades/widgets/mostro_message_detail_widget.dart (4)

5-6: Appropriate imports added for the new functionality.

The Session and OrderState imports are necessary for the role-based message logic being implemented.


112-125: Excellent implementation of role-aware messaging for waitingSellerToPay.

The conditional logic correctly identifies makers and shows the appropriate waiting message. The replaceAll('\\n', '\n') properly handles escaped newlines from the localization string.


134-145: Good implementation of conditional messaging for waitingBuyerInvoice.

The logic properly checks both maker status and sell order type before showing the maker-specific message, maintaining consistency with the navigation logic changes.


276-283: Consistent helper method implementation.

The _isUserCreator() method matches the implementation in AbstractMostroNotifier, ensuring consistent role determination logic across both navigation and messaging components.

Comment thread lib/l10n/intl_es.arb
@Catrya Catrya merged commit 7935c31 into main Aug 4, 2025
2 checks passed
@Catrya Catrya deleted the orderTakenWaitingCounterpart branch August 8, 2025 22:11
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.

1 participant