Commit Graph

1080 Commits

Author SHA1 Message Date
Jonas Bark
8a2d83139b feat(trainer): cycle the bridge connection when the control protocol changes
Trainers latch their control session to the protocol live at connect
time, so a switch only takes real effect on a fresh connection (Jonas
verified on hardware via the manual Bridge disconnect/reconnect). Both
switch sites — the VS-options selector and the self-test verdict CTA —
now run ProxyDevice.reconnectUpstream(), which mirrors the
ConnectionCard cycle and waits for the reseeded definition. Inert picks
(same effective delivery) skip the cycle.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 15:33:57 +02:00
Jonas Bark
253cc0557b Merge self-test: resistance self-test + control-protocol delivery toggle
# Conflicts:
#	prop
2026-08-20 15:15:45 +02:00
Jonas Bark
1d1a0dbf72 feat(click v2): keep the right puck awake, and say when it can't
The right puck switches itself off after a minute of not being used.
BikeControl now prevents that on its own, with no button to press. The
sequence lives in prop; this side supplies what only it knows and shows
the rider the one case they can fix.

- the gate reads raw adverts, not the device list: the sibling only has
  to be nearby, and a left puck the rider ignored — every left puck in
  right-side-only mode — still counts. Discovery is also the retrigger,
  since an ignored puck never completes a handshake
- an optional step on the controller card, and a note on the right puck's
  own card, when no left puck is in range. An offer, never a blocker
- drops the D-pad line from "use the right side only"

Fixes a related bug: the controller link counted every undone step,
optional or not, so an optional offer alone turned a working controller
amber and held back "Ready to ride". The other two links already
excluded optional steps.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 14:55:15 +02:00
Jonas Bark
0191fcc990 feat(trainer): control-protocol selector in VS options, persisted per trainer
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 13:38:32 +02:00
Jonas Bark
9ba09657a1 fix(controller): firmware hints now point at the Zwift Companion app
Riders who can't find their controller are told the firmware may be out of
date, but never where to update it — a support report showed someone had no
idea updates run through the Zwift Companion app.

- name the Companion app in every firmware hint and give each one an action
  that opens it (scan-time Zwift Ride toast, missing-custom-service alert,
  newer-firmware-available alert)
- add a firmware tip with the same link to the onboarding "no controllers
  found" state, where riders actually get stuck
- localize the three hints, which were hardcoded English, across all 6 locales

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 20:23:48 +02:00
Jonas Bark
ff9671bfc5 fix: no crash on button press when no keymap is set
The keymap ('app') and the trainer app ('trainer_app') are independent
prefs. When the keymap one is missing while a trainer app is selected,
actionHandler.supportedApp stays null — every button press then threw
"Null check operator used on a null value" and the device registered no
buttons at all, so the SRAM edit screen came up empty.

- RemoteActions/DesktopActions/AndroidActions no longer dereference
  supportedApp (or getKeyPair) with `!`; they return the same
  noKeymapSet / noActionAssigned Error BaseActions already produces.
- Fall back to the selected trainer app when the keymap pref can't be
  resolved (initializeActions, Settings.init, deleteCustomAppProfile).
- BaseDevice.getOrAddButton keeps the created button in availableButtons
  even without a keymap, so the device still renders its buttons.
- The OBC BLE/mDNS emulators evaluated connectedApp.value! before the
  null guard that follows, making the guard dead code — reordered.
- handleButtonsClicked now forwards through recordError, which is why
  this never showed up in crash reporting.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-17 13:14:09 +02:00
Jonas Bark
510a85ac20 Merge branch '6.4' of github.com:OpenBikeControl/bikecontrol into 6.4 2026-08-16 14:35:31 +02:00
Jonas Bark
4df41bdece fix(rouvy): keep the bridge connection stable 2026-08-16 14:13:09 +02:00
Jonas Bark
f0d2d1253b feat(home): make the gear overlay an optional checklist step, not a toast
Riders keep writing in about the wrong gear number in MyWhoosh and others.
The answer has always been the gear overlay, and the one-time toast that said
so was the wrong messenger: it fired once, mid-connect, and scrolled away
before anyone read it.

Move the offer onto the trainer card, where it stays until it is acted on.

- New SetupStepId.trainerGearOverlay, last in the trainer checklist and
  offered only once the bridge is up, the trainer app runs on this device
  (Target.thisDevice), the platform can draw an overlay, and a Virtual
  Shifting session is producing a gear to draw. Ticks off — and leaves the
  card — as soon as the overlay is enabled.
- Its button reads "Enable overlay" and deep-links to the trainer detail
  page's Overlay section, which owns the permission and PiP flows.
- SetupStep gains an `optional` flag so an offer stays an offer: it does not
  colour the card, does not count towards the banner's steps, and never
  stops "Ready to ride". Marked OPTIONAL on its own line, via the tag the
  card header already wore (now a shared OptionalTag).
- Drops OverlayConnectHint, its ProxyDevice listener and the
  overlay_connect_hint_shown flag. The two l10n strings it owned are reused
  as the step's hint and button label in all six locales.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 13:03:56 +02:00
Jonas Bark
55d35b0add fix(rouvy): restore Virtual Shifting on the bridged trainer 2026-08-16 12:44:23 +02:00
Jonas Bark
27462b1c58 fix(rouvy): adjust the bridge's advertised services 2026-08-16 12:44:22 +02:00
Jonas Bark
9ade43d060 feat: label WiFi vs Bluetooth trainer entries
The same physical trainer is regularly discovered twice — once over BLE
(MAC/UUID device id) and once over mDNS/DirCon (dircon://<serviceName>) —
and BluetoothDevice.== is id-based, so the two never dedupe. Both rows
carried the same name, the same "Supports virtual shifting" subtitle and
the same bike icon, leaving the rider to guess which one to tap.

Name the upstream transport wherever the duplicates surface:
- the onboarding trainer picker (both the scan rows and the already-
  connected card) now reads "<transport> · Supports virtual shifting"
  and leads with a wifi/bluetooth mark instead of the generic bike;
- ProxyDevice.nameBadge drops the exact-duplicate-name gate — real
  duplicates differ slightly (BLE advertisement vs DirCon service name),
  which is exactly the case the gate missed;
- the diagnostics bundle gains upstream=wifi|ble next to the existing
  mode= (which is the *downstream* retrofit mode, not the same thing);
- the home chain card ranks bridged > connected > connecting > idle so a
  live entry always beats its idle twin.

New reusable connectionWifi / connectionBluetooth l10n keys replace the
hardcoded 'WiFi'/'BT' strings in the connection card and the proxy
metric row.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-15 08:43:26 +02:00
Jonas Bark
f4c8aba982 feat: overlay hint when trainer app first connects
Nearly every MyWhoosh/Rouvy bridge rider pairs the virtual trainer, then
writes support asking why the gear shown in the trainer app doesn't sync
— trainer apps can't display BikeControl's virtual gears. Surface the
canonical answer (the gear overlay) exactly once, at the moment the
question would otherwise arise: the first time a trainer app connects to
the virtual trainer while the overlay is off.

- OverlayConnectHint fires an AlertNotification (toast + activity-log
  entry) whose button deep-links to the trainer detail page, scrolled to
  the Overlay section (new revealOverlaySection param).
- Hooked on ProxyDevice's device-level isConnected wrapper so it
  survives emulator/mode swaps; gated on an active VS session
  (fitnessBike != null), overlay disabled, and a persisted one-time
  flag (overlay_connect_hint_shown).
- New l10n strings in all six locales.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-14 14:06:24 +02:00
Jonas Bark
8023060121 fix(click-v2): unlock-with-Zwift folds the split entries back into one controller
Picking unlock-with-Zwift on the right puck's card updated the mode but left
the separate right-side entry connected, with no way back to the joined
controller. chooseUnlockWithZwift has never touched useNewUnlockMethod — the
only thing that could turn the split representation off was the "use new
unlock method" switch, and removing that switch (74bb2737) left the setting a
one-way door: chooseRightSideOnly turns it on, nothing turned it back off.

Make the mode own the representation, mirroring chooseRightSideOnly in the
other direction. Unlock-with-Zwift is the both-pucks mode and the unified
controller is both pucks as one device; the split exists so the RIGHT puck
can work alone, unlock free, which is the other mode. So the choice drops
every split instance, clears the scan cache and rescans: the left puck's
advert rebuilds as the unified controller and the right puck's builds nothing,
which is what removes the separate entry. The flag is set before
restoreLeftSides(), which can restart the scan and would otherwise rebuild the
very entry being folded away.

The unified controller's card carries the unlock-mode row now too. It only
ever rendered its unlock warnings, so landing on it would have been a trip
with no route back to right-side-only.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 08:54:33 +02:00
Jonas Bark
74bb2737ba fix: UI feedback round — remembered devices, Click V2 unlock, paywall, Pro dialog
- Remembered controllers offer a single "Forget" instead of two disconnect
  variants: there is no link to drop on a device that isn't here.
- Click V2: drop the unlock-mode dropdown and the new-unlock-method toggle.
  The explainer stays the one place the mode is chosen — it also does the
  follow-on work (un-ignoring the left puck, the right-side-only remap,
  cancelling the reset timer) that the bare dropdown never did. "Set up
  again" now sits on the right puck's card too.
- Paywall: the Base column reads "Basis"/"Base" rather than "VOLL"/"FULL",
  and the one-time Base card moves above the Pro plans so top-to-bottom
  matches the comparison table's left-to-right.
- A remembered controller's own settings page shows its button mapping
  again. The gate counted live controllers only and KeymapExplanation
  looked its filterDevice up in the live list, so the page fell through to
  a warning about connection methods, which had nothing to do with it.
- showGoProDialog takes a feature name for its title, so the keymap sync
  cloud icon says what it does instead of only "Pro Feature".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 07:50:34 +02:00
Jonas Bark
c66cac4591 feat(home): the Click V2 setup step, status warning glyphs, and an unused trainer's pitch
Three chain-card changes. They arrived as one commit because the first
was still uncommitted when the others landed on top of it.

**A Click V2 waiting for its unlock-mode choice.** Reported edge case: a
brand-new install where the wizard was skipped or finished on another
controller leaves clickV2OnboardingDone false, so a Click V2 switched on
afterwards is discovered, in range, healthy — and deliberately not
connected. The chain had no way to say "we are choosing not to connect
this", fell back to presence, and told the rider their controller had
never been paired and should be brought back into range, about a device
switched on beside them.

That step now REPLACES the checklist rather than joining it. Putting it
first would have left the false steps sitting below it; every other step
is unknowable until the device is allowed to connect. Once the choice is
made the normal checklist returns. The card's action reads "Set up" and
opens the explainer, since the choice is what releases the controller
into the connect queue.

**Warning glyphs beside the status.** A flat battery, a pending firmware
update or a signal about to drop are qualifiers on "Connected" — it
works, but not for much longer, or not well — and the card said nothing.
They show only when something is actually wrong, so a glyph appearing
means something. Thresholds are the device page's own (20%, -70 dBm)
rather than new ones, so the two screens cannot disagree about "low".

**The bridging pitch on an unused trainer.** A trainer that is here but
has never been connected now shows what bridging it would buy instead of
an empty card; that list already existed on the device page, and this is
exactly the rider who has not seen it. Dropped once bridged, where live
numbers are the useful content, and dropped for one that broke
mid-session, where it would read as if nothing were wrong.

Not covered by tests: which badges get chosen, and when the feature list
appears — both are private methods on _HomePageState, which has no
widget test to hang a case on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 19:41:37 +02:00
Jonas Bark
6dc4136567 fix(click-v2): enabling the new unlock method lands on the right puck
Reported from a device: switching "use new unlock method" on from the
detail page connected only the LEFT puck — the one that needs unlocking
— which is the setup the switch exists to move the rider off.

Two causes, both needed fixing.

Nothing put the rider into a mode. The toggle only flipped the
representation, so with unlock-with-Zwift off and right-side-only off,
the left puck's gate let it connect while the right puck's gate — which
needs one of those two settings — kept it out. Enabling now routes
through chooseRightSideOnly(), so the toggle and the explainer leave
identical state. A rider who deliberately chose unlock-with-Zwift keeps
both sides; this only redirects the default.

And even with the mode set, the right puck could never appear. In the
legacy representation its advert IS scanned and cached, but
fromScanResult returns null for it — the advert is remembered while
resolving to no device, and the scanner then dedupes against that cache
forever. So the switch also restarts the scan, the same thing
restoreLeftSides already needed.

That meant widening what counts as a left puck. In the legacy
representation the unified ZwiftClickV2 IS the left puck, built from its
advert (the right one builds nothing), so ignoring only
ZwiftClickV2LeftSide missed the very case this bug is about.
_ignoreLeftSides now matches ZwiftClickV2 — which covers both classes
and cannot catch the right side, since that extends ZwiftRide — and
restoreLeftSides recognises both label constants, or a puck ignored as
the unified controller could never be restored.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 18:02:03 +02:00
Jonas Bark
c69c0819ab fix(home): show the unlock deadline, and fix "Unlock again" on the details page
Two things.

The unlock step now says when the unlock runs out rather than just
ticking. That makes it the one done step in the chain carrying detail,
deliberately: an unlock expires, so a bare tick would hide that this
comes back tomorrow.

It also has to distinguish two states the device page already drew
apart. BikeControl cannot read a Click V2's lock state back — after an
unlock it knows when the 24 hours ought to run out, but not whether the
unlock took — so SetupStep.uncertain carries that, and the step reads
"Likely unlocked until Friday, 14:30" instead of claiming more than is
known. The date is preformatted at the page: the chain model stays free
of locales and date formats, which is what keeps it testable without a
loaded locale.

ZwiftClickV2 grows an `unlockedUntil` getter rather than the page
reaching into propPrefs. The +24h arithmetic already existed twice in
that file, and widening its `prop` import is its own hazard — that
package exports a `Set` which shadows dart:core's.

Separately, "Unlock again" on the controller details page threw "No
DrawerOverlay found in the widget tree" and did nothing. The page wraps
itself in a DrawerOverlay, but _buildDeviceCard and _buildActions are
methods on the State, so the context they close over is State.context —
which sits ABOVE the overlay its own build creates. Two callers were
hitting it, "Unlock again" and the device-script drawer. Both now build
from the context under the overlay, the pattern onboarding_page already
documents for the same trap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 17:46:15 +02:00
Jonas Bark
21fd24446d Merge branch '6.4' into 6.4-accessories 2026-08-11 16:28:34 +02:00
Jonas Bark
77596ffbe0 fix(click-v2): ignore the left puck in right-side-only, and name both pucks
Three things the first cut of right-side-only got wrong on a real phone.

The left puck was held back by a setting rather than ignored, so it kept
its entry in the device list and the active scan handed it straight back
— an orphan stuck on "connecting" that never could. Filtering it out of
controllerDevices fixed the onboarding list and missed the home chain,
which also draws from offlineControllers. That is the argument against
inventing a second mechanism: ignoring is the one the scan filter, the
remembered-device loader and the device list all already honour, so
using it takes the puck out of every list at once. The dedicated gate
and the isExcludedBySetup filter are gone with it.

Ignoring has to cover the remembered stand-in too, not just a live
device — the chain lists both side by side, and the card in the report
was a stand-in.

It also has to be undoable, or picking "unlock with Zwift" after
right-side-only silently still yields one controller. Removing the
ignored entry is not enough on its own: the scanner dedupes against its
cached advert, and performScanning() returns immediately while a scan is
already running, so the puck only came back on the next launch. It now
restarts the scan.

Both lists showed "Zwift Click" for both pucks: `name` is the raw BLE
advertised name, identical for the two. They use displayName, which
carries the translated left/right suffix.

Finally, the chain sat 24px in from each screen edge on mobile —
Overview's scroll view pads it by 12 and HomePage added 12 of its own,
before each card's padding on top. Desktop keeps its inset; there the
chain sits in a centred max-width box with no padding of its own.

Known sharp edge, left deliberately: un-ignoring the left puck by hand
while still in right-side-only mode brings both up live, and the right
side's handshake cancels the left's restart timer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 16:23:38 +02:00
Jonas Bark
d985e6d2b5 feat(accessory): name the actions an accessory obeys, and where to assign them
An accessory's settings page had nothing to say about what the device can
actually do: its actions live on a controller's buttons, and the page that
would have shown them (button mapping) is hidden here because a fan has no
buttons of its own.

It now lists them — the six Headwind speed/HR actions, the four incline
ones — straight off the device via a new BaseDevice.assignableActions, and
hands over to the controller that can carry them: the connected one, since
that is the one a rider can test a mapping on right away. With no
controller around it says so rather than offering a dead link.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 16:23:28 +02:00
Jonas Bark
04c97f20dc fix(home): show accessories so a stray Headwind can be ignored
Every Headwind or Climb the scanner finds is connected automatically,
including one that isn't the rider's — a neighbour's fan through a wall.
Getting rid of it means putting it on the ignore list, and the only route
onto that list is "Disconnect & forget" on a device's settings page. But
accessories are excluded from controllerDevices, which is the only device
list the setup chain renders, so such a device appeared nowhere at all and
could not be dismissed.

They now get their own quiet section below the chain: one card per
accessory, no checklist, opening the settings page that already carries
the forget action. That page in turn drops the button-mapping section and
"Reset to defaults" for an accessory — a fan has no buttons, so both were
empty promises — and titles itself "Device Settings" instead of
"Controller Settings". A Headwind also stops presenting itself with the
default gamepad icon.

Auto-connecting to any accessory in range is left as it is: the rider
ignores the neighbour's fan once, and it stays gone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 16:05:25 +02:00
Jonas Bark
aa0720b984 fix(click-v2): the no-unlock option is the right puck, not the left
The first-run explainer offered "use the left side only" as the way to
avoid Zwift. That is the one puck Zwift actually locks. Picking it left
the rider on the 59-second restart loop, and — because
ZwiftClickV2RightSide.shouldAutoConnect required unlock-with-Zwift — it
also withheld the puck that needs nothing at all. Worse, with Zwift's
built-in keymap binding the right paddle to shiftUp and the left paddle
to shiftDown, the left side alone could only ever shift down. The
genuinely clean setup was reachable only by first choosing the mode it
was meant to replace, then tapping "Use the right side only" on the
right card.

So the option becomes right-side-only: no unlock ever, no restarts, and
the +/B remap the right card already applied so one puck covers both
shift directions. The cons now name the real price — no D-pad, so no
steering and no action bar.

Click V2 state is three modes now, not a boolean, and both connect gates
say so out loud. ClickLogic drives the left side's restart loop from a
single static timer that the right side's handshake cancels, so those
two can never be live together; that invariant used to be implied by one
gate and is now stated in both. Left-restart mode survives as the left
card's existing Select for riders who want the D-pad, just not as a
first-run choice.

The right card's shortcut delegates to the same policy rather than
keeping its own path, so both leave identical state: the left side held
back by the setting instead of pushed onto the ignored-devices list,
which is what lets "Set up again" undo it. Its confirmation copy moves
accordingly, and it stops offering itself once the left side is merely
listed rather than connected.

The remap sits in its own recordError guard. It needs a trainer app to
have been picked, and a mode the rider explicitly chose must not be left
half-written because an optional convenience could not run.

This also turns emulation_zwift_profiles_test's right-side case green:
it had been red since the gate landed, because e74c5920 fixed only the
isPending half of what was holding that side back.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 15:40:00 +02:00
Jonas Bark
56a8e87f7d i18n(home): translate the setup chain, align its checklist, stop billing
undelivered shifts

Three things.

The chain's 68 strings existed only in English, so five locales fell back
to it on the app's main screen. Now translated, in each file's own register
— informal second person throughout, matching the copy already around
them. Polish needed a `few` plural category for the step and day counters:
it uses a distinct form for 2-4, so `other` would have rendered "Zostały 2
kroków" instead of "kroki". Two keys written speculatively and never wired
up are dropped rather than sent to five translators.

The checklist's summary row sat inside a Button whose own padding inset it
past the steps below, and the leading glyphs differed in both width (15px
icon, 17px tick) and gap, so matching the outer inset alone would not have
lined them up. One _rowInset / _leadingSize / _leadingGap now governs both,
with the glyphs centred in a box of equal width. Two tests pin the tick and
the label columns, because this is exactly what drifts back unnoticed.

Finally, shifting with a trainer connected but no app holding the bridge
was charged to the daily command budget. Those shifts reach nothing. The
existing exemption only covered the case where the 20-minute
virtual-shifting budget was already ticking — that avoids double-billing —
so it grows a second reason: a command that was never delivered anywhere is
not a command the rider spent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 14:39:07 +02:00
Jonas Bark
70f0532da1 feat(home): show the trainer's live values whenever it is connected
Watts and cadence come off the trainer, not off the bridge, so they are
just as real — and just as worth showing — before BikeControl starts
bridging it. Two gates were hiding them: the readout itself required
isBridged, and the builder only passed metrics through on a fully ready
link, so relaxing either alone would have changed nothing.

The readout moves onto ProxyDevice as liveReadout rather than being
reimplemented on the home page, because the home page's version only read
fitnessBike — in proxy mode the numbers live on ProxyBikeDefinition, so it
would have shown an empty line exactly where a proxied trainer's values
belong. It now mirrors showMetaInformation: proxy definition first, then
the fitness bike, plus the gear or ERG target when BikeControl computes
one.

Showing the numbers exposed a contradiction in the status line: "Not
connected · 250 W · 90 rpm" asks the rider to resolve something the app
should have resolved for them. A trainer whose Bluetooth link is up but
which isn't bridged now reads "Connected", which is true, and the Connect
action carries the rest. "Not connected" is left to mean a trainer that
genuinely isn't there. The bridged states keep onboarding's wording.

The metrics ticker was gated on isBridged too, so the numbers would have
been frozen in precisely the state this change exists to show.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 13:50:26 +02:00
Jonas Bark
16ad75336d fix(home): pair-as-trainer instructions, and finish the onboarding audit
"Waiting for MyWhoosh to pick it up" opened the trainer picker, whose
bridged branch renders "Trainer connected" — an answer to a question the
rider wasn't asking. The trainer IS connected; the app hasn't picked the
bridge up. The connection step's pairing block is extracted as
OnboardingPairAsTrainerCard — bridge entry, the power/controllable/cadence
slot rows, the warning about pairing the bare trainer — and both the
wizard and the sheet render it. Routing is on the card's active step, so
the three trainer problems get three answers: not bridged opens the
picker, bridged-but-unclaimed opens the pairing instructions, ready opens
troubleshooting.

Auditing the rest against onboarding turned up two more.

isBridged now lives on ProxyDevice as a single getter that onboarding and
the home screen both call, so the definition cannot drift again. Three
places here were still keyed on the Bluetooth link rather than the bridge:
choosing which trainer the card shows, gating the metrics ticker, and
deciding whether the trial's virtual-shifting meter applies. Each was
measuring or picking the wrong thing.

The worse one: a remembered trainer mapped to amber, and on an optional
card amber blocks "Ready to ride" — so a trainer that was not in the room
would have held the banner hostage. Because the card inferred "bridged"
back out of its own status instead of asking the device, it would also
have claimed to be bridged and offered Edit. An uncommitted trainer now
rests at off, and bridged comes from the device.

Verified equivalent while in there: connectedTrainerConnections.isNotEmpty
is exactly onboarding's .any((c) => c.isConnected.value), since the list is
already filtered, and appHoldsBridge is the same isConnectedListenable the
onboarding summary uses to choose between "Bridged" and "Waiting for {app}".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 13:26:14 +02:00
Jonas Bark
24f5da596d fix(home): device-testing fixes, and drop the VS takeover dialog
Four things found riding the real app.

The offline note claimed "your changes apply the next time it connects",
which is simply untrue — button mappings live in the keymap, not on the
device, so nothing is queued up waiting for a reconnect. It now says what
is actually true: you can still change what its buttons do.

A smart trainer that had only just been discovered announced itself as
"Wahoo KICKR lost connection". That was mine, and the cause is worth
recording: _handleConnectionQueue calls _connect() on every queued device,
but ProxyDevice.connect() deliberately no-ops unless the rider has asked
for that trainer. Recording "connected this session" right after connect()
returned therefore marked a trainer that never connected as having
connected — and the chain then read the disconnected state as a break.
Recording now hangs off the actual connection signal, and a new
DevicePresence.discovered ("in range, never connected") maps to a grey
"Not connected" that, being optional, doesn't stop the rider being ready.
A trainer that genuinely drops is still red.

"More options" had picked up two things that don't belong in a settings
drawer: a scanner running a permanent searching animation, implying work
the app wasn't doing on anyone's behalf, and a Close row on desktop, where
SystemNavigator.pop() does nothing useful and the window's own close
button is the way out. Pairing lives in the controller card's setup sheet,
which is where the scanner already was.

The virtual-shifting takeover dialog is gone entirely — the widget, the
shouldAutoConnect gate, the settings accessors and the onboarding call
site. Tapping Connect once is the whole consent story. Two tests asserted
the old gate; one is rewritten around intent alone being sufficient, and
the widget test for the dialog's presence is dropped rather than inverted,
because showSmartTrainerConsentDialog no longer exists and bringing the
gate back could not compile.

Also removes twelve imports in overview.dart left orphaned by the chain
refactor. Verified against the untouched 6.4 baseline: analyze reports no
errors, and the suite's failures are unchanged pre-existing golden drift.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 12:02:24 +02:00
jonas.bark@gmx.de
5d16ab6cb5 fix: two BikeControl installs no longer overwrite each other in trainer apps
Running BikeControl on a second device made the one next to the trainer app
unreachable. Each install now advertises its own identity.

Because that identity changes, an app that was already paired will ask to
pair once more.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 15:38:46 +02:00
jonas.bark@gmx.de
599e2e644d fix: let trainer apps on the network find BikeControl again
Retires the Windows IPv6 workaround instructions along with it — they no
longer apply.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-10 14:33:34 +02:00
Jonas Bark
d98483fa3b fix(click-v2): explainer auto-opens once per pair, right side stays off in left-only mode
The wizard's Click V2 auto-prompt marked 'the pair' by uniqueId before the
second side was even discovered, so two concurrent connectionStream runs
each opened the explainer — replaced with a single flag set synchronously
before the await (the row's Setup-needed button remains the way back in).

ZwiftClickV2RightSide.shouldAutoConnect now also requires unlock-with-
Zwift mode: after 'left side only' the right controller is deliberately
unused, and connecting it anyway burned battery and disturbed ClickLogic's
restart cycle. Covers both the auto-connect queue and ClickV2Onboarding's
_connectPending (connect() is a no-op while the gate is false).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-10 11:24:53 +02:00
Jonas Bark
866c0164e7 feat(onboarding): device sub-flows and press-a-button-to-continue 2026-08-09 22:16:23 +02:00
Jonas Bark
0929cebfe3 fix(sram): prevent 3-minute idle disconnect with BLE keepalive
The SRAM rear derailleur drops idle connections after ~3 minutes.
Reverse-engineering the official SRAM AXS app revealed it requests
CONNECTION_PRIORITY_HIGH immediately after connecting. This fix adds
the same priority request, subscribes to the gear-state characteristic
for additional notification traffic, and reads it every 60s as a
fallback keepalive.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-08-08 16:01:07 +02:00
Jonas Bark
2e63bf580a fix(dircon): derive a real mDNS serial-number for WiFi trainers
The advertised serial was sliced off the raw device id. WiFi trainer ids
are `dircon://<name>` and `dircon://` is itself exactly nine characters —
the same length as the reference serial the slice was sized against — so
every WiFi-proxied trainer advertised the identical, information-free
`serial-number=dircon://`.

Strip any `scheme://` prefix before slicing, and pad short ids instead of
letting substring throw. BLE device ids keep their existing derivation,
covered by a regression test.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-07 11:30:12 +02:00
Jonas Bark
653dfbf461 feat(click-v2): hold discovered controllers for unlock-mode onboarding 2026-08-03 09:21:02 +02:00
Jonas Bark
8634db7dbc refactor(bluetooth): lift shouldAutoConnect onto BaseDevice 2026-08-03 09:15:13 +02:00
Jonas Bark
7f93ad043f feat: data-informed probe candidates, full byte transcript, quiet probe churn
From the +20 field log the pod replied 04 38 0f 4b to 04 11 15 and
09 01 00 00 to 01 (on 6e400003); add both as candidates (7 frames now).
Log every inbound frame and every outbound write verbatim while probing
(WHEELTOP PROBE rx/tx <slot> <hex>) so the support log is a full
transcript, not just unparseable frames. Suppress the connect-failure
give-up guidance while the experiment runs — the 147-timeout reconnect
churn is expected and is NOT rear-derailleur contention (fixed the
misleading 'claimed by the derailleur' alert the user saw with the RD
off).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 19:50:58 +02:00
Jonas Bark
1fed2971e5 fix: subscribe to all WHEELTOP notify slots; log reply slot + length
The +15 field log showed the probe auto-arming and the pod RESPONDING to
each candidate — but the response logged as empty. Cause: we subscribed
to 6e400002 only, so a reply on the second Nordic-UART slot (6e400003)
was never delivered, and the empty frames were artifacts on the write
slot. Subscribe to every notify/indicate characteristic (pressed-set
dedup absorbs any duplicated button event), and log each unexpected frame
with its slot and byte length so an empty artifact is distinguishable
from a real reply. Next field log will show which slot the pod answers on
and the actual bytes.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-16 08:26:49 +02:00
Jonas Bark
08d31ede0c feat: auto-arm WHEELTOP keepalive probe; quiet quick-drop loop when off
The probe was only reachable via a device-page toggle, but TX pods drop
so fast the user can never open the page — the one field tester couldn't
enable it. Arm the probe automatically on the first 0x10 status frame
(the moment that proves a pod needs the reply), default on; the toggle
becomes an opt-out. Move probe creation out of handleServices into a
lazy arm on that frame.

When the experiment is off, count a connect that dies within
quickDropThreshold (5s) as a failure via the same backoff, so the
endless connect/connected/disconnected loop gives up after 3 and shows
the guidance instead of spamming forever. While the experiment is on the
device opts out (keepsReconnectingWhileDropping) so the loop keeps
cycling for the probe. Extract _engageBackoff shared by both paths.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-15 13:25:54 +02:00
Jonas Bark
4a7a301043 feat: WHEELTOP keepalive-reply prober (opt-in beta experiment)
TX pods drop the link after three unanswered 1 Hz status frames; the
derailleur's reply is unknown and undocumented anywhere public. When the
user opts in (device page > Preferences), each reconnect cycle writes
the next reply candidate (type-echo, ack, 3-byte XOR shapes, bare ACK —
on 6e400003 first, then other writable NUS slots) once after subscribe
and again per status frame, and logs the connection lifetime per
candidate. A lifetime past 5 s marks the likely answer; unexpected
frames are logged loudly as potential pod responses. Worst case per
attempt is the disconnect that already happens.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 09:38:50 +02:00
Jonas Bark
1c5cb640b8 feat: accept WHEELTOP TX 4-byte frames (additive checksum), dedupe frame logs
TX firmware frames carry a sender type byte and an additive checksum
(04 type code sum), unlike the OX 3-byte XOR shape — both validate now
and route through the same opcode switch. The 1 Hz TX status frame 0x10
and any unknown/invalid frame log once per connection instead of
flooding the support log.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-13 08:55:08 +02:00
Jonas Bark
1a40888c31 feat: connect-backoff seams on BluetoothDevice, Wheeltop opts in
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-12 16:34:23 +02:00
Jonas Bark
db5cc74a12 fix(erg,sram): shared ERG stepping with boundary guards; scope §7 guard to shifting-enabled; coalesce iOS echo presses
ERG (review findings on the ±5W change):
- New ErgPowerStepping extension is the single home for the 5W step and
  500W manual cap, replacing 7 inline copies (physical buttons, hero-card
  buttons/slider, three overlay controllers).
- Boundaries are guards, not clamps: up at >=500W is a no-op like the
  disabled UI button (a 600W FTMS target is no longer slashed to 500),
  down from >500W steps relative, and an unknown baseline (hub-commanded
  ERG reports no target) is a no-op with a new localized message instead
  of slamming the trainer to ~150W.
- ERG shift-up Success carries the button again so +5W presses show
  activity feedback (missed conversion from 843f7985).

SRAM gesture:
- Same-lever repeats inside the 90ms combo window coalesce as duplicates:
  a finger can't re-press in 90ms, but iOS re-delivers a colliding read
  response of the 0xFF edge through the notify callback — it must not
  actuate twice (nor break a combo when it misdecodes to the other lever).
- The §7 multishift guard only runs while shifting is enabled — the one
  state where a held paddle actually bursts (per c94b87f0's --observe
  capture). Bonded rapid tapping and both-lever combos are never
  throttled. Timer-driven instead of DateTime.now() (deterministic under
  fakeAsync) and cleared by _resetGesture on (re)connect.
- The "set up SRAM control" warning fires once per connection, not on
  every undecoded press.

Harness:
- EmulationSession.notify drops notifications for removed peripherals so
  delayed notifies (SRAM double-tap) can't land after teardown.
- The 0xFF press edge is SramAxsConstants.triggerEdge at all call sites;
  the emulation test waits on the named TRIGGER_UUID constant.
- New coverage: guard behavior through processCharacteristic in both
  states, burst suppression while unbonded, all-taps-delivered once
  bonded, ERG boundary/game-set-target cases.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 17:51:35 +02:00
Jonas Bark
39e9082e53 fix(sram): don't swallow same-lever repeats; restore §7 burst guard; fix failing tests
Gesture engine: a repeat of the SAME lever inside the 90ms combo window
can't be a combo, so flush the pending click instead of overwriting it —
rapid double-taps now deliver both shifts. The old press-swallowing was
accidentally doing multishift suppression, so bring back the explicit §7
guard (forward the first two rapid triggers, drop the 3rd+ within 350ms)
that the discrete-click rework removed.

Test fixes for the rest of the failing suite:
- review_prompt_service_test: derive seeds from sessionThreshold /
  snoozeSessions instead of hardcoding the old threshold of 3
- controller_settings_signal_change_test: persist a session key and run
  handleServices so the device is bonded and the Restore branch renders
- emulated SRAM AXS profile: send real 1-byte 0xFF edges (0x01 is now
  filtered as a read-response echo), expect the generic 'SRAM Button'
  name, and wait for the app's trigger subscription before tapping so
  the press can't land mid-connect and get wiped by the gesture reset

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-07-09 16:24:01 +02:00
Jonas Bark
5c44ca43f2 UI adjustments 2026-07-09 15:48:34 +02:00
Jonas Bark
0723272455 prepare release 2026-07-09 15:17:51 +02:00
Jonas Bark
ff2a2aace7 Merge branch '6.2-beta' into 6.3
# Conflicts:
#	lib/bluetooth/devices/sram/sram_axs.dart
#	lib/pages/controller_settings.dart
2026-07-09 15:07:49 +02:00
Jonas Bark
c94b87f08a feat(sram): discrete-click gesture + "both levers" front-shift combo
A SRAM press is a single 0xFF edge on d9050054 — no release event, and (with
shifting disabled) no multishift burst. An --observe capture confirmed a HELD
lever emits exactly one edge, so a hold is indistinguishable from a tap and
long-press cannot be reconstructed. Replace the old instant-down+up-per-edge
guard with a small assembler that treats every press as a discrete CLICK and
reconstructs the one thing the base device can't get from the raw edges — "both
levers at once":

- a press is buffered for a short combo window; if the other lever's press lands
  inside it, both buttons are emitted together in ONE call so the base device's
  _maybeHandleFrontShiftCombo fires frontShift ({shiftUp,shiftDown}) and
  suppresses the rear shifts — the "left+right together" goal;
- otherwise the single button clicks (down+up). Single vs double click is left
  to the base device (two discrete taps in its double-click window);
- supportsLongPress is set false — it's not achievable on this hardware.

Buffer/timer reset on (re)connect and cancelled on disconnect. Single clicks now
land ~_comboWindow (90ms) after the press instead of waiting on a release that
never comes. Combo detection still needs a two-lever hardware check.

Tests: fakeAsync coverage for a single discrete click, both-levers-together one
click, a held (single-edge) lever as a single click, and two spaced taps as two
clicks.
2026-07-09 14:49:28 +02:00
Jonas Bark
2868ad39c0 some fixes 2026-07-09 09:47:29 +02:00
Jonas Bark
bd2f729981 logs 2026-07-09 09:20:36 +02:00
Jonas Bark
3778136411 fix(sram): differentiate left/right shifters and default one lever to shift down
Testers reported both AXS shifters doing the same thing and gears only ever
increasing, with presses logged as a generic "SRAM Paddle". Root cause: both
drop-bar paddles report button mask 1, so the mask alone can't tell them apart,
and every discovered button was hardcoded to InGameAction.shiftUp.

- Use the button event's controller device_type (prop SramPress.deviceType,
  field 2) to name and key buttons, so left and right become distinct keymap
  entries even in a plaintext (serial-less) session — the common case in the
  field. Names now resolve to "SRAM Left/Right Shifter" without needing an
  advert or the sparse d9050003 serial.
- Default the LEFT paddle to shift DOWN and everything else to shift UP so the
  shifters aren't identical out of the box ("one lever changes down") without
  hunting through the keymap. Every button stays freely remappable.
- Persist the device_type in the button record so a restart re-registers the
  same left/right name + default instead of a duplicate entry; two serial-less
  paddles that differ only by side stay separate, and a legacy side-less record
  upgrades in place once the side is known.
- Remember a shifter's side against its serial (preserving any known model) when
  both are seen, so its other buttons resolve the same name.
- Bump the prop submodule to the field-2 decode.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01H48NvkfXYm2spiiwcTQsv8

# Conflicts:
#	prop
2026-07-09 09:20:12 +02:00