Skip to content

refactor(telegram): share HTML text escaping - #146936

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/telegram-html-escaping-20260913
Sep 13, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/telegram-html-escaping-20260913

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 13, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Telegram formatting has two private escape functions that duplicate the existing HTML text encoder.

User Impact

No user-visible behavior changes.

Why This Change Was Made

Route their callers to the existing encoder and keep attribute quote escaping separate. Production changes: −21 lines; tests unchanged.

Evidence

  • CI attempt 1 passed at exact head 03a93ad0ddfc0cfa8a61e6cc2930bee27402cdb6. The covering job passed all 65 format tests and all 44 Markdown-wrapping tests. Type/lint checks and pinned formatting also passed.
  • Before/after encoder, attribute and unsupported-HTML results matched 4,691 inputs; public plain-text fallback matched 5,051 inputs with the actual entity decoder. These comparisons supplement the hosted suites; no live Telegram execution is claimed.
  • Independent source review, fresh P2 autoreview and the exact-head ClawSweeper review are clean, with no Before merge item or rank-up move. The formatter baseline remains unchanged on the main snapshot used for native preparation.

@vincentkoc vincentkoc self-assigned this Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 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: XS maintainer Maintainer-authored PR labels Sep 13, 2026
@vincentkoc
vincentkoc marked this pull request as ready for review September 13, 2026 10:37
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 6:42 AM ET / 10:42 UTC.

ClawSweeper review

What this changes

Consolidates Telegram HTML text escaping into the existing encoder while preserving separate attribute quote escaping and plain-text fallback output.

Merge readiness

✅ Ready for maintainer review

No actionable defect found. This is a coherent, behavior-preserving cleanup that remains absent from current main; the member-authored, protected PR should remain open for normal landing.

Priority: P3
Reviewed head: 03a93ad0ddfc0cfa8a61e6cc2930bee27402cdb6

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable refactor with equivalent escaping and no identified correctness or security defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The MEMBER-authored internal formatter refactor is exempt from external-contributor proof, and it changes no authority boundary. Reported encoder and fallback comparisons are supplemental evidence, not live Telegram proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The MEMBER-authored internal formatter refactor is exempt from external-contributor proof, and it changes no authority boundary. Reported encoder and fallback comparisons are supplemental evidence, not live Telegram proof.
Evidence reviewed 6 items Introduced change preserves encoding: The complete introduced diff removes a forwarding wrapper and an equivalent character encoder. Both encode ampersands, less-than signs, and greater-than signs identically; the shared encoder processes ampersands first, so newly generated entities are not escaped again. Attribute quotes retain their separate replacement.
Current main still contains the duplication: Comparison with fetched main shows the same narrow formatter cleanup remains outstanding; this is not an already-implemented change.
Latest release retains both private helpers: The supplied latest-release commit for v2026.9.4 contains escapeHtml and encodePlainTextForTelegramHtmlStrip, including their callers.
Findings None None.
Security None None.

How this fits together

The Telegram formatter converts outgoing Markdown and HTML into Telegram-compatible messages. Its escaping also preserves literal text when formatted messages need a plain-text fallback.

flowchart TD
  A[Outgoing Markdown or HTML] --> B[Telegram formatter]
  B --> C[Shared text escaping]
  C --> D[Attribute quote escaping]
  C --> E[Formatted message]
  D --> E
  E --> F[Plain-text fallback]
  E --> G[Telegram delivery]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -21. Total -21 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 1 8 29 -21
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 8 29 -21

Review metrics

None.

Technical review

Best possible solution:

Keep one Telegram text encoder, retain attribute-specific quote escaping, and preserve the existing formatter and fallback contracts.

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

Not applicable: this PR claims no behavior defect or visible change; source inspection supports equivalent string transformations.

Is this the best way to solve the issue?

Yes. Reusing the existing encoder removes duplication without introducing another owner or changing the attribute and fallback contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against f3bdcc10d628.

Labels

Label changes:

  • add P3: This removes internal duplication without changing user-visible behavior, configuration, or public APIs.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The MEMBER-authored internal formatter refactor is exempt from external-contributor proof, and it changes no authority boundary. Reported encoder and fallback comparisons are supplemental evidence, not live Telegram proof.

Label justifications:

  • P3: This removes internal duplication without changing user-visible behavior, configuration, or public APIs.
  • 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: The MEMBER-authored internal formatter refactor is exempt from external-contributor proof, and it changes no authority boundary. Reported encoder and fallback comparisons are supplemental evidence, not live Telegram proof.

Evidence

What I checked:

  • Introduced change preserves encoding: The complete introduced diff removes a forwarding wrapper and an equivalent character encoder. Both encode ampersands, less-than signs, and greater-than signs identically; the shared encoder processes ampersands first, so newly generated entities are not escaped again. Attribute quotes retain their separate replacement. (extensions/telegram/src/format.ts:28, 03a93ad0ddfc)
  • Current main still contains the duplication: Comparison with fetched main shows the same narrow formatter cleanup remains outstanding; this is not an already-implemented change. (extensions/telegram/src/format.ts:32, f3bdcc10d628)
  • Latest release retains both private helpers: The supplied latest-release commit for v2026.9.4 contains escapeHtml and encodePlainTextForTelegramHtmlStrip, including their callers. (extensions/telegram/src/format.ts:357, 3a9d69db306c)
  • Existing observable coverage: The unchanged formatter suite checks unsafe characters, unsupported tags, literal code, table fallbacks, and preservation of escaped angle brackets and URL ampersands in fallback links. Tests were inspected, not executed under this read-only review. (extensions/telegram/src/format.test.ts:429, 03a93ad0ddfc)
  • Submitted validation and protected status: The captured PR body reports matching encoder, attribute, and unsupported-HTML results across 4,691 inputs and matching public fallback results across 5,051 inputs using the actual decoder. It explicitly excludes Markdown-engine and live Telegram execution. The author association is MEMBER and the PR carries maintainer protection. (03a93ad0ddfc)
  • Area history and routing limits: Recent formatter history identifies Peter Steinberger and Ayaan Zaidi as routing candidates. Deeper symbol-history and blame inspection encountered an unavailable historical blob, so no source-line introduction attribution is claimed. A bounded GitHub related-PR search was also rejected by the managed read interface; no canonical replacement was established. (extensions/telegram/src/format.ts, f3bdcc10d628)

Likely related people:

  • Peter Steinberger: 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)

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.

@vincentkoc
vincentkoc merged commit c07d397 into main Sep 13, 2026
180 checks passed
@vincentkoc
vincentkoc deleted the refactor/telegram-html-escaping-20260913 branch September 13, 2026 13:24
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* temp/pr-137049: (110 commits)
  improve: reduce GitHub OAuth maintenance work for large agent rosters (#147021)
  fix(test): avoid settings lock writer startup timeouts (#147029)
  fix(update): correct backup guidance and cover incident regressions (#147023)
  refactor(gateway): share connection lifecycle across transports (#145950)
  refactor(telegram): share HTML text escaping (#146936)
  perf(build): reduce disk use in UI performance checks (#146687)
  refactor(memory-wiki): share freshness result construction (#146935)
  improve(gateway): use metadata projection for presence (#146817)
  test(agents): reuse complete Responses model fixtures (#147015)
  fix(sessions): align the reclamation-memory test with the archive session owner (#147028)
  refactor(terminal): simplify copy-sensitive token checks (#146934)
  refactor(media): remove duplicate spaced path fallback (#146933)
  refactor(cli): reuse command-group names (#146893)
  improve(plugins): reduce JavaScript generation capture work (#146993)
  test: align plugin fixtures with current runtime contracts (#147000)
  refactor(browser): separate session tab tracking from cleanup (#146973)
  fix(tests): make systemd clock fixtures private (#146990)
  fix(linux): retire sleep guards when logind disconnects (#146046)
  refactor(matrix): share draft fallback delivery (#144840)
  fix(sessions): preserve cross-agent replies after reload (#146799)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* commit '0ac8a700e43efceef73d92fe8e50b185819e38ad': (27 commits)
  test(acpx): prove targeted turn cancellation (#137049)
  fix(ci): honor realtime meeting live-test opt-in (#147044)
  improve: reduce heartbeat enrollment work for large fleets (#147055)
  fix(gateway): install despite stale Linux session bus addresses (#146569)
  chore(i18n): refresh native locales (#147025)
  fix: avoid Gateway reinstalls when macOS service inspection is inconclusive (#146880)
  fix(pairing): QR setup rejects trusted-proxy gateways without a shared secret (#147036)
  fix(update): bound activation and accept slow Windows identity reads (#147019)
  perf(accounts): avoid materializing avatars for owner checks (#147032)
  improve(status): report external and ArrayBuffer memory (#141902)
  fix(update): preserve linked plugins during post-core sync (#147009)
  fix(channels): keep replies working after hot config reloads (#147001)
  refactor(gateway): defer worker transcript runtime loading (#143495)
  improve: reduce GitHub OAuth maintenance work for large agent rosters (#147021)
  fix(test): avoid settings lock writer startup timeouts (#147029)
  fix(update): correct backup guidance and cover incident regressions (#147023)
  refactor(gateway): share connection lifecycle across transports (#145950)
  refactor(telegram): share HTML text escaping (#146936)
  perf(build): reduce disk use in UI performance checks (#146687)
  refactor(memory-wiki): share freshness result construction (#146935)
  ...

# Conflicts:
#	src/config/sessions/session-accessor.sqlite-reclamation-memory.test.ts
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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