Skip to content

fix(telegram): keep streamed final pages on word boundaries - #104608

Merged
steipete merged 3 commits into
mainfrom
codex/telegram-draft-final-pagination
Jul 11, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/telegram-draft-final-pagination

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #102469

What Problem This Solves

Fixes an issue where users receiving long Telegram answers through draft streaming could see final pages split in the middle of words. Because those pages were split after HTML rendering, a boundary could also cut an entity or formatting span and cause Telegram to reject the page.

Why This Change Was Made

The standard Telegram draft renderer now retains the original Markdown and table mode, then final pagination uses the same render-aware markdownToTelegramChunks planner as durable delivery. Raw HTML and rich-message previews keep their existing specialized paths.

User Impact

Long streamed Telegram answers now paginate at Markdown-aware word and block boundaries, matching durable sends and avoiding malformed HTML fragments.

Evidence

  • Blacksmith Testbox tbx_01kx95jqgtn54t9cgfjhcq900v: 292 focused Telegram tests passed on exact head, covering draft streaming, dispatch, and delivery traces.
  • Blacksmith Testbox tbx_01kx94hed97fq1sf10pcqdgvj5: pnpm check:changed passed, including extension and test typechecking, lint, import-cycle, and policy gates.
  • QA Lab channel-message-flows passed with mock-openai and the qa-channel driver.
  • Artifact contract validator passed: three pages, lengths 3967 / 3967 / 3223, starting at complete lines 0001 / 0065 / 0129.
  • Overflow trace golden regenerated intentionally; the old pages began mid-word at th... and mid-line-number at 30....
  • Fresh autoreview: clean, no accepted/actionable findings.
  • Live Telegram three-chunk QA was attempted, but the Testbox lacks OPENCLAW_QA_CONVEX_SITE_URL; no direct Telegram QA credentials are exported.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S maintainer Maintainer-authored PR labels Jul 11, 2026
@steipete

steipete commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor Author

Land-ready evidence:

  • Exact head: 73dde12cf85 (runtime/test behavior unchanged from the reviewed Testbox head; final commit applies the exact oxfmt output to the shared-predicate test).
  • Focused Testbox proof (tbx_01kx95jqgtn54t9cgfjhcq900v): pnpm test extensions/telegram/src/draft-stream.test.ts extensions/telegram/src/delivery-trace.test.ts extensions/telegram/src/bot-message-dispatch.test.ts — 292 passed.
  • Changed gate (tbx_01kx94hed97fq1sf10pcqdgvj5): pnpm check:changed — passed, including extension/test typechecking and extension lint.
  • QA Lab: channel-message-flows with mock-openai / qa-channel — passed.
  • Artifact contract: pages are 3967 / 3967 / 3223 chars and start at complete lines 0001 / 0065 / 0129.
  • Fresh autoreview after the formatting-only follow-up: clean, no actionable findings.

Known proof gap: the real Telegram three-chunk QA lane was attempted but could not acquire credentials because OPENCLAW_QA_CONVEX_SITE_URL is absent and direct Telegram QA credentials are not exported. The Telegram dispatch trace exercises the exact overflow path and its regenerated golden.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

ClawSweeper status: review started.

I am starting a fresh review of this pull request: fix(telegram): keep streamed final pages on word boundaries This is item 1/1 in the current shard. Shard 0/1.

This placeholder means the worker is alive and reading the current context. I will edit this same comment with the actual review when the claws are done clicking.

Crustacean status: shell secured, claws on keyboard, evidence pebbles being sorted.

@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 11, 2026, 2:22 PM ET / 18:22 UTC.

Summary
The PR retains original Markdown and table mode for standard Telegram draft streams, then uses the durable render-aware Markdown planner for final overflow pages.

PR surface: Source +17, Tests +36. Total +53 across 5 files.

Reproducibility: yes. at source level: current main renders standard draft Markdown to HTML and then splits that HTML for final pages, while the trace demonstrates pages starting mid-token. A failing real-Telegram run was not established.

Review metrics: none identified.

Merge readiness
Overall: 🦪 silver shellfish
Proof: 🦪 silver shellfish
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof from a real setup is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add a redacted Telegram Desktop recording or live transcript showing a long streamed response finalizing into complete pages without rejection; redact phone numbers, tokens, IP addresses, private endpoints, and other private details.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Focused Testbox tests, CI, QA Lab, and trace artifacts are strong supplemental evidence, but the contributor explicitly reports that no after-fix real Telegram run was available; add redacted native proof, update the PR body to trigger review, or ask a maintainer to comment @clawsweeper re-review.

Mantis proof suggestion
Mantis can provide the exact missing native Telegram proof without modifying code or GitHub state. A maintainer can ask Mantis to capture proof by posting this exact PR comment:

@openclaw-mantis telegram desktop proof: reproduce a long streamed final response and record that final pages start and end on complete Markdown-aware boundaries without Telegram rejection.

Risk before merge

  • [P1] No after-fix run on real Telegram is shown; the supplied evidence consists of focused tests, trace artifacts, CI, and QA harness output, so it does not prove Telegram accepts and displays the final multi-page result in a real setup.

Maintainer options:

  1. Decide the mitigation before merge
    Keep the shared render-aware planner implementation and its specialized rich/raw path separation, then add a redacted Telegram Desktop recording or live transcript proving that a long streamed answer finalizes into complete pages without Telegram rejection.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] No actionable code repair was found; the protected-label PR should remain open for real Telegram proof and normal maintainer handling.

Security
Cleared: The focused Telegram TypeScript, tests, and trace update adds no dependency, secret, permission, package-resolution, downloaded-code, or supply-chain concern.

Review details

Best possible solution:

Keep the shared render-aware planner implementation and its specialized rich/raw path separation, then add a redacted Telegram Desktop recording or live transcript proving that a long streamed answer finalizes into complete pages without Telegram rejection.

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

Yes at source level: current main renders standard draft Markdown to HTML and then splits that HTML for final pages, while the trace demonstrates pages starting mid-token. A failing real-Telegram run was not established.

Is this the best way to solve the issue?

Yes. Reusing the durable render-aware Markdown planner is the narrowest maintainable fix, avoids a competing chunker, preserves rendered-length enforcement, and leaves specialized rich-message, raw HTML, and parse-fallback paths intact.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add P2: This fixes a bounded but user-visible Telegram pagination defect that can split long streamed answers awkwardly or cause page rejection.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused Testbox tests, CI, QA Lab, and trace artifacts are strong supplemental evidence, but the contributor explicitly reports that no after-fix real Telegram run was available; add redacted native proof, update the PR body to trigger review, or ask a maintainer to comment @clawsweeper re-review.
  • add mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The changed word boundaries, formatting, page starts, and successful final delivery can be demonstrated directly in a short Telegram Desktop recording.

Label justifications:

  • P2: This fixes a bounded but user-visible Telegram pagination defect that can split long streamed answers awkwardly or cause page rejection.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused Testbox tests, CI, QA Lab, and trace artifacts are strong supplemental evidence, but the contributor explicitly reports that no after-fix real Telegram run was available; add redacted native proof, update the PR body to trigger review, or ask a maintainer to comment @clawsweeper re-review.
  • mantis: telegram-visible-proof: Mantis should capture Telegram visible proof. The changed word boundaries, formatting, page starts, and successful final delivery can be demonstrated directly in a short Telegram Desktop recording.
Evidence reviewed

PR surface:

Source +17, Tests +36. Total +53 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 3 21 4 +17
Tests 2 37 1 +36
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 58 5 +53

What I checked:

Likely related people:

  • steipete: Prior merged commits on the related Telegram projection and streaming refactor include steipete, and repository history shows the strongest contribution count across the central draft-stream, formatter, and dispatch files. (role: recent Telegram delivery contributor; confidence: high; commits: 8fe9b5bc6b23, dc1f0847a925; files: extensions/telegram/src/draft-stream.ts, extensions/telegram/src/format.ts, extensions/telegram/src/bot-message-dispatch.ts)
  • scoootscooob: The Telegram implementation's move into the current bundled-plugin path appears to date to this contributor's migration commit, making them relevant to the current ownership history. (role: path migration contributor; confidence: low; commits: e5bca0832fbd; files: extensions/telegram/src/draft-stream.ts, extensions/telegram/src/format.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.

@clawsweeper clawsweeper Bot added 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. mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. labels Jul 11, 2026
@steipete
steipete merged commit fe3884a into main Jul 11, 2026
178 of 185 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/telegram-draft-final-pagination branch July 11, 2026 18:44
steipete added a commit that referenced this pull request Jul 11, 2026
…ed final pagination (#104760)

The behavior fix landed on main in #104608 (fe3884a): draft-stream final
pagination now routes markdownSource previews through markdownToTelegramChunks,
the same chunker the durable reply funnel uses (delivery.replies.ts
buildChunkTextResolver), and the overflow-pagination golden was re-recorded on
safe boundaries there. This adds the missing parity regression coverage:
table-driven cases for mid-word, mid-entity, mid-tag, and fenced code-block
page boundaries assert the streamed pages equal the durable chunker's HTML
chunks exactly, and that retained/current page snapshots carry the durable
plainText projection so an HTML-parse 400 degrades both funnels identically.

Formatting proof: Testbox tbx_01kx9n9q7rksfxgr5baj0esw57 check:changed format
lane passed on this diff (local worktree has no node_modules for the hook).
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…#104608)

* fix(telegram): align draft final pagination

* chore: drop release-owned changelog entry

* style(telegram): format pagination parity test
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 12, 2026
…ed final pagination (openclaw#104760)

The behavior fix landed on main in openclaw#104608 (370bfff): draft-stream final
pagination now routes markdownSource previews through markdownToTelegramChunks,
the same chunker the durable reply funnel uses (delivery.replies.ts
buildChunkTextResolver), and the overflow-pagination golden was re-recorded on
safe boundaries there. This adds the missing parity regression coverage:
table-driven cases for mid-word, mid-entity, mid-tag, and fenced code-block
page boundaries assert the streamed pages equal the durable chunker's HTML
chunks exactly, and that retained/current page snapshots carry the durable
plainText projection so an HTML-parse 400 degrades both funnels identically.

Formatting proof: Testbox tbx_01kx9n9q7rksfxgr5baj0esw57 check:changed format
lane passed on this diff (local worktree has no node_modules for the hook).

This branch had an error being deployed

1 failed deployment
qa-live-shared — 73dde12c Deployed Jul 11, 2026 by clawsweeper[bot] via Run agentic native Telegram proof #340782
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 mantis: telegram-visible-proof Mantis should capture Telegram visible proof. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant