Skip to content

Flex picker: refresh discovered radios live while dialog is open#325

Closed
patrickrb wants to merge 1 commit into
devfrom
fix/flex-picker-live-discovery
Closed

Flex picker: refresh discovered radios live while dialog is open#325
patrickrb wants to merge 1 commit into
devfrom
fix/flex-picker-live-discovery

Conversation

@patrickrb

Copy link
Copy Markdown
Owner

Problem

When connecting to a FlexRadio over the network, the picker's "discovered radios" list only refreshed via a one-shot FlexRadioFactory event 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.flexRadios while 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

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

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 33.33333% with 8 lines in your changes missing coverage. Please review.
✅ Project coverage is 11.54%. Comparing base (bc6c21e) to head (4ac7575).

Files with missing lines Patch % Lines
...adio/ks3ckc/ft8af/ui/settings/ConnectionDialogs.kt 0.00% 8 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             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              
Files with missing lines Coverage Δ
.../radio/ks3ckc/ft8af/ui/settings/FlexPickerLogic.kt 100.00% <100.00%> (ø)
...adio/ks3ckc/ft8af/ui/settings/ConnectionDialogs.kt 0.00% <0.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

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 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 FlexPickerLogic helper functions to compute stable identity keys and detect when the displayed list actually changed.
  • Add pure unit tests covering FlexPickerLogic behavior.

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()
@patrickrb

Copy link
Copy Markdown
Owner Author

Consolidated into #329 (single combined PR) as requested.

@patrickrb patrickrb closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants