Commit Graph

9 Commits

Author SHA1 Message Date
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
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
6dc4136567 fix(click-v2): enabling the new unlock method lands on the right puck
Reported from a device: switching "use new unlock method" on from the
detail page connected only the LEFT puck — the one that needs unlocking
— which is the setup the switch exists to move the rider off.

Two causes, both needed fixing.

Nothing put the rider into a mode. The toggle only flipped the
representation, so with unlock-with-Zwift off and right-side-only off,
the left puck's gate let it connect while the right puck's gate — which
needs one of those two settings — kept it out. Enabling now routes
through chooseRightSideOnly(), so the toggle and the explainer leave
identical state. A rider who deliberately chose unlock-with-Zwift keeps
both sides; this only redirects the default.

And even with the mode set, the right puck could never appear. In the
legacy representation its advert IS scanned and cached, but
fromScanResult returns null for it — the advert is remembered while
resolving to no device, and the scanner then dedupes against that cache
forever. So the switch also restarts the scan, the same thing
restoreLeftSides already needed.

That meant widening what counts as a left puck. In the legacy
representation the unified ZwiftClickV2 IS the left puck, built from its
advert (the right one builds nothing), so ignoring only
ZwiftClickV2LeftSide missed the very case this bug is about.
_ignoreLeftSides now matches ZwiftClickV2 — which covers both classes
and cannot catch the right side, since that extends ZwiftRide — and
restoreLeftSides recognises both label constants, or a puck ignored as
the unified controller could never be restored.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 18:02:03 +02:00
Jonas Bark
65f4f22527 fix(home): restore the Click after switching off the split representation
Reported from a device: pick right-side-only, then turn "use new unlock
method" off, and you are left with no Click at all and a chain showing
its empty "Controller" placeholder.

One cause, not two. Right-side-only puts the left puck on the ignored
list — but in the legacy representation the LEFT puck is what becomes
the unified ZwiftClickV2, and the right puck builds nothing at all (see
BluetoothDevice.fromScanResult). Ignored left plus null right leaves
nothing to build, and the "Controller" entry was never an orphan: it is
chainControllerTitle, the placeholder the chain correctly falls back to
when no controller exists.

So the toggle now clears the mode and un-ignores the left side before
switching. That path was private to the onboarding policy on the
assumption that right-side-only was the only way out of it; it is not,
so it becomes restoreLeftSides().

Three UI fixes alongside it.

The error banner over the chain is gone, with the state that only fed it
— both animation controllers, the shake, the latest-error entry. The
activity log and its tab dot are untouched; the chain says what is wrong
now, and a card repeating it above was the older answer to the same
question.

Button-action errors no longer toast while the onboarding wizard is
open. The wizard asks the rider to press a button precisely while the
trainer app or the keymap is not set up yet, so those presses fail by
design, and "X could not be performed" over the step that asked for the
press reads as the wizard being broken. Still logged to the activity
list.

And the checklist's step rows sat 4px from the card edge, so the active
step's highlight read as a panel the card had failed to contain. At 10
it sits inside the card, with StepRow's own inset still letting the
highlight bleed slightly wider than the text.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 17:00:05 +02:00
Jonas Bark
77596ffbe0 fix(click-v2): ignore the left puck in right-side-only, and name both pucks
Three things the first cut of right-side-only got wrong on a real phone.

The left puck was held back by a setting rather than ignored, so it kept
its entry in the device list and the active scan handed it straight back
— an orphan stuck on "connecting" that never could. Filtering it out of
controllerDevices fixed the onboarding list and missed the home chain,
which also draws from offlineControllers. That is the argument against
inventing a second mechanism: ignoring is the one the scan filter, the
remembered-device loader and the device list all already honour, so
using it takes the puck out of every list at once. The dedicated gate
and the isExcludedBySetup filter are gone with it.

Ignoring has to cover the remembered stand-in too, not just a live
device — the chain lists both side by side, and the card in the report
was a stand-in.

It also has to be undoable, or picking "unlock with Zwift" after
right-side-only silently still yields one controller. Removing the
ignored entry is not enough on its own: the scanner dedupes against its
cached advert, and performScanning() returns immediately while a scan is
already running, so the puck only came back on the next launch. It now
restarts the scan.

Both lists showed "Zwift Click" for both pucks: `name` is the raw BLE
advertised name, identical for the two. They use displayName, which
carries the translated left/right suffix.

Finally, the chain sat 24px in from each screen edge on mobile —
Overview's scroll view pads it by 12 and HomePage added 12 of its own,
before each card's padding on top. Desktop keeps its inset; there the
chain sits in a centred max-width box with no padding of its own.

Known sharp edge, left deliberately: un-ignoring the left puck by hand
while still in right-side-only mode brings both up live, and the right
side's handshake cancels the left's restart timer.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-11 16:23:38 +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
ff8d393046 fix(click-v2): apply pre-merge review fixes to onboarding flow
Fixes five review findings on the Click V2 onboarding branch:

1. "Set up again" now performs the same ClickLogic side effects
   (setupHandshake / resetTimer) the connect-time flow does for an
   already-connected left side, and refreshes UnlockToggle's state on
   return instead of leaving it stale.
2. ClickV2OnboardingCard gained an onCompleted callback (wired to
   DevicePage.onUpdate) so the device list refreshes even when no
   connectionStream event fires after the onboarding page closes.
3. A connect failure in ClickV2Onboarding._connectPending() now also
   surfaces a user-visible AlertNotification, not just a logged error.
   New l10n key clickV2Onboarding_connectFailed added in all six
   languages.
4. ClickV2OnboardingPage now builds its staggered-entrance
   CurvedAnimations once in initState instead of one per row per
   build, fixing an unbounded status-listener leak on _rows.
5. pendingDevices is intentionally left ungated on isPending (gating
   it would break _connectPending, which needs it precisely because
   isPending already flipped false) but is now correctly documented,
   and _connectPending skips devices the battery saver suppressed via
   the new Connection.isAutoReconnectSuppressed.

Also drops the redundant flutter/widgets.dart import from
click_v2_onboarding.dart (shadcn_flutter re-exports PageView/
PageController).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_011GcRAUvS3gwjmfi2qJipcc
2026-08-03 18:14:06 +02:00
Jonas Bark
3693f1b1d0 feat(click-v2): apply the chosen unlock mode and connect 2026-08-03 09:32:17 +02:00
Jonas Bark
e005a1e136 feat(click-v2): add onboarding trigger policy 2026-08-03 09:09:04 +02:00