Skip to content

feat: add mostro-p2p.tech as fallback default relay#607

Closed
21Mill wants to merge 2 commits into
MostroP2P:mainfrom
21Mill:feat/add-fallback-default-relays
Closed

feat: add mostro-p2p.tech as fallback default relay#607
21Mill wants to merge 2 commits into
MostroP2P:mainfrom
21Mill:feat/add-fallback-default-relays

Conversation

@21Mill

@21Mill 21Mill commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

When relay.mostro.network is unreachable, clients have no fallback and all communication with any Mostro instance breaks. Adding mostro-p2p.tech as a second default relay ensures connectivity is maintained when the primary relay has an outage.

Also refactors RelaysNotifier to derive default relay seeds from Config.nostrRelays instead of a hardcoded single URL, so future additions only require updating Config.

Summary by CodeRabbit

  • New Features
    • Added an additional Nostr relay endpoint to the app's default configuration.
    • Relay reset now restores the full set of configured default relays instead of a single relay.
    • Relay loading and syncing improved to pre-populate from configured defaults and avoid creating duplicate relay entries.

@coderabbitai

coderabbitai Bot commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b14daf1a-830c-429f-8ab2-20637a1fb6d5

📥 Commits

Reviewing files that changed from the base of the PR and between e6ce046 and afcd897.

📒 Files selected for processing (1)
  • lib/features/relays/relays_notifier.dart
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/features/relays/relays_notifier.dart

Walkthrough

The PR expands default Nostr relays from one hardcoded endpoint to a configurable list: Config.nostrRelays adds wss://mostro-p2p.tech, and RelaysNotifier initializes, deduplicates, and resets relays using the full configured list.

Changes

Multiple Default Relays

Layer / File(s) Summary
Configuration expansion and notifier wiring
lib/core/config.dart, lib/features/relays/relays_notifier.dart
Config.nostrRelays adds the new relay endpoint wss://mostro-p2p.tech. RelaysNotifier imports Config to access the expanded default relay list.
Default relay initialization
lib/features/relays/relays_notifier.dart
_loadRelays iterates over Config.nostrRelays to pre-populate default relays and filters saved relays to exclude URLs already in the configured set, avoiding duplicates.
Reset to configured defaults
lib/features/relays/relays_notifier.dart
_cleanAllRelaysAndResync reset path clears state to Config.nostrRelays.map(Relay.fromDefault) and persists that full default set instead of a single hardcoded relay.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 New hops on the mesh tonight,
WSS veins glow with gentle light,
Config stitched another thread,
Relays awake where defaults led,
Rabbits sync and bound with delight.

🚥 Pre-merge checks | ✅ 5
✅ 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 accurately describes the main change: adding mostro-p2p.tech as a fallback default relay, which is the primary focus of both the config update and the RelaysNotifier refactoring.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@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

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/features/relays/relays_notifier.dart`:
- Around line 64-69: The duplicate-filtering logic uses
Config.nostrRelays.contains(url) without normalizing URLs; update the filter on
saved.relays to compare normalized URLs by calling _normalizeRelayUrl(url) (and
_normalizeRelayUrl on entries of Config.nostrRelays if not already normalized)
before contains checks so trailing slashes don't cause misses; change the
where(...) predicate that builds relaysFromSettings to use normalized
comparisons, then continue mapping to Relay.fromMostro and adding to
loadedRelays as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 8f8f2f6b-26b3-49c5-b6cb-72bacdea849d

📥 Commits

Reviewing files that changed from the base of the PR and between e46854f and a11d30f.

📒 Files selected for processing (2)
  • lib/core/config.dart
  • lib/features/relays/relays_notifier.dart

Comment thread lib/features/relays/relays_notifier.dart
When relay.mostro.network is unreachable, clients have no fallback and
all communication with any Mostro instance breaks. Adding mostro-p2p.tech
as a second default relay ensures connectivity is maintained when the
primary relay has an outage.

Also refactors RelaysNotifier to derive default relay seeds from
Config.nostrRelays instead of a hardcoded single URL, so future
additions only require updating Config.
@21Mill 21Mill force-pushed the feat/add-fallback-default-relays branch from a11d30f to e6ce046 Compare June 2, 2026 13:35

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

This is a small PR, but I do see one real correctness issue and I would request changes for it.

Blocking issue:

  • The new duplicate-filtering path compares saved relays against Config.nostrRelays with contains(_normalizeRelayUrl(url)), but the configured defaults themselves are not normalized before the comparison. That means a saved relay like wss://mostro-p2p.tech/ or wss://relay.mostro.network/ will not match the slashless default entry and will be loaded as an extra custom relay even though it is the same endpoint.
  • In practice this can leave duplicate logical relays in state and can lead to duplicate connections/subscriptions against the same server, which is exactly what this refactor is supposed to avoid.

Please normalize both sides of the comparison (or precompute a normalized default set) before filtering saved.relays.

Aside from that, the direction of the refactor is fine, and deriving defaults from Config.nostrRelays is the right cleanup. But I would still block until the duplicate detection is actually normalization-safe.

@Catrya

Catrya commented Jun 8, 2026

Copy link
Copy Markdown
Member

Hi @21Mill How's this PR going? Please take into account the changes requested by mostroneitor.

@21Mill

21Mill commented Jun 8, 2026

Copy link
Copy Markdown
Contributor Author

Hi @21Mill How's this PR going? Please take into account the changes requested by mostroneitor.

Thanks for reminding me, Catrya, I'd forgotten. I'll get on it.

The previous filter normalized the saved URL but compared against raw
Config.nostrRelays entries. A trailing slash on either side would cause
a mismatch, leaving duplicate logical relays in state.

Precompute a normalized Set from Config.nostrRelays so both sides of
the contains() check are normalized consistently.

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

I re-reviewed the latest head with the normalization fix in place, and I do not see a remaining blocking issue.

What I re-checked strictly:

  • The duplicate-filtering bug is fixed correctly. Precomputing a normalized default set and comparing saved relays against that set closes the trailing-slash mismatch I previously blocked on.
  • The reset path now derives its seed state from Config.nostrRelays as well, so the notifier is no longer split between one hardcoded default in one path and a configurable list in another.
  • The scope is still tight: this changes the default relay seed behavior without altering unrelated relay logic.

I do not see another correctness issue that should hold merge on this revision.

Approved.

@Catrya Catrya left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

tACK

@grunch

grunch commented Jun 10, 2026

Copy link
Copy Markdown
Member

closing this one in favor of #610

@grunch grunch closed this Jun 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.

3 participants