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>
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>
ERG (review findings on the ±5W change):
- New ErgPowerStepping extension is the single home for the 5W step and
500W manual cap, replacing 7 inline copies (physical buttons, hero-card
buttons/slider, three overlay controllers).
- Boundaries are guards, not clamps: up at >=500W is a no-op like the
disabled UI button (a 600W FTMS target is no longer slashed to 500),
down from >500W steps relative, and an unknown baseline (hub-commanded
ERG reports no target) is a no-op with a new localized message instead
of slamming the trainer to ~150W.
- ERG shift-up Success carries the button again so +5W presses show
activity feedback (missed conversion from 843f7985).
SRAM gesture:
- Same-lever repeats inside the 90ms combo window coalesce as duplicates:
a finger can't re-press in 90ms, but iOS re-delivers a colliding read
response of the 0xFF edge through the notify callback — it must not
actuate twice (nor break a combo when it misdecodes to the other lever).
- The §7 multishift guard only runs while shifting is enabled — the one
state where a held paddle actually bursts (per c94b87f0's --observe
capture). Bonded rapid tapping and both-lever combos are never
throttled. Timer-driven instead of DateTime.now() (deterministic under
fakeAsync) and cleared by _resetGesture on (re)connect.
- The "set up SRAM control" warning fires once per connection, not on
every undecoded press.
Harness:
- EmulationSession.notify drops notifications for removed peripherals so
delayed notifies (SRAM double-tap) can't land after teardown.
- The 0xFF press edge is SramAxsConstants.triggerEdge at all call sites;
the emulation test waits on the named TRIGGER_UUID constant.
- New coverage: guard behavior through processCharacteristic in both
states, burst suppression while unbonded, all-taps-delivered once
bonded, ERG boundary/game-set-target cases.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
- The floating overlay's drag handle now fills the full 24px trailing slot
instead of only the 14px icon.
- iOS overlay: arm PiP only while still showing and tear it down if a hide
lands mid-start(), so a show/hide race can't orphan a frozen PiP window.
- Detect Dynamic Island via the max safe-area inset instead of the top inset,
which collapsed in landscape and could auto-start an unwanted PiP.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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>
- New "Floating window (Picture-in-Picture)" overlay setting (iOS 16+). Default
follows the per-device auto behavior (on for iPad / non-DI iPhones, off for
Dynamic-Island iPhones); DI-iPhone users can opt in. The Live Activity keeps
running alongside it (additive).
- iPad: start PiP immediately on activation (foreground) instead of only when
backgrounded — there's screen room (DeviceCapabilities.prefersForegroundPip +
scheduleForegroundStart poll).
- DeviceCapabilities.isPipCapable (any iOS 16+ PiP device) + bike_control/pip_ios
"isCapable"; settings.getOverlayUsePip/setOverlayUsePip; show() resolves the
preference.
- requiresLinearPlayback = true to drop the PiP skip/scrub (next/prev) controls
(it's a live HUD; central play/pause is system chrome, harmless no-op).
- overlayUsePip + overlayUsePipSubtitle in all 6 languages; changelog updated.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Replaces the trailing mode pill in the Dynamic Island expanded
region (which was redundant — the bottom row already shows the
SIM/ERG pill) with an `xmark.circle.fill` button.
Tapping the button:
1. Fires a new `StopRideIntent` App Intent.
2. That intent posts a Darwin notification
`de.jonasbark.swiftcontrol.overlay.action.stop`.
3. `AppDelegate.swift`'s observer forwards `action: 'stop'` over
the `bike_control/overlay_actions_ios` MethodChannel.
4. `IosOverlayController._stopRide`:
- `core.connection.disconnectAll()`
- `core.connection.stop()`
- `core.settings.setOverlayEnabled(false)` so Navigation's
auto-show doesn't immediately re-open the activity on the
next BLE reconnect.
- `hide()` ends the Live Activity.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Fixes the user-reported bugs after the auto-show landed:
1. Auto-opened overlay buttons did nothing
The trainer emulator rebinds a fresh FitnessBikeDefinition each time
its transport restarts (e.g. when a trainer app connects), so the
`def` captured at show() time can already be stale by the time the
user taps + / −. Action handlers now re-resolve through a new
`LiveDefinitionLookup` callback on every dispatch. Navigation's
auto-show and OverlaySettingsSection's manual show both pass a
lookup that reads `device.emulator.activeDefinition` live.
2. Toggling "Show overlay during ride" off didn't close the panel
The vendored macOS plugin's `closeWindow` handler ignored its args
and called `closeWindow(NSApp.mainWindow)`, which either terminated
the app or no-op'd silently. Patched it to honor
`isMainWindow: false` and close the (single) secondary window.
3. "Error in overlay.position.decode: Unexpected character: light"
The vendored macOS plugin packs the Dart entrypoint args in the
order [routeName, theme, argsJson]; the Windows runner uses
`std::map` iteration order. The sub-window was indexing `args[1]`
blindly. Now it scans `args[1..]` for the first JSON-looking
payload with `x`/`y`.
Also:
- TrainerOverlayController.show now takes optional `liveDef`; all
three implementations (desktop, android, ios) thread it through.
- Navigation initState no longer early-`return`s after auto-show, so
the post-frame system-UI / changelog logic still runs.
- All silent `catch (_) {}` blocks in the overlay code now forward
via `recordError(e, s, context: '...')`. New project memory
entry [feedback_record_error.md] documents the rule.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Auto-show:
- Navigation initState now subscribes to core.connection.connectionStream
when the persisted overlay_enabled flag is true. The first connected
smart trainer with a FitnessBikeDefinition triggers
TrainerOverlayService.show(...) with the persisted overlay fields.
- Subscription is one-shot (cancels itself after a successful show) and
also checks already-connected devices on mount, so the overlay reopens
whether the trainer was reconnected before or after Navigation mounted.
Debug-log cleanup:
- Removed the `bikecontrol_dart_alive.log` liveness probe, the
`[main:entry]` / `[main:entry/stderr]` print + stderr.writeln, the
`[overlay-main]` step-by-step logs in the sub-window dispatch, the
`[main:wm-spy]` channel-handler wrapper, the `[overlay-run]` /
`[overlay-sub]` action logs in desktop_overlay_window, the
`[overlay-main]` action-receive / dispatch-fail logs in
desktop_overlay_controller, the `[main]` Android handler-retry logs,
and the noisy `[multi_window_native] CreateNewWindow` cerr in the
Windows runner.
- Kept catch handlers as silent (or kDebugMode-guarded) where the
original error path was still useful.
Also: MainFlutterWindow simplified back to NSWindow — the vendored
multi_window_native plugin now creates the overlay sub-window as an
NSPanel with .screenSaver level + .fullScreenAuxiliary itself, so
the main window no longer needs the canBecomeMain/canBecomeKey
NSPanel overrides or the .normal level pin.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two macOS regressions reported by the user:
- Initial sub-window size way too large. multi_window_native's macOS
plugin hard-codes the sub-window at 1000x1000 with minSize 800x900
(see plugin source createNewWindow ~line 148). Override from Dart
in `_runOverlay`: setMinimumSize(180, 100) then setSize(220, 140).
- Overlay no longer appears above fullscreened trainer apps. The
plugin fires `onEngineCreatedCallback` BEFORE it creates the
NSWindow + sets its contentViewController, so our previous single
`DispatchQueue.main.async { ... }` raced the plugin's own setup and
found nothing in NSApp.windows. Retry up to 30 times (0.1s apart)
until the window with our `engine` appears, then apply
`.statusBar` level + `.fullScreenAuxiliary` collection behaviour.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Three issues:
1. Zone mismatch from runApp:104. The diagnostic
`WidgetsFlutterBinding.ensureInitialized()` + ping MethodChannel call
ran BEFORE `runZonedGuarded` and bound the binding to the root zone;
`runApp` then fired inside the zone -> mismatch. Removed the outer
diagnostic — Dart liveness is no longer the unknown here, and the
file-write probe at the top of main() still confirms it if needed.
2. Black window background looks bad on macOS. Win32 can't do real
transparency without WS_EX_LAYERED, so it needs the dark fill, but
macOS handles NSWindow alpha properly via window_manager. Make the
Scaffold backgroundColor platform-conditional:
- Windows: opaque 0xFF111114
- everything else: transparent
3. Button events from the overlay don't arrive in the main app. Adding
debugPrint at both ends ([overlay-sub] −/+ tap and [overlay-main]
action received) to see where the BroadcastToAll → Dart listener
chain breaks. Behaviour unchanged.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drop desktop_multi_window entirely; unify macOS + Windows on
multi_window_native. Windows runner re-gets the CreateNewWindow /
CloseWindow / SetMainWindowMethodHandler plumbing with selective
sub-engine registration (only WindowManagerPlugin +
MultiWindowNativePlugin) to avoid the deadlock caused by full
RegisterPlugins on secondary engines. macOS MainFlutterWindow narrows
onEngineCreatedCallback from RegisterGeneratedPlugins to the same two
plugins for consistency.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add `desktop_multi_window: ^0.3.0` alongside `multi_window_native: ^1.0.4`.
On Windows the sub-window is now spawned via `WindowController.create` with a
JSON `role=trainer-overlay` argument (detected in `main()` before any heavy
bootstrap), and state/actions flow over `WindowMethodChannel(kOverlayChannel)`.
macOS continues using `MultiWindowNative.createWindow` / `notifyAllWindows` /
`registerListener` unchanged.
Windows runner reverts all `multi_window_native` plumbing:
`SecondaryWindowContext`, `CreateNewWindow`, `CloseWindow`,
`SetMainWindowMethodHandler`, and the plugin source compiled directly into the
runner are removed. `flutter_window.cpp` instead registers
`DesktopMultiWindowSetWindowCreatedCallback` so every sub-engine gets plugins.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Even a flat Container doesn't render in the sub-window on Windows.
Need to know whether Dart main() reaches runApp at all — if
`wm.windowManager.waitUntilReadyToShow()` or `getId()` blocks, the
engine never gets widgets to paint and we see the Win32 background
brush regardless of widget tree.
These prints land on the console attached to `flutter run` and will
show us the exact step that stalls.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
`waitUntilReadyToShow(WindowOptions(...))` tries to apply size +
titleBarStyle + backgroundColor + alwaysOnTop all at once. On Windows
that combination misbehaves:
- `Colors.transparent` background can't be honoured without
`WS_EX_LAYERED`, so it ends up filling the window with white.
- `TitleBarStyle.hidden` rewrites window styles mid-startup, which the
sub-window's render surface doesn't recover from — the engine paints
once at the wrong size and then sits idle.
The package example's `SecondScreen` never calls `waitUntilReadyToShow`
with options. Match that: apply each setting individually after the
engine boots — set alwaysOnTop, minimumSize, hasShadow, and (macOS only)
visibleOnAllWorkspaces. No titleBarStyle/backgroundColor on Windows.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two issues caused the sub-window to show as "all white initially, white
box on black after resize":
- The runner's CreateNewWindow skipped FlutterWindow::OnCreate's engine
kickoff (`SetNextFrameCallback` + `ForceRedraw`). The sub-window's
engine then never spontaneously painted and stayed at its construction
metrics; a manual resize forced a paint but with the old 220x100
surface, hence the "white box that doesn't follow the window".
Replicating the same boot sequence in CreateNewWindow.
- The Scaffold background used `Theme.of(context).colorScheme.background`,
which resolves to near-white under shadcn's light theme, masking the
gear card on its near-white surface. Win32 doesn't do real transparency
without WS_EX_LAYERED anyway, so use an explicit opaque dark colour
(0xFF111114) — gives the window a clear chrome regardless of the
user's system theme.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Drops desktop_multi_window 0.3.0 in favour of multi_window_native 1.0.4
on a new branch (feature/trainer-overlay-multi-window-native).
Mechanism is different but the responsibilities map cleanly:
- `MultiWindowNative.createWindow([routeName, argsJson, theme])` spawns
the sub-window; main() detects it via the first arg.
- Communication is broadcast by method name through
`notifyAllWindows` + `registerListener`. Conventions:
main → overlay: trainerOverlay.state
overlay → main: trainerOverlay.action / ready / positionChanged
Each side filters by method name; the API has no per-window targeting.
- The overlay window grabs its windowId via `windowManager.getId()` and
broadcasts `trainerOverlay.ready` so the controller can later close it.
- `notifyUiRendered()` is called after the first frame, per the package's
black-screen workaround on macOS/Windows.
Native shims:
- macOS MainFlutterWindow.swift: re-register plugins on every new
sub-engine via `MultiWindowNativePlugin.onEngineCreatedCallback`. Kept
the `.statusBar` / `.fullScreenAuxiliary` elevation for visibility
above fullscreened trainer apps; the callback now finds the new
sub-window's NSWindow by matching the FlutterViewController's engine.
- Windows flutter_window.cpp: reverted the desktop_multi_window callback;
multi_window_native's Windows wiring requires a more invasive
flutter_window.h / cpp change (SetOnCloseCallback, GetFlutterViewController,
callback registration in main.cpp) which is TBD. The overlay is only
verified on macOS in this branch.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Android's SYSTEM_ALERT_WINDOW + specialUse foreground service requires
*some* notification — we can't suppress it entirely. Empty the content
line and set visibility to secret so it doesn't appear on the lock
screen or as a heads-up; it lives unobtrusively in the notification
shade only.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Two reasons the Android overlay was rendering invisibly:
1. flutter_overlay_window 0.5.0 passes the width/height args through to
WindowManager.LayoutParams as RAW PIXELS (not dp). Passing width=400
produced a ~100dp-wide strip on a high-density phone. The default y
position is -statusBarHeightPx(), which hid most of the surface
behind the status bar.
- Use WindowSize.matchParent for width (-1 = MATCH_PARENT).
- Use a generous pixel height (600).
- Pass an explicit startPosition so y isn't negative.
- Close any stale active overlay before re-showing (survives hot restart).
2. ShadcnApp does not produce stable layout constraints in the overlay's
secondary Flutter engine. Match the package's working example: use
MaterialApp + Material(color: transparent) at the root and a
plain-Material overlay card with hardcoded colors. The shared
TrainerOverlayView is for desktop only; Android needs its own
minimal Material-friendly variant.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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>
Replace the compact-mode-of-main-window logic (which mutated
window_manager properties on the single main window) with a real
second-window approach:
- WindowController.create() spawns the overlay sub-window via
desktop_multi_window.
- State is pushed from the main isolate at ~10 Hz (debounced) through
WindowController.invokeMethod('state', json).
- The parent registers a WindowMethodChannel handler for 'hide',
'toggleMode', and 'positionChanged' callbacks from the overlay.
- Dragging and window-move position persistence are handled in the
sub-window via window_manager's WindowListener.onWindowMoved.
- No window_manager mutations on the main window at all.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add lib/services/overlay/desktop_overlay_window.dart with
runDesktopOverlayWindow(): configures the sub-window via window_manager
(220×140, frameless, transparent, always-on-top), registers a
setWindowMethodHandler for 'state'/'close' calls from the parent, and
routes 'hide'/'toggleMode'/'positionChanged' back via WindowMethodChannel.
Update main() to call WindowController.fromCurrentEngine() after
WidgetsFlutterBinding.ensureInitialized(); if the arguments indicate
role=trainer-overlay it dispatches to runDesktopOverlayWindow and
returns early, keeping all heavy init (Settings, IAP, Supabase) out of
the sub-window process.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The overlay isolate's overlayMain was annotated @pragma('vm:entry-point')
but the file was not imported anywhere, so Flutter never compiled it into
the binary. Android then logged 'Width is zero' followed by 'Destroying
the overlay window service' because the secondary engine couldn't find
the entry point. Importing it from android_overlay_controller.dart pulls
the file into the build.
Also gate the 'Grant overlay permission' settings tile on the actual
runtime permission state (FlutterOverlayWindow.isPermissionGranted),
hiding it once permission has been granted.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
live_activities routes the map through NSUserDefaults in the App Group,
which crashes with NSInvalidArgumentException on null values. Swift's
Codable decoder maps missing keys to nil for Optional types, so omitting
power/cadence/ergTarget when null produces the same ContentState without
the crash.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Pass def explicitly to _snapshot(FitnessBikeDefinition) instead of
force-unwrapping _def! inside it. In _push(), capture both _activityId
and _def upfront and bail early if either is null, preventing a crash
when hide() clears them between a Timer callback and _push() executing.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Set background color back to opaque black in _restore() before
reverting other window properties, so the transparent overlay color
does not leak into the restored main-window state on macOS/Windows.
Co-Authored-By: Claude Sonnet 4.6 <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>