Commit Graph

12 Commits

Author SHA1 Message Date
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
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
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@gmx.de
7e58213dc2 chore: drop the mDNS query listing from diagnostics
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>
2026-08-10 14:44:01 +02:00
Jonas Bark
274a6ba634 diag: show repeat counts in the mDNS query log; bump prop submodule
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
2026-07-30 21:52:25 +02:00
Jonas Bark
8b8b94b0af fix(diagnostics): surface received mDNS queries; bump prop submodule
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
2026-07-30 13:11:24 +02:00
Jonas Bark
7ab6c6959b style: sort diagnostics TXT entries alphabetically by key 2026-06-22 17:00:17 +02:00
Jonas Bark
ae2943c752 style: tidy diagnostics Permissions line; omit when nothing to show 2026-06-22 12:27:11 +02:00
Jonas Bark
dc2467566e refactor: drop Bluetooth/Location from diagnostics permissions; keep iOS local-network inference 2026-06-22 12:14:07 +02:00
Jonas Bark
0008e173a2 feat: label OpenBikeControl TCP server; gate iOS local-network inference to iOS 2026-06-22 10:53:56 +02:00
Jonas Bark
0e38f0d819 feat: add DebugDiagnostics aggregator and text formatter 2026-06-22 10:30:24 +02:00