Skip to content

fix(sidecar): resume truncated Gmail history via page token (#595) - #652

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

fix(sidecar): resume truncated Gmail history via page token (#595)#652
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-97a4

Conversation

@cursor

@cursor cursor Bot commented Jul 26, 2026

Copy link
Copy Markdown

Summary

  • Persist history_page_token in sidecar_state (migration 32) when a Gmail history listing hits the 3-page cap and the current slice is fully worked
  • Resume truncated listings from the saved nextPageToken on the next poll instead of re-fetching pages 1–3 forever
  • Clear the token on complete listings, history-gap re-anchor, or batch-cap mid-slice

Why

When listNewMessageIds hits MAX_HISTORY_PAGES, the cursor correctly stays frozen. But if pages 1–3 are already deduped, the poller re-fetched them on every tick and never reached page 4+ — silently skipping new mail for busy sidecar mailboxes.

Test plan

  • npm test passes locally (59 targeted tests: gmail-client, workspace-poll, sidecar-state)
  • New regression test covers the two-poll deadlock scenario (deduped pages 1–3 → save token → resume → advance cursor)

Notes for reviewer

Minimal fix scoped to the page-cap continuation path. No changes to cursor-advance semantics for non-truncated listings.

Open in Web View Automation 

When listNewMessageIds hits MAX_HISTORY_PAGES the cursor correctly stays
frozen, but if pages 1-3 are already deduped the poller re-fetched them
forever and never reached page 4+ — silently skipping new mail.

Persist history_page_token (migration 32) once a truncated slice is fully
worked; the next poll resumes from that nextPageToken with the same cursor.
Clear the token on a complete listing or when a batch cap leaves unprocessed
ids in the current slice.

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 0baf027 Commit Preview URL

Branch Preview URL
Jul 26 2026, 11:02 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 0baf027 Jul 26 2026, 11:03 AM

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.

1 participant