fix(sidecar): resume truncated Gmail history via page token (#595) - #650
Draft
cursor[bot] wants to merge 1 commit into
Draft
fix(sidecar): resume truncated Gmail history via page token (#595)#650cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
When listNewMessageIds hits MAX_HISTORY_PAGES (3) and pages 1-3 are already ingested, every subsequent poll re-listed the same pages and never reached page 4+ — silently skipping new mail for busy mailboxes catching up after downtime. Persist history_page_token in sidecar_state (migration 32) when a truncated listing is fully worked, and resume from that token on the next poll. Clear the token when the listing completes or when a batch cap leaves unprocessed ids in the current slice. Co-authored-by: schmug <schmug@users.noreply.github.com>
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
ais-hub | b6451e1 | Commit Preview URL Branch Preview URL |
Jul 25 2026, 11:06 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
agentic-inbox | b6451e1 | Jul 25 2026, 11:07 AM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
history_page_tokeninsidecar_state(migration 32) when a Gmail history listing hitsMAX_HISTORY_PAGESand the current slice is fully workednextPageTokeninstead of re-fetching pages 1–3 foreverWhy
listNewMessageIdscaps at 3 history pages and correctly freezes the cursor whentruncated: true. However, if pages 1–3 are already ingested (all deduped), every subsequent poll re-listed the same pages and never reached page 4+ — silently skipping new mail for busy mailboxes catching up after downtime.Concrete trigger: >3 pages of Gmail history since the cursor, with the first 3 pages already stored.
Closes #595.
Test plan
npm testpasses locally (workspace-poll, gmail-client, sidecar-state — 59 tests)Notes for reviewer
Minimal fix scoped to the page-cap deadlock. Preserves #627 poll-lease heartbeat and RELAY_CREDS_ runtime guard (unlike earlier draft PR #635 which regressed both). Does not address the separate gateway passthrough policy re-fetch drop or sidecar post-ingest audit gap — reported only.