Flex picker: refresh discovered radios live while dialog is open#325
Closed
patrickrb wants to merge 1 commit into
Closed
Flex picker: refresh discovered radios live while dialog is open#325patrickrb wants to merge 1 commit into
patrickrb wants to merge 1 commit into
Conversation
The FlexRadio network picker only refreshed its discovered-radio list via a one-shot FlexRadioFactory event listener that fired on the first add. Discovery typically takes a few seconds, so a radio that surfaced shortly after the dialog opened never appeared — the user had to close and reselect Network to get a fresh seed. Replace the listener with a 1s poll of FlexRadioFactory.flexRadios while the dialog is open, rebuilding the displayed list only when the discovered set actually changes (FlexPickerLogic.identityKey/listChanged) so the list doesn't recompose / reset scroll every tick. Covered by FlexPickerLogicTest. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #325 +/- ##
============================================
+ Coverage 11.51% 11.54% +0.02%
- Complexity 113 122 +9
============================================
Files 88 89 +1
Lines 12466 12469 +3
Branches 2230 2233 +3
============================================
+ Hits 1435 1439 +4
+ Misses 10900 10899 -1
Partials 131 131
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Pull request overview
This PR improves the FlexRadio network picker so the “discovered radios” list updates live while the dialog is open, addressing cases where discovery completes a few seconds after the dialog is shown.
Changes:
- Add a polling loop (1s interval) while the Flex picker dialog is open to refresh the discovered radio list.
- Introduce
FlexPickerLogichelper functions to compute stable identity keys and detect when the displayed list actually changed. - Add pure unit tests covering
FlexPickerLogicbehavior.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ft8af/app/src/main/kotlin/radio/ks3ckc/ft8af/ui/settings/ConnectionDialogs.kt | Replaces the one-shot Flex discovery listener with an in-dialog polling loop and conditional list rebuild. |
| ft8af/app/src/main/kotlin/radio/ks3ckc/ft8af/ui/settings/FlexPickerLogic.kt | Adds pure helper logic for stable radio identity keys and change detection. |
| ft8af/app/src/test/kotlin/radio/ks3ckc/ft8af/ui/settings/FlexPickerLogicTest.kt | Adds unit tests validating identityKey and listChanged semantics. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| } | ||
| override fun OnFlexRadioInvalid(flexRadio: FlexRadio) { | ||
| while (true) { | ||
| val latest = factory.flexRadios.toList() |
Owner
Author
|
Consolidated into #329 (single combined PR) as requested. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When connecting to a FlexRadio over the network, the picker's "discovered radios" list only refreshed via a one-shot
FlexRadioFactoryevent listener that fired on the first add. Discovery takes a few seconds, so a radio that surfaced shortly after the dialog opened never appeared — the user had to close the dialog and re-select Network to get a fresh seed of the list.Fix
Replace the one-shot listener with a 1-second poll of
FlexRadioFactory.flexRadioswhile the dialog is open, so newly discovered radios show up live without reopening. To avoid recomposing / resetting the list's scroll position every tick, the displayed list is rebuilt only when the discovered set actually changed, compared by a stable identity key.New pure helper
FlexPickerLogic:identityKey(serial, ip)— stable id per radio (serial, falling back to ip, trimmed).listChanged(displayedKeys, latestKeys)— whether a rebuild is needed.Test
FlexPickerLogicTest(pure JUnit4 + Truth): identityKey serial-preference / ip-fallback / trimming / empty; listChanged false when identical, true when a radio appears or drops off.🤖 Generated with Claude Code