From 8c55b9b10fecd45ac5acf3f13fc23d342a4aa53b Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 29 Jun 2026 10:29:12 +0000 Subject: fix: calendar/meals sync, tomorrow flat layout, /health endpoint - Calendar: fall back to GOOGLE_CALENDAR_ID config when no source_configs synced yet (fixes blank calendar after fresh deploy) - Meals: call fetchMeals in HandleTimeline so PlanToEat cache refreshes on every timeline load, not just during manual refresh - Tomorrow section: replace calendar-grid with flat chronological list matching widget layout (time label | source bar | title) - Add /health endpoint (no auth required) for deploy health checks Co-Authored-By: Claude Sonnet 4.6 --- cmd/dashboard/main.go | 7 +++ internal/handlers/handlers.go | 10 ++-- internal/handlers/timeline.go | 7 +++ web/templates/index.html | 2 +- web/templates/partials/timeline-tab.html | 79 ++++++++++---------------------- 5 files changed, 45 insertions(+), 60 deletions(-) diff --git a/cmd/dashboard/main.go b/cmd/dashboard/main.go index 9f69d46..7e58125 100644 --- a/cmd/dashboard/main.go +++ b/cmd/dashboard/main.go @@ -207,6 +207,13 @@ func main() { // Rate limiter for agent auth (stricter - 10 requests/minute per IP) agentAuthRateLimiter := appmiddleware.NewRateLimiter(10, time.Minute) + // Health check (no auth) + r.Get("/health", func(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/plain") + w.WriteHeader(http.StatusOK) + _, _ = w.Write([]byte("ok")) + }) + // Public routes (no auth required) r.Get("/login", authHandlers.HandleLoginPage) r.With(authRateLimiter.Limit).Post("/login", authHandlers.HandleLogin) diff --git a/internal/handlers/handlers.go b/internal/handlers/handlers.go index 5ecaf7c..eaef558 100644 --- a/internal/handlers/handlers.go +++ b/internal/handlers/handlers.go @@ -392,10 +392,14 @@ func (h *Handler) fetchCalendarEvents(ctx context.Context, forceRefresh bool) ([ } } - // If none enabled but we have a default from config, use that as a fallback - // (or if we want to respect the toggle strictly, we should only use enabled ones) if len(enabledIDs) == 0 { - return nil, nil + // No source_configs synced yet — fall back to the configured calendar ID + if len(configs) == 0 && h.config.GoogleCalendarID != "" { + enabledIDs = []string{h.config.GoogleCalendarID} + } else { + // Configs exist but all disabled — respect that + return nil, nil + } } h.googleCalendarClient.SetCalendarIDs(enabledIDs) diff --git a/internal/handlers/timeline.go b/internal/handlers/timeline.go index bbdae51..2c3c6b6 100644 --- a/internal/handlers/timeline.go +++ b/internal/handlers/timeline.go @@ -69,6 +69,13 @@ func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) { log.Printf("Warning: failed to fetch calendar events: %v", err) } + // Refresh meals cache before building timeline + if h.planToEatClient != nil { + if _, err := h.fetchMeals(r.Context(), false); err != nil { + log.Printf("Warning: failed to fetch meals: %v", err) + } + } + // Call BuildTimeline items, err := BuildTimeline(r.Context(), h.store, start, end) if err != nil { diff --git a/web/templates/index.html b/web/templates/index.html index febacf1..c34bacf 100644 --- a/web/templates/index.html +++ b/web/templates/index.html @@ -104,7 +104,7 @@ - + diff --git a/web/templates/partials/timeline-tab.html b/web/templates/partials/timeline-tab.html index 8874440..e58f793 100644 --- a/web/templates/partials/timeline-tab.html +++ b/web/templates/partials/timeline-tab.html @@ -203,8 +203,7 @@ - - + {{if .TomorrowItems}}
@@ -215,24 +214,37 @@ - -
+ +
{{range .TomorrowItems}} - {{if or .IsOverdue .IsAllDay}} -
+
+ + + {{if and (not .IsAllDay) (or (ne .Time.Hour 0) (ne .Time.Minute 0))}} + {{.Time.Format "3:04 PM"}} + {{end}} + + +
+
+ {{if or (eq .Type "task") (eq .Type "card") (eq .Type "gtask")}} + class="h-4 w-4 rounded bg-black/40 border-white/30 text-white/80 focus:ring-white/30 cursor-pointer shrink-0"> {{end}} - {{.Title}} - {{if .IsOverdue}}overdue{{end}} + + + {{.Title}} + {{if .EndTime}}– {{.EndTime.Format "3:04 PM"}}{{end}} + {{if .URL}} - + @@ -240,52 +252,7 @@ {{end}}
{{end}} - {{end}}
- - -
- - {{range .TomorrowHours}} -
- {{if eq . 0}}12am{{else if lt . 12}}{{.}}am{{else if eq . 12}}12pm{{else}}{{subtract . 12}}pm{{end}} -
- {{end}} - - - {{range .TomorrowItems}} - {{if and (not .IsOverdue) (not .IsAllDay)}} - - {{end}} - {{end}} -
-
{{end}} -- cgit v1.2.3