From dace5a7852211f16a01530445ebbd5cfc5676b21 Mon Sep 17 00:00:00 2001 From: uvtqt Date: Tue, 17 Nov 2026 20:21:00 +0100 Subject: [PATCH 1/2] day timeline: a run of double-taps is one line with its count Ball sports set the firmware's tap detector off on every contact, and the timeline listed each one as 'You double-tapped the band', burying the day. Taps closer than 10 minutes now form one line with the time range and the band's own count; a lone tap is unchanged. Co-Authored-By: Claude Opus 5.5 --- lib/ui2/screens/day_timeline.dart | 35 ++++++++++++++++++++++++++++++- test/day_timeline_test.dart | 23 ++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/lib/ui2/screens/day_timeline.dart b/lib/ui2/screens/day_timeline.dart index 65e0c4b5d..8bb326b8d 100644 --- a/lib/ui2/screens/day_timeline.dart +++ b/lib/ui2/screens/day_timeline.dart @@ -96,7 +96,7 @@ class DayNote { Map _events(AppLocalizations? l) => { 7: (l?.dayTimelineChargerOn ?? 'On the charger', LucideIcons.batteryCharging), 8: (l?.dayTimelineChargerOff ?? 'Off the charger', LucideIcons.batteryFull), - 14: (l?.dayTimelineDoubleTap ?? 'You double-tapped the band', LucideIcons.hand), + _kDoubleTapEventId: (l?.dayTimelineDoubleTap ?? 'You double-tapped the band', LucideIcons.hand), 15: (l?.dayTimelineRestarted ?? 'The band restarted', LucideIcons.rotateCw), 21: (l?.dayTimelineBatteryPackAttached ?? 'Battery pack attached', LucideIcons.batteryCharging), @@ -104,6 +104,11 @@ Map _events(AppLocalizations? l) => { 57: (l?.dayTimelineAlarmWentOff ?? 'Alarm went off', LucideIcons.alarmClock), }; +const int _kDoubleTapEventId = 14; + +/// Double-taps closer together than this are one run on the timeline. +const int kDoubleTapRunGapSec = 10 * 60; + /// An off-wrist gap shorter than this is a dropout, not an event in a day. /// Listing every one of them would bury the four that mean something under /// forty that mean the strap moved. @@ -244,11 +249,16 @@ List dayMoments({ // times, and a day with the charger on it should not read as four chargers. final seen = {}; final events = _events(l); + final taps = []; for (final e in (timeline['events'] as List?) ?? const []) { if (e is! Map) continue; final id = asInt(e['event_id']), t = asInt(e['ts']); final def = id == null ? null : events[id]; if (def == null || t == null || !seen.add('$id/$t')) continue; + if (id == _kDoubleTapEventId) { + taps.add(t); + continue; + } out.add(Moment( at: t, title: def.$1, @@ -256,6 +266,29 @@ List dayMoments({ icon: def.$2, )); } + // Double-taps in a run (a ball sport sets the firmware's tap detector off on + // every contact) are one span carrying the band's own count, not one line + // per tap burying the rest of the day. + taps.sort(); + final tap = events[_kDoubleTapEventId]!; + for (var i = 0; i < taps.length;) { + var j = i; + while (j + 1 < taps.length && + taps[j + 1] - taps[j] <= kDoubleTapRunGapSec) { + j++; + } + final n = j - i + 1; + out.add(Moment( + at: taps[i], + until: n > 1 ? taps[j] : null, + title: tap.$1, + detail: n > 1 + ? '${clockOfTs(taps[i])}–${clockOfTs(taps[j])} · $n×' + : clockOfTs(taps[i]), + icon: tap.$2, + )); + i = j + 1; + } for (final m in meals) { final t = m.atTs; diff --git a/test/day_timeline_test.dart b/test/day_timeline_test.dart index 3ce9c72ae..f29f7b04b 100644 --- a/test/day_timeline_test.dart +++ b/test/day_timeline_test.dart @@ -72,6 +72,29 @@ void main() { expect(m, hasLength(2)); }); + test('a run of double-taps is one line with its count, not one per tap', + () { + // Volleyball: every ball contact the firmware reads as a double-tap. The + // run stays on the page (it happened, and the count is the band's), but + // as one span instead of forty lines burying the day. + final m = dayMoments(timeline: { + 'day_start': _day, + 'events': [ + for (var i = 0; i < 14; i++) {'event_id': 14, 'ts': _at(18, 2 + i * 4)}, + // A tap on its own hours later is still its own line. + {'event_id': 14, 'ts': _at(21)}, + ], + }); + expect(m, hasLength(2)); + final run = m.first; + expect(run.at, _at(18, 2)); + expect(run.until, _at(18, 54)); + expect(run.detail, contains('14×')); + expect(m.last.at, _at(21)); + expect(m.last.until, isNull); + expect(m.last.detail, isNot(contains('×'))); + }); + test('a meal with no time is never placed, and is not lost either', () { const timed = FoodEntry( id: 'a', date: '2026-08-14', meal: 'Lunch', label: 'Soup', kcal: 300); From e57bb6ad2931b4e22a1a2aa79a664d80230b033f Mon Sep 17 00:00:00 2001 From: uvtqt Date: Wed, 18 Nov 2026 09:53:36 +0100 Subject: [PATCH 2/2] day timeline: taps exactly 10 minutes apart stay separate; share the double-tap id Co-Authored-By: Claude Opus 5.5 --- lib/ui2/screens/day_timeline.dart | 11 +++++------ test/day_timeline_test.dart | 12 ++++++++++++ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/lib/ui2/screens/day_timeline.dart b/lib/ui2/screens/day_timeline.dart index 8bb326b8d..32fcfea52 100644 --- a/lib/ui2/screens/day_timeline.dart +++ b/lib/ui2/screens/day_timeline.dart @@ -36,6 +36,7 @@ import '../../compute/inputs/measurement_inputs.dart' import '../../compute/profile.dart' show bmiOf; import '../../data/coverage_resolver.dart' show OwnedSpan, coverageFromJson, spanAt; import '../../data/day_label.dart' show localDayEndSec; +import '../../data/triathlon_store.dart' show kTriathlonDoubleTapEventId; import '../../data/db.dart'; import '../../data/journal_fields.dart'; import '../../data/local_repository.dart'; @@ -96,7 +97,7 @@ class DayNote { Map _events(AppLocalizations? l) => { 7: (l?.dayTimelineChargerOn ?? 'On the charger', LucideIcons.batteryCharging), 8: (l?.dayTimelineChargerOff ?? 'Off the charger', LucideIcons.batteryFull), - _kDoubleTapEventId: (l?.dayTimelineDoubleTap ?? 'You double-tapped the band', LucideIcons.hand), + kTriathlonDoubleTapEventId: (l?.dayTimelineDoubleTap ?? 'You double-tapped the band', LucideIcons.hand), 15: (l?.dayTimelineRestarted ?? 'The band restarted', LucideIcons.rotateCw), 21: (l?.dayTimelineBatteryPackAttached ?? 'Battery pack attached', LucideIcons.batteryCharging), @@ -104,8 +105,6 @@ Map _events(AppLocalizations? l) => { 57: (l?.dayTimelineAlarmWentOff ?? 'Alarm went off', LucideIcons.alarmClock), }; -const int _kDoubleTapEventId = 14; - /// Double-taps closer together than this are one run on the timeline. const int kDoubleTapRunGapSec = 10 * 60; @@ -255,7 +254,7 @@ List dayMoments({ final id = asInt(e['event_id']), t = asInt(e['ts']); final def = id == null ? null : events[id]; if (def == null || t == null || !seen.add('$id/$t')) continue; - if (id == _kDoubleTapEventId) { + if (id == kTriathlonDoubleTapEventId) { taps.add(t); continue; } @@ -270,11 +269,11 @@ List dayMoments({ // every contact) are one span carrying the band's own count, not one line // per tap burying the rest of the day. taps.sort(); - final tap = events[_kDoubleTapEventId]!; + final tap = events[kTriathlonDoubleTapEventId]!; for (var i = 0; i < taps.length;) { var j = i; while (j + 1 < taps.length && - taps[j + 1] - taps[j] <= kDoubleTapRunGapSec) { + taps[j + 1] - taps[j] < kDoubleTapRunGapSec) { j++; } final n = j - i + 1; diff --git a/test/day_timeline_test.dart b/test/day_timeline_test.dart index f29f7b04b..f4d10125e 100644 --- a/test/day_timeline_test.dart +++ b/test/day_timeline_test.dart @@ -95,6 +95,18 @@ void main() { expect(m.last.detail, isNot(contains('×'))); }); + test('taps exactly 10 minutes apart are two lines', () { + final m = dayMoments(timeline: { + 'day_start': _day, + 'events': [ + {'event_id': 14, 'ts': _at(18)}, + {'event_id': 14, 'ts': _at(18, 10)}, + ], + }); + expect(m, hasLength(2)); + expect(m.every((x) => x.until == null), isTrue); + }); + test('a meal with no time is never placed, and is not lost either', () { const timed = FoodEntry( id: 'a', date: '2026-08-14', meal: 'Lunch', label: 'Soup', kcal: 300);