Skip to content

fix(telegram): warn on selected quote tool-progress caveat#73495

Merged
steipete merged 2 commits into
openclaw:mainfrom
GodsBoy:fix/telegram-replytomode-tool-progress-doc-and-doctor
May 3, 2026
Merged

fix(telegram): warn on selected quote tool-progress caveat#73495
steipete merged 2 commits into
openclaw:mainfrom
GodsBoy:fix/telegram-replytomode-tool-progress-doc-and-doctor

Conversation

@GodsBoy

@GodsBoy GodsBoy commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Summary

Problem

The original report was framed as replyToMode disabling Telegram tool-progress preview. Current code is narrower: extensions/telegram/src/bot-message-dispatch.ts only skips the answer draft preview when replyToMode !== "off" and the inbound context includes selected quote text. In that selected/native quote path, answerLane.stream is not created, so streaming.preview.toolProgress cannot render the short Working... preview lines for that turn.

Current-message replies without selected quote text still keep preview streaming. That runtime behavior is covered by existing dispatch tests and remains unchanged.

What Changed

  • Added a Telegram-owned doctor warning in extensions/telegram/src/doctor.ts.
  • The warning scans listTelegramAccountIds(cfg) plus mergeTelegramAccountConfig(cfg, accountId) so top-level defaults, empty accounts: {}, and per-account inheritance match runtime account resolution.
  • The warning only fires when preview streaming and preview tool progress are enabled, replyToMode is not "off", and block streaming has not already taken over delivery.
  • Updated Telegram and streaming docs to describe selected quote replies as the exception, not a blanket replyToMode incompatibility.
  • Added focused Telegram doctor tests for the default account, empty accounts: {}, merged account config, opt-out via streaming.preview.toolProgress: false, preview-off, and block-streaming cases.
  • Added a changelog entry.

What Did Not Change

No runtime fallback was added. Sending separate progress messages while preserving native Telegram selected-quote replies would be a product behavior change and should be handled separately if desired.

Validation

  • pnpm exec oxfmt --check --threads=1 extensions/telegram/src/doctor.ts extensions/telegram/src/doctor.test.ts docs/channels/telegram.md docs/concepts/streaming.md CHANGELOG.md
  • pnpm test extensions/telegram/src/doctor.test.ts
  • git diff --check
  • Testbox OPENCLAW_TESTBOX=1 pnpm check:changed on tbx_01kqq6akq82kq7m0r4q925v6fm

Note: pnpm config:docs:check currently reports generated config baseline drift without modifying files. This PR does not touch config schema/help surfaces.

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Runtime message delivery changed? No

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation channel: telegram Channel integration: telegram commands Command implementations size: M labels Apr 28, 2026
@greptile-apps

greptile-apps Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds an openclaw doctor warning that surfaces the silent mutual exclusion between channels.telegram.replyToMode != "off" and streaming.preview.toolProgress, and adds explanatory <Note> callouts to both docs/channels/telegram.md and docs/concepts/streaming.md. There are no runtime code changes. The implementation correctly propagates inherited streaming.mode: "off" through the shallow account-merge path, guards against ANSI/log-injection via sanitizeForLog, and is covered by a thorough test suite including per-account inheritance, opt-out, and CWE-117 edge cases.

Confidence Score: 5/5

Safe to merge — read-only doctor scan over already-loaded config, no runtime path changes, comprehensive test coverage.

No P0 or P1 findings. All logic is tested, including per-account inheritance and edge cases. The await removal in active-memory tests is correct (register is synchronous). The shallow-merge false-negative for accounts: {} is a theoretical edge case with no practical impact.

No files require special attention.

Reviews (3): Last reviewed commit: "test(active-memory): remove stale async ..." | Re-trigger Greptile

Comment thread src/commands/doctor/shared/telegram-replyto-streaming.ts Outdated
Comment thread src/commands/doctor/shared/telegram-replyto-streaming.ts Outdated
@clawsweeper

clawsweeper Bot commented Apr 28, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
This PR updates Telegram and streaming docs, adds a Telegram-owned doctor warning scanner with tests, and records a changelog entry for selected Telegram quote replies suppressing tool-progress preview.

Reproducibility: yes. Current main source shows selected Telegram quote replies disable the answer preview stream, and existing tests already distinguish that path from current-message replies that keep preview streaming.

Next step before merge
No repair lane is needed because the current PR has no blocking findings; the remaining action is normal maintainer review, CI confirmation, and merge handling.

Security
Cleared: Cleared: the diff adds docs, tests, changelog, and a read-only Telegram doctor config scan without dependency, workflow, secret, network, or runtime delivery changes.

Review details

Best possible solution:

Land this PR or an equivalent Telegram-owned guardrail after normal CI, keeping runtime delivery unchanged and treating any separate progress-message fallback as a future product change.

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

Yes. Current main source shows selected Telegram quote replies disable the answer preview stream, and existing tests already distinguish that path from current-message replies that keep preview streaming.

Is this the best way to solve the issue?

Yes. Docs plus a Telegram doctor warning are the narrowest maintainable fix for the silent doc/runtime mismatch; sending separate progress messages while preserving native selected quote replies would be a larger behavior change.

What I checked:

  • Current main source reproduction: Selected quote text with replyToMode enabled sets hasTelegramQuoteReply, prevents answer draft stream creation, and therefore makes previewToolProgressEnabled false for that turn. (extensions/telegram/src/bot-message-dispatch.ts:399, d0497d13d18e)
  • Current main behavior is already narrowed in tests: Existing dispatch tests assert selected quote replies skip answer draft preview while current-message replies with native quote candidates still create the preview stream. (extensions/telegram/src/bot-message-dispatch.test.ts:450, d0497d13d18e)
  • PR scanner follows runtime account/default helpers: The PR adds scanTelegramSelectedQuoteToolProgressWarnings using listTelegramAccountIds, mergeTelegramAccountConfig, resolveTelegramPreviewStreamMode, block streaming, and tool-progress resolution instead of moving Telegram-specific policy into core doctor code. (extensions/telegram/src/doctor.ts:203, 847c0c0e69f9)
  • PR regression coverage covers scanner parity cases: The PR adds Telegram doctor tests for the default account, empty accounts object, merged account config, tool-progress opt-out, preview-off, and block-streaming cases. (extensions/telegram/src/doctor.test.ts:331, 847c0c0e69f9)
  • Maintainer direction supports the chosen scope: A maintainer comment says the best fix is to keep runtime behavior unchanged, add a Telegram-owned doctor warning, document the selected/native quote caveat, and leave separate progress-message fallback as a larger product change.
  • Security-sensitive surface review: The diff changes docs, changelog, Telegram doctor/tests, and a read-only config warning; it does not add dependencies, workflows, package metadata, secret handling, network calls, or runtime delivery changes. (847c0c0e69f9)

Likely related people:

  • steipete: Recent main commits touch Telegram doctor and Telegram preview/reply delivery, and the latest maintainer comment/force-push shaped this PR’s final scope. (role: recent maintainer and reviewer; confidence: high; commits: ac58dc2e929c, e65b490f11f5, cb8c513ce3f2; files: extensions/telegram/src/doctor.ts, extensions/telegram/src/bot-message-dispatch.ts, docs/channels/telegram.md)
  • obviyus: Recent main history includes Telegram preview transport and Telegram docs work adjacent to the selected-quote/preview-streaming behavior. (role: adjacent Telegram streaming maintainer; confidence: medium; commits: 2a4dd8925323, 565f4314fe1d; files: extensions/telegram/src/bot-message-dispatch.ts, docs/channels/telegram.md)
  • VACInc: Recent main history includes the Telegram tool-progress delivery behavior that this PR documents and warns about. (role: tool-progress behavior contributor; confidence: medium; commits: 78c7292c9515; files: extensions/telegram/src/bot-message-dispatch.ts)

Remaining risk / open question:

  • No local tests were run because this was a read-only review; the PR-reported targeted checks and Testbox changed gate should still be confirmed by normal maintainer/CI flow before merge.

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

@GodsBoy
GodsBoy force-pushed the fix/telegram-replytomode-tool-progress-doc-and-doctor branch from 2a207aa to 4508fbd Compare April 28, 2026 10:57
@GodsBoy

GodsBoy commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

🟡 Medium · Terminal escape/log injection in doctor warning via unsanitized Telegram account IDs (CWE-117)

Sanitize any config-derived values before interpolating into terminal/log output. Option A (localized fix): apply sanitizeForLog() to hit.path (and any other interpolated values) when building warning lines.

Addressed: Option A. Imported sanitizeForLog from src/terminal/ansi.ts and wrapped both hit.path (which contains user-controlled accountId) and hit.replyToMode before interpolating into the warning line. This matches the existing pattern in src/commands/doctor/shared/legacy-config-core-normalizers.ts for the same class of config-key interpolation. Added a regression test that injects ANSI escape sequences and a bare newline into a synthetic accountId and asserts the rendered warning contains neither.

Option B (config-time validation of account record keys) was not done in this PR; it is out of scope for the doc/runtime-mismatch fix and would touch broader Telegram channel schema validation. Worth a separate issue if the maintainers want defense-in-depth.

Force-pushed the fix on commit 4508fbd5b3 after rebasing onto current main.

@GodsBoy

GodsBoy commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Before landing, review that the new doctor scanner mirrors Telegram's account config merge. Current runtime shallow-merges top-level Telegram config into account config before resolving replyToMode and stream mode, so the PR's direct scan of raw account entries should be checked for top-level streaming.mode and streaming.preview.toolProgress inheritance edge cases.

Same concern Greptile P1 raised (#73495 review thread on telegram-replyto-streaming.ts:37-39), now addressed in commit 4508fbd5b3 (force-pushed after the rebase onto current main). Per-account evaluateEntry now receives an effectiveStreamingModeOff boolean that inherits the top-level streaming.mode when the account omits its own; the same inheritance pattern was already in place for replyToMode and toolProgressDefault. Two regression tests cover both directions of the inheritance (top-level off + account override = no warning, account explicitly re-enabling streaming over off top-level = warning).

Closing now would drop a focused implementation candidate for the still-open paired bug #73487.

PR body uses Closes #73487, which only fires on merge; the paired issue stays open until maintainers land this PR. Pre-merge close is not in play.

Your snapshot was against dc541662f815; latest force-push is at 4508fbd5b3. Re-running against the latest commit would also pick up the Aisle CWE-117 sanitization fix and the Greptile P2 unused-param cleanup that landed in the same amend.

@GodsBoy GodsBoy closed this Apr 28, 2026
@GodsBoy
GodsBoy deleted the fix/telegram-replytomode-tool-progress-doc-and-doctor branch April 28, 2026 11:13
@GodsBoy
GodsBoy restored the fix/telegram-replytomode-tool-progress-doc-and-doctor branch April 28, 2026 11:16
@GodsBoy GodsBoy reopened this Apr 28, 2026
@GodsBoy
GodsBoy force-pushed the fix/telegram-replytomode-tool-progress-doc-and-doctor branch 2 times, most recently from 16977fe to 7deac62 Compare April 28, 2026 13:04
@GodsBoy

GodsBoy commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

Rebased on origin/main 189c91eae6 (CHANGELOG conflict resolved). New HEAD 7deac62b6d. Diff vs the commit Greptile last endorsed at 5/5 (4508fbd5b3) is purely the CHANGELOG entry placement; no source or test changes.

@GodsBoy
GodsBoy force-pushed the fix/telegram-replytomode-tool-progress-doc-and-doctor branch from d59b44d to 4fa38d5 Compare April 28, 2026 14:17
@GodsBoy

GodsBoy commented Apr 28, 2026

Copy link
Copy Markdown
Contributor Author

@greptileai please re-review latest head 150ed765a6.

Current follow-up state:

  • Rebased onto current main; GitHub now reports mergeStateStatus: CLEAN, so the earlier branch conflict is resolved.
  • Addressed the reviewer concern about Telegram multi-account config by scanning the same shallow merged per-account config shape the runtime uses.
  • Fixed the CI lint regression from extensions/active-memory/index.test.ts by removing stale awaits around synchronous plugin registration.
  • Current GitHub checks are green, including check, check-lint, and check-additional-extension-bundled.
  • Existing Greptile review threads are resolved and outdated.

The previous visible Greptile 5/5 summary points at older commit 4508fbd5b3; this comment is requesting a fresh Greptile pass against 150ed765a6 so the review signal is current.

@steipete

steipete commented May 3, 2026

Copy link
Copy Markdown
Contributor

Update after code review:

The issue is narrower than “replyToMode disables tool progress.” Telegram only loses the short Working… • tool: … preview when the turn uses a selected/native quote reply: replyToMode != "off" plus quote text from the inbound context. In that path, OpenClaw intentionally does not create the answer draft preview stream because the final native quote reply is delivered through Telegram’s normal send path, not by editing the preview message.

Best fix: keep runtime behavior unchanged for now. Add a Telegram-owned openclaw doctor warning and docs note explaining that selected/native quote replies suppress tool-progress preview. The doctor scanner should live in the Telegram doctor adapter and use listTelegramAccountIds() + mergeTelegramAccountConfig() so it matches runtime account/default inheritance.

Runtime fallback to separate progress messages is a larger product change and should be separate.

@steipete
steipete force-pushed the fix/telegram-replytomode-tool-progress-doc-and-doctor branch from 150ed76 to 0035831 Compare May 3, 2026 15:13
@openclaw-barnacle openclaw-barnacle Bot added size: S and removed commands Command implementations size: M labels May 3, 2026
@steipete steipete changed the title fix(telegram): document and warn when replyToMode silently disables tool-progress preview fix(telegram): warn on selected quote tool-progress caveat May 3, 2026
GodsBoy and others added 2 commits May 3, 2026 16:14
…xclusion

Document that channels.telegram.streaming.preview.toolProgress requires
channels.telegram.replyToMode: 'off'. Quote-reply requires the final message
reference at send time, which is incompatible with preview-edit streaming, so
the two features are mutually exclusive on Telegram.

Adds:
- Note callout in docs/channels/telegram.md after the existing toolProgress
  guidance, explaining the exclusion and how to restore visibility.
- Cross-link bullet in docs/concepts/streaming.md pointing to the Telegram
  channel doc for the full note.

Surfaces a doc/runtime gap that has been silent since v2026.4.22.
@steipete
steipete force-pushed the fix/telegram-replytomode-tool-progress-doc-and-doctor branch from 0035831 to 847c0c0 Compare May 3, 2026 15:15
@steipete
steipete merged commit e2c8db2 into openclaw:main May 3, 2026
176 of 178 checks passed
@steipete

steipete commented May 3, 2026

Copy link
Copy Markdown
Contributor

Landed via rebase onto main.

  • Local proof: pnpm test extensions/telegram/src/doctor.test.ts, targeted oxfmt --check, git diff --check
  • Remote proof: Testbox OPENCLAW_TESTBOX=1 pnpm check:changed
  • GitHub CI: failed once in unrelated src/gateway/server.config-patch.test.ts, rerun passed before merge
  • PR head before merge: 847c0c0e69f9117343f9aab2781339845db27802
  • Landed commit: e2c8db2cad406b00e37a2b60e7767ad6232fbf3a

Thanks @GodsBoy!

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

Labels

channel: telegram Channel integration: telegram docs Improvements or additions to documentation size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Telegram tool-progress preview silently disabled when channels.telegram.replyToMode != "off" (doc/runtime mismatch)

2 participants