Skip to content

feat(coexist): keep synced history out of AI context by default - #967

Merged
viethung0o0 merged 3 commits into
mainfrom
feat/coexist-skip-ai-context
Aug 18, 2026
Merged

feat(coexist): keep synced history out of AI context by default#967
viethung0o0 merged 3 commits into
mainfrom
feat/coexist-skip-ai-context

Conversation

@viethung0o0

Copy link
Copy Markdown
Contributor

Summary

Adds an AI-context boundary for coexist history sync on WhatsApp, Messenger, and Instagram.

  • By default, messages imported by a coexist sync are excluded from AI context: after each sync batch, Conversation.aiContextLastMessageId advances to the newest sync-inserted message (either direction), so AI features (AI agent, automated responses, flow AI steps) only consider newer messages.
  • The coexist onboarding dialog gains a switch (default off) — "AI reads synced history" — letting a workspace opt in to feeding the imported history to the AI instead.
  • New coexistAiReadsSyncedHistory column on the three integration tables (additive migration, default false); the flag is written only on enable, never on decline/disable.
  • Conversation activity + AI-marker updates are batched into a single statement per sync bulk via the business layer, with advance-only semantics, per-workspace scoping, and cache invalidation.

Behavior notes

  • Turning the switch off later only stops future marker advancement; it does not re-expose already-skipped history.
  • Marker updates are forward-only and idempotent across sync retries; markers set by delete-message-history are never regressed.
  • Existing API clients are unaffected: the new request field is optional and defaults to false.

Test plan

  • Worker: 1500/1500 (incl. direction-agnostic newest-message cases, fallback-timestamp batches, dedup/advance-only, per-channel flag threading)
  • Builder: 1547/1547 (coexist API schema/write paths, popup default + toggle, i18n parity across 20 locales)
  • Business: 963/963 (batched conversation update semantics + cache invalidation)
  • Typecheck clean (database, business, worker, builder); lint clean

Deployment

Apply the additive migration 20260818153651_coexist-ai-reads-synced-history before starting the new processes. With the default false, existing coexist integrations start excluding synced history from AI context on their next sync run.

@github-actions github-actions Bot added the feature New feature or request label Aug 18, 2026
@viethung0o0
viethung0o0 marked this pull request as ready for review August 18, 2026 16:58
@viethung0o0
viethung0o0 merged commit 22bff56 into main Aug 18, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants