Skip to content

refactor(channels): deslop telegram and whatsapp transports - #156752

Merged
steipete merged 2 commits into
mainfrom
deslop/l16-telegram-transport-cleanup-20260923
Sep 24, 2026
Merged

steipete merged 2 commits into
mainfrom
deslop/l16-telegram-transport-cleanup-20260923

Conversation

@steipete

@steipete steipete commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Telegram and WhatsApp repeat transport preparation, result projection, lifecycle bookkeeping, and small forwarding layers. Keeping those copies aligned adds maintenance work around identity, authorization, and partial delivery.

User Impact

No intended behavior change. This preserves public plugin/SDK exports, config, protocol, persisted schemas, Telegram DM/forum-topic distinctions, WhatsApp PN/LID matching and linked-device auth, reaction approvals, rich/plain recovery, and send/reply accounting. No dependencies or tests were changed.

Why This Change Was Made

  • Telegram polling/webhook status now has one publisher; global registries reuse the existing SDK singleton owner. Formatting, credential result construction, native-command setup, and forwarding paths shed duplicate orchestration.
  • WhatsApp reuses existing owners for deferred settlement, bounded caches, UUID creation, durable message IDs, and text normalization. QR outcomes, setup patches, document sends, location extraction, group gating, and live/replay approval preparation each share their repeated work.
  • Private pass-through wrappers, an unused empty-send policy knob, duplicate types, and validation of already typed results are removed. The original PN/LID mapping-file readers remain intact.

The assertion and file-size baselines only shrink to reflect removed code and casts. Separate durable/streaming delivery contracts, ownership checks, credential barriers, and recovery behavior remain intact.

Evidence

  • node scripts/check-changed.mjs: all selected gates passed, including types, format, lint, dead exports, storage guards, and import cycles (proof run).
  • pnpm test:extension telegram: 165 files / 2,579 tests passed.
  • pnpm test:extension whatsapp: 105 files / 1,421 tests passed.
  • Explicit E2Es: 5 files / 58 tests passed. Cross-area consumers: 11 files / 76 tests passed across the same six-shard selection.
  • pnpm build: passed in 7m25.3s, including SDK export validation and UI build. The combined suite/build Testbox run returned exit 0; both leases are stopped.
  • Final location, connection, and PN/LID follow-up selection: 3 files / 167 tests passed. Targeted lint passed after the final direct boolean-field cleanup. git diff --check: passed.

The Linux suite/build capture preceded the small lint corrections and restoration of the original LID readers; the focused follow-up and final changed checks cover those final sources. The subsequent rebase incorporated the Workshop clock repair and left all 63 changed transport paths byte-identical. No tests were added or changed. The build emitted a nonfatal Mermaid asset diagnostic (1,555.8 KiB gzip versus 960.0 KiB); this PR does not change that asset or budget.

Requested non-test/non-doc measurement: 65 files changed, 722 insertions(+), 2004 deletions(-) — 1,282 net lines removed, including six baseline lines. Production code alone: 1,276 net lines removed (Telegram 743; WhatsApp 533).

Codex autoreview completed through P2. Reports were checked against the full source and merge base; no accepted/actionable finding remains. The reported Telegram table/URL rules and WhatsApp empty-quote guard already existed at the base; the shared WhatsApp sanitizer already collapses whitespace-only text; and reply finalization explicitly uses error when no visible reply was delivered. Lint corrections removed a shadowed name and unnecessary boolean conversion; a LID-reader consolidation was reverted instead of introducing a stringification cast.

These are isolated/loopback proofs. No authenticated live Telegram or WhatsApp probe was run. Native /fast reader consolidation remains deferred pending a coordinated worker-backed SDK reader outside this transport cleanup.

CI

Landing refresh: rebased onto current main after commit df47b734490 centralized WhatsApp history finalization. The single conflict resolution preserves that upstream owner and retains this PR's conditional reply-status finalization; no other PR code changed. The three focused delivery/history files passed 97 tests, and fresh Codex review found no accepted/actionable issue in the resolution. The previously reported quote-body concern remains unsupported by the string construction and formatter guard.

Rebased head 7463f64bed2c59f3ccdbabbb1875798e8544660d passed fresh CI 35937820429: 131 jobs completed without failures. The native GitHub-gated flow merged it as f6dd4b06f4b519d51ef6d879a4097f3879854d16; a fresh fetch confirmed that merge commit is an ancestor of origin/main.

Explicit E2E and cross-area selection
node scripts/run-vitest.mjs \
  extensions/telegram/src/bot.media.downloads-media-file-path-no-file-download.e2e.test.ts \
  extensions/telegram/src/bot.media.stickers-and-fragments.e2e.test.ts \
  extensions/telegram/src/bot.media.warning-topics.e2e.test.ts \
  extensions/telegram/src/telegram-ingress-coalescing.e2e.test.ts \
  extensions/whatsapp/src/auto-reply.web-auto-reply.connection-and-logging.e2e.test.ts \
  test/loopback-ask-user-telegram-channel.test.ts \
  test/telegram-recovery-notice-send.test.ts \
  test/telegram-outbound-permanent-rejection-loopback.test.ts \
  test/telegram-question-gateway.test.ts \
  test/outbound-sanitize-text-delivery.test.ts \
  test/telegram-reply-conversation.test.ts \
  test/telegram-history-read.integration.test.ts \
  test/progress-card-channel-literals.integration.test.ts \
  src/channels/message-access/context-builder-callers.test.ts \
  src/channels/turn/message-turn-guardrails.test.ts \
  src/plugins/contracts/plugin-sdk-runtime-api-guardrails.test.ts

@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XL labels Sep 23, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
@clawsweeper

clawsweeper Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 23, 2026, 8:32 PM ET / September 24, 2026, 00:32 UTC (Revision 4).

ClawSweeper review

What this changes

The branch consolidates Telegram and WhatsApp transport, formatting, setup, and delivery helpers while aiming to preserve existing channel behavior.

Merge readiness

⛔ Blocked before merge - 3 items remain

Keep open. Current main has not absorbed this cleanup, and the source review found no definite patch regression. Telegram’s scoped live-proof requirement remains unmet.

Priority: P2
Reviewed head: 7463f64bed2c59f3ccdbabbb1875798e8544660d

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🌊 off-meta tidepool Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
Evidence reviewed 8 items Telegram streaming change: The introduced edit path combines rich-message and HTML fallback handling while retaining preview edits and plain-text fallback.
WhatsApp delivery change: Live and durable replay paths now call the same approval-reaction preparation with the same account and identity inputs; the durable message ID retains its prior hash formula.
Scoped Telegram review policy: The Telegram plugin guide requires real Telegram proof for changes touching transport, streaming, topics, callbacks, authorization, or reply context.
Findings None None.
Security None None.

How this fits together

Telegram and WhatsApp plugins turn account settings and Gateway messages into platform requests. Incoming platform events feed agent turns, while delivery results and transport status return to the Gateway.

flowchart LR
  A[Account settings] --> B[Channel plugins]
  C[Gateway messages] --> B
  D[Platform events] --> B
  B --> E[Telegram or WhatsApp API]
  B --> F[Agent turns]
  E --> G[Delivery results and status]
Loading

Before merge

  • Resolve merge risk (P1) - Real Telegram preview editing and final-reply parity remain unverified for this head; the submitted checks are isolated or loopback proof, while the Telegram plugin guide requires a live check for these paths.
  • Complete next step (P2) - Add redacted live Telegram Test Server evidence showing streaming preview edits and one persistent final reply before merge.
  • Resolve review confidence - ClawSweeper must reach high confidence before merge readiness is known.
Agent review details

Security

None.

PR surface

Source -1276, Other -6. Total -1282 across 65 files.

View PR surface stats
Area Files Added Removed Net
Source 63 705 1981 -1276
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 2 9 15 -6
Total 65 714 1996 -1282

Review metrics

None.

Merge-risk options

Maintainer options:

  1. Prove Telegram reply parity (recommended)
    Capture a redacted live Telegram Test Server trace showing a preview edited into one persistent final reply on this head.

Technical review

Best possible solution:

Keep the channel-specific transport owners consolidated and preserve existing account, delivery, and SDK contracts, backed by an observed Telegram streaming-to-final reply.

Do we have a high-confidence way to reproduce the issue?

Not applicable: this PR proposes a behavior-preserving refactor rather than reporting a failing current-main behavior.

Is this the best way to solve the issue?

Yes, the consolidation follows the existing channel owners and no narrower supported capability replaces it. Live Telegram parity evidence is still needed for merge readiness.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against d1a3a33acc1c.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded internal channel cleanup with no established current user regression.
  • merge-risk: 🚨 message-delivery: The branch changes Telegram streaming and WhatsApp delivery paths where a semantic drift could alter visible replies despite passing isolated checks.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Real behavior proof is not required for maintainer- or bot-authored pull requests.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The changed streaming and topic-delivery paths affect Telegram chat results that a Test Server user can observe.

Evidence

What I checked:

  • Telegram streaming change: The introduced edit path combines rich-message and HTML fallback handling while retaining preview edits and plain-text fallback. (extensions/telegram/src/draft-stream.ts:285, 7463f64bed2c)
  • WhatsApp delivery change: Live and durable replay paths now call the same approval-reaction preparation with the same account and identity inputs; the durable message ID retains its prior hash formula. (extensions/whatsapp/src/inbound/message-delivery.ts:384, 7463f64bed2c)
  • Scoped Telegram review policy: The Telegram plugin guide requires real Telegram proof for changes touching transport, streaming, topics, callbacks, authorization, or reply context. (extensions/telegram/AGENTS.md:131, 7463f64bed2c)
  • Submitted proof: The captured PR body reports passing extension, loopback, targeted E2E, build, and changed-file checks, and explicitly says no authenticated live Telegram or WhatsApp probe was run. A bounded Telegram proof request in this review returned no observations before termination, so it supplies no pass or failure evidence. (7463f64bed2c)
  • Current-main comparison: The fetched current main still differs across the central Telegram and WhatsApp transport paths; the cleanup remains unique work on this branch. (extensions/telegram/src/draft-stream.ts, d1a3a33acc1c)
  • Release inclusion check: No repository tag contains the proposed head; the provided latest release is v2026.9.6, and this open PR is not an already-shipped implementation. (7463f64bed2c)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Tighten the PR description with what changed, how it was validated, and any remaining risk.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-23T21:09:13.710Z sha 177ec02 :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-23T22:52:04.264Z sha 74431d79a477c827c5daec6d9e6b967525ff14da :: blocked before merge. :: none
  • reviewed 2026-09-23T23:07:25.547Z sha 74431d79a477c827c5daec6d9e6b967525ff14da :: blocked before merge. :: none

@steipete
steipete force-pushed the deslop/l16-telegram-transport-cleanup-20260923 branch from 177ec02 to 74431d7 Compare September 23, 2026 22:39
@steipete steipete changed the title refactor(telegram): deslop telegram refactor(channels): deslop telegram and whatsapp transports Sep 23, 2026
@openclaw-barnacle openclaw-barnacle Bot added the channel: whatsapp-web Channel integration: whatsapp-web label Sep 23, 2026
@clawsweeper clawsweeper Bot added proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 23, 2026
@steipete
steipete force-pushed the deslop/l16-telegram-transport-cleanup-20260923 branch from 74431d7 to 7463f64 Compare September 24, 2026 00:18
@steipete
steipete merged commit f6dd4b0 into main Sep 24, 2026
180 of 181 checks passed
@steipete
steipete deleted the deslop/l16-telegram-transport-cleanup-20260923 branch September 24, 2026 00:39
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant