Repository navigation
improve(telegram): reduce formatting work for prose replies - #150222
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 16, 2026, 2:55 PM ET / 18:55 UTC (Revision 2). ClawSweeper reviewWhat this changesThe Telegram formatter skips filename-matching scans for text segments without periods, reducing formatting work while preserving HTML and chunk boundaries. Merge readiness✅ Ready for maintainer review Keep open: this remains a useful, bounded optimization absent from inspected main and the latest release. No actionable correctness or security defects were found; the prior review also reported no findings. Priority: P2 Review scores
Verification
How this fits togetherTelegram’s outbound formatter converts Markdown replies into size-limited HTML messages. Filename wrapping prevents file references from becoming unwanted links before those messages reach delivery. flowchart TD
A[Markdown reply] --> B[Parse and render HTML]
B --> C[Inspect text segments]
C --> D{Protected context or no period?}
D -->|Yes| E[Preserve segment]
D -->|No| F[Wrap matching filenames]
E --> G[Size-limited HTML messages]
F --> G
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource 0. Total 0 across 1 file. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Retain the existing Telegram formatter and its output contracts while avoiding scans that cannot match. Do we have a high-confidence way to reproduce the issue? Not applicable as a functional bug: the unnecessary scans are evident in source, and the PR reports paired production-formatter benchmarks. Is this the best way to solve the issue? Yes. The period check directly expresses a necessary condition of both existing patterns without adding state, changing public APIs, or altering formatting policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 70b587ba4056. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
What Problem This Solves
Telegram spends unnecessary time checking prose segments for file references while formatting replies.
User Impact
Formatted prose and link-heavy replies take less CPU to format, with identical HTML and chunk boundaries. No configuration or migration is required.
Why This Change Was Made
Both filename patterns require a literal period. Skip their two replacement scans when a text segment has none, after checking the existing protected HTML contexts. This is a one-line change with no cache. Measurements include the already-landed optimization in #150213 in both baseline and candidate.
Evidence
Measured the actual
markdownToTelegramChunkscaller in 12 fresh processes: three alternating baseline/candidate pairs per Node version, totaling 51,120 timed calls. All scheduled results were retained. Median paired wall-time changes:The no-period prose and link-heavy cases improved in all six pairs, including process CPU. Other inputs were mixed: individual adverse wall-time pairs included +4.3% for filenames, +3.0% for punctuated prose, and +7.1% for code. No universal improvement or network-latency claim. Short cases took only tens of milliseconds per batch and their Windows CPU counters were coarse. The final Node 26 baseline overlapped review-snapshot disk activity; it remains included.
Synthetic fixtures include short replies and long prose, links, filenames, and code, using a 4,000-character HTML cap. Imports, full-output comparisons, and five warmups per case were outside timing.