# [FEATURE] Add timeline view ## Description Add timeline view. ## User Story As a user, I want a timeline/agenda view so I can see my day's schedule visually. ## Technical Context - New view aggregating multiple data sources by time - Requires merging tasks + meals + (future) calendar events - New tab or view mode in existing UI ## Test Strategy ### Unit Test (Red) **File:** `internal/handlers/handlers_test.go` ```go func TestBuildTimeline(t *testing.T) { tasks := []Task{{Name: "Task 1", DueDate: todayAt(10, 0)}} meals := []Meal{{Name: "Lunch", Date: today, Type: "lunch"}} // lunch = 12:00 timeline := BuildTimeline(tasks, meals) assert.Len(t, timeline, 2) assert.Equal(t, "Task 1", timeline[0].Title) assert.Equal(t, "Lunch", timeline[1].Title) } func TestTimelineItemsSortedByTime(t *testing.T) { // Items from different sources // Assert sorted by timestamp regardless of source } ``` ### E2E Test (Red) Timeline renders with correct order and time markers. ## Proposed Approach 1. **Data Structure:** ```go type TimelineItem struct { Time time.Time Title string Source string // "task", "meal", "calendar" Type string // source-specific type URL string Metadata map[string]any } ``` 2. **Handler:** - New endpoint `GET /timeline` or extend tab handler - Aggregate items from tasks, meals, (future) calendar - Sort by time ascending - Group by hour or time block 3. **UI:** - Vertical timeline with time gutter on left - Color-coded by source - Expandable items for details 4. **Meal time mapping:** - breakfast: 08:00 - lunch: 12:00 - dinner: 18:00 - snack: configurable or omit from timeline ## Affected Components - `internal/handlers/handlers.go` or `internal/handlers/timeline.go` (new) - `internal/handlers/handlers_test.go` - `internal/models/types.go` (TimelineItem struct) - `web/templates/partials/timeline-tab.html` (new) - `web/templates/index.html` (add tab) ## Definition of Done - [ ] Timeline view accessible from UI - [ ] Tasks with times appear at correct position - [ ] Meals appear at appropriate meal times - [ ] Items sorted chronologically - [ ] Visual time markers/gutter - [ ] Color coding by source - [ ] Unit tests for timeline building - [ ] E2E test for rendering