Skip to content

fix(qr): add channels as key to remember block to fix add-channel rac…#4607

Merged
jamesarich merged 4 commits intomeshtastic:mainfrom
nreisbeck:fix/qr-add-channel-race
Feb 21, 2026
Merged

fix(qr): add channels as key to remember block to fix add-channel rac…#4607
jamesarich merged 4 commits intomeshtastic:mainfrom
nreisbeck:fix/qr-add-channel-race

Conversation

@nreisbeck
Copy link
Copy Markdown
Contributor

…e condition

The remember block on channelSet only keyed on shouldReplace, so it captured
the empty initial ChannelSet before channelSetFlow emitted the device's actual
channels. This caused "Add" mode to merge [] + [incoming] = [incoming], wiping
the user's existing channels and LoRa config. Adding channels as a key forces
recomputation when the real device channels load.

Related: #3464

And if you want to display the state before and after a change, you can use this table template:

Before After
-->

Closes #4606

…e condition

The remember block on channelSet only keyed on shouldReplace, so it captured
  the empty initial ChannelSet before channelSetFlow emitted the device's actual
  channels. This caused "Add" mode to merge [] + [incoming] = [incoming], wiping
  the user's existing channels and LoRa config. Adding channels as a key forces
  recomputation when the real device channels load.

  Related: meshtastic#3464
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Feb 20, 2026

CLA assistant check
All committers have signed the CLA.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@github-actions github-actions bot added the bugfix PR tag label Feb 20, 2026
@nreisbeck
Copy link
Copy Markdown
Contributor Author

CLA assistant check Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.You have signed the CLA already but the status is still pending? Let us recheck it.

Not sure why this double posted, and the CLA isn't showing in this message as signed, it was above.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes a critical race condition in the QR code channel scanning dialog that caused user data loss when adding channels. The bug occurred because the remember block computing the merged channel set was only keyed on shouldReplace, causing it to capture the empty initial ChannelSet() before the actual device channels loaded from the async StateFlow. This resulted in "Add" mode effectively doing [] + [incoming] = [incoming], wiping out existing channels and LoRa configuration.

Changes:

  • Added channels as a key to the remember block computing channelSet, forcing recomputation when the real device channels load from the StateFlow

@codecov
Copy link
Copy Markdown

codecov bot commented Feb 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 8.29%. Comparing base (e720a39) to head (8aecaa8).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@          Coverage Diff          @@
##            main   #4607   +/-   ##
=====================================
  Coverage   8.29%   8.29%           
=====================================
  Files        296     296           
  Lines      10782   10782           
  Branches    1666    1666           
=====================================
  Hits         894     894           
  Misses      9692    9692           
  Partials     196     196           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Copy Markdown
Collaborator

@jamesarich jamesarich left a comment

Choose a reason for hiding this comment

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

looks good, thanks for the fix

@jamesarich jamesarich enabled auto-merge February 21, 2026 00:56
@jamesarich jamesarich added this pull request to the merge queue Feb 21, 2026
github-merge-queue bot pushed a commit that referenced this pull request Feb 21, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Feb 21, 2026
@jamesarich jamesarich merged commit 7d7292a into meshtastic:main Feb 21, 2026
11 of 13 checks passed
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.

[Bug]: Scanning Android Channel QR causes Replace & LoRa reset

4 participants