From 9a3ece4fef431c2c35af239f3df6eeaa10ddeaf4 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 10 Aug 2026 03:16:39 +0000 Subject: Fix widget showing tomorrow's dated tasks under today Root cause: doot-native and Google Tasks due dates are always midnight-anchored (even when a task genuinely has a due date), which trips TimelineItem.ComputeDaySection's "midnight means no specific time" heuristic and sets IsAllDay=true on them. TimelineItemToWidgetItem then left wi.Start nil for any Task/GTask with IsAllDay=true, and the Android client's undated/floating pool (DootWidget.kt's `floating` list) has zero per-day awareness -- it just packs items forward from "now" -- so a task due tomorrow rendered as if due today. This was previously diagnosed and deliberately set aside (see project_doot_isallday_midnight_bug memory) with a simpler proposed fix (gate ComputeDaySection's heuristic to Event/Meal types); re-verifying that plan against the actual code before implementing it surfaced a real problem with it: it would also flip IsAllDay to false for same-day dated tasks, moving them from the web's untimed-item strip into the hourly grid with a fabricated "12:00 AM" time label -- fixing the widget by breaking the web's currently-correct rendering. Actual fix: added TimelineItem.Undated, a signal genuinely independent of IsAllDay -- true only for the caller's two genuinely-dateless constructions (nativeUndated tasks, gtasks with no due date), both of which already use Time=now as a layout placeholder rather than a real date. ComputeDaySection and IsAllDay are untouched, so web rendering is unaffected. This gate.go change routes on that new signal instead: dated Task/GTask items now get wi.Start populated (so the Android client's existing, already-correct Start-based day bucketing runs for them) while genuinely undated ones keep today's nil-Start floating treatment exactly as before. Also fixed the same latent bug in wi.DueDate's guard while in the same code path: it only checked !Time.IsZero(), but nativeUndated's Time=now placeholder is non-zero, so an undated task's Android detail popup would have shown a fabricated due date of whatever moment the request happened to run. Now guards on !Undated too. Verified: added TestTimelineItemToWidgetItem_DatedGTaskGetsStart and TestTimelineItemToWidgetItem_UndatedTaskWithPlaceholderTime_NilDueDate, and updated the three existing tests that had encoded the bug's old "Start stays nil for any IsAllDay task" assumption as expected behavior (TestTimelineItemToWidgetItem_Task, _DootTaskGetsDueDate, _AllDayTask_KeepsFloatingBehavior -- the last one needed Undated: true added since it no longer implies undated on its own). Proved the fix by reverting internal/handlers/widget.go to the pre-fix condition against a real backup and confirming exactly the three tests exercising the new behavior fail, then restored from that backup and confirmed byte-identical. go build/vet/test all clean. Co-Authored-By: Claude Sonnet 5 Claude-Session: https://claude.ai/code/session_01EZ7ikw2ukGJFTHE3bJS7zL --- internal/handlers/timeline_logic.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'internal/handlers/timeline_logic.go') diff --git a/internal/handlers/timeline_logic.go b/internal/handlers/timeline_logic.go index b008221..b25be1f 100644 --- a/internal/handlers/timeline_logic.go +++ b/internal/handlers/timeline_logic.go @@ -151,8 +151,13 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([ // to "now", which otherwise lands it among scheduledEvents and // renders it via EventBlock/HourRow -- rows whose click handler // always opens the source URL/Google Calendar, not the task's - // detail sheet. + // detail sheet. Undated (not just IsAllDay) also has to be set + // here: a gtask WITH a due date is midnight-anchored too (see + // reference_google_tasks_due_date_utc_quirk), which sets IsAllDay + // true regardless -- Undated is what actually tells + // TimelineItemToWidgetItem "no date at all" vs "has a date". IsAllDay: gTask.DueDate == nil, + Undated: gTask.DueDate == nil, } item.ComputeDaySection(now) items = append(items, item) @@ -230,6 +235,7 @@ func BuildTimeline(ctx context.Context, s *store.Store, start, end time.Time) ([ IsCompleted: task.Completed, Source: "doot", IsAllDay: true, + Undated: true, ProjectColor: projectColors[task.ProjectID], } setChainBadge(s, &item, task) -- cgit v1.2.3