Fix review findings, add default flood scope, and address recent issues

Review fixes:
- Keep stored message history beyond the 200-message window; stop
  messages leaking between radios; reset link/session state on disconnect
- Accept firmware's 176-byte RX frames over USB/TCP
- Hold APP_START during contact sync; contact-sync watchdog; replay DMs
  from not-yet-known senders; tombstone late command replies; finish
  channel sync on ERR_NOT_FOUND; fail region-scoped sends cleanly
- DM retry watchdog when RESP_CODE_SENT never arrives; late repeater CLI
  replies; ACK hash collisions; UTF-8-safe name truncation
- Image pipeline: delete-during-decode, lifecycle cancels, decoder memory
  release, entry cap, dead worker recovery, atomic model writes
- Storage: deterministic reaction hash across web/native, Smaz
  double-decode, per-entry parsing, per-radio path history and regions,
  review-mode data isolation
- UI: safe channel slot selection, byte-length name limits, double-send
  guard, mounted checks, localized hardcoded strings
- Skip persisted-store reload on repeat SELF_INFO

Features:
- Radio default flood scope (firmware ver 11+) and explicit unscoped
  sends (ver 12+)
- Scan for nearby nodes (#570)
- Optional distinct first-hop repeater counting for channel resend (#589)
- Optional region next to hop count (#580)

Issues:
- Message text follows system font size (#569)
- Repeater/room password field accepts 20 chars (#576)
- TCP auto-reconnect and keepalive (#571)
- Order feeds by local receive time; flag future timestamps (#584)
- Coding rate help text (#568), French "Favoris" (#575)
- iOS/macOS app badge now clears

Translations for all new strings in every locale.
This commit is contained in:
zjs81 committed 2026-10-11 01:25:31 -07:00
1 parent a64a33d0c0
commit 25f197c979
120 files changed
+10424 -687

No files matched your search

@@ -0,0 +1,26 @@
import 'package:flutter/material.dart';
import '../l10n/l10n.dart';
import '../theme/mesh_theme.dart';
/// Small warning shown next to a message time when the sender's clock put
/// the timestamp well into the future (#584). The message itself is ordered
/// by when it arrived.
class FutureTimestampIndicator extends StatelessWidget {
final double size;
const FutureTimestampIndicator({super.key, this.size = 16});
@override
Widget build(BuildContext context) {
final label = context.l10n.chat_futureTimestampWarning;
return Tooltip(
message: label,
triggerMode: TooltipTriggerMode.tap,
child: Semantics(
label: label,
child: Icon(Icons.update, size: size, color: MeshPalette.warn),
),
);
}
}
+4 -2
View File
@@ -2,6 +2,8 @@ import 'dart:ui' as ui;
import 'package:flutter/material.dart';
import '../l10n/l10n.dart';
class GifMessage extends StatefulWidget {
final String url;
final Color backgroundColor;
@@ -147,7 +149,7 @@ class _GifMessageState extends State<GifMessage> {
if (_error != null) {
content = Center(
child: Text(
"Can't load GIF\nTap to retry",
context.l10n.gif_loadFailedRetry,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 12, color: widget.fallbackTextColor),
),
@@ -163,7 +165,7 @@ class _GifMessageState extends State<GifMessage> {
} else if (_image == null) {
content = Center(
child: Text(
'Tap to load GIF',
context.l10n.gif_tapToLoad,
textAlign: TextAlign.center,
style: TextStyle(fontSize: 12, color: widget.fallbackTextColor),
),
+310
View File
@@ -0,0 +1,310 @@
import 'dart:async';
import 'package:flutter/material.dart';
import '../connector/meshcore_connector.dart';
import '../connector/meshcore_protocol.dart';
import '../helpers/snack_bar_builder.dart';
import '../l10n/contact_localization.dart';
import '../l10n/l10n.dart';
import '../models/contact.dart';
import '../theme/mesh_theme.dart';
import 'mesh_ui.dart';
/// Opens the nearby-node scan (#570): a zero-hop DISCOVER_REQ whose answers
/// are listed live and can be added as contacts.
Future<void> showNodeScanSheet(
BuildContext context,
MeshCoreConnector connector,
) {
return showMeshSheet<void>(
context,
builder: (_) => NodeScanSheet(connector: connector),
);
}
class NodeScanSheet extends StatefulWidget {
const NodeScanSheet({super.key, required this.connector});
final MeshCoreConnector connector;
@override
State<NodeScanSheet> createState() => _NodeScanSheetState();
}
class _NodeScanSheetState extends State<NodeScanSheet> {
final List<NodeDiscoverResponse> _results = [];
final Set<String> _adding = {};
StreamSubscription<NodeDiscoverResponse>? _subscription;
bool _scanning = false;
bool _failed = false;
@override
void initState() {
super.initState();
_startScan();
}
@override
void dispose() {
_subscription?.cancel();
super.dispose();
}
void _startScan() {
_subscription?.cancel();
setState(() {
_results.clear();
_scanning = true;
_failed = false;
});
_subscription = widget.connector.discoverNearbyNodes().listen(
(response) {
if (!mounted) return;
setState(() {
_results
..add(response)
..sort((a, b) => b.snr.compareTo(a.snr));
});
},
onError: (Object _) {
if (!mounted) return;
setState(() => _failed = true);
},
onDone: () {
if (!mounted) return;
setState(() => _scanning = false);
},
);
}
bool _isContact(NodeDiscoverResponse response) {
final keyHex = response.publicKeyHex;
return widget.connector.contacts.any(
(contact) => contact.publicKeyHex.startsWith(keyHex),
);
}
Future<void> _add(NodeDiscoverResponse response) async {
final keyHex = response.publicKeyHex;
setState(() => _adding.add(keyHex));
final contact = widget.connector.contactForDiscoverResponse(response);
var imported = false;
try {
imported = await widget.connector.importDiscoveredContact(contact);
} catch (_) {
imported = false;
}
if (!mounted) return;
setState(() => _adding.remove(keyHex));
showDismissibleSnackBar(
context,
content: Text(
imported
? context.l10n.discoveredContacts_contactAdded
: context.l10n.contacts_contactImportFailed,
),
);
}
@override
Widget build(BuildContext context) {
final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
final status = _failed
? l10n.discoveredContacts_scanFailed
: _scanning
? l10n.discoveredContacts_scanning
: l10n.discoveredContacts_scanFound(_results.length);
return ConstrainedBox(
constraints: BoxConstraints(
maxHeight: MediaQuery.sizeOf(context).height * 0.85,
),
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.stretch,
children: [
BottomSheetHeader(
title: l10n.discoveredContacts_scanTitle,
subtitle: status,
),
Padding(
padding: const EdgeInsets.fromLTRB(20, 4, 20, 8),
child: Text(
l10n.discoveredContacts_scanExplanation,
style: TextStyle(fontSize: 14, color: scheme.onSurfaceVariant),
),
),
if (_scanning) const LinearProgressIndicator(minHeight: 3),
Flexible(
child: _results.isEmpty
? Padding(
padding: const EdgeInsets.all(24),
child: _scanning
? const SizedBox.shrink()
: Text(
l10n.discoveredContacts_scanNoResults,
textAlign: TextAlign.center,
style: const TextStyle(fontSize: 15),
),
)
: ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.symmetric(
horizontal: 12,
vertical: 8,
),
itemCount: _results.length,
itemBuilder: (context, index) =>
_buildResult(context, _results[index]),
),
),
Padding(
padding: const EdgeInsets.fromLTRB(16, 4, 16, 16),
child: FilledButton.icon(
onPressed: _scanning ? null : _startScan,
icon: const Icon(Icons.radar, size: 20),
label: Text(l10n.discoveredContacts_scanAgain),
),
),
],
),
);
}
Widget _buildResult(BuildContext context, NodeDiscoverResponse response) {
final l10n = context.l10n;
final scheme = Theme.of(context).colorScheme;
final contact = widget.connector.contactForDiscoverResponse(response);
final known = _isKnownNode(contact);
final inContacts = _isContact(response);
final adding = _adding.contains(response.publicKeyHex);
final color = _typeColor(response.nodeType);
return Padding(
padding: const EdgeInsets.symmetric(vertical: 4),
child: MeshCard(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
child: Row(
children: [
AvatarCircle(
name: contact.name,
size: 42,
color: color,
icon: _typeIcon(response.nodeType),
),
const SizedBox(width: 12),
Expanded(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Row(
children: [
Expanded(
child: Text(
contact.name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: const TextStyle(
fontWeight: FontWeight.w600,
fontSize: 16,
),
),
),
const SizedBox(width: 6),
StatusChip(
label: contact.typeLabel(l10n).toUpperCase(),
color: color,
icon: _typeIcon(response.nodeType),
),
],
),
const SizedBox(height: 4),
Row(
children: [
SignalBars(snr: response.snr, height: 16),
const SizedBox(width: 6),
Expanded(
child: Text(
l10n.discoveredContacts_scanSignal(
response.snr.toStringAsFixed(1),
response.remoteSnr.toStringAsFixed(1),
),
style: TextStyle(
fontSize: 13,
color: scheme.onSurfaceVariant,
),
),
),
],
),
const SizedBox(height: 2),
Text(
inContacts
? l10n.discoveredContacts_scanInContacts
: known
? contact.shortPubKeyHex
: l10n.discoveredContacts_scanNameLater,
style: MeshTheme.mono(
fontSize: 12,
color: scheme.onSurfaceVariant,
),
),
],
),
),
const SizedBox(width: 8),
if (inContacts)
Icon(Icons.check_circle, size: 24, color: MeshPalette.signal)
else if (adding)
const SizedBox(
width: 24,
height: 24,
child: CircularProgressIndicator(strokeWidth: 2),
)
else
IconButton(
tooltip: l10n.discoveredContacts_addContact,
icon: const Icon(Icons.person_add_alt_1),
onPressed: response.hasFullKey ? () => _add(response) : null,
),
],
),
),
);
}
bool _isKnownNode(Contact contact) =>
contact.isActive ||
widget.connector.discoveredContacts.any(
(c) => c.publicKeyHex == contact.publicKeyHex,
);
static Color _typeColor(int type) {
switch (type) {
case advTypeRepeater:
return MeshPalette.warn;
case advTypeRoom:
return MeshPalette.magenta;
case advTypeSensor:
return const Color(0xFF4ACCC4); // teal, as in the discovery list
default:
return MeshPalette.blue;
}
}
static IconData? _typeIcon(int type) {
switch (type) {
case advTypeRepeater:
return Icons.cell_tower;
case advTypeRoom:
return Icons.meeting_room;
case advTypeSensor:
return Icons.sensors;
default:
return null;
}
}
}
+7 -5
View File
@@ -2,6 +2,8 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:mobile_scanner/mobile_scanner.dart';
import '../l10n/l10n.dart';
/// A reusable QR code scanner widget that can be embedded anywhere.
///
/// Features:
@@ -277,17 +279,17 @@ class _QrScannerWidgetState extends State<QrScannerWidget>
switch (error.errorCode) {
case MobileScannerErrorCode.permissionDenied:
message =
'Camera permission denied.\nPlease enable camera access in settings.';
message = context.l10n.qr_cameraPermissionDenied;
icon = Icons.no_photography;
break;
case MobileScannerErrorCode.unsupported:
message = 'Camera not supported on this device.';
message = context.l10n.qr_cameraUnsupported;
icon = Icons.videocam_off;
break;
default:
message =
'Failed to start camera.\n${error.errorDetails?.message ?? ''}';
message = context.l10n.qr_cameraStartFailed(
error.errorDetails?.message ?? '',
);
icon = Icons.error_outline;
}
+14 -1
View File
@@ -526,6 +526,7 @@ class _ReceivedImageMessageState extends State<ReceivedImageMessage> {
png: png,
synthesized: entry.synthesized,
bytes: entry.bitstreamByteCount,
aspectRatio: entry.displayAspectRatio,
),
),
);
@@ -609,10 +610,15 @@ class _ReceivedImageViewer extends StatelessWidget {
/// the one in the transcript.
final int bytes;
/// Source shape (w/h) to undo the sender's stretch, as in the bubble. Null
/// means square or unknown.
final double? aspectRatio;
const _ReceivedImageViewer({
required this.png,
required this.synthesized,
required this.bytes,
this.aspectRatio,
});
@override
@@ -634,7 +640,14 @@ class _ReceivedImageViewer extends StatelessWidget {
Flexible(
child: Stack(
children: [
InteractiveViewer(child: Image.memory(png)),
InteractiveViewer(
// fill inside the original aspect box: the exact
// inverse of the sender's stretch, as in the bubble.
child: AspectRatio(
aspectRatio: aspectRatio ?? 1,
child: Image.memory(png, fit: BoxFit.fill),
),
),
if (synthesized)
const Positioned(
left: 0,
+2 -1
View File
@@ -52,6 +52,7 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
final savedPassword = await _storage.getRepeaterPassword(
widget.repeater.publicKeyHex,
);
if (!mounted) return;
if (savedPassword != null) {
setState(() {
_passwordController.text = savedPassword;
@@ -357,7 +358,7 @@ class _RepeaterLoginDialogState extends State<RepeaterLoginDialog> {
obscureText: _obscurePassword,
// Firmware stores at most 15 bytes (CommonCLI.h password[16]).
inputFormatters: const [
Utf8LengthLimitingTextInputFormatter(15),
Utf8LengthLimitingTextInputFormatter(20),
],
decoration: InputDecoration(
labelText: l10n.login_password,
+2 -1
View File
@@ -48,6 +48,7 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
final savedPassword = await _storage.getRepeaterPassword(
widget.room.publicKeyHex,
);
if (!mounted) return;
if (savedPassword != null) {
setState(() {
_passwordController.text = savedPassword;
@@ -294,7 +295,7 @@ class _RoomLoginDialogState extends State<RoomLoginDialog> {
obscureText: _obscurePassword,
// Firmware stores at most 15 bytes (CommonCLI.h password[16]).
inputFormatters: const [
Utf8LengthLimitingTextInputFormatter(15),
Utf8LengthLimitingTextInputFormatter(20),
],
decoration: InputDecoration(
labelText: l10n.login_password,