summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPeter Stone <thepeterstone@gmail.com>2026-07-16 07:03:03 +0000
committerPeter Stone <thepeterstone@gmail.com>2026-07-16 07:03:03 +0000
commit6651dc17110a558342a4ef0a97a5b37adbfa04c7 (patch)
tree238d26106f88abb5a00ace811779bc7274997ff9 /internal
parent8a200f7f56c2894349b3f2831cd82625655acc7f (diff)
Show a scheduled-vs-available indicator on the web timeline's Today section
Task 11 of the task-budgets-and-availability plan: reuse the computeBudgetStatus helper (Task 8) in HandleTimeline so the dashboard's Today section header shows scheduled/available minutes when a budget-tracked task exists. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PQaPGQVSfmKUiHXB87qRTC
Diffstat (limited to 'internal')
-rw-r--r--internal/handlers/handlers_test.go34
-rw-r--r--internal/handlers/timeline.go10
2 files changed, 44 insertions, 0 deletions
diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go
index d16c7cf..bb383aa 100644
--- a/internal/handlers/handlers_test.go
+++ b/internal/handlers/handlers_test.go
@@ -2321,3 +2321,37 @@ func TestHandleCompleteAtom_DootShowsTitle(t *testing.T) {
}
}
+func TestHandleTimeline_IncludesBudgetStatusWhenTrackedTaskExists(t *testing.T) {
+ h, cleanup := setupTestHandler(t)
+ defer cleanup()
+
+ project, err := h.store.CreateProject("Tracked", "#111111")
+ if err != nil {
+ t.Fatal(err)
+ }
+ if err := h.store.SetProjectBudgetTracked(project.ID, true); err != nil {
+ t.Fatal(err)
+ }
+ due := time.Now()
+ if err := h.store.CreateNativeTask(models.Task{ID: "t-tracked", Content: "Tracked", ProjectID: project.ID, DueDate: &due, EstimatedMinutes: 30}); err != nil {
+ t.Fatal(err)
+ }
+
+ req := httptest.NewRequest("GET", "/tabs/timeline", nil)
+ w := httptest.NewRecorder()
+ h.HandleTimeline(w, req)
+
+ mock := h.renderer.(*MockRenderer)
+ lastCall := mock.Calls[len(mock.Calls)-1]
+ data, ok := lastCall.Data.(TimelineData)
+ if !ok {
+ t.Fatalf("expected TimelineData, got %T", lastCall.Data)
+ }
+ if data.BudgetStatus == nil {
+ t.Fatal("expected non-nil BudgetStatus")
+ }
+ if data.BudgetStatus.Today.ScheduledMinutes != 30 {
+ t.Errorf("Today.ScheduledMinutes = %d, want 30", data.BudgetStatus.Today.ScheduledMinutes)
+ }
+}
+
diff --git a/internal/handlers/timeline.go b/internal/handlers/timeline.go
index 9656d4c..9284451 100644
--- a/internal/handlers/timeline.go
+++ b/internal/handlers/timeline.go
@@ -101,6 +101,10 @@ type TimelineData struct {
// Current time for "now" line
NowHour int
NowMinute int
+
+ // Opt-in budget/availability indicator for Today -- nil when no
+ // budget-tracked task exists (see computeBudgetStatus).
+ BudgetStatus *models.BudgetStatus
}
// HandleTimeline renders the timeline view
@@ -204,6 +208,12 @@ func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) {
data.TomorrowHours = append(data.TomorrowHours, h)
}
+ budgetStatus, err := h.computeBudgetStatus(now)
+ if err != nil {
+ log.Printf("Warning: failed to compute budget status: %v", err)
+ }
+ data.BudgetStatus = budgetStatus
+
HTMLResponse(w, h.renderer, "timeline-tab", data)
}