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>
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>
- 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>
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>
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>
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>
It was added while chasing the network discovery problem and is not useful
now that the cause is fixed.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Renders "×N" on folded entries so a continuous poller reads as one line that
fired N times rather than silently occupying one slot. Single occurrences stay
unmarked.
Picks up the prop-side fold + the 40 -> 200 ceiling, after a field capture
filled the whole buffer in eight seconds and lost the window that mattered.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PanTG9kRBi4QTQ2psvpTxP
Adds the "mDNS queries received" section to the diagnostics report, listing
each query the responder saw with its source, the QU bit and whether the reply
went out unicast, multicast, both or not at all.
This is the missing half of diagnosing "the trainer app on this machine can't
find BikeControl". A same-host querier appears with the advertised address as
its source, so the report now distinguishes three very different situations:
the app never queried us at all, it queried for the service (PTR/SRV — the
browse step), or it queried for our hostname (A — the resolve step). Empty on
iOS, where the OS responder handles queries and never reports them to us.
Picks up the prop-side fix for the Windows shared-port QU delivery problem.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PanTG9kRBi4QTQ2psvpTxP
Gesture engine: a repeat of the SAME lever inside the 90ms combo window
can't be a combo, so flush the pending click instead of overwriting it —
rapid double-taps now deliver both shifts. The old press-swallowing was
accidentally doing multishift suppression, so bring back the explicit §7
guard (forward the first two rapid triggers, drop the 3rd+ within 350ms)
that the discrete-click rework removed.
Test fixes for the rest of the failing suite:
- review_prompt_service_test: derive seeds from sessionThreshold /
snoozeSessions instead of hardcoding the old threshold of 3
- controller_settings_signal_change_test: persist a session key and run
handleServices so the device is bonded and the Restore branch renders
- emulated SRAM AXS profile: send real 1-byte 0xFF edges (0x01 is now
filtered as a read-response echo), expect the generic 'SRAM Button'
name, and wait for the app's trigger subscription before tapping so
the press can't land mid-connect and get wiped by the gesture reset
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- Ignore toggles during the transient starting/stopping states (in-flight
guard) so a double-press can't double-start or stop-during-start.
- macOS: reset the recorder handle when start() throws, so one failure no
longer permanently blocks recording (only stop() nilled it before).
- iOS: remove the broadcast picker view after triggering so a 1x1 view doesn't
accumulate on the key window on every start.
- Report failures via recordError (was debugPrintStack, which vanishes in
release builds). Adds an in-flight-toggle guard test.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Without this, in-the-wild VS reports can't be correlated with whether
the new opt-in spike filter was active. Mirrors the existing
gradeSmoothing → grade_smoothing plumbing.
The global trainerOverlayMode notifier was only used by TrainerOverlayHost
to swap the main window UI. Both are gone; remove the notifier from
trainer_overlay_service.dart and drop the corresponding test assertion.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Trial users haven't yet decided whether the app is worth paying for, so
prompting them to rate it produces noisy reviews. Hide the banner while
the trial is active; it returns once the user buys or the trial ends.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Removes the need to `hide OverlayState` on shadcn_flutter imports in
trainer_overlay_view.dart and its widget test.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds a Supabase-backed support chat that replaces the existing trainer
feedback page and the mail support entry in the help dropdown. The chat
captures the same telemetry snapshot (extracted into a shared
TelemetrySnapshot module) and supports threaded replies and attachments.
- New SupportChatService wrapping the four edge functions plus a signed
URL helper for support-attachments storage.
- New SupportChatPage / SupportThreadPage with composer, attachment chips,
optimistic send, sign-in gate, and pull-to-refresh.
- Help dropdown's Mail entry replaced with "Chat with Support" that
pre-fills debugText() as freetext on the first message.
- Trainer device details "Provide Feedback" button now opens the chat
with TelemetrySnapshot.fromDevice telemetry.
- Login screen gets a subordinate "Don't want to sign in? Write a mail
instead" ghost button (mobile only) that opens the existing mailto.
- Telemetry helpers moved out of the deleted trainer feedback files into
lib/services/telemetry_snapshot.dart; test rewritten for the new class.
https://claude.ai/code/session_0155Bb4kCYaxKh7zQfoQHZET
Adds PastWorkout model, WorkoutRepository (save/list/delete) with UTC-stamped filenames, and wires it into Core.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements WorkoutRecorder with start/pause/resume/stop transitions, 1 Hz
sampling loop via configurable tick timer, active duration tracking that
excludes pause time, and WorkoutResult with summary. Wires recorder into Core.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Implements FitFileWriter.encode() which converts WorkoutSamples and a
WorkoutSummary into a standards-compliant FIT Activity file with
FileId → Event(start) → Records → Event(stop) → Lap → Session → Activity.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>