Skip to content

fix(telegram): start partial draft previews immediately#79696

Closed
TurboTheTurtle wants to merge 1 commit into
openclaw:mainfrom
TurboTheTurtle:fix/telegram-partial-streaming
Closed

fix(telegram): start partial draft previews immediately#79696
TurboTheTurtle wants to merge 1 commit into
openclaw:mainfrom
TurboTheTurtle:fix/telegram-partial-streaming

Conversation

@TurboTheTurtle

@TurboTheTurtle TurboTheTurtle commented May 9, 2026

Copy link
Copy Markdown
Contributor

Resubmission of #79682 after it was auto-closed by the active-PR limit. Supersedes the older draft #79664.

Summary

Fixes #79605.

Telegram partial preview mode now starts the draft preview immediately instead of applying the block-streaming first-message debounce. That preserves the debounce for block previews, while allowing direct model partial text to create the live Telegram preview before final delivery.

The regression test uses the real Telegram draft stream transport from the dispatcher test, emits a short direct partial (Hi), verifies the draft transport sends the preview before final delivery, then verifies the final answer edits that preview instead of falling back to the normal final-send path.

Root Cause

dispatchTelegramMessage passed DRAFT_MIN_INITIAL_CHARS to the draft stream for both partial and block modes. Short direct model partials in partial mode could stay below the 30-character initial threshold, so no visible Telegram preview was created even though partial callbacks reached the lane.

Real behavior proof

  • Behavior or issue addressed: Telegram partial streaming should create the draft preview on the first short model partial instead of waiting for the 30-character block-mode debounce threshold.

  • Real environment tested: Local OpenClaw source checkout on macOS with Node/pnpm, exercising the Telegram dispatcher and draft stream transport paths in extensions/telegram/src/bot-message-dispatch.test.ts and extensions/telegram/src/draft-stream.test.ts.

  • Exact steps or command run after this patch: pnpm test extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/draft-stream.test.ts src/plugin-sdk/channel-streaming.test.ts

  • Evidence after fix: Copied terminal output from the focused Telegram streaming validation:

    pnpm test extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/draft-stream.test.ts src/plugin-sdk/channel-streaming.test.ts
    
    Test Files  1 passed (1)
         Tests  17 passed (17)
    
    Test Files  2 passed (2)
         Tests  70 passed (70)
    
    [test] passed 2 Vitest shards in 13.04s
    
  • Observed result after fix: A direct model partial Hi reaches replyOptions.onPartialReply, the Telegram draft transport sends the preview message before final delivery, the final answer Hi there edits that preview, and the normal final deliverReplies path is not used for that turn.

  • What was not tested: A live Telegram DM screenshot or recording from a real bot account was not captured in this environment; the proof covers the OpenClaw Telegram dispatcher/draft-stream runtime path locally.

Validation

  • pnpm test extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/draft-stream.test.ts src/plugin-sdk/channel-streaming.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/telegram/src/bot-message-dispatch.ts extensions/telegram/src/bot-message-dispatch.test.ts
  • git diff --check FETCH_HEAD

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. size: XS labels May 9, 2026
@clawsweeper

clawsweeper Bot commented May 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

Summary
This PR changes Telegram draft preview threshold selection so only block mode keeps the 30-character initial debounce, and adds a dispatcher regression test for short direct partials editing the preview.

Reproducibility: yes. source inspection gives a high-confidence reproduction path: docs require Telegram partial preview send/edit behavior, current main passes a 30-character initial threshold to partial mode, and the draft stream drops short initial updates below that threshold.

Real behavior proof
Needs real behavior proof before merge: The supplied proof is copied terminal output from focused Vitest tests with mocked Telegram API transport, and the author explicitly notes that no live Telegram bot DM screenshot or recording was captured. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, ask a maintainer to comment @clawsweeper re-review.

Next step before merge
Remaining action is contributor-supplied real Telegram proof, not an automated code repair.

Security
Cleared: The diff only changes Telegram TypeScript runtime logic and tests, with no dependency, workflow, secret, install, or supply-chain surface changes.

Review details

Best possible solution:

Land the narrow Telegram plugin fix after live Telegram DM proof or equivalent redacted runtime logs show a short partial creates and then edits the preview while block-mode debounce remains covered.

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

Yes, source inspection gives a high-confidence reproduction path: docs require Telegram partial preview send/edit behavior, current main passes a 30-character initial threshold to partial mode, and the draft stream drops short initial updates below that threshold.

Is this the best way to solve the issue?

Yes for the code direction: limiting the 30-character debounce to block mode is the narrowest maintainable fix and preserves the existing block-mode behavior, but merge should wait for real Telegram behavior proof.

Acceptance criteria:

  • pnpm test extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/draft-stream.test.ts src/plugin-sdk/channel-streaming.test.ts
  • pnpm exec oxfmt --check --threads=1 extensions/telegram/src/bot-message-dispatch.ts extensions/telegram/src/bot-message-dispatch.test.ts
  • git diff --check
  • pnpm check:changed --base upstream/main

What I checked:

  • Current main applies debounce to partial mode: Current dispatch code sets draftMinInitialChars to 30 for every stream mode except progress, so the default partial mode still receives the first-message threshold. (extensions/telegram/src/bot-message-dispatch.ts:431, 17f03566d81b)
  • Draft stream suppresses short first previews: The draft transport returns without sending when no preview message exists and rendered text is shorter than minInitialChars, matching the short-partial failure mode. (extensions/telegram/src/draft-stream.ts:284, 17f03566d81b)
  • Docs define partial preview behavior: Telegram docs describe partial replies as a live preview message plus editMessageText, with partial as the default streaming mode. Public docs: docs/channels/telegram.md. (docs/channels/telegram.md:272, 17f03566d81b)
  • PR diff targets the implicated branch: The PR changes the threshold conditional to streamMode === "block" ? DRAFT_MIN_INITIAL_CHARS : 0 and adds a regression test using a short Hi partial. (extensions/telegram/src/bot-message-dispatch.ts:431, 977c2fdbfbbc)
  • Real behavior proof remains test-only: The PR body and follow-up comment provide copied focused Vitest output and explicitly say no live Telegram bot DM screenshot or recording was captured. (977c2fdbfbbc)
  • Current checks are green for the PR head: Public check-runs for the current head include successful check, checks-node-channels, check-lint, check-prod-types, build-artifacts, and the structured real-behavior-proof policy check. (977c2fdbfbbc)

Likely related people:

  • steipete: Current-line blame and local shortlog for the central Telegram dispatch, draft stream, tests, and docs point to Peter Steinberger as the recent maintainer of this path; the prior ClawSweeper review also routed the area to this handle. (role: recent maintainer and likely Telegram streaming owner; confidence: high; commits: 70ac5f54212d; files: extensions/telegram/src/bot-message-dispatch.ts, extensions/telegram/src/draft-stream.ts, extensions/telegram/src/bot-message-dispatch.test.ts)

Remaining risk / open question:

  • No redacted live Telegram bot run, runtime log, or recording currently proves that a real DM creates the preview before final delivery after this patch.

Codex review notes: model gpt-5.5, reasoning high; reviewed against d2ac6c3dd5d5.

@TurboTheTurtle
TurboTheTurtle force-pushed the fix/telegram-partial-streaming branch from fdc8eed to 977c2fd Compare May 9, 2026 07:26
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels May 9, 2026
@TurboTheTurtle

Copy link
Copy Markdown
Contributor Author

Updated this PR after the failed checks:

  • Rebased the branch onto current openclaw/main, which picks up the Matrix sidecar packaging/test changes that were missing from the older base and causing the unrelated dist/extensions/matrix/helper-api.js failures.
  • Rewrote the PR body with the structured Real behavior proof fields (behavior, environment, steps, evidence, observedResult, notTested) and verified it locally with scripts/github/real-behavior-proof-policy.mjs.
  • Re-ran the focused Telegram streaming validation locally:
pnpm test extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/draft-stream.test.ts src/plugin-sdk/channel-streaming.test.ts
Test Files  3 passed
Tests       87 passed

Also passed:

pnpm exec oxfmt --check --threads=1 extensions/telegram/src/bot-message-dispatch.ts extensions/telegram/src/bot-message-dispatch.test.ts
git diff --check FETCH_HEAD

One limitation: I still do not have a live Telegram bot DM screenshot/recording from this environment, so the proof is local runtime validation of the real dispatcher/draft-stream path rather than live production traffic.

@clawsweeper re-review

@obviyus

obviyus commented May 9, 2026

Copy link
Copy Markdown
Contributor

Thanks for the focused repro and test. We’re going to close this one because the patch removes Telegram’s 30-character first-preview debounce in partial mode, which is intentional push-notification UX. #79605 should stay open for a fix that restores preview streaming while preserving that debounce.

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

Labels

channel: telegram Channel integration: telegram proof: supplied External PR includes structured after-fix real behavior proof. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram streaming mode "partial" has no effect — only sendMessage ok in logs, no preview edits

2 participants