Skip to content

fix(sidecar): persist history page token to unblock truncated Gmail history - #677

Closed
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-a764
Closed

cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-a764

Conversation

@cursor

@cursor cursor Bot commented Aug 7, 2026

Copy link
Copy Markdown

Summary

  • Persist Gmail history.list nextPageToken in sidecar_state.history_page_token (migration 32) when the 3-page cap leaves more pages pending.
  • Resume pagination from the stored token on the next poll; clear it when the listing completes or on history-gap re-anchor.

Why

When listNewMessageIds hits MAX_HISTORY_PAGES=3 with more pages pending, the poller correctly froze history_cursor but restarted at page 1 on every subsequent poll. Once pages 1–3 were fully deduped, the cursor could never advance and mail on page 4+ was permanently lost — a silent data-loss bug for sidecar mailboxes during bursts or catch-up after downtime.

Test plan

  • npm test passes locally (workspace-poll, gmail-client, sidecar-state — 60 tests)
  • New regression: two-poll convergence resumes from stored page token and advances cursor
  • Existing truncated-history test updated to assert history_page_token is saved

Notes for reviewer

Same fix has been drafted in prior automation runs (#667, #673) but never landed on main. This is the minimal migration + resume path; no change to the page cap itself.

Open in Web View Automation 

…istory

When listNewMessageIds hits the 3-page cap with more pages pending, the
poller froze history_cursor but restarted pagination at page 1 on every
subsequent poll. Once pages 1–3 were fully deduped the cursor could never
advance and mail on page 4+ was permanently lost.

Persist the dangling nextPageToken in sidecar_state (migration 32) and
resume from it on the next poll. Clear the token when the listing completes
or on history-gap re-anchor.

Co-authored-by: schmug <schmug@users.noreply.github.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
ais-hub 2565328 Commit Preview URL

Branch Preview URL
Aug 07 2026, 11:10 AM

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
✅ Deployment successful!
View logs
agentic-inbox 2565328 Aug 07 2026, 11:11 AM

@schmug

schmug commented Aug 23, 2026

Copy link
Copy Markdown
Owner

Closing as superseded by #686.

This is one of 24 near-identical PRs re-filed daily by an automation that has since been fixed. #686 carries the same Gmail history page-token change and is the one kept open, so no work is lost here.

@schmug schmug closed this Aug 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants