Commit Graph

36 Commits

Author SHA1 Message Date
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
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
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
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
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
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
67e405e6ad fix: name the Click V2 unlock mode, and say where unlocking happens
The card showed only "Entsperrmodus" and "Erneut einrichten", so it looked
identical whichever mode was set and coming back from the explainer read as
if the choice had done nothing. Name the mode that is actually set, modelled
as the three states the setup can rest in — unlock-with-Zwift, right-side-
only, and the legacy restart loop — resolved in one place so both pucks name
the same mode the same way.

The missing unlock option was real, too. unlockWarnings — which carries
"Jetzt freischalten" — is rendered only by the left puck and the legacy
unified controller, and returns nothing without a connection; the right puck
never carried it, correctly, since the left one is what Zwift locks. So in
Zwift mode with the left puck off, asleep or not yet rediscovered, the action
existed nowhere and the card sat silent. Point at the left controller in that
case instead. When it is connected nothing changes: the left card shows the
real unlock UI and the right card stays quiet.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 08:37:18 +02:00
Jonas Bark
74bb2737ba fix: UI feedback round — remembered devices, Click V2 unlock, paywall, Pro dialog
- Remembered controllers offer a single "Forget" instead of two disconnect
  variants: there is no link to drop on a device that isn't here.
- Click V2: drop the unlock-mode dropdown and the new-unlock-method toggle.
  The explainer stays the one place the mode is chosen — it also does the
  follow-on work (un-ignoring the left puck, the right-side-only remap,
  cancelling the reset timer) that the bare dropdown never did. "Set up
  again" now sits on the right puck's card too.
- Paywall: the Base column reads "Basis"/"Base" rather than "VOLL"/"FULL",
  and the one-time Base card moves above the Pro plans so top-to-bottom
  matches the comparison table's left-to-right.
- A remembered controller's own settings page shows its button mapping
  again. The gate counted live controllers only and KeymapExplanation
  looked its filterDevice up in the live list, so the page fell through to
  a warning about connection methods, which had nothing to do with it.
- showGoProDialog takes a feature name for its title, so the keymap sync
  cloud icon says what it does instead of only "Pro Feature".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-13 07:50:34 +02:00
Jonas Bark
c66cac4591 feat(home): the Click V2 setup step, status warning glyphs, and an unused trainer's pitch
Three chain-card changes. They arrived as one commit because the first
was still uncommitted when the others landed on top of it.

**A Click V2 waiting for its unlock-mode choice.** Reported edge case: a
brand-new install where the wizard was skipped or finished on another
controller leaves clickV2OnboardingDone false, so a Click V2 switched on
afterwards is discovered, in range, healthy — and deliberately not
connected. The chain had no way to say "we are choosing not to connect
this", fell back to presence, and told the rider their controller had
never been paired and should be brought back into range, about a device
switched on beside them.

That step now REPLACES the checklist rather than joining it. Putting it
first would have left the false steps sitting below it; every other step
is unknowable until the device is allowed to connect. Once the choice is
made the normal checklist returns. The card's action reads "Set up" and
opens the explainer, since the choice is what releases the controller
into the connect queue.

**Warning glyphs beside the status.** A flat battery, a pending firmware
update or a signal about to drop are qualifiers on "Connected" — it
works, but not for much longer, or not well — and the card said nothing.
They show only when something is actually wrong, so a glyph appearing
means something. Thresholds are the device page's own (20%, -70 dBm)
rather than new ones, so the two screens cannot disagree about "low".

**The bridging pitch on an unused trainer.** A trainer that is here but
has never been connected now shows what bridging it would buy instead of
an empty card; that list already existed on the device page, and this is
exactly the rider who has not seen it. Dropped once bridged, where live
numbers are the useful content, and dropped for one that broke
mid-session, where it would read as if nothing were wrong.

Not covered by tests: which badges get chosen, and when the feature list
appears — both are private methods on _HomePageState, which has no
widget test to hang a case on.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 19:41:37 +02:00
Jonas Bark
d985e6d2b5 feat(accessory): name the actions an accessory obeys, and where to assign them
An accessory's settings page had nothing to say about what the device can
actually do: its actions live on a controller's buttons, and the page that
would have shown them (button mapping) is hidden here because a fan has no
buttons of its own.

It now lists them — the six Headwind speed/HR actions, the four incline
ones — straight off the device via a new BaseDevice.assignableActions, and
hands over to the controller that can carry them: the connected one, since
that is the one a rider can test a mapping on right away. With no
controller around it says so rather than offering a dead link.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 16:23:28 +02:00
Jonas Bark
04c97f20dc fix(home): show accessories so a stray Headwind can be ignored
Every Headwind or Climb the scanner finds is connected automatically,
including one that isn't the rider's — a neighbour's fan through a wall.
Getting rid of it means putting it on the ignore list, and the only route
onto that list is "Disconnect & forget" on a device's settings page. But
accessories are excluded from controllerDevices, which is the only device
list the setup chain renders, so such a device appeared nowhere at all and
could not be dismissed.

They now get their own quiet section below the chain: one card per
accessory, no checklist, opening the settings page that already carries
the forget action. That page in turn drops the button-mapping section and
"Reset to defaults" for an accessory — a fan has no buttons, so both were
empty promises — and titles itself "Device Settings" instead of
"Controller Settings". A Headwind also stops presenting itself with the
default gamepad icon.

Auto-connecting to any accessory in range is left as it is: the rider
ignores the neighbour's fan once, and it stays gone.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 16:05:25 +02:00
Jonas Bark
aa0720b984 fix(click-v2): the no-unlock option is the right puck, not the left
The first-run explainer offered "use the left side only" as the way to
avoid Zwift. That is the one puck Zwift actually locks. Picking it left
the rider on the 59-second restart loop, and — because
ZwiftClickV2RightSide.shouldAutoConnect required unlock-with-Zwift — it
also withheld the puck that needs nothing at all. Worse, with Zwift's
built-in keymap binding the right paddle to shiftUp and the left paddle
to shiftDown, the left side alone could only ever shift down. The
genuinely clean setup was reachable only by first choosing the mode it
was meant to replace, then tapping "Use the right side only" on the
right card.

So the option becomes right-side-only: no unlock ever, no restarts, and
the +/B remap the right card already applied so one puck covers both
shift directions. The cons now name the real price — no D-pad, so no
steering and no action bar.

Click V2 state is three modes now, not a boolean, and both connect gates
say so out loud. ClickLogic drives the left side's restart loop from a
single static timer that the right side's handshake cancels, so those
two can never be live together; that invariant used to be implied by one
gate and is now stated in both. Left-restart mode survives as the left
card's existing Select for riders who want the D-pad, just not as a
first-run choice.

The right card's shortcut delegates to the same policy rather than
keeping its own path, so both leave identical state: the left side held
back by the setting instead of pushed onto the ignored-devices list,
which is what lets "Set up again" undo it. Its confirmation copy moves
accordingly, and it stops offering itself once the left side is merely
listed rather than connected.

The remap sits in its own recordError guard. It needs a trainer app to
have been picked, and a mode the rider explicitly chose must not be left
half-written because an optional convenience could not run.

This also turns emulation_zwift_profiles_test's right-side case green:
it had been red since the gate landed, because e74c5920 fixed only the
isPending half of what was holding that side back.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 15:40:00 +02:00
Jonas Bark
1b72284c41 feat(home): show only the steps still to do
A ticked step has said everything it can the moment it ticks. Keeping it
on screen buries the one line that still matters under a list of things
that don't — and a card whose work is finished was spending a whole row on
telling the rider so.

Cards now render their outstanding steps and nothing else, and the
accordion goes with them: no summary row, no "N of M steps done", no
chevron, no tap to unfold a list of completed work. A finished card is
just its header. The banner already carries the count across the whole
chain, so the per-card tally was saying it twice.

startsExpanded gives way to pendingSteps in the model — the card had no
open/closed state left to remember. The first outstanding step is still
the active one and still carries the sole instructions button. The
AnimatedSize stays: when the last step ticks the card folds to its header
as a movement rather than a jump.

chainStepsDone and chainAllStepsDone were the accordion's only copy, so
they come out of all six locales rather than linger as strings nothing
renders.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 15:33:22 +02:00
Jonas Bark
56a8e87f7d i18n(home): translate the setup chain, align its checklist, stop billing
undelivered shifts

Three things.

The chain's 68 strings existed only in English, so five locales fell back
to it on the app's main screen. Now translated, in each file's own register
— informal second person throughout, matching the copy already around
them. Polish needed a `few` plural category for the step and day counters:
it uses a distinct form for 2-4, so `other` would have rendered "Zostały 2
kroków" instead of "kroki". Two keys written speculatively and never wired
up are dropped rather than sent to five translators.

The checklist's summary row sat inside a Button whose own padding inset it
past the steps below, and the leading glyphs differed in both width (15px
icon, 17px tick) and gap, so matching the outer inset alone would not have
lined them up. One _rowInset / _leadingSize / _leadingGap now governs both,
with the glyphs centred in a box of equal width. Two tests pin the tick and
the label columns, because this is exactly what drifts back unnoticed.

Finally, shifting with a trainer connected but no app holding the bridge
was charged to the daily command budget. Those shifts reach nothing. The
existing exemption only covered the case where the 20-minute
virtual-shifting budget was already ticking — that avoids double-billing —
so it grows a second reason: a command that was never delivered anywhere is
not a command the rider spent.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 14:39:07 +02:00
Jonas Bark
ca885c79d9 fix(trial): commands are capped during the trial too, and say so
"Unlimited commands until the trial ends" was not true.
RevenueCatService.canExecuteCommand is dailyCommandCount <
getDailyCommandLimit() and returns early only for purchased users — never
for trial users. What actually happens is setDailyCommandLimit(80) while
the trial runs, falling back to 15 once it expires. So the cap is 80/day
during the trial and 15/day after, and the card now shows the command
meter in both states rather than promising something the code does not do.

The same falsehood was in trialPeriodDescription, which is worse: it is
rendered only while the trial is live (iap_status_widget's !isTrialExpired
branch) and handed the *current* limit, so it read "unlimited now, 80 per
day later" — where 80 is precisely the limit that applies now. Corrected
in all six locales rather than leaving five of them asserting it, each
keeping the informal register its neighbouring strings already use.

More Options opens by default — what is in it is short, and collapsing it
on a screen the rider is already scrolling only hides it — and the quit
row now says what it does to the connections as well as to the app.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 14:07:29 +02:00
Jonas Bark
3f83351144 feat(home): connect trainers from the card, animate status changes
Three things the chain got wrong once a real trainer was in the room.

The trainer card offered "Edit" for a trainer that had never been
connected — an offer to edit nothing. It now offers Connect until the
trainer is actually bridged, and that opens the onboarding trainer picker
itself: connectTrainerFromPicker is extracted so onboarding and the home
card share one path, and "connect my trainer" behaves identically wherever
a rider reaches it. Extracting it also removed an empty `if
(device.isSmartTrainer) {}` that the consent removal had left behind.

The checklist is withheld until the rider has committed to bridging. A
trainer merely in range and one deliberately left on "let the app handle
shifting" are the same state underneath — not connected — and in both
cases a column of unticked boxes reads as work outstanding when there is
none. That surfaced a related bug: picking "No connection" sets
autoConnect false, but a trainer that had connected earlier in the session
was still classified as lost, so deliberately disconnecting it turned the
card red. An explicit "no connection" is now a resting state regardless of
what happened earlier.

Status changes animate. The checklist grows and shrinks through
AnimatedSize, so when the last step ticks the card folds to its one-line
summary as a movement the eye can follow rather than a jump; the card
border and the banner — colour, wash, and the badge resizing between its
calm and alarmed sizes — move on the same curve, so the screen resolves as
one gesture instead of several. The test asserts the collapse is genuinely
taller mid-flight than at rest, because "it animates" is otherwise not
something a test can hold onto.

Finally, the trainer-app instructions sheet was a thinner retelling of the
setup steps rather than the steps themselves. The onboarding guide block
is extracted as OnboardingAppGuideCard and both use it, so a rider who
loses the connection gets the same numbered steps, the same screenshots
and the same full-guide link that got them connected in the first place.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 12:27:35 +02:00
Jonas Bark
55e2229a98 feat(home): rebuild the main screen as the setup chain
The old Main tab showed three cards that each exposed whatever the app
happened to know — battery, BETA tags, four live metrics, a media toggle,
a dropdown — and none of them answered the only question a rider has
before a ride: am I ready? When something broke, nothing on screen said
which link failed or what to do about it.

Now every link in the chain gets one card with the same three parts: a
status light in one shared vocabulary, an Edit in the same place on every
card, and a tick-off checklist whose next action carries its own
instructions. Ready cards collapse to one line; unresolved cards open
themselves onto the single active step. Green stays in the dot and ready
status lines stay grey, so colour on this screen always means "look
here". The banner is derived from the cards below it, never asserted
separately, so it cannot contradict them.

Remembered devices close a real gap. A controller that was switched off
or out of range vanished from the app completely — riders could not see
what they owned, could not tell "never set up" from "not here right now",
and could not change a mapping away from the bike. The contour now stays
on screen and stays interactive while disconnected, since mapping a
button is a keymap edit, not a radio operation. Swiping a disconnected
card forgets it, with Undo; a connected one has no dismiss gesture at
all, so the swipe can never drop a working controller.

Desktop follows ui_kits/app-desktop: the chain reads as one centred
column and the activity log is promoted from a tab to a permanent rail,
which is where Help now lives.

The status dot pulses six times rather than forever. This app holds a
wakelock so the home screen can sit lit on a handlebar for an entire
ride, and an animation that never ends also never lets a frame loop go
quiet — which hung every widget test that rendered an attention card.

Nothing is dropped: the scan options, media-key and phone-steering
toggles, ignored-devices list, recording indicator and quit action move
into a collapsed "More options" section below the chain.

Verified against a stashed baseline — the suite's 32 failures (stale
golden screenshots plus one load-dependent flake) are all pre-existing
and unchanged; 93 new tests pass and analyze is clean.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 10:38:37 +02:00
Jonas Bark
4f1db04b77 fix(click-v2): drop lock badge animation from the decision page
The decision page is about choosing, not explaining -- the animated
padlock that sells page 1's Zwift-unlock trade-off was noise once both
options are already laid out in the buttons below. Pass
ClickContours(page: 1, animate: false) there instead, leaving pages 0
and 1's badges untouched.

Also covers animate: false with real test coverage (previously only
MediaQuery.disableAnimations exercised the no-loop path) and updates
click_contours.dart's stale doc comment, which still pointed at the
64x40 card thumbnail removed in an earlier task.
2026-08-03 20:30:23 +02:00
Jonas Bark
54e718b2ee fix(click-v2): apply three product-owner UI corrections to onboarding
- Drop the nested Card in the placeholder device-list entry so it sits
  flush with sibling cards, and replace the 64x40 ClickContours thumbnail
  (illegible at that scale) with the standard StatusIcon badge, matching
  the gamepad icon Zwift Click V2 devices already carry.
- Move the onboarding pager's hero inside each page's own scrollable
  content instead of as fixed chrome above the PageView, so a drag on the
  contours swipes the pager and short viewports can scroll the hero too.
  Each page now gets a fixed hero state instead of the shared scrubbing
  value, since two scrubbing heroes sliding past each other mid-swipe
  looked broken.
- Make the swipe hint tappable (advances one page via the PageController)
  per updated product direction, while keeping it visually light and
  free of any choice-applying behavior.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GcRAUvS3gwjmfi2qJipcc
2026-08-03 18:30:30 +02:00
Jonas Bark
074955d92d feat(click-v2): make the unlock-mode choice its own pager step
Riders were tapping the first page's CTA by reflex without ever swiping
to compare the two unlock modes, so page one became a de-facto default.
The two option pages are now explanation-only (swipe hint instead of a
CTA), and a new third pager page presents both choices side by side with
equal visual weight so a decision can't be made without seeing both.

Also updates test/click_v2_onboarding_l10n_test.dart's hardcoded key
count (19 -> 24) and runtime smoke-test list for the five new arb keys,
since that test was not otherwise part of the brief's file list but
would fail on the new keys without it.
2026-08-03 17:31:32 +02:00
Jonas Bark
aec4760e76 feat(click-v2): animate the unlock trade-offs in the onboarding
Adds looping state badges to the onboarding hero (an idle-timeout pill on
page 0, a padlock with a sweeping ring on page 1, cross-fading with the
pager) and a staggered fade/rise entrance for each option's pro/con rows,
so the trade-off reads at a glance instead of as two paragraphs of text.
Both badges respect reduced motion via a MediaQuery.disableAnimations
guard that stops the shared loop controller rather than letting it run
forever under pumpAndSettle. Also closes a minor double-tap gap on the
two CTAs.

The three pre-existing tests that navigate to the onboarding page and
pumpAndSettle needed a one-line disableAnimations pin so the new
perpetual-while-visible loop doesn't make them hang, matching the
existing pattern in device_page_click_v2_collapse_test.dart for the same
class of problem.
2026-08-03 17:06:30 +02:00
Jonas Bark
37152aafbe feat(click-v2): reopen the onboarding explainer from the unlock-mode selector
Adds a ghost "Set up again" button beside the Unlock mode label in
UnlockToggle so the Click V2 explainer stays reachable after the
one-time onboarding flow completes.

Also guards ClickLogic.setupHandshake against a null `services`: a
device's isConnected can flip true (via the raw BLE connection-state
listener) before connect() finishes assigning services, so the prior
force-unwrap could throw on that narrow race. The setting write still
happens either way; only the handshake is skipped, and skipping is
logged via a LogNotification rather than swallowed.
2026-08-03 16:20:11 +02:00
Jonas Bark
3752701455 test(click-v2): cover the pending-sides-collapse behaviour on DevicePage
Review found the onboarding card test only exercised the card in
isolation, leaving _deviceGroups' actual collapse/pairing logic
unverified. Add device_page_click_v2_collapse_test.dart covering both
pending, only-one-side pending, already-onboarded (regression), and
the preserved connected-pair layout. Also close a vacuous-pass gap in
the existing card test's ancestor-exclusion assertion.
2026-08-03 16:04:13 +02:00
Jonas Bark
b484b1069a feat(click-v2): show a pending-setup card for undiscovered-mode controllers 2026-08-03 15:26:10 +02:00
Jonas Bark
3a2d26378e feat(click-v2): add the fullscreen unlock-mode onboarding flow 2026-08-03 15:14:20 +02:00
Jonas Bark
d559bd0a28 fix(click-v2): scale contour hero constants to the given box, add coverage
Review findings on ClickContours:

- The glow blur/spread and the right-puck outward offset were authored as
  absolute pixels against the onboarding pager's 180px-tall hero. A later
  task reuses this widget as a much smaller card thumbnail, where a 34px
  blur or a 14px translate would overwhelm the art. Wrap the layout in a
  LayoutBuilder and scale those three constants by
  (availableHeight / 180).clamp(0, 1), so appearance at the pager size is
  unchanged and the thumbnail degrades proportionally instead of breaking.
- Document the widget's bounded-width/finite-height contract in the class
  doc comment (Row+Flexible asserts otherwise).
- Add ValueKeys to the right puck's Transform.scale/Transform.translate and
  the left puck's glow DecoratedBox, and cover the previously-untested
  interpolated properties: right puck scale and x-offset, left puck glow
  alpha, and a small-thumbnail case proving the offset scales down rather
  than staying a flat 14px. The existing right-puck-opacity key and its
  four tests are unchanged.
2026-08-03 10:16:06 +02:00
Jonas Bark
b0d7af8f48 feat(click-v2): add animated contour hero for the onboarding
Adds ClickContours, the two-puck silhouette that animates as the Click V2
onboarding pager moves between "left side only" and "unlock with Zwift".
Takes a fractional page value instead of owning a PageController so it can
be scrubbed continuously by a swipe or driven by a plain animation later.
2026-08-03 09:58:19 +02:00
Jonas Bark
48e80d2925 feat(emulation): Emulation card on controller settings page 2026-07-02 10:11:49 +02:00
Jonas Bark
ff57b005d5 feat(shifting): show 2×N gear position when the front derailleur is active
With the virtual front derailleur on, the compact gear readout switches
from rear gear/total (14/25) to head-unit-style front×rear position
notation (small ring 1×N, large ring 2×N, e.g. 2×14) — matching how
Garmin/Wahoo display Di2/AXS gearing. With it off, it stays 14/25.

- Add tested formatGearReadout helper.
- Wire into the proxy card, debug menu, desktop second window + Android
  PiP/overlay (trainer_overlay_view), and the gear hero card (2× · 50T).
- Carry frontShiftEnabled + frontRingLarge through TrainerOverlayState
  (json, ==, hashCode, activity map) so the snapshot reaches the overlay
  and the iOS surfaces.
- iOS PiP + Live Activity: format 2×N centrally in GearSnapshot.
- Standardize the off-state readout to 14/25 across all surfaces.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-26 15:02:40 +02:00
Jonas Bark
cfe9e1d6b7 fix: guard crash-logger debugText call; migrate widget test to new permissions API 2026-06-22 12:15:06 +02:00
Jonas Bark
16ab318877 feat: show diagnostics block above the Logs page with refresh + share 2026-06-22 10:38:10 +02:00
Jonas Bark
5dbd091f27 Fix crash in Go Pro dialog when opener is unmounted
The dialog builder captured the caller's BuildContext for l10n lookups
and the purchase flow. When the widget that opened the dialog was
removed from the tree while the dialog was still showing (e.g. a
ConnectionCard remount), any rebuild of the dialog hit
AppLocalizations.of on the defunct context and crashed the isolate
with "Null check operator used on a null value" (l10n.dart:50 via
go_pro_dialog.dart:43, seen on Windows 6.0.0).

Use the dialog's own builder context instead, and guard the
post-purchase pop with a mounted check.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 21:41:23 +02:00
Jonas Bark
9c43a07cb0 fix gear change buttons 2026-05-10 11:10:22 +02:00
Jonas Bark
73954458bd refactor(overlay): rename OverlayState -> TrainerOverlayState to avoid Flutter collision
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>
2026-05-08 23:06:24 +02:00
Jonas Bark
7940255188 feat(overlay): TrainerOverlayView shared widget
Adds TrainerOverlayView — a self-contained, platform-agnostic widget that
renders gear N/M, mode pill (ERG/SIM), and optional power/cadence metrics.
Wired via ValueListenable<OverlayState>; onModeToggle/onDragStart are nullable
for Android isolate compatibility. Covered by 3 widget tests (TDD).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 23:04:21 +02:00
Jonas Bark
41e6c28851 feat(ui): add StepperControl reusable widget 2026-04-15 21:07:07 +02:00