Skip to content

fix(search): bound personal Gmail sources and sync them from Gmail history - #7717

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/gmail-search-defaults-history-feed
Sep 10, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/gmail-search-defaults-history-feed

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Sep 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Search sources start from a connector's declared defaults; Gmail now indexes the last 6 months unless the source sets a range. Explicit settings win, blank form fields keep the default, and knowledge-base connectors outside Search are unchanged
  • Gmail gets a change feed on users.history.list: the members engine opens a cursor at the mailbox history id and later syncs re-read only threads that gained a message, were relabelled, or were deleted, instead of relisting the whole mailbox every hour
  • Labels, date range and category exclusions are evaluated locally against thread metadata; a source with a free-form search filter cannot be evaluated locally and keeps relisting. An expired history id reopens the feed from a full listing through the engine's existing cursor-invalid path
  • The approved-source path accepts the fields the defaults cover and applies them before the config identity is compared, so a second person connecting lands on the source the first connection created
  • Docs: Gmail Search page describes the 6-month default and history-based sync

Type of Change

  • Bug fix

Testing

  • New tests: Gmail change feed (cursor open, scope filters, paging, expired/malformed cursor), Search defaults helper, connect and approved-source paths applying defaults
  • vitest on gmail, sim-search, connectors application, member-sync engine and sync primitives: 393 passing
  • bun run type-check, bun run lint, bun run check:audits, docs-manifest:check pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

…story

A personal Gmail connection indexed the whole mailbox from all time, and
members mode removes the thread cap by design (a capped listing cannot tell
a thread that fell out of the window from one the person lost access to).
Search sources now start from the connector's declared defaults, so Gmail
indexes the last six months unless the source says otherwise. Explicit
settings still win and knowledge-base connectors are unchanged.

Every hourly Gmail sync relisted the entire mailbox because the connector
had no change feed. It now opens a cursor at the mailbox history id and
reads users.history.list, re-reading only threads that gained a message,
were relabelled, or were deleted, and evaluates the configured labels,
date range and category exclusions locally. A free-form search filter
cannot be evaluated locally, so such a source keeps relisting. An expired
history id reopens the feed from a full listing through the engine's
existing cursor-invalid path.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@vercel

vercel Bot commented Sep 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Sep 10, 2026 5:32am UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

The PR appears safe to merge with no outstanding findings.

Summary

  • Applies Search-specific defaults before source identity lookup and creation while preserving explicit settings.
  • Reconciles changed, deleted, trashed, and relabelled Gmail threads through a paginated change feed.
  • Evaluates supported Gmail scope filters locally and falls back to full listing for free-form queries or invalid history cursors.
  • Documents the new default and synchronization behavior.
  • The previous date-window concern was explicitly accepted as designed by waleedlatif1, and its thread was resolved.
  • The previous const-assertion requirement is fully fixed by the latest change.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Create personal Gmail Search source] --> B[Apply six-month default]
    B --> C[Full thread listing]
    C --> D[Open cursor at mailbox history ID]
    D --> E{Free-form Gmail query?}
    E -->|Yes| C
    E -->|No| F[Read Gmail history page]
    F --> G[Fetch metadata for touched threads]
    G --> H{Thread remains in configured scope?}
    H -->|Yes| I[Upsert document stub]
    H -->|No| J[Remove indexed document]
    I --> K{More history pages?}
    J --> K
    K -->|Yes| F
    K -->|No| L[Advance history cursor]
    L --> M[Periodic full reconciliation]
    M --> D
Loading

Reviews (2) · Last reviewed commit: "fix(search): assert the Gmail date-range..."

Comment thread apps/sim/connectors/gmail/gmail.ts
Comment thread apps/sim/connectors/gmail/gmail.ts Outdated
The lookup narrows an arbitrary config string through a type guard
instead of indexing a widened record.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@waleedlatif1
waleedlatif1 merged commit 1da2820 into staging Sep 10, 2026
24 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/gmail-search-defaults-history-feed branch September 10, 2026 05:34
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.

1 participant