Skip to content

fix(qr): Preserve incoming channels when adding from QR#6013

Merged
jamesarich merged 1 commit into
meshtastic:mainfrom
jeremiah-k:bugfix/qr-add-channel-merge
Jun 29, 2026
Merged

fix(qr): Preserve incoming channels when adding from QR#6013
jamesarich merged 1 commit into
meshtastic:mainfrom
jeremiah-k:bugfix/qr-add-channel-merge

Conversation

@jeremiah-k

@jeremiah-k jeremiah-k commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Overview

This PR fixes QR ADD-mode channel preview construction so incoming channels are not silently removed before the user can review them.

The previous ADD-mode flow merged existing and incoming channels with .distinct(). That used raw ChannelSettings structural equality, which could remove an incoming channel before it appeared in the import preview. When that happened, later incoming channels could shift positions and the user had no way to inspect or recover the dropped entry.

ADD mode should preserve the current radio channels and show incoming channels in scanned order. This change makes the preview construction explicit: existing channels stay first, and incoming channels are appended without automatic deduplication.

This follows the related QR replacement work in #5999. That PR made REPLACE imports authoritative and sequential; this PR keeps ADD-mode previews non-lossy.

Key Changes

  • Replaced raw structural .distinct() merging in QR ADD mode.
  • Added explicit ADD-mode preview construction for existing and incoming channels.
  • Preserved existing channels in their current order.
  • Appended incoming channels in scanned order.
  • Kept structurally equal incoming channels visible instead of silently dropping them.
  • Left duplicate/conflict classification to a future follow-up.
  • Left QR REPLACE behavior unchanged.
  • Left channel write sequencing unchanged.

Testing

  • Added unit-test coverage for ADD-mode preview construction.
  • Covered preserving existing channels, appending incoming channels, preserving duplicate-looking incoming entries, preserving same-name/different-PSK entries, preserving same-PSK/different-name entries, preserving duplicate entries inside incoming, and empty-list cases.
  • Verified manually by deleting channels and re-adding them from QR/import flow.

Migration Notes

  • No user data migration is required.
  • Existing channel data remains unchanged until the user imports channels.
  • This only changes the QR ADD-mode preview behavior before the user accepts the import.

QR ADD-mode used structural `.distinct()` to merge existing and incoming
channel settings. Protobuf structural equality silently dropped incoming
channels that matched existing entries, shifting later channels to wrong
firmware indices and hiding them from the import preview.

Replace `.distinct()` with an explicit append-only merge. Every existing
channel is preserved at its position; every incoming channel is appended
in order. The user selects which incoming channels to keep via the
existing checkbox UI.
@github-actions github-actions Bot added the bugfix PR tag label Jun 29, 2026
@jeremiah-k jeremiah-k marked this pull request as ready for review June 29, 2026 16:02
@jamesarich jamesarich added this pull request to the merge queue Jun 29, 2026
Merged via the queue into meshtastic:main with commit 2dba958 Jun 29, 2026
17 checks passed
@jeremiah-k jeremiah-k deleted the bugfix/qr-add-channel-merge branch June 29, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants