Commit Graph

4738 Commits

Author SHA1 Message Date
Jonas Bark
f99052d420 fix(onboarding): bring the network method up once Local Network is granted
Two gaps, both downstream of the launch-time deferral.

verifyEnabledNetworkMethod returned on success without starting anything, so
granting the permission left the method reading as enabled while advertising
nothing — the launch-time start had already been skipped while the wizard held
the screen, and nothing re-ran it.

The wizard's three exits (done + paywall, done + start riding, welcome/later)
mark onboarding completed and pop, but none started the enabled methods either.
Before the deferral the launch call had already done that; afterwards a method
carried over from a previous session stayed down until the next launch. That
one bites without any permission involved.

startEnabledConnectionMethod gains userInitiated, which opts out of the
deferral: app launch and trainer_setup keep the default and still hold off
while the wizard owns the screen, while the grant path and the three exits pass
true. The existing !isStarted.value guards mean nothing double-starts.

The test asserts the mDNS registration attempt actually reaches the channel,
rather than a proxy for it: the first version asserted the method stayed
enabled and failed even with the fix, because there is no nsd plugin under
`flutter test` and startServer()'s catchError switches the setting back off.
Checked both ways — without the start it fails Expected: non-empty / Actual: [].

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 10:55:26 +02:00
Jonas Bark
a488b0169f fix(onboarding): re-verify an already-enabled network method on step 5
setOnboardingMethodEnabled checks Local Network on the *enable* transition, an
edge a rider arriving at the connection step with the method already switched
on never crosses — tapping the tile there turns it off, which correctly skips
the check. So nothing verified the permission during onboarding for exactly the
riders who most need it: the ones with a configuration from a previous session,
or who granted Local Network once and revoked it since.

Step 3 already had this shape: _goTo calls _enterControllerStep, which checks
its requirements on entry. Step 5 had no equivalent. Add one.

verifyEnabledNetworkMethod() only acts on a method that is visible *and*
already enabled — asking about one that is off is the toggle's job, not step
entry's — and switches it back off when the permission is still missing, so the
tile stops claiming it is on.

The _liveStatus / _satisfy helpers move out of setOnboardingMethodEnabled to
top level so the toggle and the entry check share one path rather than drifting.

The test was checked both ways: stubbed out, it fails with
Expected: contains 'check' / Actual: [].

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 10:40:36 +02:00
Jonas Bark
c0ee01f4d8 fix(permissions): let the onboarding wizard always win at launch
The Local Network warning fired at startup and the wizard then opened over it.
_NavigationState.initState calls startEnabledConnectionMethod() synchronously,
while the onboarding push happens later in an async block — so the toast lands
first.

The deferral rule required *both* "onboarding not yet run" and "no connection
method enabled", so a pending wizard on a device that already had a method
switched on still probed. Every method setting defaults to false, so that
conjunction only ever differed in exactly this case: a rider re-entering the
wizard with an existing configuration. Drop it — if the wizard is about to take
the screen, defer, full stop. That also makes this gate and the
getScanRequirements one identical.

Guard inside startEnabledConnectionMethod() rather than at the navigation call
site, so trainer_setup.dart's two calls are covered as well; the wizard hits
those when the rider picks a trainer app, which is the same bug one step later.
Nothing is lost while onboarding runs: setOnboardingMethodEnabled starts its
servers directly.

hasAnyConnectionMethodEnabled goes with it — it existed only to feed the clause
that is now gone.

The regression test was checked both ways: with the guard stubbed out it fails
with Expected: empty / Actual: ['check'].

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
(cherry picked from commit 1eee7644213e93201f7073d97c74f13c593b4cde)
2026-08-21 10:31:20 +02:00
Jonas Bark
6be3345548 fix(mdns): bring back the received-query log, announce on demand on Windows
Support bundles from Jul 24 - Aug 21 show the OpenBikeControl button on a
same-host Windows PC failing in one shape: advertisement published,
self-discovered, one adapter, no VPN, and OpenBikeControl :36867 never sees
a client. The 6.3 bundles that still carried the responder's query log
explained it - browse and resolve answered, then the PC asking
'A <host>.local' ×114 without accepting the answer - and the field
workarounds confirm it: priming the Windows resolver with tnc <host>.local,
or starting MyWhoosh *before* BikeControl so it takes our startup
announcement. Neither signal is visible in a 6.4 bundle, because the query
log was dropped with the hostname fix in e3e451c.

- Diagnostics: 'mDNS queries received:' is back, between the VPN line and
  the TCP servers, same format as 6.3 (folded repeats with ×N).
- prop 37729cc: queries touching our records also earn a full unsolicited
  announcement on the querier's interface once the one-second floor clears;
  desktop announces every 10s instead of 60s; recentQueries on responder and
  advertiser.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 10:12:54 +02:00
Jonas Bark
b011e0e19d fix(permissions): check at launch, but not on a fresh unconfigured install
Checking a permission means *asking* for it on Apple platforms — instantiating
the BLE stack raises the Bluetooth dialog, and probing Bonjour raises the Local
Network one. Connection.initialize() runs from _StarterState.initState, so a
fresh install got both before the wizard had explained anything.

Launch-time checks are still the right thing for everyone else: a rider who
revoked a permission in System Settings should find out then, not from a
connection that silently does nothing. So defer only the case with nothing to
check for — onboarding not yet run *and* no connection method switched on:

  deferLaunchPermissionChecks(onboardingAction:, anyConnectionMethodEnabled:)

kept as a pure function beside decideOnboardingTrigger so navigation and
Connection cannot drift, and reachable as core.logic.deferLaunchPermissions.
Reading it during Connection.initialize() is safe: setLastSeenVersion is
written later (navigation.dart), so the pref still holds the previous launch's
value. An existing install upgrading reads markCompleted and is not degraded.

hasAnyConnectionMethodEnabled is new rather than !hasNoConnectionMethod: that
one mixes in show* visibility predicates, so it answers "should the UI nag"
rather than "did the rider turn something on".

startEnabledConnectionMethod() now gates the three network methods on Local
Network, mirroring what the BLE branches already did. They previously started
regardless and failed silently when the permission was off — the shape behind
the support tickets. The probe only runs when one of them is enabled, so a
BLE-only rider never sees the dialog, and a denial raises a warning instead of
a server listening into a black hole.

Third path, found only because a test that should have passed did not:
PermissionsSnapshot.gather() forced a probe, and _persistCrash builds a
diagnostics bundle on every recorded error —

  LocalNetworkAccess.status <- PermissionsSnapshot.gather <- DebugDiagnostics.gather
    <- debugText (menu.dart) <- _persistCrash (main.dart)

so any error at launch could pop the dialog past every gate above. Tie the
probe to the existing includeDiscovery seam, which the crash handler already
passes false for precisely because it must not do live network work.
User-initiated support bundles still get a fresh probe.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 09:58:33 +02:00
Jonas Bark
fb86df9841 fix(requirements): stop probing Local Network before onboarding is shown
getScanRequirements() runs on Connection init (connection.dart:548), long
before the onboarding wizard appears, so putting LocalNetworkRequirement in
that list popped the system Local Network dialog at app launch.

Probing it there was the wrong call twice over. Every consumer of that list
treats a non-empty result as "don't scan":

  connection.dart:424    skips performScanning()
  connection.dart:548    skips performScanning()
  onboarding_page.dart   shows the *Bluetooth* permission phase (_onAllowBluetooth)
  scan.dart:132          skips performScanning()

so a denied Local Network permission would also have silently stopped all BLE
scanning — the rider could no longer find their shifter at all. It is a
Bluetooth-scan gate; a network permission does not belong in it.

Gate OnboardingMethod.network on it instead, mirroring how .local already gates
on getLocalControlRequirements(), with the probe-prompt-recheck logic factored
into a shared satisfy() helper. The permission is then asked exactly when the
rider picks a network method, which is also where a denial is actionable. The
three network tiles keep their own gate.

getScanRequirements() gains a doc comment recording why Local Network is
deliberately absent, so it doesn't get added back.

Tests: the network method must consult the permission and must not report
itself enabled on a denial; getScanRequirements must neither carry the
requirement nor probe it at all — probing is what raises the system prompt, so
that one is the direct regression test for the launch-time dialog.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-21 09:37:04 +02:00
Jonas Bark
f10bf9f9c7 Merge branch '6.5' of github.com:OpenBikeControl/bikecontrol into 6.5 2026-08-21 09:07:54 +02:00
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
f14cdd07d1 cleanup 2026-08-21 08:47:37 +02:00
Jonas Bark
f524c77b8c Merge remote-tracking branch 'origin/6.4' into 6.5 2026-08-21 08:42:38 +02:00
Jonas Bark
f76689c451 cleanup 2026-08-21 08:41:31 +02:00
Jonas Bark
c03fe6518f fix(trainer): tear the bridge down when the upstream link drops on its own
Connection.disconnect only ran device.disconnect() while isConnected was
true, but both drop listeners (BLE connectionStream, DirCon onDisconnected)
clear that flag before calling in. So an unexpected drop removed the
ProxyDevice from the list without its teardown: the FitnessBikeDefinition
stayed attached to the shared emulator with a dead transport, every trainer
app control-point write still hit it ("Bad state: DirconClient is not
connected" once per write, per leaked definition), gear commands routed to
the stale first-of-type definition went nowhere, and "<trainer> -
BikeControl" kept advertising with no trainer behind it (support bd2f3b55).

The listeners now pass dropped: true so the teardown runs. The BLE listener
passes it only when the device was connected until that event, so a late
echo of a deliberate disconnect stays on the old path; and a re-entrant call
for the platform event that lands mid-teardown skips a second teardown
(_disconnecting), which is what emulation_forget_test tripped over.

Regression tests drop a real loopback DirCon socket and a fake BLE
peripheral under a live bridge and assert the definition is detached, the
emulator stopped and nothing advertised.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-21 08:41:21 +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
eed0651cd8 test(self-test): drain FTMS control-grant timer in single-protocol selector test
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-08-20 15:17:09 +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
c60942018a chore: bump prop to self-test head (protocol toggle + diagnostics) 2026-08-20 14:52:37 +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
4af3dbcddf Bump prop
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-08-20 14:12:28 +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
431f008a1a Merge branch 'vpn-diagnostics-line' 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
7f3e696356 test(paywall): cover opening "Go Pro" from a DrawerOverlay-less context
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>
2026-08-20 07:37:43 +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
jonasbark
91179b846b Merge pull request #379 from OpenBikeControl/test/local-connection-snapshots-v2
Snapshots for the Local tutorial: entry point, mouse editor, Android action list
2026-08-18 21:06:33 +02:00
Jonas Bark
a58edfbb2c test(snapshots): the Local tutorial's entry point, mouse editor and Android list
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>
2026-08-18 20:59:27 +02:00
Jonas Bark
f0297fa6cc chore: submodule
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 20:24:52 +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
40a114b913 test: housekeeping
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-18 20:23:17 +02:00
jonasbark
6771203b43 Merge pull request #378 from OpenBikeControl/test/local-connection-snapshots
Snapshot test for the Local connection method tutorial
2026-08-18 20:08:54 +02:00
Jonas Bark
b80107b358 test(snapshots): capture the Local connection method for the blog tutorial
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>
2026-08-18 20:03:53 +02:00
Jonas Bark
1f1c1e2eef fix(trainer): the bridge answers its feature read without waiting on the trainer 2026-08-18 20:01:19 +02:00
Jonas Bark
50ac4379ba fix(trainer): the bridge presents its own services and never waits on the trainer 2026-08-18 18:44:07 +02:00