Skip to content

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

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

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

Conversation

@cursor

@cursor cursor Bot commented Jul 30, 2026

Copy link
Copy Markdown

Summary

  • Persist Gmail nextPageToken in sidecar_state.history_page_token when a history listing hits the MAX_HISTORY_PAGES cap and the current slice is fully worked.
  • Resume truncated history from the saved page token on the next poll so pages beyond the cap are eventually reached.
  • Clear the token on cursor advance, history-gap re-anchor, or batch-cap mid-slice.

Why

When listNewMessageIds hits the 3-page cap, the cursor correctly freezes — but if pages 1–3 are already deduped, the poller re-fetches them forever and never reaches page 4+. Inbound mail on later pages is silently skipped.

Trigger: Sidecar mailbox with a burst of >3 pages of Gmail history where the first pages were already ingested in a prior partial run.

Test plan

  • npm test passes locally (workspace-poll, gmail-client, sidecar-state suites — 59 tests)
  • New regression test: truncated history deadlock — deduped pages save token, next poll resumes and advances cursor

Notes for reviewer

  • Adds migration 32_history_page_token.
  • Same fix was previously drafted on cursor/critical-bug-investigation-e194 but never merged to main.
Open in Web View Automation 

When listNewMessageIds hits the MAX_HISTORY_PAGES cap the cursor correctly
freezes, but if pages 1-3 are already deduped the poller re-fetches them
forever and never reaches page 4+ — silently skipping inbound mail.

Persist the dangling nextPageToken in sidecar_state.history_page_token once
the current slice is fully worked; the next poll resumes from that token with
the same cursor. Clear the token on cursor advance, history-gap re-anchor,
or batch-cap mid-slice (restart from page 1 to finish unprocessed ids).

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 d46a731 Commit Preview URL

Branch Preview URL
Jul 30 2026, 11:06 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 d46a731 Jul 30 2026, 11:07 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