diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-03-22 23:45:19 +0000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-03-22 23:45:19 +0000 |
| commit | 8abc63efdbc0bb96cd6c9aa99d6e9166e0bcabae (patch) | |
| tree | f4d6a082eed9b10bc67436a3ca5188e0182961eb /.agent/timeline_design.md | |
| parent | 11b905fd437d651b2e39745aa82a5dd36f70331e (diff) | |
chore: unify and centralize agent configuration in .agent/
Diffstat (limited to '.agent/timeline_design.md')
| -rw-r--r-- | .agent/timeline_design.md | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/.agent/timeline_design.md b/.agent/timeline_design.md new file mode 100644 index 0000000..61c71b5 --- /dev/null +++ b/.agent/timeline_design.md @@ -0,0 +1,82 @@ +# Timeline Feature Design + +## Objective +Create a unified timeline view showing Tasks, Meals, Trello Cards, and Google Calendar Events, sorted chronologically. + +## Data Sources +1. **Tasks (Todoist):** From DB `tasks` table. Filter: `due_date` is not null. +2. **Meals (PlanToEat):** From DB `meals` table. Filter: `date` is not null. +3. **Cards (Trello):** From DB `cards` table. Filter: `due_date` is not null. +4. **Google Calendar Events:** From `GoogleCalendarClient` (Live API). + +## Backend Logic + +### 1. Data Models (`internal/models/timeline.go`) +We need a polymorphic structure to hold different item types. + +```go +type TimelineItemType string + +const ( + ItemTypeTask TimelineItemType = "task" + ItemTypeMeal TimelineItemType = "meal" + ItemTypeCard TimelineItemType = "card" + ItemTypeEvent TimelineItemType = "event" +) + +type TimelineItem struct { + ID string `json:"id"` + Type TimelineItemType `json:"type"` + Title string `json:"title"` + Description string `json:"description"` + Time time.Time `json:"time"` + AllDay bool `json:"all_day"` + URL string `json:"url"` + Meta map[string]any `json:"meta"` // Extra data like ProjectName, RecipeURL, etc. +} +``` + +### 2. Store Extensions (`internal/store/`) +Add methods to fetch items by date range. +* `GetTasksByDateRange(start, end time.Time) ([]models.Task, error)` +* `GetMealsByDateRange(start, end time.Time) ([]models.Meal, error)` +* `GetCardsByDateRange(start, end time.Time) ([]models.Card, error)` + +### 3. Logic Layer (`internal/handlers/timeline_logic.go`) +* **Function:** `BuildTimeline(store Store, calendarClient *api.GoogleCalendarClient, start, end time.Time) ([]TimelineItem, error)` +* **Aggregation:** + 1. Fetch from Store (Tasks, Meals, Cards). + 2. Fetch from Calendar API. + 3. Convert all to `TimelineItem`. + 4. **Meal Time Defaults:** + * Breakfast: 08:00 + * Lunch: 12:00 + * Dinner: 19:00 + * Other: 12:00 + 5. Sort by `Time`. + +### 4. HTTP Handler (`internal/handlers/timeline.go`) +* **Route:** `GET /timeline` +* **Params:** `start` (default: today), `days` (default: 7) +* **Response:** Render `timeline-tab.html` partial. + +## UI Design (`web/templates/partials/timeline-tab.html`) +* **Structure:** + * Container + * Loop through Days + * Date Header (e.g., "Mon, Jan 2") + * List of Items + * Time Column (e.g., "14:00") + * Content Column (Icon + Title + Subtitle) +* **Styling:** + * Use existing CSS variables. + * Distinct icons/colors for Tasks vs Meals vs Events. + +## Files to Modify +1. `internal/models/timeline.go` (New) +2. `internal/store/store.go` (Interface update) +3. `internal/store/sqlite.go` (Implementation update) +4. `internal/handlers/timeline_logic.go` (New) +5. `internal/handlers/timeline.go` (New) +6. `web/templates/partials/timeline-tab.html` (New) +7. `cmd/dashboard/main.go` (Route registration) |
