summaryrefslogtreecommitdiff
path: root/issues/011-add-timeline-view.md
blob: 49e744a09c6c221d48a6d654b86e721fa8ec28b0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# [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