Skip to content

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

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

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

Conversation

@cursor

@cursor cursor Bot commented Jul 28, 2026

Copy link
Copy Markdown

Summary

  • Fix a deadlock in the Workspace sidecar poller when Gmail history listings exceed the 3-page cap and early pages are already deduped.
  • Persist the dangling nextPageToken in sidecar_state.history_page_token (migration 32) so the next poll can resume past the page cap.
  • Clear the token on cursor advance, history-gap re-anchor, or batch-cap mid-slice.

Why

listNewMessageIds caps at MAX_HISTORY_PAGES=3. When truncated, the cursor correctly freezes — but if pages 1–3 are all deduped, the poller re-fetches them forever and never reaches page 4+. Inbound mail beyond the page cap is silently skipped.

Closes #595.

Test plan

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

Notes for reviewer

Also clears history_page_token on history-gap re-anchor (stale token + new cursor would be invalid).

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 811dd85 Commit Preview URL

Branch Preview URL
Jul 28 2026, 11:04 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 811dd85 Jul 28 2026, 11:05 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.

feat(sidecar): /setup/sidecar onboarding wizard with Directory-API mailbox picker

1 participant