Skip to content

Commit 9b6ac16

Browse files
committed
Page the overdue to-dos report in the CLI and its MCP server
Basecamp answers the overdue to-dos report one page at a time since basecamp/bc3#14519. The reports overdue command showed the first page as if it were the whole report and counted only that page. It reads one page, says how many to-dos the whole report holds, and offers the next page while one remains. The MCP server's get_overdue_todos already answered next_page, but refused it as an unknown parameter. The SDK model it reads declares page, so the next page can be asked for. Pins basecamp-sdk to 8f70192 on its main, which takes a page on the overdue report (basecamp/basecamp-sdk#1100), until v0.37.0 carries it. The new go.sum changes the Nix vendorHash, so nix/package.nix carries the refreshed hash. https://app.basecamp.com/2914079/buckets/27/card_tables/cards/10512247737
1 parent ef2b350 commit 9b6ac16

11 files changed

Lines changed: 172 additions & 27 deletions

File tree

‎.surface‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15002,6 +15002,7 @@ FLAG basecamp reports overdue --markdown type=bool
1500215002
FLAG basecamp reports overdue --md type=bool
1500315003
FLAG basecamp reports overdue --no-hints type=bool
1500415004
FLAG basecamp reports overdue --no-stats type=bool
15005+
FLAG basecamp reports overdue --page type=int32
1500515006
FLAG basecamp reports overdue --profile type=string
1500615007
FLAG basecamp reports overdue --project type=string
1500715008
FLAG basecamp reports overdue --quiet type=bool

‎go.mod‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
charm.land/bubbles/v2 v2.2.1
99
charm.land/bubbletea/v2 v2.1.0
1010
charm.land/lipgloss/v2 v2.0.6
11-
github.com/basecamp/basecamp-sdk/go v0.36.0
11+
github.com/basecamp/basecamp-sdk/go v0.36.1-0.20261117211228-8f70192fb5a7
1212
github.com/basecamp/cli v0.2.2-0.20261023171439-c9bce8206df9
1313
github.com/basecamp/mcp v0.0.0-20260828100356-2d6f44b51e9d
1414
github.com/basecamp/surfguard/go v0.1.0

‎go.sum‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,8 @@ github.com/aymerick/douceur v0.2.0 h1:Mv+mAeH1Q+n9Fr+oyamOlAkUNPWPlA8PPGR0QAaYuP
8989
github.com/aymerick/douceur v0.2.0/go.mod h1:wlT5vV2O3h55X9m7iVYN0TBM0NH/MmbLnd30/FjWUq4=
9090
github.com/basecamp/actioncable-go v1.2.0 h1:t0MxlfMTcmaGXZ5ztgKRs7ZiY1MwXtBRwSSSAh1ofVg=
9191
github.com/basecamp/actioncable-go v1.2.0/go.mod h1:ezaV5z1GXQAsqyejqTs6wCFl2D8Wj+COLQkHc/kwoRs=
92-
github.com/basecamp/basecamp-sdk/go v0.36.0 h1:mkAcJQlh+5Vz64OmpImSda/pfa/usWPJ6gDTuZYVaTI=
93-
github.com/basecamp/basecamp-sdk/go v0.36.0/go.mod h1:ynVJME8mVV3UHMUMnzBgygTnMtadQFxz1iYg7fqwUeM=
92+
github.com/basecamp/basecamp-sdk/go v0.36.1-0.20261117211228-8f70192fb5a7 h1:D356PBCefv75HAMF15zlrsSPrglCHBOtnGcrkE7FYR8=
93+
github.com/basecamp/basecamp-sdk/go v0.36.1-0.20261117211228-8f70192fb5a7/go.mod h1:ynVJME8mVV3UHMUMnzBgygTnMtadQFxz1iYg7fqwUeM=
9494
github.com/basecamp/cli v0.2.2-0.20261023171439-c9bce8206df9 h1:3NfGs+zx23Tp6cf+97+UewrJHlzZMLzmvEXOmOJyQAk=
9595
github.com/basecamp/cli v0.2.2-0.20261023171439-c9bce8206df9/go.mod h1:iTBTaWvsPEFIcZfkxQHEfISyJ6sZ7036K6bNx0RY3EE=
9696
github.com/basecamp/mcp v0.0.0-20260828100356-2d6f44b51e9d h1:zEQVGq1x1nhKMZ2TudFAcSJ32CHT8richI1vQakIKz4=

‎internal/commands/reports.go‎

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,14 @@ Results can be grouped by project or date.`,
178178
}
179179

180180
func newReportsOverdueCmd() *cobra.Command {
181-
return &cobra.Command{
181+
var page int32
182+
183+
cmd := &cobra.Command{
182184
Use: "overdue",
183185
Short: "View overdue todos grouped by lateness",
184-
Long: `View all overdue todos grouped by how late they are.
186+
Long: `View overdue todos grouped by how late they are, one page at a time,
187+
most recently due first, so the longest-overdue todos are on the last
188+
pages. --page reads a later page.
185189
186190
Todos are grouped into categories:
187191
- Under a week late
@@ -195,7 +199,7 @@ Todos are grouped into categories:
195199
return err
196200
}
197201

198-
result, err := app.Account().Reports().OverdueTodos(cmd.Context())
202+
result, err := app.Account().Reports().OverdueTodos(cmd.Context(), page)
199203
if err != nil {
200204
return convertSDKError(err)
201205
}
@@ -207,7 +211,11 @@ Todos are grouped into categories:
207211
len(result.OverThreeMonthsLate)
208212

209213
var summary strings.Builder
210-
fmt.Fprintf(&summary, "%d overdue todos", total)
214+
if result.Meta.TotalCount > total {
215+
fmt.Fprintf(&summary, "%d of %d overdue todos", total, result.Meta.TotalCount)
216+
} else {
217+
fmt.Fprintf(&summary, "%d overdue todos", total)
218+
}
211219
if total > 0 {
212220
var parts []string
213221
if n := len(result.UnderAWeekLate); n > 0 {
@@ -236,21 +244,37 @@ Todos are grouped into categories:
236244

237245
return app.OK(result,
238246
output.WithSummary(summary.String()),
239-
output.WithBreadcrumbs(
240-
output.Breadcrumb{
241-
Action: "assigned",
242-
Cmd: "basecamp reports assigned",
243-
Description: "View your assigned todos",
244-
},
245-
output.Breadcrumb{
246-
Action: "schedule",
247-
Cmd: "basecamp reports schedule",
248-
Description: "View upcoming schedule",
249-
},
250-
),
247+
output.WithBreadcrumbs(overdueBreadcrumbs(page, result.Meta.Truncated)...),
251248
)
252249
},
253250
}
251+
252+
cmd.Flags().Int32Var(&page, "page", 0, "Page of the report (default: first page)")
253+
254+
return cmd
255+
}
256+
257+
func overdueBreadcrumbs(page int32, more bool) []output.Breadcrumb {
258+
breadcrumbs := []output.Breadcrumb{
259+
{
260+
Action: "assigned",
261+
Cmd: "basecamp reports assigned",
262+
Description: "View your assigned todos",
263+
},
264+
{
265+
Action: "schedule",
266+
Cmd: "basecamp reports schedule",
267+
Description: "View upcoming schedule",
268+
},
269+
}
270+
if more {
271+
breadcrumbs = append(breadcrumbs, output.Breadcrumb{
272+
Action: "next",
273+
Cmd: fmt.Sprintf("basecamp reports overdue --page %d", max(page, 1)+1),
274+
Description: "Next page of overdue todos",
275+
})
276+
}
277+
return breadcrumbs
254278
}
255279

256280
func resolveReportsScheduleWindow(startDate, endDate string, now time.Time) (string, string) {

‎internal/commands/reports_test.go‎

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
package commands
22

33
import (
4+
"bytes"
5+
"encoding/json"
6+
"net/http"
47
"testing"
58
"time"
69

710
"github.com/stretchr/testify/assert"
11+
"github.com/stretchr/testify/require"
12+
13+
"github.com/basecamp/basecamp-cli/internal/output"
814
)
915

1016
func TestResolveReportsScheduleWindow(t *testing.T) {
@@ -51,3 +57,72 @@ func TestResolveReportsScheduleWindow(t *testing.T) {
5157
})
5258
}
5359
}
60+
61+
const overdueReportPage = `{"under_a_week_late":[{"id":1,"content":"One"}],"over_a_week_late":[],` +
62+
`"over_a_month_late":[{"id":2,"content":"Two"}],"over_three_months_late":[]}`
63+
64+
type overdueReportEnvelope struct {
65+
Summary string `json:"summary"`
66+
Breadcrumbs []struct {
67+
Action string `json:"action"`
68+
Cmd string `json:"cmd"`
69+
} `json:"breadcrumbs"`
70+
}
71+
72+
func runReportsOverdue(t *testing.T, header http.Header, args ...string) (overdueReportEnvelope, recordedCall) {
73+
t.Helper()
74+
app, transport := setupRecordingTestApp(t, stubRoute{
75+
method: http.MethodGet,
76+
path: "/99999/reports/todos/overdue.json",
77+
status: http.StatusOK,
78+
body: overdueReportPage,
79+
header: header,
80+
})
81+
buf := &bytes.Buffer{}
82+
app.Output = output.New(output.Options{Format: output.FormatJSON, Writer: buf})
83+
app.Flags.Hints = true
84+
85+
require.NoError(t, executeRecordingCommand(NewReportsCmd(), app, append([]string{"overdue"}, args...)...))
86+
87+
var envelope overdueReportEnvelope
88+
require.NoError(t, json.Unmarshal(buf.Bytes(), &envelope))
89+
return envelope, transport.last(t)
90+
}
91+
92+
func overdueBreadcrumb(envelope overdueReportEnvelope, action string) string {
93+
for _, bc := range envelope.Breadcrumbs {
94+
if bc.Action == action {
95+
return bc.Cmd
96+
}
97+
}
98+
return ""
99+
}
100+
101+
func TestReportsOverduePageWithMoreNamesTheNextPage(t *testing.T) {
102+
envelope, request := runReportsOverdue(t, http.Header{
103+
"Link": []string{`<https://3.basecampapi.com/99999/reports/todos/overdue.json?page=2>; rel="next"`},
104+
"X-Total-Count": []string{"21"},
105+
})
106+
107+
assert.Empty(t, request.Query)
108+
assert.Equal(t, "2 of 21 overdue todos (1 <1 week, 1 >1 month)", envelope.Summary)
109+
assert.Equal(t, "basecamp reports overdue --page 2", overdueBreadcrumb(envelope, "next"))
110+
}
111+
112+
func TestReportsOverdueLaterPageNamesThePageAfterIt(t *testing.T) {
113+
envelope, request := runReportsOverdue(t, http.Header{
114+
"Link": []string{`<https://3.basecampapi.com/99999/reports/todos/overdue.json?page=3>; rel="next"`},
115+
"X-Total-Count": []string{"95"},
116+
}, "--page", "2")
117+
118+
assert.Equal(t, "page=2", request.Query)
119+
assert.Equal(t, "2 of 95 overdue todos (1 <1 week, 1 >1 month)", envelope.Summary)
120+
assert.Equal(t, "basecamp reports overdue --page 3", overdueBreadcrumb(envelope, "next"))
121+
}
122+
123+
func TestReportsOverdueWholeReportOnOnePageNamesNoNextPage(t *testing.T) {
124+
envelope, _ := runReportsOverdue(t, nil)
125+
126+
assert.Equal(t, "2 overdue todos (1 <1 week, 1 >1 month)", envelope.Summary)
127+
assert.Empty(t, overdueBreadcrumb(envelope, "next"))
128+
}

‎internal/mcpserver/model/PROVENANCE.json‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"source": "github.com/basecamp/basecamp-sdk",
3-
"commit": "867cdd87d0fbbefbad9fd99648002496c909c834",
4-
"ref": "go/v0.36.0",
3+
"commit": "8f70192fb5a732d2c86546c91c9bec11f738a4b9",
4+
"ref": "go/v0.36.0-8-g8f70192f",
55
"files": ["behavior-model.json", "openapi.json"],
66
"synced_by": "scripts/sync-mcp-model.sh",
77
"patches": "binary-upload operations dropped because the toolkit refuses their non-JSON bodies (EXCLUDED_OPERATIONS) and the stream-ticket mint dropped by policy (POLICY_EXCLUDED_OPERATIONS); no tag patches applied (PATCHED_TAGS is empty — the export tags every operation) — see the sync script"

‎internal/mcpserver/model/openapi.json‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23089,7 +23089,7 @@
2308923089
},
2309023090
"/{accountId}/reports/todos/overdue.json": {
2309123091
"get": {
23092-
"description": "Get overdue todos grouped by lateness",
23092+
"description": "Get one page of overdue todos grouped by lateness, latest first.\n\nPages hold 15, 30, 50, then 100 to-dos, and each page fills the same four\ngroups with only its own to-dos, so a group can continue onto the next\npage. A `Link: rel=\"next\"` header names the next page and `X-Total-Count`\nthe total. This operation is not auto-paginated in any SDK: the response\nis an object of four arrays, which no pagination key can name.",
2309323093
"operationId": "GetOverdueTodos",
2309423094
"parameters": [
2309523095
{
@@ -23102,6 +23102,16 @@
2310223102
"description": "Basecamp account ID (numeric string)"
2310323103
},
2310423104
"required": true
23105+
},
23106+
{
23107+
"name": "page",
23108+
"in": "query",
23109+
"description": "Page number for paginating through results. Defaults to 1. This\noperation is not auto-paginated in any SDK, so a page is returned as\nasked for and later pages are not followed.",
23110+
"schema": {
23111+
"type": "integer",
23112+
"description": "Page number for paginating through results. Defaults to 1. This\noperation is not auto-paginated in any SDK, so a page is returned as\nasked for and later pages are not followed.",
23113+
"format": "int32"
23114+
}
2310523115
}
2310623116
],
2310723117
"responses": {

‎internal/mcpserver/server_test.go‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,41 @@ func TestServerAcceptsSynthesizedPageParam(t *testing.T) {
238238
assert.JSONEq(t, `[{"id":2}]`, text)
239239
}
240240

241+
func TestServerPagesTheOverdueReport(t *testing.T) {
242+
upstream := newUpstream(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
243+
require.Equal(t, "/999/reports/todos/overdue.json", r.URL.Path)
244+
w.Header().Set("Content-Type", "application/json")
245+
if r.URL.Query().Get("page") == "2" {
246+
_, _ = w.Write([]byte(`{"under_a_week_late":[],"over_a_week_late":[{"id":2}],"over_a_month_late":[],"over_three_months_late":[]}`))
247+
} else {
248+
w.Header().Set("Link", `<http://`+r.Host+`/999/reports/todos/overdue.json?page=2>; rel="next"`)
249+
_, _ = w.Write([]byte(`{"under_a_week_late":[{"id":1}],"over_a_week_late":[],"over_a_month_late":[],"over_three_months_late":[]}`))
250+
}
251+
}))
252+
253+
srv, err := New(newTestAPI(upstream), Config{})
254+
require.NoError(t, err)
255+
session := mcptest.Connect(t, srv.BuildMCPServer(slog.New(slog.DiscardHandler)))
256+
257+
text, isError := mcptest.CallText(t, session, "basecamp_reports", map[string]any{
258+
"action": "get_overdue_todos",
259+
"params": map[string]any{},
260+
})
261+
require.False(t, isError, "get_overdue_todos failed: %s", text)
262+
var wrapped struct {
263+
NextPage int `json:"next_page"`
264+
}
265+
require.NoError(t, json.Unmarshal([]byte(text), &wrapped))
266+
require.Equal(t, 2, wrapped.NextPage)
267+
268+
text, isError = mcptest.CallText(t, session, "basecamp_reports", map[string]any{
269+
"action": "get_overdue_todos",
270+
"params": map[string]any{"page": wrapped.NextPage},
271+
})
272+
require.False(t, isError, "passing next_page back must dispatch, got: %s", text)
273+
assert.JSONEq(t, `{"under_a_week_late":[],"over_a_week_late":[{"id":2}],"over_a_month_late":[],"over_three_months_late":[]}`, text)
274+
}
275+
241276
func TestServerSurfacesAPIErrorsInBand(t *testing.T) {
242277
upstream := newUpstream(t, http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
243278
http.Error(w, `{"error":"Record not found"}`, http.StatusNotFound)

‎internal/mcpserver/testdata/catalog_snapshot.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ Call {"action": "describe", "params": {"action": "NAME"}} for an action's full p
313313

314314
ACTIONS (RO = read-only):
315315
- get_assigned_todos (RO): Get todos assigned to a specific person
316-
- get_overdue_todos (RO): Get overdue todos grouped by lateness
316+
- get_overdue_todos (RO): Get one page of overdue todos grouped by lateness, latest first
317317
- get_person_progress (RO, paginated): Get a person's activity timeline
318318
- get_progress_report (RO, paginated): Get account-wide activity feed (progress report)
319319
- get_project_timeline (RO, paginated): Get project timeline

‎internal/version/sdk-provenance.json‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"sdk": {
33
"module": "github.com/basecamp/basecamp-sdk/go",
4-
"version": "v0.36.0",
5-
"revision": "867cdd87d0fb",
6-
"updated_at": "2026-11-12T18:43:30Z"
4+
"version": "v0.36.1-0.20261117211228-8f70192fb5a7",
5+
"revision": "8f70192fb5a7",
6+
"updated_at": "2026-11-17T21:12:28Z"
77
},
88
"api": {
99
"repo": "basecamp/bc3",

0 commit comments

Comments
 (0)