fix(sidecar): resume truncated Gmail history via history_page_token - #667
Closed
cursor[bot] wants to merge 1 commit into
Closed
cursor[bot] wants to merge 1 commit into
cursor[bot] wants to merge 1 commit into
Conversation
When a Gmail history listing hits MAX_HISTORY_PAGES with a dangling nextPageToken and the first N pages are entirely deduped, the poller re-fetched the same pages every tick without advancing — mail on later pages was never ingested. Persist history_page_token in sidecar_state (migration 32) and pass it to listNewMessageIds on the next poll. Clear the token when the listing completes and the cursor advances. 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 | f10d939 | Commit Preview URL Branch Preview URL |
Jul 31 2026, 11:08 AM |
Deploying with
|
| Status | Name | Latest Commit | Updated (UTC) |
|---|---|---|---|
| ✅ Deployment successful! View logs |
agentic-inbox | f10d939 | Jul 31 2026, 11:09 AM |
| "/history": (u) => { | ||
| const pageToken = u.searchParams.get("pageToken"); | ||
| if (!pageToken) { | ||
| let pages = 0; |
This was referenced Aug 6, 2026
4 tasks
Owner
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_tokento sidecar state (migration 32) to resume Gmail history listings truncated byMAX_HISTORY_PAGESnextPageTokenfromlistNewMessageIdswhen the page cap is hit; poller persists it when the batch is drained but the listing is incompleteWhy
When a Gmail history listing spans more than three pages and the first three pages are entirely deduped (
processed=0), the poller re-fetched the same pages every cron tick without advancinghistory_cursor(correctly frozen whiletruncated=true) — but with no page-token resume, mail on page 4+ was never ingested.Test plan
npm testpasses locally (gmail-client,workspace-poll,sidecar-state)nextPageTokenbehaviorNotes for reviewer
The page token is only advanced when
!hitCap && truncated— if the per-poll message cap fires mid-batch, the token stays unchanged so already-processed ids dedupe cleanly on the next tick.