libpebble3: add calendar reminder vibration override#193
Conversation
## Summary
Adds `NotificationConfig.overrideCalendarVibePattern: String?` to mirror the
existing `overrideDefaultVibePattern` (which covers notifications). When set,
the named pattern is applied to every calendar reminder synced to the watch.
Also adds an optional `vibePattern: List<UInt>?` parameter to:
- `CalendarEvent.toTimelineReminder(timestamp, pinUuid, vibePattern = null)`
- `CalendarEvent.toTimelinePin(calendar, supportsRsvpActions, vibePattern = null)`
Both default to `null` — existing callers are unaffected.
## Motivation
The notification path already supports a global vibration-pattern override via
`overrideDefaultVibePattern`. Calendar reminders are the other major surface
where a user might want to enforce a specific vibration style without per-app
or per-event configuration. The symmetric `overrideCalendarVibePattern` field
closes that gap.
`PhoneCalendarSyncer` is the only producer of calendar `TimelinePin` and
`TimelineReminder` items in libpebble3, so the wiring is contained.
## Implementation
Three files change:
- `LibPebbleConfig.kt` — adds one `String?` field to `NotificationConfig`.
- `CalendarEvent.kt` — `toTimelineReminder` and `toTimelinePin` both gain
an optional `vibePattern: List<UInt>?` parameter. When non-null, the
reminder / pin's attribute block appends `vibrationPattern { it }`.
- `PhoneCalendarSyncer.kt` — resolves the name in `overrideCalendarVibePattern`
to the actual pattern bytes via `VibePatternDao` and passes them to both
builders during sync. Also re-triggers a full calendar sync whenever the
config changes, via a `notificationConfigFlow.flow` collector with
`.distinctUntilChanged().drop(1)`, so an in-flight override change
immediately rewrites the existing pins on the watch instead of waiting
for the next event modification.
## Behavior notes
The watch fires the actual vibration from the `TimelineReminder`, not the
`TimelinePin` — but the pattern is set on both for consistency (the pin's
attribute is harmless when unused).
## Backward compatibility
Non-breaking. New field and parameters all default to `null`; callers that
don't set `overrideCalendarVibePattern` or pass `vibePattern` see no behavior
change. Source-compatible: existing call sites in the monorepo (`composeApp`,
`experimental`, etc.) that build calendar pins/reminders compile without
modification. Changes are confined to the `libpebble3/` module.
## Test plan
- [ ] Set `overrideCalendarVibePattern` to a known pattern name → next
calendar reminder on the watch fires with that pattern
- [ ] Unset the override → next reminder reverts to the bundled default
- [ ] Change the override mid-day → existing pins on the watch get rewritten
(validates the reactive re-sync collector)
- [ ] Leave the override null → behavior identical to before this change
## Context
Same change shipped via matejdro#2 and has
been validated through real-world downstream usage. Upstreaming here so it
lives in coredevices/mobileapp directly and downstream forks don't need to
carry the patch locally.
| // } | ||
| stringList(TimelineAttribute.Headings) { headings } | ||
| stringList(TimelineAttribute.Paragraphs) { paragraphs } | ||
| vibePattern?.let { vibrationPattern { it } } |
There was a problem hiding this comment.
I don't think we should write this to the pin - it's not used and just a waste of bytes (BLE + stored in the watch blobdb)
There was a problem hiding this comment.
@sjp4 Thanks for taking time to review the change and sorry for the late reply
I'd like to keep this on the pin, for two reasons:
-
Parity with the microPebble libpebble3 fork — the equivalent change there (matejdro/libpebble3) carries the override on both the pin and the reminder, and I'd rather keep the two lineages in lockstep so they don't drift.
-
Future-proofing at ~zero cost — it's optional and only written when an override is actually set (null otherwise → no attribute, no extra bytes in the default case). When it is set, it's one small attribute, and it leaves the door open if Core Devices ever wants a pin-level pattern.
You're right that the watch doesn't act on it today, so if you'd still prefer to keep the wire minimal I'm happy to drop it — just let me know and I'll remove it.
| return@mapNotNull null | ||
| } | ||
| }.map { event.toTimelineReminder(it, pinId) } | ||
| newReminder.copy(itemId = existing?.itemId ?: newReminder.itemId) |
There was a problem hiding this comment.
Is this flow tested with a real watch (both when the vibe pattern changed, and when nothing changed)? The logic looks OK but it's the kind of thing which is complicated enough not to notice a bug..
There was a problem hiding this comment.
Yes — this is the same implementation I've been running in microPebble (via matejdro/libpebble3) for ~2 months now, used daily on a real watch, so the calendar-reminder flow (including this dedup) has had a lot of real-world hours. Both cases behave as intended:
- Override changed → reminders re-sync and fire with the new pattern.
- Nothing changed → no reminder writes/churn — the recordHashCode() comparison skips unchanged ones.
The logic here is identical to the microPebble version, so it's well-exercised on hardware. Happy to re-verify any specific scenario you have in mind.
fa9a425 to
19ce54b
Compare
Summary
Adds
NotificationConfig.overrideCalendarVibePattern: String?to mirror the existingoverrideDefaultVibePattern(which covers notifications). When set, the named pattern is applied to every calendar reminder synced to the watch.Also adds an optional
vibePattern: List<UInt>?parameter to:CalendarEvent.toTimelineReminder(timestamp, pinUuid, vibePattern = null)CalendarEvent.toTimelinePin(calendar, supportsRsvpActions, vibePattern = null)Both default to
null— existing callers are unaffected.Motivation
The notification path already supports a global vibration-pattern override via
overrideDefaultVibePattern. Calendar reminders are the other major surface where a user might want to enforce a specific vibration style without per-app or per-event configuration. The symmetricoverrideCalendarVibePatternfield closes that gap.PhoneCalendarSynceris the only producer of calendarTimelinePinandTimelineReminderitems in libpebble3, so the wiring is contained.Implementation
Three files change:
LibPebbleConfig.kt— adds oneString?field toNotificationConfig.CalendarEvent.kt—toTimelineReminderandtoTimelinePinboth gain an optionalvibePattern: List<UInt>?parameter. When non-null, the reminder / pin's attribute block appendsvibrationPattern { it }.PhoneCalendarSyncer.kt— resolves the name inoverrideCalendarVibePatternto the actual pattern bytes viaVibePatternDaoand passes them to both builders during sync. Also re-triggers a full calendar sync whenever the config changes, via anotificationConfigFlow.flowcollector with.distinctUntilChanged().drop(1), so an in-flight override change immediately rewrites the existing pins on the watch instead of waiting for the next event modification.Behavior notes
The watch fires the actual vibration from the
TimelineReminder, not theTimelinePin— but the pattern is set on both for consistency (the pin's attribute is harmless when unused).Backward compatibility
Non-breaking. New field and params all default to
null; callers that don't setoverrideCalendarVibePatternor passvibePatternsee no behavior change.Test plan
overrideCalendarVibePatternto a known pattern name → next calendar reminder on the watch fires with that pattern