Skip to content

Improve Mostro instance configuration UX#390

Merged
grunch merged 5 commits intomainfrom
fix-message-change-instance
Jan 7, 2026
Merged

Improve Mostro instance configuration UX#390
grunch merged 5 commits intomainfrom
fix-message-change-instance

Conversation

@Catrya
Copy link
Copy Markdown
Member

@Catrya Catrya commented Dec 26, 2025

fix #380

  • Add 3-second debounce timer to prevent restore interruptions
  • Implement hex/npub format validation with localized error messages
  • Auto-convert npub format to hex before saving
  • Update info dialog to document supported formats (en/es/it)

Now the user can enter the npub format in the pubkey field and it will automatically be converted to hex format. This does not affect the functionality of the pubkey in hex format as it was previously used, it is simply a change to improve the user experience.

Summary by CodeRabbit

  • New Features

    • Added input validation for Mostro public key with inline error messages and real-time feedback.
    • Support for both hex and npub formats with automatic conversion and display as hex.
  • Improvements

    • Debounced processing of public key input to reduce unnecessary updates.
    • Safer update/restore flow with improved error handling and resource cleanup.
  • Localization

    • Updated help text and added validation message strings in English, Spanish, and Italian.

✏️ Tip: You can customize this high-level summary in your review settings.

  - Add Timer to prevent immediate session restoration while typing
  - Only trigger restore 3 seconds after user stops typing
  - Cancel timer properly in dispose to prevent memory leaks
  - Add format validation for Mostro public keys (hex and npub)
  - Auto-convert npub format to hex before saving
  - Display localized error messages for invalid formats
  - Support both hex (64 chars) and npub1 (63 chars) formats
  - Show converted hex in field after npub input
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Dec 26, 2025

Walkthrough

Adds Mostro public-key handling in Settings: accepts hex or npub, validates and converts npub→hex, debounces input (3s), shows inline error for invalid keys, syncs controller to hex, only triggers restore when the key actually changes, and cancels debounce on dispose.

Changes

Cohort / File(s) Summary
Settings Screen Feature
lib/features/settings/settings_screen.dart
Adds pubkey validation helpers (_isValidPubkey, _convertToHex), 3s debounced input processing, _pubkeyError inline error display, controller sync to hex when npub entered, conditional restore initiation wrapped in try/catch, and debounce timer cancellation in dispose.
Localization Updates
lib/l10n/intl_en.arb, lib/l10n/intl_es.arb, lib/l10n/intl_it.arb
Prepends mostroInfoText with support note for hex/npub, adds @_comment_validation and invalidKeyFormat entries in each locale, and minor formatting tweaks.

Sequence Diagram

sequenceDiagram
    actor User
    participant UI as Settings UI\n(TextField)
    participant Debounce as Debounce Timer
    participant Validator as Validation & Conversion
    participant Store as Settings Store
    participant Restore as Restore Workflow

    User->>UI: Type or paste Mostro key
    UI->>Debounce: start/reset 3s timer
    Note right of UI: clear inline error on edit

    Debounce->>Validator: timer fires
    activate Validator
    Validator->>Validator: validate (hex or npub)
    alt invalid format
        Validator-->>UI: set `_pubkeyError` (show red message)
    else valid format
        Validator->>Validator: convert npub → hex (if needed)
        Validator->>UI: update controller text to hex (when converted)
        Validator->>Store: save hex key
        Store->>Restore: compare previous key
        alt key changed
            Restore->>Restore: start restore workflow (try/catch)
        else unchanged
            Restore-->>Store: skip restore
        end
    end
    deactivate Validator
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Settings screen redesigned #207: Edits to lib/features/settings/settings_screen.dart and Mostro UI; directly related to Mostro settings and localization changes.

Suggested reviewers

  • chebizarro
  • grunch

Poem

🐰 In fields of keys I lightly hop,

I wait three beats before I stop,
Hex or npub, I tidy each line,
Errors glow red, restores run when fine,
A carrot-coded fix — quick, neat, and hop! 🥕

Pre-merge checks

✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: improving the user experience for Mostro instance configuration.
Linked Issues check ✅ Passed The pull request addresses all requirements from issue #380: implements a 3-second debounce to prevent restore popups during typing, validates hex/npub formats, auto-converts npub to hex, and adds localized validation messages.
Out of Scope Changes check ✅ Passed All changes directly support the objectives: debounce timer and validation for pubkey handling, UI error feedback, and localization updates for the new validation messages and format documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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.

Copy link
Copy Markdown
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: 1

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between b594627 and f6d759e.

📒 Files selected for processing (4)
  • lib/features/settings/settings_screen.dart
  • lib/l10n/intl_en.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_it.arb
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{dart,flutter}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{dart,flutter}: Run flutter analyze after any code change - Mandatory before commits to ensure zero linting issues
Run flutter test after any code change - Mandatory before commits to ensure all unit tests pass

Files:

  • lib/features/settings/settings_screen.dart
**/*.dart

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.dart: Use Riverpod for all state management - encapsulate business logic in Notifiers and access data only through repository classes
All code comments must be in English - use clear, concise English for variable names, function names, and comments
Always check mounted before using BuildContext after async operations to prevent errors on disposed widgets
Use const constructors where possible for better performance and immutability
Remove unused imports and dependencies to maintain code cleanliness and reduce build size

**/*.dart: Application code should be organized under lib/, grouped by domain with lib/features/<feature>/ structure, shared utilities in lib/shared/, dependency wiring in lib/core/, and services in lib/services/
Persistence, APIs, and background jobs should live in lib/data/ and lib/background/; generated localization output must be in lib/generated/ and must stay untouched
Apply flutter format . to enforce canonical Dart formatting (two-space indentation, trailing commas) before committing
Resolve every analyzer warning in Dart code
Name Riverpod providers using the <Feature>Provider or <Feature>Notifier convention
Localize all user-facing strings via ARB files and access them with S.of(context) rather than hard-coded literals

Files:

  • lib/features/settings/settings_screen.dart
lib/l10n/**/*.arb

📄 CodeRabbit inference engine (CLAUDE.md)

Add new localization keys to all three ARB files (en, es, it) - use S.of(context)!.keyName for all user-facing strings

Files:

  • lib/l10n/intl_en.arb
  • lib/l10n/intl_it.arb
  • lib/l10n/intl_es.arb
🧠 Learnings (14)
📓 Common learnings
Learnt from: grunch
Repo: MostroP2P/mobile PR: 306
File: docs/architecture/REQUEST_ID_ANALYSIS.md:176-183
Timestamp: 2025-09-17T20:45:32.468Z
Learning: For PR #306 in MostroP2P/mobile repository: This is a documentation-only PR intended to explain how the current requestId system works, not to fix any bugs or issues in the code. The documentation should accurately reflect existing behavior.
Learnt from: grunch
Repo: MostroP2P/mobile PR: 306
File: docs/architecture/REQUEST_ID_ANALYSIS.md:114-118
Timestamp: 2025-09-17T20:45:07.179Z
Learning: For the MostroP2P/mobile project, grunch prefers to separate documentation PRs from code improvement PRs. Documentation PRs should focus on explaining how the current system works, while code fixes and improvements should be handled in separate PRs.
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T12:10:26.407Z
Learning: PR descriptions should capture intent, list key changes, link tracking issues, flag risk areas, include command output for manual tests, and provide screenshots for UI updates
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/relays/**/*.dart : Use dual storage strategy: store Mostro/default relays in `settings.relays` and user relays in `settings.userRelays` with full JSON metadata via `toJson()`/`fromJson()`

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/core/app_routes.dart : Use GoRouter for all navigation configuration instead of Navigator API - maintain all routes in app_routes.dart

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to **/*.dart : Use Riverpod for all state management - encapsulate business logic in Notifiers and access data only through repository classes

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/**/providers/**/*.dart : Organize Riverpod providers by feature in `features/{feature}/providers/` using Notifier pattern for complex state logic

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-05-06T15:49:26.443Z
Learnt from: chebizarro
Repo: MostroP2P/mobile PR: 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/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:26.407Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T12:10:26.407Z
Learning: Applies to **/*.dart : Name Riverpod providers using the `<Feature>Provider` or `<Feature>Notifier` convention

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to **/*.dart : Always check `mounted` before using BuildContext after async operations to prevent errors on disposed widgets

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/settings/settings.dart : Use null-aware operators (`??`) in Settings `copyWith()` method to preserve existing values for selectedLanguage and defaultLightningAddress when not explicitly overridden

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-10-14T21:12:06.887Z
Learnt from: Catrya
Repo: MostroP2P/mobile PR: 327
File: lib/features/order/notfiers/abstract_mostro_notifier.dart:141-154
Timestamp: 2025-10-14T21:12:06.887Z
Learning: In the MostroP2P mobile codebase, the notification system uses a two-layer localization pattern: providers/notifiers (without BuildContext access) call `showCustomMessage()` with string keys (e.g., 'orderTimeoutMaker', 'orderCanceled'), and the UI layer's `NotificationListenerWidget` has a switch statement that maps these keys to localized strings using `S.of(context)`. This architectural pattern properly separates concerns while maintaining full localization support for all user-facing messages.

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/**/screens/**/*.dart : Use `S.of(context)!.yourKey` for all user-facing strings instead of hardcoded text

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:26.407Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T12:10:26.407Z
Learning: Applies to **/*.dart : Localize all user-facing strings via ARB files and access them with `S.of(context)` rather than hard-coded literals

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-08-21T14:45:43.974Z
Learnt from: Catrya
Repo: MostroP2P/mobile PR: 272
File: lib/features/relays/widgets/relay_selector.dart:13-15
Timestamp: 2025-08-21T14:45:43.974Z
Learning: In the Mostro mobile app's RelaySelector widget (lib/features/relays/widgets/relay_selector.dart), watching relaysProvider.notifier correctly triggers rebuilds because the relaysProvider itself depends on settingsProvider (line 8 in relays_provider.dart). When blacklist changes via toggleMostroRelayBlacklist(), the settingsProvider updates, causing relaysProvider to rebuild, which then notifies widgets watching the notifier. The UI correctly reflects active/inactive states in real-time through this dependency chain.

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/l10n/**/*.arb : Add new localization keys to all three ARB files (en, es, it) - use `S.of(context)!.keyName` for all user-facing strings

Applied to files:

  • lib/l10n/intl_it.arb
  • lib/l10n/intl_es.arb
⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (7)
lib/l10n/intl_en.arb (1)

907-907: LGTM!

The localization updates are well-structured:

  • mostroInfoText now clearly documents hex/npub format support with appropriate formatting.
  • The new invalidKeyFormat validation key follows the established pattern and is properly categorized under the validation comment section.

Also applies to: 1220-1223

lib/l10n/intl_es.arb (1)

886-886: LGTM!

Spanish translations are accurate and consistent with the English locale. The validation section and key follow the same structure as intl_en.arb.

Also applies to: 1198-1201

lib/l10n/intl_it.arb (1)

942-942: LGTM!

Italian translations are accurate and consistent with other locales. All three ARB files (en, es, it) now contain the required localization keys for the new validation feature, as per coding guidelines.

Also applies to: 1253-1256

lib/features/settings/settings_screen.dart (4)

1-1: LGTM!

The new imports are appropriate for the debounce timer functionality and Bech32 decoding.

Also applies to: 15-15


28-29: LGTM!

State variables and timer cleanup are properly implemented. Canceling the timer in dispose() prevents memory leaks and callbacks firing on disposed widgets.

Also applies to: 40-46


552-561: LGTM!

The inline error display follows a clean pattern with appropriate styling. The conditional rendering with if (_pubkeyError != null) prevents unnecessary UI elements when there's no error.


48-71: No issues found with NostrUtils.decodeBech32 implementation.

The method is correctly defined at lib/shared/utils/nostr_utils.dart:103 with signature static String decodeBech32(String bech32String), properly imported, and correctly used in _convertToHex(). The validation logic correctly handles both hex (64 chars) and npub (Bech32, 63 chars with npub1 prefix) formats, and the conversion properly delegates to the NostrUtils method.

Comment thread lib/features/settings/settings_screen.dart
Copy link
Copy Markdown
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 (2)
lib/features/settings/settings_screen.dart (2)

494-542: Previous review concern addressed; consider capturing localized string before async operations.

The mounted check at lines 509-510 correctly addresses the previous review comment. However, in the catch block (line 538), S.of(context) is called after potential async operations. While the mounted check at line 536 protects against disposed widgets, best practice is to capture localized strings before any async work to avoid subtle context/locale issues.

🔎 Suggested improvement

Capture the localized error message before entering the async callback:

                onChanged: (value) async {
+                 final invalidKeyMsg = S.of(context)!.invalidKeyFormat;
                  _debounceTimer?.cancel();
                  _debounceTimer = Timer(const Duration(seconds: 3), () async {
                    if (!mounted) return;
                    
                    try {
                      if (_isValidPubkey(value)) {
                        setState(() {
                          _pubkeyError = null;
                        });
                        
                        final hexValue = _convertToHex(value);
                        final oldValue = ref.read(settingsProvider).mostroPublicKey;
                        await ref.read(settingsProvider.notifier).updateMostroInstance(hexValue);

                        // Check mounted after async operation
                        if (!mounted) return;

                        // Update text controller to show hex if it was npub
                        if (value.startsWith('npub1')) {
                          controller.text = hexValue;
                        }

                        // Trigger restore if pubkey changed
                        if (oldValue != hexValue && hexValue.isNotEmpty) {
                          try {
                            final restoreService = ref.read(restoreServiceProvider);
                            await restoreService.initRestoreProcess();
                          } catch (e) {
                            // Ignore errors during restore
                          }
                        }
                      } else if (value.isNotEmpty) {
                        setState(() {
-                         _pubkeyError = S.of(context)!.invalidKeyFormat;
+                         _pubkeyError = invalidKeyMsg;
                        });
                      } else {
                        setState(() {
                          _pubkeyError = null;
                        });
                      }
                    } catch (e) {
                      if (mounted) {
                        setState(() {
-                         _pubkeyError = S.of(context)!.invalidKeyFormat;
+                         _pubkeyError = invalidKeyMsg;
                        });
                      }
                    }
                  });
                },

Based on coding guidelines requiring BuildContext safety after async operations.


513-515: Minor: Programmatic controller update triggers extra debounce cycle.

When converting npub→hex, setting controller.text at line 514 triggers onChanged again, starting a new 3-second timer. The second cycle validates the hex (correctly) but adds a 3-second delay before restore completes. Consider adding a flag to skip debounce during programmatic updates, or compare values before setting.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f6d759e and 07e105e.

📒 Files selected for processing (1)
  • lib/features/settings/settings_screen.dart
🧰 Additional context used
📓 Path-based instructions (2)
**/*.{dart,flutter}

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.{dart,flutter}: Run flutter analyze after any code change - Mandatory before commits to ensure zero linting issues
Run flutter test after any code change - Mandatory before commits to ensure all unit tests pass

Files:

  • lib/features/settings/settings_screen.dart
**/*.dart

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.dart: Use Riverpod for all state management - encapsulate business logic in Notifiers and access data only through repository classes
All code comments must be in English - use clear, concise English for variable names, function names, and comments
Always check mounted before using BuildContext after async operations to prevent errors on disposed widgets
Use const constructors where possible for better performance and immutability
Remove unused imports and dependencies to maintain code cleanliness and reduce build size

**/*.dart: Application code should be organized under lib/, grouped by domain with lib/features/<feature>/ structure, shared utilities in lib/shared/, dependency wiring in lib/core/, and services in lib/services/
Persistence, APIs, and background jobs should live in lib/data/ and lib/background/; generated localization output must be in lib/generated/ and must stay untouched
Apply flutter format . to enforce canonical Dart formatting (two-space indentation, trailing commas) before committing
Resolve every analyzer warning in Dart code
Name Riverpod providers using the <Feature>Provider or <Feature>Notifier convention
Localize all user-facing strings via ARB files and access them with S.of(context) rather than hard-coded literals

Files:

  • lib/features/settings/settings_screen.dart
🧠 Learnings (15)
📓 Common learnings
Learnt from: grunch
Repo: MostroP2P/mobile PR: 306
File: docs/architecture/REQUEST_ID_ANALYSIS.md:176-183
Timestamp: 2025-09-17T20:45:32.468Z
Learning: For PR #306 in MostroP2P/mobile repository: This is a documentation-only PR intended to explain how the current requestId system works, not to fix any bugs or issues in the code. The documentation should accurately reflect existing behavior.
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/relays/**/*.dart : Use dual storage strategy: store Mostro/default relays in `settings.relays` and user relays in `settings.userRelays` with full JSON metadata via `toJson()`/`fromJson()`

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to **/*.dart : Always check `mounted` before using BuildContext after async operations to prevent errors on disposed widgets

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-10-21T21:47:03.451Z
Learnt from: Catrya
Repo: MostroP2P/mobile PR: 327
File: lib/features/order/notfiers/abstract_mostro_notifier.dart:157-182
Timestamp: 2025-10-21T21:47:03.451Z
Learning: In MostroP2P/mobile, for Action.canceled handling in abstract_mostro_notifier.dart (Riverpod StateNotifier), do not add mounted checks after async sessionNotifier.deleteSession(orderId) as they break order state synchronization during app restart. The Action.canceled flow contains critical business logic that must complete fully; Riverpod handles provider disposal automatically. Mounted checks should only protect UI operations, not business logic in StateNotifiers.

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-07-20T23:33:17.689Z
Learnt from: Catrya
Repo: MostroP2P/mobile PR: 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/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/core/app_routes.dart : Use GoRouter for all navigation configuration instead of Navigator API - maintain all routes in app_routes.dart

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to **/*.dart : Use Riverpod for all state management - encapsulate business logic in Notifiers and access data only through repository classes

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/**/providers/**/*.dart : Organize Riverpod providers by feature in `features/{feature}/providers/` using Notifier pattern for complex state logic

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-05-06T15:49:26.443Z
Learnt from: chebizarro
Repo: MostroP2P/mobile PR: 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/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:26.407Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T12:10:26.407Z
Learning: Applies to **/*.dart : Name Riverpod providers using the `<Feature>Provider` or `<Feature>Notifier` convention

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/settings/settings.dart : Use null-aware operators (`??`) in Settings `copyWith()` method to preserve existing values for selectedLanguage and defaultLightningAddress when not explicitly overridden

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-10-14T21:12:06.887Z
Learnt from: Catrya
Repo: MostroP2P/mobile PR: 327
File: lib/features/order/notfiers/abstract_mostro_notifier.dart:141-154
Timestamp: 2025-10-14T21:12:06.887Z
Learning: In the MostroP2P mobile codebase, the notification system uses a two-layer localization pattern: providers/notifiers (without BuildContext access) call `showCustomMessage()` with string keys (e.g., 'orderTimeoutMaker', 'orderCanceled'), and the UI layer's `NotificationListenerWidget` has a switch statement that maps these keys to localized strings using `S.of(context)`. This architectural pattern properly separates concerns while maintaining full localization support for all user-facing messages.

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/features/**/screens/**/*.dart : Use `S.of(context)!.yourKey` for all user-facing strings instead of hardcoded text

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-11-27T12:10:26.407Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-27T12:10:26.407Z
Learning: Applies to **/*.dart : Localize all user-facing strings via ARB files and access them with `S.of(context)` rather than hard-coded literals

Applied to files:

  • lib/features/settings/settings_screen.dart
📚 Learning: 2025-08-21T14:45:43.974Z
Learnt from: Catrya
Repo: MostroP2P/mobile PR: 272
File: lib/features/relays/widgets/relay_selector.dart:13-15
Timestamp: 2025-08-21T14:45:43.974Z
Learning: In the Mostro mobile app's RelaySelector widget (lib/features/relays/widgets/relay_selector.dart), watching relaysProvider.notifier correctly triggers rebuilds because the relaysProvider itself depends on settingsProvider (line 8 in relays_provider.dart). When blacklist changes via toggleMostroRelayBlacklist(), the settingsProvider updates, causing relaysProvider to rebuild, which then notifies widgets watching the notifier. The UI correctly reflects active/inactive states in real-time through this dependency chain.

Applied to files:

  • lib/features/settings/settings_screen.dart
⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (3)
lib/features/settings/settings_screen.dart (3)

48-58: Validation logic looks correct.

Properly validates 64-character lowercase/uppercase hex and 63-character npub1 format per NIP-19 spec.


60-71: Conversion logic correctly delegates to NostrUtils.

Npub decoding is handled by NostrUtils.decodeBech32 with proper error handling. Hex input passes through unchanged.


28-29: Proper resource cleanup in dispose.

Debounce timer and error state are correctly initialized and cleaned up.

Also applies to: 42-42

Copy link
Copy Markdown
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)
lib/l10n/intl_en.arb (1)

1238-1239: Consider making the error message more specific.

The current message "Invalid key format" is quite generic. Users might not immediately know what formats are valid. Consider adding the expected formats to help users self-correct.

🔎 Suggested improvement
-  "invalidKeyFormat": "Invalid key format"
+  "invalidKeyFormat": "Invalid key format. Please enter a hex or npub key"

This makes the error message more actionable, though the current version may be acceptable if there's sufficient context from the field label and info dialog.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07e105e and 8942d83.

📒 Files selected for processing (3)
  • lib/l10n/intl_en.arb
  • lib/l10n/intl_es.arb
  • lib/l10n/intl_it.arb
🚧 Files skipped from review as they are similar to previous changes (2)
  • lib/l10n/intl_it.arb
  • lib/l10n/intl_es.arb
🧰 Additional context used
📓 Path-based instructions (1)
lib/l10n/**/*.arb

📄 CodeRabbit inference engine (CLAUDE.md)

Add new localization keys to all three ARB files (en, es, it) - use S.of(context)!.keyName for all user-facing strings

Files:

  • lib/l10n/intl_en.arb
🧠 Learnings (2)
📓 Common learnings
Learnt from: grunch
Repo: MostroP2P/mobile PR: 306
File: docs/architecture/REQUEST_ID_ANALYSIS.md:176-183
Timestamp: 2025-09-17T20:45:32.468Z
Learning: For PR #306 in MostroP2P/mobile repository: This is a documentation-only PR intended to explain how the current requestId system works, not to fix any bugs or issues in the code. The documentation should accurately reflect existing behavior.
Learnt from: grunch
Repo: MostroP2P/mobile PR: 306
File: docs/architecture/REQUEST_ID_ANALYSIS.md:114-118
Timestamp: 2025-09-17T20:45:07.179Z
Learning: For the MostroP2P/mobile project, grunch prefers to separate documentation PRs from code improvement PRs. Documentation PRs should focus on explaining how the current system works, while code fixes and improvements should be handled in separate PRs.
📚 Learning: 2025-11-27T12:10:12.082Z
Learnt from: CR
Repo: MostroP2P/mobile PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-11-27T12:10:12.082Z
Learning: Applies to lib/l10n/**/*.arb : Add new localization keys to all three ARB files (en, es, it) - use `S.of(context)!.keyName` for all user-facing strings

Applied to files:

  • lib/l10n/intl_en.arb
⏰ 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). (1)
  • GitHub Check: build
🔇 Additional comments (2)
lib/l10n/intl_en.arb (2)

923-923: LGTM! Clear documentation of supported formats.

The addition clearly documents that both hex and npub formats are accepted, and helpfully notes that the display will show hex format. This aligns well with the PR objective to improve UX by supporting multiple input formats.


1236-1236: Good wording improvement.

The change from "Save" to "Back up" is more appropriate terminology for recovery phrases and aligns with standard crypto wallet conventions.

Copy link
Copy Markdown
Member

@grunch grunch left a comment

Choose a reason for hiding this comment

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

tACK

@BraCR10
Copy link
Copy Markdown
Member

BraCR10 commented Jan 7, 2026

LGTM

@AndreaDiazCorreia
Copy link
Copy Markdown
Member

tACK

@grunch grunch merged commit d549633 into main Jan 7, 2026
2 checks passed
@Catrya Catrya deleted the fix-message-change-instance branch January 12, 2026 23:39
@coderabbitai coderabbitai Bot mentioned this pull request Feb 10, 2026
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.

Annoying “Restoring Orders” popup when modifying Mostro key

4 participants