Repository navigation
fix(channels): collapse cumulative commentary snapshots onto one line - #116272
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 30, 2026, 3:25 AM ET / 07:25 UTC. ClawSweeper reviewWhat this changesThe branch makes cumulative, id-less commentary snapshots update one progress-draft line and passes the channel’s resolved streaming mode into commentary gating. Merge readinessThe direct channel-progress fix is coherent, tested, and backed by real Telegram output; no patch defect was found. This PR should remain open for a human decision on whether the optional resolved-mode argument is an acceptable exported plugin-SDK contract, especially because it carries the protected Priority: P2 Review scores
Verification
How this fits togetherChannel streaming configuration determines whether commentary is shown, then the progress-draft compositor turns provider commentary and tool updates into an editable channel draft. This change affects the intermediate draft that Telegram and other progress-draft channels render before the final receipt. flowchart LR
A[Provider commentary snapshots] --> B[Channel streaming configuration]
B --> C[Resolved channel mode]
C --> D[Commentary gate]
D --> E[Progress draft compositor]
E --> F[Channel draft message]
F --> G[Final compact receipt]
Decision needed
Why: The implementation is compatible for existing two-argument callers and mirrors a sibling helper, but the generated SDK baseline confirms a durable exported contract change that cannot be settled by tests alone. Before merge
Agent review detailsSecurityNone. PR surfaceSource +52, Tests +153, Generated 0. Total +205 across 5 files. View PR surface stats
Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Accept the additive resolved-mode API only if maintainers want channel callers to own unset-mode defaults; then merge this focused compositor repair and track the separate ACP default-resolution gap independently. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the prior text-derived id makes cumulative commentary snapshots create distinct draft lines, and the PR supplies both focused coverage and a real Telegram before/after transcript. I did not execute the Telegram scenario in this read-only review. Is this the best way to solve the issue? Yes for the direct progress-draft path: remembering the active id-less commentary line matches the existing reasoning-line approach and preserves distinct commentary entries. The remaining question is the exported resolver contract, not the local replacement logic. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ad1dc602594b. LabelsLabel 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)
|
Providers stream commentary as growing snapshots, and the draft line id was
derived from the text itself, so every snapshot minted a new id and appended a
line. One preamble rendered as three overlapping 💬 lines on Telegram.
Id-less commentary now remembers its open line and reuses that id when the next
snapshot is a prefix of it in either direction, so cumulative growth updates in
place while genuinely distinct commentary still appends. The continuation check
requires non-empty sanitized text, otherwise a directive-only snapshot would
match via `prior.startsWith("")` and clear the visible line — only an explicit
itemId retraction removes one.
Also: resolveChannelStreamingProgressCommentary guessed "partial" when
streaming.mode was unset, which since the Telegram default flip made
progress.commentary a silent no-op on the default path. It now takes the caller's
resolved mode, matching the tool-progress resolver.
Live proof on real Telegram, same scenario the audit recorded three lines for:
one 💬 line, surviving a later tool-line edit in position, receipt unchanged at
`💬 1 note`.
The line id was a four-level nested ternary mixing three distinct rules: an explicit item id owns its line, sanitized-to-nothing addresses no line, and a continuing snapshot reuses the open line. resolveCommentaryLineId states each as its own early return, so the sanitize-to-empty case reads as a rule rather than a branch that happens to fall through. Also reuse the already-computed bare text instead of a second stripLaneItalics pass per push.
cb31bc8 to
66f80ec
Compare
|
Working the three rank-up moves. 1. Accept the additive resolver contract. Accepted, and it is parity rather than a new pattern: 2. Activation change across callers. Three call sites exist for the resolver:
The ACP caller pre-resolves the mode into the entry before calling, so the two-argument form is correct there — but only for one channel. That hardcode predates Telegram's default becoming 3. Rebase. Rebased onto latest |
What Problem This Solves
With
streaming.progress.commentaryenabled, a single model preamble rendered as three overlapping 💬 lines in the Telegram draft. Recorded live before this change:Providers stream commentary as cumulative snapshots. The draft line id was derived from the commentary text itself (
commentary:${normalized}), so every snapshot minted a new id andmergeChannelProgressDraftLineappended another line instead of replacing the previous one.A second defect made the first one invisible on the default path:
resolveChannelStreamingProgressCommentaryguessed"partial"whenstreaming.modewas unset. Since Telegram's default becameprogress,progress.commentary: truewas a silent no-op — the documented lane never activated at all.Why This Change Was Made
Documented intent is one interleaved 💬 line per preamble item (
docs/concepts/progress-drafts.md:259-269). The reasoning lane immediately above already solves the same snapshot-growth problem by remembering its open line, so this mirrors that shape rather than inventing a mechanism.Id-less commentary now remembers its open line and reuses that id when the next snapshot is a prefix of it in either direction: cumulative growth updates in place, genuinely distinct commentary still appends. Because merge replaces at the existing index, a line that has been overtaken by newer tool lines keeps its position.
The continuation check requires non-empty sanitized text. Without that guard a directive-only snapshot (
[[reply_to_current]], NO_REPLY-shaped — the repo already fixtures this) matches viaprior.startsWith("")and clears the visible line. Only an explicititemIdretraction removes a line, matching the preamble precedent that rejected input keeps the previous valid value.User Impact
Operators running
progress.commentary: trueget the documented single interleaved line instead of stacked duplicates — and on Telegram's current default they get the lane at all, where before the setting did nothing. No config surface added, changed, or retired.resolveChannelStreamingProgressCommentarygains a third optional parameter. Omitting it preserves the previous configured-mode reading exactly, so a third-party caller of the two-argument form is unaffected; the compositor passes its resolved mode, matching whatresolveChannelStreamingPreviewToolProgressalready does.Evidence
Live on real Telegram, same scenario the audit recorded three lines for, via
$telegram-e2e-userbotwithE2E_TELEGRAM_PROVIDER_API=openai-completions:💬 1 note💬 1 noteThe single line survives the later tool-line edit in position, and the note count is unchanged.
Unit coverage (60 tests): three cumulative id-less snapshots → one line whose text is the final snapshot; two unrelated id-less texts → two lines; an id-less line updated after a tool line keeps its position; a directive-only snapshot leaves the line untouched and returns
falsewith no extra update; existing itemId replace and retract still pass. Plus a regression test that the commentary gate honors the caller's mode.The activation fix was necessary for the first fix to be observable: an earlier run on the default path recorded no 💬 line at all.
Known gaps
A third defect in this feature is deliberately not fixed here: with
commentary: trueon anopenai-responsesprovider the preamble vanishes entirely, because the headline steps aside for the commentary lane (as documented) while that transport never tags commentary. Separate change, separate evidence.Delegated the duplication fix to grok-4.5 under a bounded brief; I reviewed the diff, found and had it correct the sanitize-to-empty regression, then added the activation fix and the mode-gate test myself.
🤖 Generated with Claude Code