Commit Graph

3174 Commits

Author SHA1 Message Date
Jonas Bark
fcd277e3ba fix(local-network): don't let a pre-Settings probe repopulate the cache
invalidate() cleared the cached status but did nothing about a probe already in
flight. That probe then completed and wrote its answer back — the answer from
before whatever prompted the invalidation.

The case that matters is the one invalidate() exists for: the user is told
Local Network is off, taps through to System Settings, grants it and comes back.
If a probe was in flight when they left, its stale "denied" lands afterwards and
becomes the cached truth, so the app still claims the permission is off.

Tag each probe with a generation, bump it in invalidate(), and only write the
cache when the generation is still current. Whoever is awaiting the stale probe
still gets its result — it just doesn't become the shared answer. invalidate()
also drops _inFlight now, so the next caller starts a fresh probe instead of
being handed the pre-invalidation one.

Found while chasing an intermittent test failure. That turned out to be an
unrelated ambient issue (a MissingPluginException on the app_links EventChannel
that attaches to whichever test is in flight, which already fails ten other
files), but the race it exposed here was real.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 09:07:18 +02:00
Jonas Bark
20788e46b6 fix(requirements): stop the permission sheet opening for a granted permission
Toggling the "Direct connection" card could wedge: the sheet opened for a
permission that was already granted, and then sat there, because PermissionList
only re-probes on app resume.

ConnectionMethod probed one requirement list, awaited, then re-read
`widget.requirements` on the far side of the gap:

    Future.wait(widget.requirements.map((e) => e.getStatus())).then((_) async {
      final notDone = widget.requirements.filter((e) => !e.status).toList();

The tiles build that list inside `build()`, so any rebuild in that window hands
back fresh objects whose mutable `status` is still false — and these tiles
rebuild on every isConnected/isStarted tick, plus onChange's own setState. The
probe result was read off objects that were never probed.

Capture the list once per operation instead. This was pre-existing and not
specific to Local Network: di2_ble_tile and openbikecontrol_ble_tile pass
getRemoteControlRequirements() the same way, so they had the same latent race.

Also hoist the requirement lists out of build() into State fields across the
five tiles, so a probed `status` is not discarded every frame.

Separately: LocalNetworkRequirement was only wired into the network tiles, so
onboarding, app start and scanning never checked it at all — every one of those
reads getScanRequirements(). Add it there for iOS and macOS. The list is
filtered to unsatisfied requirements, so it surfaces only on an actual denial.

Note for macOS: keyboard-control-only users will now see a Local Network prompt
they do not need. Accepted deliberately in favour of one list over a
platform-split.

The regression test drives the real race — gate the probe, force a rebuild
mid-flight, release — and fails with "Found 1 widget with type PermissionList"
without the capture fix.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 08:55:04 +02:00
Jonas Bark
c4c48dff07 Merge remote-tracking branch 'origin/6.5' into 6.5 2026-08-21 08:03:17 +02:00
Jonas Bark
905c2641cd feat(ios/macos): detect the Local Network permission instead of failing silently
Denial of Apple's Local Network privacy permission is the most common cause of
"BikeControl can't see my trainer app" on iOS and macOS, and it fails
completely silently: Bonjour browses return nothing forever, advertisements
never leave the device, nothing throws. An app watching only for errors cannot
tell "permission is off" from "there is nothing out there".

Apple ships no authorization-status API for it (not iOS 14...26, not macOS
15...26), so the new local_network_permission plugin measures it: an NWListener
and an NWBrowser on _bikecontrol-preflight._tcp, then

  browser discovers the listener        -> granted
  kDNSServiceErr_PolicyDenied (-65570)  -> denied
  neither, before the deadline          -> unknown

unknown is a real outcome, not an error — a device with no usable network never
completes the round trip even when the permission is fine — so everything fails
open on it and only a positive denial blocks the user.

The probe *is* the request: the system prompt fires on the first Bonjour
operation, so there is no separate request step, and after the user answers,
System Settings is the only way back.

- LocalNetworkAccess caches the result (probes cost a real round trip while
  getStatus() runs on every tile mount, tap and resume) and collapses
  concurrent probes into one, since two listeners on the same service type
  would resolve each other.
- LocalNetworkRequirement gates the three LAN tiles: MyWhoosh Link, Zwift mDNS
  and OpenBikeControl mDNS. Suppressed in screenshot/demo mode like the rest.
- Diagnostics drop the old guess (inferred from whether a discovery scan
  returned anything, which could not tell denied from an empty LAN) for the
  measured local-network=granted|denied|unknown.
- _bikecontrol-preflight._tcp added to NSBonjourServices on both platforms;
  without it the browse fails for a reason unrelated to the permission.

The Xcode project deployment-target bumps (ios 13.0->15.0, macos 10.15->12.0)
are Flutter's own migration aligning project defaults with the Podfiles; they
happen on any first build.

Verified with real builds on both platforms, not just analysis: flutter build
macos --debug and flutter build ios --no-codesign both succeed, the framework
is linked in, and the preflight service type is present in both built
Info.plists. 35 tests cover the mapping, cache, concurrency and fail-open
behaviour.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 07:58:18 +02:00
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
e1703b6f59 fix(self-test): surface precheck refusals on reruns; drop unused import
- self_test_card.dart: a precheck refusal on "Run again" now clears
  _engine inside the same setState. _body only renders _idle (where
  _refusal is shown) when _engine is null, so a refusal raised while a
  finished verdict engine was still attached rendered invisibly behind
  the verdict view — the rerun CTA silently no-opped.
- settings.dart: add missing static to _selfTestKey, matching its
  sibling key helpers.
- self_test_harness_test.dart: drop unused self_test_harness.dart import.

Adds a widget test: complete a run to a verdict, attach the trainer
app, tap "Run again" — the trainer-app refusal is now visible and no
new run starts.
2026-08-20 14:52:04 +02:00
Jonas Bark
e6407714a9 feat(self-test): offer switching the control protocol from the verdict
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 14:16:55 +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
331b864e15 feat(self-test): verdict CTAs — overlay reveal, mode switch, support hand-off
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 13:11:42 +02:00
Jonas Bark
d53a063ab8 feat(self-test): SelfTestCard with guided run flow on the trainer page
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 12:32:03 +02:00
Jonas Bark
757faff42d feat(diagnostics): proto, vsMode, ftms caps, lastCtl and selfTest on the trainer bundle line
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 12:06:37 +02:00
Jonas Bark
16038c9ffc fix(self-test): bound headroom loop, ERG-safe skip path, hardened restores
Three ways the engine could strand a rider. The headroom loop spun forever
on a small gear range (maxGear is configurable down to 1) or against a
trainer that refuses to shift, so it now stops when the gear stops moving
and is capped either way. The power-target-less skip path returned before
the phase's finally, so a rider's manual ERG survived into the sweep —
pinning plateau 1 flat — and was then silently dropped by the first
shift; the check moved inside the try, and both ERG helpers now key off
the trainer's actual mode rather than only our own writes. Restores are
individually guarded: a refused gear write can no longer cost the rider
their ERG session, a refused ERG write no longer downgrades a scored run
to aborted, and run() resolves with a result whatever the harness does.

Also: a mid-test upstream dropout now aborts instead of misreporting
NO_CONTROL — prop's notifiers latch their last value, so a dead link used
to read as a trainer that ignores us.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 11:46:16 +02:00
Jonas Bark
da3f3931ee Merge branch 'fix/ios-live-activity-target-max' into 6.4 2026-08-20 11:33:28 +02:00
Jonas Bark
631159defd fix(self-test): shift sweep always runs in SIM; rider ERG restored at finish
Restoring a rider's manual ERG target right after the staircase pinned
power flat for the whole shift sweep, so every transition read "no
change" and a healthy trainer verdicted ERG_OK_VS_FAIL. The staircase now
always exits ERG before the sweep, and the rider's own ERG session is put
back at the very end — still gated on the dirty flag, so a run that never
commanded a target (noData, early abort) writes nothing at all.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 11:20:35 +02:00
Jonas Bark
16ec79793e feat(self-test): SelfTestEngine state machine with verdict matrix
Baseline → ERG staircase → shift sweep on a 500 ms tick, with a cadence
pause watchdog and restore-always semantics: the gear goes back to where
the rider left it and our own ERG writes are undone on pass, fail, cancel
and exception alike. Eight scenarios drive it on a virtual clock through
a fake harness, so no test waits on wall time.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 11:16:32 +02:00
Jonas Bark
b85264369a fix(overlay/ios): reuse the Live Activity instead of orphaning one per ride
A rider's diagnostics (iOS 26.6, 6.4.3) carried this four times inside a
minute, with "virtual shifting isn't working" attached:

  PlatformException(LIVE_ACTIVITY_ERROR, can't launch live activity,
  Maximum number of activities for target already exists)

That is ActivityKit's `targetMaximumExceeded`. On iOS the Live Activity IS
the gear overlay — the only place a rider can read BikeControl's virtual
gear, because trainer apps never show it — so once it fires the readout is
dead until the phone reboots.

show() minted a fresh random activity name and called createActivity every
time, and the id it got back lived only in this isolate's memory. Every
force-quit, engine restart or swiped-away activity therefore left an
activity behind that still held one of ActivityKit's per-target slots, and
nothing ever went looking for it. After enough rides the target is full and
every request throws.

- Query what iOS actually holds, adopt the one activity that is still
  live (updateActivity writes under its own attributes prefix, so an
  activity from a previous launch picks up fresh gear data), and end
  everything else before requesting anything.
- Collapse overlapping show() calls onto one in-flight future, so a
  trainer app flapping its connection can't queue up requests.
- Retry once after sweeping everything when the request still throws:
  `Activity.activities` reads empty for a beat after a cold start, which
  the plugin works around the same way in createOrUpdateActivity.
- Ask for removeWhenAppIsKilled so a graceful termination frees the slot.
- Use a stable activity name, which also stops each ride from leaking a
  new set of never-collected App Group UserDefaults keys.
- A show() that starts nothing now reports isShowing == false, instead of
  leaving the Overlay switch and the auto-show guard claiming an overlay
  the rider cannot see.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 11:07:00 +02:00
Jonas Bark
514c396e5d feat(diagnostics): call out an active VPN on its own line
A user on iOS reported "MyWhoosh sees BikeControl but won't pair". Their
bundle looked healthy end to end: the advertisement was on the right
interface, our own mDNS record came back on the discovery scan, local
network permission was fine, both TCP servers were listening. The only
trace of the actual cause was a "(virtual)" suffix on one of three
interface rows: utun4/10.2.0.2. Turning the VPN off fixed it.

That asymmetry is the norm, not a fluke. mDNS is multicast and is not
carried into the tunnel, so discovery keeps working; the unicast TCP
connection that follows is the part a full-tunnel VPN swallows. Every
other line in the block therefore reads green.

Give it a line of its own, prefixed "VPN", so support sees it at a
glance instead of decoding scores. Only interfaces that carry a routable
IPv4 count -- Apple platforms always keep several idle utun devices
around for Private Relay / Continuity / Wi-Fi Calling, and those have no
IPv4 at all, so they never reach the candidate list. Names are matched
case-insensitively and partly as substrings because Dart reports the
adapter FriendlyName on Windows ("NordLynx", "ProtonVPN TUN"), where
prefix matching would miss nearly every VPN. Mesh VPNs handing out
100.64/10 are named but marked usually harmless: they route their own
overlay and leave the LAN path alone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 11:04:37 +02:00
Jonas Bark
f6eab0eead feat(self-test): per-trainer result persistence and FitnessBikeHarness 2026-08-20 10:57:12 +02:00
Jonas Bark
f0c3a74050 feat(self-test): SelfTestResult model with bundle string and json roundtrip 2026-08-20 10:45:35 +02:00
Jonas Bark
47ed186ced feat(auth): put email sign-in below the social buttons
The social logins are what most riders reach for, so they lead; the emailed
code is the fallback and now sits under the "or" divider. Covered by a test
asserting the form renders below the last social button, so the order cannot
drift back unnoticed.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 09:04:54 +02:00
Jonas Bark
2eca5d4178 feat(auth): sign in with an emailed six-digit code
Riders without a Google, Apple, GitHub or Facebook account can now sign in
with their email address: Supabase mails a six-digit code and EmailLoginForm
redeems it via verifyOTP.

Deliberately code-only rather than a clickable magic link — a link has to
travel back through bikecontrol://, which is unreliable on Windows and Linux,
and corporate mail scanners routinely open (and thereby burn) one-shot links
before the rider ever sees the message. A typed code behaves the same on every
platform, including web.

The Supabase side is the send-auth-email hook in the website repo, which
renders the branded BikeControl mail through Resend.

Also folds the pop/onBack block that was duplicated across all four OAuth
handlers into _afterSignIn(), which adds the mounted guard those calls were
missing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 08:52:34 +02:00
Jonas Bark
07e78821c5 feat(support): add heads-up about slower replies to chat intro
Second line under the chat intro sets expectations on response time,
translated into all six locales.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 08:03:33 +02:00
Jonas Bark
2c7b18f410 fix(paywall): "Go Pro" from the trainer picker opens instead of crashing
The onboarding trainer picker passed the State's own context into
connectTrainerFromPicker. Its trial gate opens the Go Pro dialog, whose
purchase action opens the paywall drawer -- and that context sits above
the Scaffold's DrawerOverlay, so openDrawer's `parentLayer!` threw. In
release the user saw only a "Null check operator used on a null value"
toast and the paywall never appeared, which on an expired trial leaves
no way forward at all.

Pass _sheetContext, which lives below the Scaffold.

_showPaywall also stops depending on callers getting that right: with no
DrawerOverlay ancestor it now falls back to showDialog, which only needs
a Navigator. The paywall already constrains and scrolls itself, so it
renders correctly either way. The paywall is the last thing that should
break when a caller passes the wrong context.

Symbolized from a support bundle (chat 197d1f1a, Windows 6.4.3 patch 13):
four identical traces seconds apart, each on the Go Pro tap.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-19 22:13:47 +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
8170cd97b9 fix(trainingpeaks): direction and face buttons now reach the app
The TPV profile mapped navigationUp and the coloured face buttons to a
keyboard key / touch position only. _handleDirectConnect forwards a KeyPair
solely when it carries an inGameAction, so those presses never left the
phone — and an actionless default is worse than no default at all, because
it shadows the action the button would otherwise inherit from
ControllerButton.action via Keymap.addNewButtons (which is exactly why
navigationDown, absent from the profile, worked).

Same gap hit the HUD-toggle and difficulty defaults. Steer Left/Right are
added to defaultObpSupportedButtons as well: TPV advertises them in its
live app-info frame, but without them the button editor hid steering
before a connection.

Reported by a rider on Android with TPV on an iPad, whose log showed
"Sent Down button press" next to "No connection method active".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 12:54:00 +02:00
Jonas Bark
8f4c0e9773 fix(store): drop the Pro button from the screenshot renders
It sat first in the app bar's trailing row, and the marketing renders lay that
bar out narrower than a real window — enough that AppTitle's wordmark wrapped
mid-word, "BikeContr / ol". Harmless in the framed boards, glaring on the
website hero, which shows the frameless render at ~150px where the broken
wordmark is the first thing the eye lands on.

Gating it on !screenshotMode gives the title its line back, and buys enough
trailing room that "Add keyboard and mouse actions" stops wrapping too. A Pro
upsell was never what these boards were selling.

71 goldens follow: the six device-* slots per locale, where the app bar lives,
plus the androidTablet / noFrame pairs that flap between runs.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-17 17:02:49 +02:00
Jonas Bark
12b51447a3 fix: sending a screenshot without text no longer crashes
SupportComposer._submit caught the send failure to restore the text and
the staged attachment, then rethrew. The send button drops the returned
Future, so that rethrow escaped into the zone as an unhandled error and
was reported as "App crashed".

- _submit is terminal now, and the button invokes it via unawaited() so
  no Future is silently dropped. The page-level rethrows stay: they are
  how the composer learns it must restore.
- The page-level send catches forward through recordError
  ('support.chat.send') — this path had no crash reporting at all.
- Interim client mitigation for image-only messages: substitute a
  localized placeholder body when the body is empty but an attachment is
  present, since the send-support-message edge function still rejects an
  empty body.
- A failed send no longer orphans the uploaded blob: the successful
  upload is retained against the staged attachment the composer restores,
  so a retry re-uses it instead of uploading a second copy (there is no
  client-side delete for the attachment bucket).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-17 13:14:18 +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
351bb4ca63 fix(attribution): guard install-referrer report on settings init + document reporter ctor
Add core.settings.isInitialized to the Android install-referrer gate in
main.dart. Settings._prefs is a late SharedPreferences assigned during
Settings.init(); if SharedPreferences.getInstance() throws, _prefs is
never assigned. The referrer block previously read core.settings.prefs
unconditionally, so that failure would raise a LateInitializationError
from inside the guarded zone before runApp(BikeControlApp(error: error))
ran, skipping the intended error screen. Gating on isInitialized (already
used the same way in click_v2_onboarding.dart) skips the block instead.

Also add a one-line doc comment to the InstallReferrerReporter
constructor describing its injected source/prefs/send collaborators, to
match the class-level doc comment already present.

No logic changes in install_referrer_parser.dart.
2026-08-17 08:06:35 +02:00
Jonas Bark
d91cd2b942 feat(attribution): report the install referrer on Android startup
Fire-and-forget after settings init so it cannot delay launch, and guarded to
Android since no other store passes a referrer through.

Failures route through recordError rather than being dropped -- a silently
broken attribution path is worse than a noisy one, because it looks identical
to having no installs.
2026-08-17 08:00:51 +02:00
Jonas Bark
d16f3b96e8 refactor(attribution): use maintained play_install_referrer plugin
android_play_install_referrer 0.4.0 is discontinued on pub.dev (replaced
by play_install_referrer). Swaps the reporter's PlayInstallReferrerSource
over to the maintained package; behaviour is unchanged — same read/catch/
recordError/return-null shape, just PlayInstallReferrer.installReferrer
instead of AndroidPlayInstallReferrer.installReferrer.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-17 07:57:10 +02:00
Jonas Bark
7e3a48d162 feat(attribution): report the Play install referrer once per install
The referrer source is behind an interface so the reporting logic is unit
tested without the Play plugin, which needs a real device.

The done-flag is only written after a successful send, so a failed report
retries on the next launch instead of vanishing. A missing referrer still
reports, because an install with no attribution is still an install and the
organic baseline is what paid gets compared against.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-16 20:29:42 +02:00
Jonas Bark
5d4a00e96a fix(attribution): normalise malformed-referrer errors to FormatException
Uri.splitQueryString throws ArgumentError, not FormatException, for
malformed percent-encoding (e.g. a truncated '%' or invalid escape) --
verified against the project's Dart SDK. The doc comment and Task 3's
brief both promise FormatException so callers can catch a single type
and route it through recordError. Catch the mismatch and rethrow as
FormatException; add a test proving the contract holds.
2026-08-16 20:26:46 +02:00
Jonas Bark
89f8638797 feat(attribution): parse UTMs from a Play install referrer
Pure function, no plugin dependency, so it is fully unit tested. Keeps Play's
organic referrer rather than discarding it -- that is how paid and organic
installs get told apart.

Lets FormatException escape on malformed encoding so the caller can record it
rather than silently losing an install.
2026-08-16 20:22:02 +02:00
Jonas Bark
dc715c9cf2 feat(home): offer local control too, and make the offers act rather than point
Three things a rider asked for, all on the same idea: an offer's button should
do the thing, and nothing should be labelled optional that is plainly working.

- "Enable overlay" now enables the overlay and *then* opens the Overlay
  section. A button that only navigates to another switch is the toast
  problem again, one tap further along. The enable path moved into a shared
  enableTrainerOverlay(), run by both the section's switch and the step, so
  the two cannot drift; it persists the flag only when the platform actually
  put something on screen, so declining Android's draw-over prompt can't
  leave a setting claiming an invisible overlay. A refusal says why, and the
  page opens anyway — that is where the permission tile lives.

- New optional step on the app card: "Add keyboard and mouse actions",
  offered when Local is available on this device but switched off (target is
  This device, per CoreLogic.showLocalControl) and an app is chosen. Local is
  not a way to reach the app, it is a way to do more to it — keystrokes and
  clicks the button editor only offers once it is on — and a rider who never
  turns it on never learns those actions exist. Its button runs the existing
  enableLocalControl(), permission sheet and all.

- The card header drops its OPTIONAL tag once the link is off "off". The
  link stays optional underneath, which is what keeps a trainer nobody owns
  from blocking "Ready to ride", but the word is there to reassure someone
  looking at an empty slot — not to caption connected hardware.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-16 14:52:46 +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
1a3fea5fa6 fix instructions 2026-08-16 14:35:27 +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
2b74a06141 feat: swipe between the Virtual Shifting preview scenes
The dots were the only way to steer the carousel by hand, and a stage that
animates on its own invites a swipe. Left goes forward, right goes back, both
wrap, and the stage follows the finger a little before it commits — a drag
too short to count springs back.

Also separates "pinned" from "reduced motion": screenshotMode still holds the
scene for deterministic captures, but reduced motion now only stops the stage
advancing by itself. Before this the dots did nothing at all with animations
off, which is exactly the setting where a rider needs to drive it themselves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 09:03:54 +02:00
Jonas Bark
0d68e370e9 revert: put the Base version back below the monthly subscriptions
Reverts the reorder from 74bb2737; _buildPlansSection is byte-identical to
what it was before that commit again. The "Basis" rename of the comparison
column stays.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 08:59:44 +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
947bfdb389 fix: stop() leaves the gamepad search timer running, and leaks one per rescan
performScanning() arms a periodic 3s gamepad poll; stop() cancelled the BLE
scan and the wifi trainer scanner but not that. Worse, stop() clears
isScanning, so the next performScanning() sails past its early-return guard
and assigns a second periodic timer over the top of the first — one leaked
per stop/rescan cycle, and restoreLeftSides plus both Click V2 unlock-mode
choices all do exactly that.

Cancel it in stop(), symmetric with the method that arms it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 08:54:23 +02:00
Jonas Bark
12392ed487 docs: drop the stale dwell comment
Written for the 8s hold; the dwell is 5.5s now.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 08:52:31 +02:00