Skip to content

refactor(connections): Show one active transport pane#5956

Merged
jamesarich merged 6 commits into
meshtastic:mainfrom
jeremiah-k:bugfix/connections-active-transport-pane
Jun 25, 2026
Merged

refactor(connections): Show one active transport pane#5956
jamesarich merged 6 commits into
meshtastic:mainfrom
jeremiah-k:bugfix/connections-active-transport-pane

Conversation

@jeremiah-k

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

Copy link
Copy Markdown
Contributor

Overview

This pull request simplifies the Connections screen by replacing the old multi-section transport filters with a single active transport pane.

Before this change, the screen could show Bluetooth, Network, and USB sections at the same time, with separate scan controls inside the Bluetooth and Network sections. That made the page feel split across multiple discovery modes instead of centered on the interface the user is actively working with.

This change makes the selected transport explicit: Bluetooth, Network, or USB. The screen now shows only the selected transport’s devices and actions, while keeping the global connection card visible regardless of the active pane.

This is intended as a focused step toward a more unified Connections experience. It keeps the behavior and layout changes scoped to the transport selection model, while leaving room for follow-up polish to spacing, visual hierarchy, and broader layout refinements.

Key Changes

  • Replaced the inclusive Bluetooth / Network / USB visibility filters with a single selected transport pane.

  • Added a persisted selected transport preference so the Connections screen can reopen on the user’s last active pane.

  • Migrated legacy transport visibility preferences to the new selected-pane preference fallback.

  • Derived the initial pane from the selected device when no explicit pane preference exists.

  • Added a single-choice transport selector for Bluetooth, Network, and USB.

  • Updated the device list so exactly one pane is rendered at a time:

    • Bluetooth shows Bluetooth devices and one Scan action.
    • Network shows discovered and recent TCP devices, manual add, and one Scan action.
    • USB shows USB/serial devices with no Scan action.
  • Added a quiet USB empty-state message when no USB devices are detected.

  • Kept BLE and Network discovery mutually exclusive.

  • Stopped incompatible scans when switching panes, including cases where the pane is already active but stale scan state needs cleanup.

  • Started screen-entry auto-scan from the active pane and persisted auto-scan preferences, including preferences that load after initial composition.

  • Gated screen-entry auto-scan so it does not start discovery when a selected device is already available for reconnect.

  • Ensured disposed panes always stop their owned scan so discovery does not continue behind the visible pane.

  • Kept the global selected-device connection card visible regardless of the active pane, while recording the matching transport pane when a device is selected.

  • Updated previews, screenshot coverage, README documentation, and tests for the single-pane model.

Testing

  • Added ScannerViewModelTest coverage for active transport defaults, selected-device fallback, explicit pane selection, scan stopping, auto-scan gating, selected-device transport recording, and manual TCP selection.
  • Updated ScannerViewModelTest setup so each test gets isolated scanner state.
  • Added UiPrefsImplTest coverage for selected transport migration from legacy visibility preferences, including explicit preference, invalid preference fallback, no legacy keys, all-visible legacy state, BLE-hidden legacy state, and USB-only legacy state.
  • Updated UiPrefsImplTest setup so each test gets a fresh coroutine scope that is cancelled during cleanup.
  • Smoke-tested the F-Droid debug build while exercising the Connections screen.
  • Verified no fatal crash, ANR, or app-process failure in the collected debug log.

Migration Notes

  • No user data migration is required.
  • Existing Bluetooth, Network, and USB address formats are unchanged.
  • Existing localized transport_* resource keys are preserved.
  • The selected device remains visible independently from the active transport pane.
  • USB remains presence-driven and does not introduce a scan action.

Replace the Connections screen's inclusive BLE, Network, and USB visibility filters with a single persisted DeviceType transport pane. Derive the initial pane from the selected device when no explicit pane preference exists, and retain a light fallback for legacy filter preferences.

Wire pane selection through ScannerViewModel so switching panes stops incompatible scans, auto-scan only starts for the active BLE or Network pane, and USB remains row-driven without scan actions. Update the device list, previews, screenshot wrapper, and focused ViewModel tests around the new active-pane behavior.
Key the screen-entry scan effects on the active transport pane so a persisted TCP or USB preference can stop an initially eligible BLE scan and start the correct network scan when permission is granted. Stop scans unconditionally on effect disposal — the stop calls are idempotent and the effect keys already define the pane lifetime, so a pane change caused by asynchronous preference loading always stops scans owned by the old effect.

Replace preview magic RSSI values with a named constant, re-baseline the transport selector screenshots for the new FlowRow layout, and rename the screenshot test and reference images from ScreenshotTransportFilterChips to ScreenshotTransportSelector.
Replace the generic 'Connect the device via serial or USB.' hint with the more actionable 'Connect a device with a USB data cable to use serial.' Charging-only cables are the most common reason USB discovery returns nothing, and the new copy names that explicitly.

Also align the title with USB's passive detection model ('No USB devices detected' rather than 'seen') to distinguish it from the scan-based BLE and Network panes.
Tighten the legacy transport-preference migration, scan lifecycle, and documentation for the single-active-transport-pane model:

- UiPrefsImpl: check legacy transport keys directly on Preferences instead of materializing the full map. Use firstOrNull() so a user who hid BLE but left Network/USB visible falls back to a still-visible pane rather than the one they hid.
- UiPrefsImplTest: add focused tests for the legacy migration paths including explicit-wins, invalid-fallback, null-default, all-visible, BLE-hidden, and USB-only cases.
- ScannerViewModel: guard selectTransport against no-op reselection to avoid a redundant DataStore write. Add a selected-device guard to startNetworkAutoScan matching the BLE equivalent so NSD discovery does not fire when a TCP device is already selected.
- Connections README: refresh the feature summary, ScannerViewModel API list, and sealed-class documentation for the new single-pane model and Replay device entry.
@github-actions github-actions Bot added bugfix PR tag refactor no functional changes labels Jun 25, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📄 Docs staleness check — advisory

This PR modifies user-facing UI source files but does not update any page under docs/en/user/ or docs/en/developer/.

⚠️ Doc changes propagate to 3 consumers: in-app docs browser, Jekyll site (GitHub Pages), and meshtastic.org (Docusaurus sync). Updating a page in docs/en/ automatically flows to all three.

Changed source files:

core/ui/src/commonMain/kotlin/org/meshtastic/core/ui/util/NetworkTransportInfo.kt
feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/ConnectionsScreen.kt
feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/components/DeviceList.kt
feature/connections/src/commonMain/kotlin/org/meshtastic/feature/connections/ui/components/TransportSelector.kt

What to check:

Changed area Likely doc page
feature/messaging/ docs/en/user/messages-and-channels.md
feature/node/ docs/en/user/nodes.md or docs/en/user/node-metrics.md
feature/map/ docs/en/user/map-and-waypoints.md
feature/connections/ docs/en/user/connections.md
feature/settings/ docs/en/user/settings-radio-user.md or docs/en/user/settings-module-admin.md
feature/firmware/ docs/en/user/firmware.md
feature/intro/ docs/en/user/onboarding.md
feature/discovery/ docs/en/user/discovery.md
feature/docs/ Internal docs infrastructure
core/ui/ docs/en/developer/codebase.md or component-specific user pages

New page checklist (if adding a new doc page):

  1. Create the .md file in docs/en/user/ or docs/en/developer/ with last_updated frontmatter
  2. Register in DocBundleLoader.kt with string resources (in-app browser)
  3. Jekyll and Docusaurus sync pick up new pages automatically — no config change needed

If this PR does not require a doc update (e.g., internal refactor, bug fix, test change), add the skip-docs-check label to dismiss this check.

Cross-platform note: This check is advisory while doc coverage matures. Both Android and Apple repos use the same skip-docs-check label and advisory severity. See meshtastic/design standards for shared conventions.

@jeremiah-k jeremiah-k marked this pull request as ready for review June 25, 2026 18:14
@jamesarich

Copy link
Copy Markdown
Collaborator

Before we get too much further on connection screen ui - this is slated as an upcoming rework for cross-platform compliance. I'm gonna say hold off an anything more for now, and once the new design is specced out - I can pass it off for implementation if you'd like.

@jamesarich jamesarich added this pull request to the merge queue Jun 25, 2026
@jeremiah-k

Copy link
Copy Markdown
Contributor Author

@jamesarich Sounds good. I tried to keep this scoped to the connection lifecycle cleanup and the existing screen model. I don't have a strong opinion on how it should look beyond wanting the connection paths to stay clear and predictable. I'd be happy to implement when it's specced out.

Merged via the queue into meshtastic:main with commit 33a4ca6 Jun 25, 2026
23 checks passed
@jeremiah-k jeremiah-k deleted the bugfix/connections-active-transport-pane branch June 25, 2026 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix PR tag refactor no functional changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants