Files
swiftcontrol/test/bluetooth/proxy
Jonas Bark 0004b9f863 fix(trainer): refuse same-device Bluetooth sharing and connect only one path of a twin trainer
Two impossible configurations kept landing in support.

Same device, Bluetooth transport: a Virtual Shifting bridge advertised over
Bluetooth can never be found by a trainer app on the device advertising it
(a BLE peripheral is invisible to a central on the same adapter). Under
Target.thisDevice the connection card no longer offers Bluetooth, and a
Bluetooth choice saved for the trainer resolves to WiFi — in one place,
ProxyDevice.savedRetrofitMode, shared by the auto-connect path and the card,
so neither starts a transport the other would not offer. The card says so
under the Virtual Shifting row (vsTransportSameDeviceNote) instead of
silently dropping the choice; the choice itself stays saved for when the app
moves to another device. A bridge that is already live over Bluetooth is
still shown as such, with WiFi tappable as the way out.

Twins: the same trainer discovered over both Bluetooth and WiFi (DirCon)
shares one trainerKey, so one tap's consent auto-connected both entries and
the two upstream paths fought over resistance. Connection.twinOf names the
pair; ProxyDevice.shouldAutoConnect is false while the twin holds the
trainer (read live — a cooldown would lift mid-ride); a manual connect on the
idle entry is a path switch: the sibling is disconnected in place (awaited,
kept listed as the way back) before this entry connects, with a bounded wait
for a still-in-flight sibling connect to unwind. The idle entry's list line
reads trainerTwinSubtitle, naming the transport currently in use. The
connection card's bridge status row now reads the device's own state
wrappers rather than the shared emulator, so a released twin's page no
longer lights up with the live twin's bridge.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-16 18:20:10 +02:00
..