Skip to content

fix(chatwoot-adapter): harden history backfill from deep review (#609)#28

Merged
rmyndharis merged 1 commit into
mainfrom
fix/chatwoot-backfill-hardening
Jul 3, 2026
Merged

fix(chatwoot-adapter): harden history backfill from deep review (#609)#28
rmyndharis merged 1 commit into
mainfrom
fix/chatwoot-backfill-hardening

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

Pre-release hardening of the v0.3.0 history backfill (still unreleased), from a deep source-traced review. Pairs with OpenWA 0.8.6.

Fixes

  • engine:read permission added. The sandboxed adapter now calls engine.getChatHistory/getChats; without the permission the host gate (resolveEngineRead) rejected them, so backfill silently no-op'd. minOpenWAVersion0.8.6 (which bridges engine.getChatHistory into the sandbox and enriches historical location/quote).
  • Bulk sweep no longer creates empty conversations. It now fetches history before ensureConversation and skips a chat with no fetchable history — so an engine without history support (Baileys, which rejects) or an empty chat can't flood Chatwoot with empty conversations.
  • Per-message failure isolation. A failed post in the replay is logged and skipped instead of aborting the rest of the chat's history, and each message is marked seen only after a successful post (retryable, not a silent drop). Previously one transient 429 truncated the chat's history and dropped the failing message.
  • backfillAllOnce accepts the string "true", not only the boolean.

Not changed

Baileys getChatHistory remains unsupported by design; the adapter degrades gracefully (lazy is a no-op + the live message still posts; bulk skips the chat). Historical location/quote fidelity comes from the 0.8.6 engine enrichment — no adapter change needed.

Tests

New: a failed history post is isolated and left unmarked while the rest post; the bulk sweep creates no conversation for a chat with no fetchable history. Full suite green (233 tests across all plugins), tsc --noEmit clean, plugin packages, catalog up to date.

Deep review of the v0.3.0 backfill surfaced defects fixed here (still
pre-release, so folded into v0.3.0):

- Add the engine:read permission — the sandboxed adapter could not call
  engine.getChatHistory/getChats without it, so backfill was rejected at the
  host gate. Bump minOpenWAVersion to 0.8.6 (the sandbox-bridged capability).
- Bulk sweep now fetches history BEFORE creating a conversation and skips a
  chat with no fetchable history, so an engine without history support
  (Baileys) or an empty chat no longer floods Chatwoot with empty conversations.
- Per-message isolation in replay: one failed post is logged and skipped
  instead of aborting the rest of the chat, and a message is marked seen only
  AFTER a successful post so a transient error stays retryable, not a silent drop.
- Accept the string "true" for backfillAllOnce, not only the boolean.

Historical location coordinates and quoted-message threading now render via
the 0.8.6 engine enrichment (no adapter change needed).
@rmyndharis rmyndharis merged commit fa7f350 into main Jul 3, 2026
1 check passed
@rmyndharis rmyndharis deleted the fix/chatwoot-backfill-hardening branch July 3, 2026 09:55
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