refactor(connections): Show one active transport pane#5956
Conversation
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.
📄 Docs staleness check — advisoryThis PR modifies user-facing UI source files but does not update any page under
Changed source files: What to check:
New page checklist (if adding a new doc page):
If this PR does not require a doc update (e.g., internal refactor, bug fix, test change), add the
|
|
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 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. |
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:
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
ScannerViewModelTestcoverage for active transport defaults, selected-device fallback, explicit pane selection, scan stopping, auto-scan gating, selected-device transport recording, and manual TCP selection.ScannerViewModelTestsetup so each test gets isolated scanner state.UiPrefsImplTestcoverage 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.UiPrefsImplTestsetup so each test gets a fresh coroutine scope that is cancelled during cleanup.Migration Notes
transport_*resource keys are preserved.