Commit Graph
209 Commits
Author SHA1 Message Date
tthandClaude Opus 5.5 9489dee1c3 Merge upstream/dev: Android Auto as opt-in flavor, decluttered map overlay
build / build (push) Failing after 3m2s
Conflicts: the manifest keeps our unread widget receiver and drops the
Android Auto meta-data, which upstream moved to the androidAuto source set
(fe7e72a). Rename detection had moved our unread_widget_info.xml into that
source set with it; it stays in main. _mapChip is gone upstream with the
map overlay declutter (ed5884e), so our terminal-theme restyle of it goes
too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 19:00:11 +01:00
zjs81 603172b3ec Batch per-frame persistence so busy meshes don't stall the UI isolate
Every received packet copy re-saved its channel's whole history, every
unread change re-saved the channel list, and adverts/path records re-saved
full contact and path-history blobs. Under load the SharedPreferences
backlog starved the Dart event loop (frames and timers stopped), the radio's
offline queue overflowed, and CPU stayed pinned after traffic ended.

- Add CoalescedWrites: keeps the latest write per key and runs them once
  per window (750 ms; 5 s for path history). Writes start synchronously so
  stores still read the current scoped key.
- Flush before the app is backgrounded, on disconnect, before switching
  radios, before the channel slot map changes, before channel history
  reloads, before deleteChannel drops a list, and before path history
  reloads an evicted contact.
- Cap in-memory channel history at ChannelMessageStore.maxStoredMessages;
  storage already kept only that many, but the list grew unbounded during a
  session and every save grew with it.
- Cache Contact.publicKeyHex and build pubKeyToHex from a hex-digit lookup; it was
  rebuilt on every equality/hash and per-advert contact scan.

Load test (fake TCP radio, 350 contacts, 17 channels, 10-150 packets/s,
Linux profile build): CPU at 10 packets/s 104% -> 45%, recovers to idle
after traffic instead of staying at 160%, and queued messages drained went
from 555 to 3237 over the same run.
2026-10-24 23:38:28 -07:00
zjs81 a4670a9275 Add a setting to show link images in all chats by default
'Show link images in all chats by default' (default off) applies to
every channel and contact without an explicit per-chat choice: the
per-chat setting is now unset/on/off and resolves to perChat ?? default.
The 'Load images from links' master switch still overrides it.
2026-10-24 22:01:30 -07:00
zjs81 79e3668c18 Add a global switch to stop loading images from links
'Load images from links' (default on) gates every link image fetch in
MessageUrlImageHelper: chat previews, notification images, ipfs://
resolution and pyx/ibb scraping. Per-chat toggles keep their values but
are disabled while it is off. IPFS uploads are unaffected.
2026-10-24 22:01:29 -07:00
zjs81 7e7e7a48db Merge remote-tracking branch 'origin/dev' into pr-593
# Conflicts:
#	lib/models/app_settings.dart
#	lib/screens/channel_chat_screen.dart
#	lib/screens/chat_screen.dart
#	untranslated.json
2026-10-24 21:45:13 -07:00
zjs81 21098f1c34 Merge branch 'dev' into feat/dns-node-banner 2026-10-24 21:38:46 -07:00
zjs81 69693f5a89 Accept plain-text values in the node banner record
Only ';' needs encoding, so the title and body fit in one TXT string.
Values that aren't valid percent-encoding are used as-is instead of
hiding the banner.
2026-10-24 21:33:14 -07:00
zjs81 ee382f9177 Configure the connect screen's node banner from a DNS TXT record
The "get a node" banner's link, and optionally its title, body and button
text, now come from the _banner.meshcoreopen.org TXT record, looked up
over Cloudflare DNS-over-HTTPS and cached for the record's TTL (1 min to
6 h). The record is `v=1;on=1;url=<https link>` with URL-encoded values;
`on=0`, a missing record or any lookup failure hides the banner.
2026-10-24 21:29:08 -07:00
zjs81 7c2f481520 Merge remote-tracking branch 'origin/dev' into fix/ui-issues
# Conflicts:
#	untranslated.json
2026-10-24 21:13:02 -07:00
zjs81 471a2b6a5e Merge branch 'dev' into issue-37-selective-notifs 2026-10-24 21:04:26 -07:00
zjs81 1e786b24ba Make the map path trace builder explicit and keep its state
The builder panel now labels its actions, lets the user pick round trip
or as-entered with an explanation, and only sends when "Run path trace"
is pressed. Hops, mode and the last result are kept in UiViewStateService
for the session, so going back no longer clears them and the last result
can be reopened without sending again.
2026-10-24 21:02:19 -07:00
zjs81 caf20b4415 Summarize location, image and GIF messages in notifications
Notification bodies now use the chat's parsers to show a localized
summary for shared locations (m: markers), channel images, GIFs and
reactions instead of the raw payload. The marker parser moves out of the
map screen into helpers/marker_message.dart so the service can use it.
2026-10-24 21:01:06 -07:00
zjs81 f667320608 Fix review findings in channel notification modes
- Detect mentions on the original text, as @[name] or a whole-word @name
- Save and restore the full mode map in review mode
- Open the mode picker from the chat bell and show the mode in its tooltip
- Share one mode picker sheet; fix the stale sheet context
- Persist modes by name and skip unknown entries
- Keep writing muted_channels so older builds keep the user's mutes
- Remove the muteChannel/unmuteChannel/isChannelMuted shims
- Update notifications docs to match the behaviour
2026-10-24 20:46:49 -07:00
zjs81 b6c1d73bf0 Fix review findings in low battery alerts
- Respect the notifications-enabled setting
- Notify only the lowest newly crossed threshold
- Ignore implausible readings (boards without a battery sensor report 0 mV)
- Wait for the device identity so the saved chemistry is used
- Require two consecutive low readings before alerting
- Re-arm and clear alerts on any link reset, not just explicit disconnect
- Cancel stale notifications on re-arm and link reset
- Scope notification ids per device and name the device in the body
- Use the connector's shared NotificationService
2026-10-24 20:45:14 -07:00
edouard caad3dd703 feat: add per-channel notification modes (all/mentions only/muted)
- Add ChannelNotificationMode enum with all, mentionsOnly, muted options
- Replace mutedChannels Set with channelNotificationModes Map for per-channel settings
- Add mention detection for @username in channel messages
- Update channels list and chat UI with notification mode selector
- Add localization strings for new notification modes
- Automatic migration from old mutedChannels to new system
- Update user documentation
- Preserve backward compatibility with existing mute/unmute API
2026-10-23 22:37:49 +02:00
tthandClaude Opus 5.5 b16314cf39 Widget: show a closed app and a disconnected companion
The third line reads "cmp off" (amber) when the companion is
disconnected and "app off" (red) when the app is closed: at once from
MainActivity.onDestroy, or when the bridge's 5-minute heartbeat has been
missing for 15 minutes (process killed). The widget now refreshes every
30 minutes so it notices the latter. Counts dim while the app is off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-23 10:19:41 +02:00
tthandClaude Opus 5.5 36806e289d Home-screen widget 1x1: unread DMs, unread channels, companion battery
build / build (push) Successful in 16m14s
A terminal-style Android widget (UnreadWidget.kt):

    dm 3
    ch 12
    bt 87%

Counts turn green when non-zero, the battery red at 20 % and grey when
the companion is disconnected (last known level kept). Tapping opens the
app. HomeWidgetBridge pushes the values over a method channel only when
they change; they are kept in SharedPreferences so the widget survives
the app being closed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-22 22:53:07 +02:00
ZIERandCopilot 4000c49213 Merge zjs81/dev into ez_share_urlimage_PR
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-10-13 10:16:13 +02:00
shortwavesurfer2009 7d55bf03df Merge remote-tracking branch 'upstream/dev' into battery_percent_warning_android 2026-10-12 10:59:41 -04:00
zjs81 e614fb32e2 Address review: consent race, unsigned advert bytes, antimeridian
- Uploads carry a consent generation: nothing is sent if sharing is
  turned off while a batch is being prepared, and a late response never
  touches a queue that was cleared and refilled
- Parse only the signed 32 advert app-data bytes, as the firmware does,
  so appended unsigned bytes can't add the hidden marker or change the
  name
- Split online map requests that cross the antimeridian into two valid
  boxes and merge the results
- README: link the network map next to the website
2026-10-11 22:09:08 -07:00
zjs81 c18b509d7e Merge remote-tracking branch 'origin/dev' into feat/network-map
# Conflicts:
#	lib/connector/meshcore_connector.dart
2026-10-11 21:55:22 -07:00
zjs81 bc14de586f Add opt-in network map uploads and online map view
- Opt-in upload of header-only packet records and repeater/room server
  adverts to map.meshcoreopen.org about once a minute; payloads, channel
  and DM hashes and transport codes are stripped on the phone, locations
  snapped to a ~2 km grid, install ID rotates daily
- One-time opt-in dialog on first radio connection; toggle and status in
  App settings
- Local / Online / Both switch on the map screen with online repeater
  hexagons, links, add-to-contacts and manage
- Node purchase banner on the connect screen (affiliate link, disclosed)
- Privacy policy and network map documentation
- Translations for all locales
2026-10-11 21:54:16 -07:00
zjs81 679116ed03 Key per-channel storage by PSK-derived channel ID
Channel messages, settings, region, order and images were persisted by
radio slot index, so a slot reused for a different channel inherited the
old channel's history and settings (#359).

- Channel.storageId: first 8 bytes of SHA-256("meshcore-channel:" + psk).
- All per-channel stores key by channel ID; in-memory state stays by slot.
- The connector keeps a slot -> channel ID map, diffs it against the saved
  map on every channel sync and reloads slots whose channel changed.
- Queued channel frames wait until this session's map is confirmed.
- One-shot per-radio migration from slot keys, using the cached channel
  list the legacy data was written under; rerun-safe if interrupted.
- Deleting a channel clears its data; a channel removed elsewhere keeps its
  history and gets it back when re-added. A PSK edit keeps its place in
  the custom order.
- Slots sharing a PSK share history and settings.
- Image entries record their channel ID; a slot change resets that slot's
  in-progress reassembly.
2026-10-11 17:52:59 -07:00
zjs81 88dcc5943f UI refresh: shared widgets, screen cleanups, and full translations
- Extract reusable widgets (chat composer/send pipeline, message bubble
  frame, reaction chips, path map scaffold, radio settings dialog,
  translation settings section, map POI clusters, nav tiles, etc.) and
  slim down the screens that used them
- Map: hide/remove markers with restore, confirm before setting node
  location, POI clustering, semantics labels
- Map cache: cancellable downloads and a bulk tile limit
- Repeater: unsaved-changes guard, CLI search/copy/share transcript,
  framed-command debug preview, disconnected banner
- Confirm before clearing chats and debug logs
- Keep cached unread totals in sync on per-contact/channel updates
- Move remaining hardcoded strings into l10n and translate the 98 new
  keys into all 17 non-English locales
2026-10-11 15:17:01 -07:00
ericz a4a7e00732 upload url image or file to ipfs 2026-10-11 13:14:14 +02:00
zjs81 616c433922 Let entry cap remove spent outgoing images; clarify channel row arrival ordering
Outgoing image entries were excluded from the maxEntries cap, and age
eviction only marks them evicted, so frequent senders accumulated entries
and sidecars without bound. Outgoing entries with nothing left on disk (or
failed) are now eligible, oldest first.

Rename _ChannelChatRow.timestamp to receivedAt: it already returned the
local arrival time used for sorting and day separators.
2026-10-11 01:37:36 -07:00
zjs81 25f197c979 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.
2026-10-11 01:25:31 -07:00
zjs81 956c779e2c Merge branch 'dev' into ez_disable_discoveredContact_eviction_PR 2026-10-07 20:59:37 -07:00
shortwavesurfer2009 296eab20ca Add low battery notification channel with threshold alerts 2026-10-04 01:26:36 -04:00
zjs81 25f8d6ae27 Add notification replies, Android Auto support, and channel mute bell
- Message notifications use Android MessagingStyle with Reply, Mark as read,
  and Mute channel actions, so they work in Android Auto and on watches
- Replies go through the normal send path (length limits, SMAZ, Cyr2Lat,
  retries), split into up to 3 messages, and report failures
- Declare Android Auto notification support and register the action receiver
- Add a bell icon to channel chat to mute/unmute; unify the channel mute key
  so unnamed channels mute correctly
- Update README and docs for Android Auto support
2026-09-27 21:55:43 -07:00
zjs81 d74c280ea3 Fix USB buffer leak on dispose and guard fl_free against orphaned close
dispose() no longer relies on FlSerial.closePort() to free the I/O buffers:
it checks the buffers' first byte instead of their address, so it usually
leaked both. Close via fl_close and always free by address.

A native close still running in a helper isolate is invisible to a fresh
isolate after hot restart, so connect() could fl_free() a slot mid-close.
Track the in-flight close with a per-process temp marker and wait for it
(bounded to 45s) before resetting the slot table.
2026-09-27 11:50:55 -07:00
zjs81 8b8715cfda Merge remote-tracking branch 'origin/dev' into fix/usb-serial-nonblocking-close
# Conflicts:
#	pubspec.yaml
2026-09-27 11:50:25 -07:00
zjs81 0e8a8bd8c4 Add unit tests for ChannelMessage replies and update untranslated.json with new translations 2026-09-25 13:23:07 -07:00
Zach d74587c167 Refactor LoRa airtime tests and add new functionality
- Updated LoRa airtime calculations in `lora_airtime_test.dart` to reflect new reference values.
- Introduced new tests for LDRO behavior and preamble symbol calculations.
- Added `contact_path_width_test.dart` to validate path hash width handling in contacts.
- Enhanced `model_changes_test.dart` to ensure legacy data migration works correctly.
- Created `remote_node_stats_test.dart` to decode and validate remote node statistics.
- Implemented `map_marker_parse_test.dart` for parsing marker text with coordinate validation.
- Developed `map_tile_cache_key_test.dart` to ensure API keys are excluded from cache keys.
- Added `message_retry_failure_test.dart` to test message retry service behavior on failures.
- Extended `path_history_service_test.dart` to preserve learned state across path attempts.
- Enhanced `received_image_store_test.dart` to handle concurrent writes and review fixes.
- Implemented `repeater_command_service_test.dart` to validate command response handling.
- Created `store_tolerant_parsing_test.dart` to ensure stores skip malformed records gracefully.
- Cleared untranslated JSON file for localization updates.
2026-09-25 10:01:18 -07:00
ericz 213f3e3971 update to zjs81/dev commit d5f54df 2026-09-21 15:59:53 +02:00
Gianluca Boiano 2910dc9f67 Apply dart format 2026-09-17 23:12:52 +02:00
Gianluca Boiano 1b5ebf6834 Honor manual disconnect and re-validate state after waiting
Sixth review round:

- disconnect(manual: true) joining an in-flight automatic teardown now
  still marks it manual (and cancels the reconnect timer / stops the
  background service), so a user-initiated disconnect can no longer be
  followed by an auto-reconnect scheduled by the teardown it joined.
- _shouldAutoReconnect is false once _disposed, so a teardown that
  outlives disposal cannot arm a timer that calls connect() on a disposed
  connector.
- connect()/connectUsb()/connectTcp() and UsbSerialService.connect()
  re-check the connection state after awaiting the in-flight teardown.
  The await is a suspension point, so two callers could previously pass
  the initial guard, resume together and both run the open sequence.
2026-09-17 23:05:43 +02:00
Gianluca Boiano fa9e9d18cd Suppress connector state publication after dispose
Fifth review round:

- MeshCoreConnector.dispose() sets _disposed, and _setState(),
  notifyListeners() and markNotifyDirty() no-op afterwards. A teardown
  started before disposal can still be running (the USB native close waits
  out the kernel's closing_wait off the UI isolate), and its tail would
  otherwise call notifyListeners() on a disposed ChangeNotifier.
- _handleSerialData() now only drops callbacks in the teardown states
  (disconnecting/disconnected) instead of everything that is not
  `connected`, so data arriving in the `connecting` window is still
  ingested and buffered by the frame decoder.
2026-09-13 15:42:34 +02:00
Gianluca Boiano fb7958a52e Serialize connects against the connector-level teardown
Fourth review round:

- UsbSerialService.connect() now waits for _activeDisconnect before it
  claims the `connecting` status, covering the Android USB-host path too;
  previously the wait sat inside the desktop branch, so an Android
  reconnect could still be overwritten by the old teardown.
- MeshCoreConnector.disconnect() is now a re-entrant-safe wrapper around
  _disconnectInternal() that publishes the teardown as _activeDisconnect,
  and connect()/connectUsb()/connectTcp() join it before starting. The
  transport-level guard alone could not prevent the connector's own
  teardown tail from setting the state back to `disconnected` after a new
  connection was up. Repeat disconnect() calls now join the in-flight
  teardown instead of returning early while it is still running.

flutter analyze clean; flutter test 570 passing, 2 pre-existing failures
in message_url_image_helper_test.dart (identical on a stashed tree);
flutter build linux --debug succeeds.
2026-09-13 15:33:44 +02:00
Gianluca Boiano 10f557e811 Serialize reconnect against the whole disconnect teardown
Third review round:

- disconnect() is now a re-entrant-safe wrapper around _disconnectInternal()
  whose future is held in _activeDisconnect for the entire teardown, not just
  the native close. connect() and dispose() wait on that instead of
  _pendingNativeClose, so a reconnect can no longer open a new port and then
  have the tail of the old teardown mark it disconnected.
- dispose() closes on any live handle (flh >= 0) instead of only when
  isOpen() reports `open`: flserial keeps a valid slot and a running
  SerialThread in the I/O error state, which would otherwise have been
  orphaned. A setDTR() failure no longer skips the close.
- _releaseSerialBuffers() takes alreadyFreed: closePort() frees both buffers
  but leaves the pointer fields dangling, so after a successful synchronous
  close the fields are only cleared, never freed a second time.

Builds: flutter build linux --debug succeeds (after patching the unrelated
glibc >= 2.42 / tinycthread once_flag clash in the flserial checkout).
2026-09-13 13:12:35 +02:00
Gianluca Boiano b0b5016806 Serialize reconnect and teardown around the pending close
Second review round:

- connect() awaits _pendingNativeClose before touching flserial's global
  slot table. fl_close() (helper isolate) and fl_free()/fl_init() mutate
  the same flserial_tab, so reconnecting during the kernel's closing_wait
  could double-close the old slot or kill the freshly opened one.
- dispose() no longer re-enters disconnect() when a close is in flight;
  the running disconnect owns the ordering (native close, then
  subscription cancel), so dispose only chains _closeFrameController onto
  the pending close.
- dispose() frees the I/O buffers through the new _releaseSerialBuffers()
  on every path, not just after a successful closePort(); with _serial
  nulled, an error/closed-state dispose used to leak both 8 KiB buffers.
- _handleSerialData() ignores callbacks once the status leaves `connected`:
  a callback queued before flh was invalidated made readList() throw and
  published a spurious transport error mid-teardown.
2026-09-13 13:01:16 +02:00
Gianluca Boiano 9a90d1f448 Coordinate dispose() with the off-isolate close
Review follow-up:

- dispose() now takes ownership of the FlSerial (nulls _serial) and clears
  serialReadBuff/serialWriteBuff after the synchronous closePort(); flserial
  frees those buffers but leaves the pointer fields dangling, so a later
  disconnect() reaching _closePortOffUiIsolate() with the same object would
  have freed them a second time. _closePortOffUiIsolate() additionally
  returns early when flh is already -1.
- dispose() skips its synchronous close when a close is already in flight:
  fl_close() sets breakThread and joins the SerialThread before it reaches
  the blocking ::close(), so the thread — and its NativeCallable — is
  already gone while the helper isolate waits out closing_wait. The
  in-flight future is tracked in _pendingNativeClose.
- If Isolate.run itself fails the port is now closed inline rather than
  leaking a native slot and SerialThread with no reachable handle.
2026-09-13 12:50:06 +02:00
Gianluca Boiano 4a25f718a8 Close USB serial port off the UI isolate
close(2) on a tty whose output the peer never drained blocks in the
kernel for the line discipline's closing_wait (measured 30.4s on Linux
against a CDC-ACM device that never reads its bulk OUT endpoint, e.g. a
MeshCore board flashed with a BLE-only companion build). FlSerial's
closePort() is a synchronous FFI call, so the whole app froze for that
window on every failed USB connect and on disconnect.

fl_close() only touches process-global native state, so run it through
Isolate.run() and replicate the Dart-side cleanup closePort() does
(stream close, calloc'd I/O buffers, flh reset). Log when the close
exceeds 1s so the "device is not draining" case is visible in the debug
log.

Verified against the wedged device: inline close blocked the calling
isolate for 30476ms with 0 timer ticks; the isolate close took 30302ms
with 302 ticks, i.e. the main isolate stayed responsive throughout.
2026-09-13 12:30:51 +02:00
hdhog d791570213 fix: use explicit time <epoch> for repeater clock sync
Companion firmware (MeshCore commit 4a869163, 2025-12-30) replaces the
CLI frame timestamp with the companion node's RTC for TXT_TYPE_CLI_DATA,
so "clock sync" sets the repeater clock to the node RTC. Nodes with a
wrong RTC push repeater clocks years into the future; firmware cannot
set the clock backwards without clkreboot.

- RepeaterCommandService: translate "clock sync" to "time <phone epoch>"
  before sending, matching official meshcore-cli behavior
- repeater login dialog: send "time <epoch>" for auto clock sync after
  login (this path bypasses RepeaterCommandService)
- add unit tests for the command translation

Ref: https://github.com/zjs81/meshcore-open/issues/464
2026-09-09 22:31:11 +04:00
ericz 4480c0d356 Merge remote-tracking branch 'zjs81/dev' into ez_disable_discoveredContact_eviction_PR 2026-09-08 18:09:32 +02:00
ericz 6786c3348f update zjs81/dev 724696cd3c and fix image preview position. 2026-08-11 20:30:14 +02:00
ericz 1dbb487fe7 fix dart analyze bracket error. 2026-08-11 19:26:41 +02:00
zjs81 cf6c93c50a rebuild translations 2026-08-11 00:15:45 -07:00
Zach eee72b4c65 Add ability to send images over lora 2026-08-10 23:20:46 -07:00
ericz d920449cbb Add Contact and Channelsettings to explicitly enable Picture preview. 2026-08-10 22:21:10 +02:00