Skip to content

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

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

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

Conversation

@cursor

@cursor cursor Bot commented Aug 10, 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.
  • Add regression tests for listNewMessageIds resume and two-poll workspace convergence.

Why

When listNewMessageIds hits MAX_HISTORY_PAGES=3 with a dangling nextPageToken, the poller correctly freezes history_cursor but restarts at page 1 on every subsequent poll. Once pages 1–3 are fully deduped, the cursor can never advance and mail on page 4+ is permanently lost — silent data loss during Gmail history bursts for sidecar mailboxes.

Test plan

  • npm test passes locally (60 tests: gmail-client, workspace-poll, sidecar-state)
  • npm run typecheck passes locally
  • Manually exercised the affected flow (describe how)

Notes for reviewer

Same fix as prior investigation branches (#595/#667); main was still missing this at 627b2b5.

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 31e1f4d Commit Preview URL

Branch Preview URL
Aug 10 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 31e1f4d Aug 10 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