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>
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>
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>
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>
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>
- 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.
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>
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>
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>
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>
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>
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>
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>
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>
Locks in the fallback added with 2c7b18f4. openDrawer needs a DrawerOverlay
ancestor and does `parentLayer!` in release, so a caller passing a context
from above its own Scaffold used to turn "Go Pro" into a bare "Null check
operator used on a null value" toast with no paywall -- and on an expired
trial, no way forward.
Two cases: a Scaffold-less tree (the shape the onboarding trainer picker
hit) must still render the paywall, and a tree with a Scaffold must still
get the drawer, so the dialog fallback can't quietly become the only path.
SheetPullToDismiss is drawer-only, which is what tells the two branches
apart. The no-DrawerOverlay test asserts DrawerOverlay.maybeFind is null
first, so it can't silently stop reproducing the bad context.
Verified by reverting the fallback: the first test fails, and passes again
once restored.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
Three more shots for the Local connection tutorial, and the harness knob one of
them needed:
- the trainer app card on the main page, which is where a rider actually
opens Trainer Connections from ("Edit"), built from the real chain via
buildChain rather than a hand-made ChainLink;
- the placement editor over an in-game screenshot, with a click target on
MyWhoosh's on-screen gear arrows;
- the button editor as Android renders it: no keyboard row, but system
actions, the assistant and a custom broadcast intent.
captureWidget gains an optional `height`. Without one nothing changes: the
widget still gets unbounded height inside a scroll view. With one, the surface
becomes exactly width x height and the scroll view is dropped — a full-screen
page can't live inside another viewport, and the touch-area editor in
particular maps percentage positions against MediaQuery, so it has to be
rendered at the size it reports.
The touch-area shot needs a little more staging than the others: path_provider
and window_manager are mocked (no plugin registrant runs under `flutter test`,
so path_provider falls back to its base method channel), the display size is
pinned to the surface so the notch compensation nets to zero, and it renders
with settle: false because that page never comes to rest.
`pinApp()` before each capture: registering a button a shipped keymap doesn't
have copies that keymap into a profile of its own, so the handler's app drifts
away from the one the test is editing — which the touch-area editor notices,
because it reads the keymap off the handler rather than taking it as a
parameter.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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>
Eight widget snapshots the Local connection tutorial on the website is built
from: the target picker, the Local tile, the keyboard-permission sheet, the
mapping table before and after editing, the button editor with a keyboard
shortcut and with a mouse click, and the press-a-key dialog.
Two departures from the usual snapshot setup, both needed for a tutorial
rather than a store board:
- screenshotMode is turned back off, because the marketing renders
anonymize the trainer app to "Trainer app" and hide permission rows —
a tutorial needs the names and the rows the reader will actually see;
- the framework's target platform is pinned to macOS per test. The harness
renders Android-like by default, which grew Android-only cards (system
actions, assistant) on what is otherwise a macOS render. The reset has to
happen inside the test body: the binding checks that no debug variable
changed *before* tearDowns run.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Bump prop: user-set ERG is now sticky against MyWhoosh (FTMS 0x11) and
Rouvy/Zwift (Zwift Sync) resistance streams; app-set ERG stays non-sticky.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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>
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>
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>
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>
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.
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.
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>
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>