Move send controls into Routing and split retry limits

Direct and flood attempts are separate settings, available with auto
route rotation off. Saved single retry limits migrate to that split,
and reset restores the whole Routing section.

Co-authored-by: zjs81 <zjs81@users.noreply.github.com>
This commit is contained in:
Cursor Agentandzjs81 committed 2026-11-21 00:50:53 +00:00
1 parent 34ea0cb7ca
commit 1b804bd1eb
69 files changed
+2199 -784

No files matched your search

+8 -7
View File
@@ -156,7 +156,7 @@ Maintains an in-memory LRU cache of up to 50 contacts, each with up to 100 route
Each route keeps delivery and failure counts that fade over time (half their weight per day, at most 16 recent results). For each send attempt a route is chosen by Thompson sampling over those counts, adjusted slightly for speed and for what the radio currently hears. There are no user-tunable weights. A route is deleted only when it keeps failing and hasn't delivered for a week. Flood deliveries that receive an ACK credit the specific return path. Details: [Auto route selection](routing-paths.md#auto-route-selection).
Used internally for:
- **Auto route rotation**: Picks a route for each attempt; retries usually move to a different route, and the last attempt floods
- **Auto route rotation**: Picks a route for each direct attempt; retries usually move to a different route, then the flood attempts run
- **Flood statistics**: Tracks flood deliveries and failures
---
@@ -167,16 +167,17 @@ Used internally for:
Handles reliable delivery of outgoing direct messages:
1. Assigns a UUID and sends immediately. Only one message per contact can be in-flight at a time (avoids overflowing the firmware's 8-entry ACK table); subsequent messages are queued
2. Listens for ACK frames matched via SHA-256 hash of `[timestamp][attempt][text][sender_pubkey]`
3. On timeout, retries with exponential backoff: `1000 × 2^retryCount` ms (1s, 2s, 4s, 8s...)
4. Each retry may use a different path (via path history diversity window)
5. After max retries: marks failed but keeps a **30-second grace window** during which a late ACK can still resolve the message to "delivered". Optionally clears the contact's path
3. On timeout, retries with exponential backoff: `1000 × 2^retryCount` ms (1s, 2s, 4s, 8s...), capped at 32 seconds
4. Each direct retry may use a different path (via path history diversity window) when auto route rotation is on
5. After the configured direct and flood attempts: marks failed but keeps a **30-second grace window** during which a late ACK can still resolve the message to "delivered". Optionally clears the contact's path
6. Reports RTT and path data for quality learning
7. Maintains an ACK hash history (last 50 entries) to handle duplicate ACKs
### Configurable Settings (App Settings → Messaging)
- Max retries (2–10, default 5)
### Configurable Settings (App Settings → Routing)
- Direct attempts (0–15, default 4) and flood attempts (0–10, default 1), set separately from auto route rotation
- Login attempts for a repeater or room server (1–10, default 5). Telemetry requests are not retried
- Clear path on max retry (on/off)
- Auto route rotation with weight parameters
- Auto route rotation
---
+1 -1
View File
@@ -124,7 +124,7 @@ The app bar overflow menu (⋮) has **Filter messages in this channel** (shown w
### Channel Auto-Resend
With **Resend channel messages until they travel far enough** on (App Settings → Messaging), the app waits after each channel send and checks how far the message was heard repeated. If no repeat reached the required hop count, it sends the message again, up to the configured number of times.
With **Resend channel messages until they travel far enough** on (App Settings → Routing), the app waits after each channel send and checks how far the message was heard repeated. If no repeat reached the required hop count, it sends the message again, up to the configured number of times.
Where your radio only hears nearby repeaters, turn on **Also count different nearby repeaters**: the message then also counts as sent once the required number of *different* first-hop repeaters have repeated it, across all attempts. Your own radio's echo and zero-hop echoes don't count.
+5 -5
View File
@@ -102,11 +102,11 @@ When a direct message is sent:
1. The app computes an expected ACK hash: `SHA256([timestamp][attempt][text][selfPubKey])[0:4]` — matching the firmware's hash calculation. If SMAZ compression is enabled, the compressed text (not the original) is hashed
2. On device acknowledgment (`RESP_CODE_SENT`), the message transitions to "sent" and a timeout timer starts. If that acknowledgment never arrives (for example a dropped BLE notification), a backup timer (the delivery timeout plus 5 seconds) runs the normal retry path instead of leaving the message pending; a late ACK still marks it delivered
3. **Timeout duration**: Preferably from the ML timeout prediction service; otherwise from the device's own `est_timeout` in `RESP_CODE_SENT` (clamped to the physics range); otherwise calculated from LoRa airtime physics: `500 + (airtime × 6 + 250) × (pathLength + 1)` ms for direct paths, `500 + 16 × airtime` ms for flood (airtime is estimated from the radio's current spreading factor, bandwidth, and coding rate). The result is capped at 45 seconds.
4. On timeout, the message is retried with **exponential backoff**: `1000 × 2^retryCount` ms (1s, 2s, 4s, 8s, 16s...)
5. **Max retries**: Configurable (default 5, range 2–10)
6. After max retries, the message is marked "failed" — but a **30-second grace window** remains during which a late ACK can still resolve the message to "delivered"
7. If **Clear Path on Max Retry** is enabled (App Settings), the contact's stored routing path is automatically cleared when max retries are exhausted
8. **Auto route rotation**: When enabled (and no manual path override is set), the retry service uses a diversity window to avoid re-using recently tried paths, cycling through known routes on each attempt
4. On timeout, the message is retried with **exponential backoff**: `1000 × 2^retryCount` ms (1s, 2s, 4s, 8s, 16s...), capped at 32 seconds
5. **Direct and flood attempts**: Set separately in App Settings → Routing (defaults 4 direct and 1 flood; up to 15 direct and 10 flood). With auto route rotation on, the direct attempts use known routes and the flood attempts follow. With it off, every attempt stays on the contact's current path and only that path's limit applies. Zero on both still sends once
6. After those attempts, the message is marked "failed" — but a **30-second grace window** remains during which a late ACK can still resolve the message to "delivered"
7. If **Clear Path on Max Retry** is enabled (App Settings → Routing), the contact's stored routing path is automatically cleared when the attempts are exhausted
8. **Auto route rotation**: When enabled (and no manual path override is set), the retry service uses a diversity window to avoid re-using recently tried paths, cycling through known routes on each direct attempt. Flood attempts come after those
### Manual Retry
+14 -1
View File
@@ -2,7 +2,7 @@
How MeshCore Open's interface is built today, and the rules to follow when adding or changing UI. Every value below comes from the code it cites. If you change one of those sources, or settle on a new pattern, update this page in the same change.
The source of truth is `lib/theme/mesh_theme.dart` (theme), `lib/widgets/mesh_ui.dart` (shared widgets) and `lib/widgets/mesh_nav_tile.dart` (settings rows). Where the code disagrees with this page, fix one of them; do not copy the inconsistency.
The source of truth is `lib/theme/mesh_theme.dart` (theme), `lib/widgets/mesh_ui.dart` (shared widgets), `lib/widgets/settings_reveal.dart` (reveal-on-enable and settings sliders) and `lib/widgets/mesh_nav_tile.dart` (settings rows). Where the code disagrees with this page, fix one of them; do not copy the inconsistency.
## 1. Principles
@@ -117,6 +117,8 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act
| Label above a group | `SectionHeader(label, trailing:)` | Upper-cases for you; pass the normal-case l10n string |
| Settings navigation row | `MeshNavTile` | `onTap: null` dims it to 50 % and reports it as disabled; use `subtitle` to say why |
| Settings switch | `SwitchListTile` inside `MeshSettingsTileTheme` | Wrap the settings screen body once in `MeshSettingsTileTheme` |
| Switch that reveals more controls | `SettingsReveal` | 200ms height ease, `surfaceContainerHighest`, 16px start indent. See [Reveal on enable](#reveal-on-enable) |
| Settings slider | `SettingsValueSlider` | The title includes the selected number, so it stays visible. The drag bubble repeats it |
| Radio-style choice in a sheet | `MeshSheetOption` | Used by the language picker and map time filter |
| Choosing between images | Selectable thumbnail tiles in a centred `Wrap` | Image send versions (`_versionTile` in `image_send_preview_sheet.dart`). `InkWell` with `MeshRadii.sm`; selected tile gets a 3px `primary` border **and** a `primary` check badge (never colour alone); caption under the tile in `bodySmall`, w600 when selected; figures such as packet counts in `MeshTheme.mono` 12; wrap the tile in `Semantics(button: true, selected:, label:)` |
| Popup menu row | **always** `PopupMenuItem(child: MeshMenuItemRow(icon:, label:))` | Label wraps to 2 lines then ellipsizes; `leading:` for `ThemedIcon`; no icon keeps the 20px slot |
@@ -147,6 +149,16 @@ Icon sizes in use: 24 for tile and banner icons, 20 for menu icons and small act
**IconButton.** Always set `tooltip:` with a localized string. It is the accessible name.
### Reveal on enable
A switch that uncovers more controls uses `SettingsReveal` (`lib/widgets/settings_reveal.dart`). The block's height eases over 200ms (`RevealOnEnable.duration`, `Curves.easeInOut`, aligned to the top). While the switch is off the extra controls are not in the tree, so they are not announced. The panel uses `surfaceContainerHighest` and a 16px start indent.
The same animation without the tint is `RevealOnEnable`. Use it when the revealed control is not a settings sub-panel: the Cyrillic-to-Latin profile picker, the Bluetooth-off banner on the scanner, and the device-info rows on the Settings screen.
Do not add a second duration, and do not reveal the controls with a plain `if` that pops them in. A block that swaps between two bodies, such as the filtered-message preview, keeps `AnimatedSize` but uses `RevealOnEnable.duration` and `RevealOnEnable.curve`.
Sliders that belong to a setting use `SettingsValueSlider`. Put the selected number in the title (a localized string with the count). The slider's drag label repeats that number; it is not the only place the value appears.
## 6. Sheets, dialogs and pages
What the code does:
@@ -216,6 +228,7 @@ Follow the same pattern for any new remote-value screen.
- [ ] Colours from `colorScheme` or theme extensions; no raw `Colors.*` or `MeshPalette.ink/bg/line` in chrome.
- [ ] Text styles from `textTheme` or `MeshTheme.mono`; nothing below 12.
- [ ] Settings rows use `MeshNavTile` / `SwitchListTile` inside `MeshSettingsTileTheme`; cards are `MeshCard` with a `SectionHeader`.
- [ ] A switch that reveals more controls uses `SettingsReveal`. A settings slider uses `SettingsValueSlider` so the selected value stays in the title.
- [ ] Popup menu rows use `MeshMenuItemRow`; segmented buttons use `MeshSegmentLabel`; destructive menu items last, in `scheme.error`.
- [ ] Every `IconButton` and FAB has a localized `tooltip`.
- [ ] Tap targets at least 48×48.
+1 -1
View File
@@ -55,7 +55,7 @@ Contacts/messages persist hop count, path bytes, and width. Legacy contact recor
- **Faded stats:** each route keeps delivery and failure counts that lose half their weight every 24 hours (`routeStatsHalfLife`), so recent behaviour outweighs old.
- **Thompson sampling:** for each attempt, a plausible delivery rate is drawn for every route from its faded counts and the best draw wins. Proven routes win most of the time; untested or recovering routes are still tried occasionally. Speed adjusts the score slightly.
- **Context:** `MeshCoreConnector.routeContextFor` reports what the radio heard in the last two hours (advertisers heard directly and the last hop of relayed adverts). Routes whose first hop was heard — or the direct route, when the contact itself was heard directly — score higher; routes that don't fit score lower. Not hearing a repeater is weak evidence, so nothing is excluded. With nothing heard, context has no effect.
- **Retries** halve the score of routes already tried for the same message, so they usually try something different without wasting an attempt on a much weaker route. The final attempt always floods.
- **Retries** halve the score of routes already tried for the same message, so they usually try something different without wasting an attempt on a much weaker route. Direct attempts use a known route. Once those are used up, the remaining attempts flood (`SendAttemptPlan.floodFromAttempt`). With flood attempts set to 0, a send never switches to flood.
- **Offline contacts:** `MessageRetryService` holds a message's route failures until its fate is known. If any attempt is acknowledged, the routes that timed out are blamed; if nothing gets through, the contact was probably unreachable and no route is blamed.
- **Forgetting:** a failing route is deleted only after it hasn't delivered for a week, so a repeater that is down for a day is still known when it returns.
- Route picks and their results are written to the app debug log under the `Routing` tag.
+12 -4
View File
@@ -119,18 +119,26 @@ A dedicated sub-screen for app-level preferences (nothing here is sent to the de
Individual channels can be muted from the channel chat bell icon, the channel list, or the channel notification. Replying from notifications, watches, and Android Auto is described in [Notifications](notifications.md).
### Messaging
- **Clear Path on Max Retry**: Erases the stored routing path after all retries fail
- **Jump to Oldest Unread**: When opening a chat, scrolls to the oldest unread message instead of the newest
- **Auto-fetch Repeater Settings** (off by default): Requests every setting when a repeater's settings screen opens. Each setting is a separate request over LoRa, so this is slow and uses airtime; when off, use Refresh All or the per-setting refresh buttons. See [Repeater Settings](repeater-management.md#repeater-settings)
- **Auto Route Rotation**: Lets the app choose each message's route from the routes that have worked for that contact (see [Auto route selection](routing-paths.md#auto-route-selection)). When enabled, it expands (hidden when off) to show:
- Max Message Retries (2–10, default 5)
- **Reset Routing Algorithm to Default**: Restores the routing settings to their factory defaults
- **Enable Message Tracing**: Shows path trace overlays and extra metadata on messages
- **Region next to hop count** (default off): Shows a channel message's region chip on the same line as its hop count instead of below it
### Routing
What happens when a message is sent. Each slider shows its selected number in the title. Turning a switch on reveals its extra controls with the same animation.
- **Clear Path on Max Retry**: Erases the stored routing path after every send attempt fails
- **Direct attempts** (0–15, default 4): How many times to try a known route. Available whether or not auto route rotation is on
- **Flood attempts** (0–10, default 1): How many times to flood. Floods use more airtime. With rotation on, these run after the direct attempts. With it off, they apply only when the contact's path is already Flood
- **Login attempts** (1–10, default 5): How many times to try logging in to a repeater or room server. Telemetry fetches are sent once and have no retry setting
- **Auto Route Rotation**: Lets the app choose each direct attempt's route from the routes that have worked for that contact (see [Auto route selection](routing-paths.md#auto-route-selection)). Off keeps the contact's current path for every attempt
- **Resend channel messages until they travel far enough** (default off): If your channel message isn't heard coming back through enough repeaters, it's sent again. Uses more airtime. When on, it shows:
- Required hops (1–8, default 2)
- Resend up to (1–5 times, default 1)
- **Also count different nearby repeaters** (default off): Treats the message as sent once that many *different* first-hop repeaters have repeated it, even if you can't hear it travel further. Useful where only nearby repeaters are audible. See [Channels](channels.md#channel-auto-resend)
- **Reset routing settings to defaults**: Restores every control in this section (the toggles, the attempt limits, and the stored route-weight constants) to the factory defaults
If both direct and flood attempts are 0, the message is still sent once on the current path. A saved `max_message_retries` value from an older version becomes that many attempts minus one direct, plus one flood, which keeps the old "last attempt floods" behaviour for the previous default of 5 (4 direct + 1 flood).
### Battery
- **Battery Chemistry**: NMC / LiFePO4 / LiPo (per device, used to calibrate percentage from voltage)