Repository navigation
fix(telegram): retain preview message on generation mismatch race - #85907
EnjouZeratul wants to merge 3 commits into
Conversation
Fixes openclaw#85831 When saving config in Control UI, required string fields with minLength constraint (e.g., z.string().min(1)) were sent as empty strings instead of being unset. This prevented schema defaults from applying. Solution: coerce empty strings with minLength > 0 to undefined, allowing schema defaults to take effect during validation. Added 5 unit tests covering edge cases.
Fixes openclaw#85807 When forceNewMessage() races with an in-flight Telegram preview send, the generation-mismatch path in draft-stream.ts was deleting the successfully sent message instead of retaining it. Added `retain: true` to the onSupersededPreview call in the generation-mismatch block, matching the behavior already used by the text-splitting superseded path at line 215-220. Test updated to verify retain field is set correctly.
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close as superseded: the Telegram fix is already isolated in #85878, while this branch mixes in unrelated Control UI config-save work that is separately tracked by #85903 and still lacks live Telegram proof. Canonical path: Close this mixed duplicate PR, continue the Telegram fix through #85878, and keep the Control UI provider-defaults work in #85903. So I’m closing this here and keeping the remaining discussion on #85878 and #85903. Review detailsBest possible solution: Close this mixed duplicate PR, continue the Telegram fix through #85878, and keep the Control UI provider-defaults work in #85903. Do we have a high-confidence way to reproduce the issue? Yes by source, not by live run: current main’s generation-mismatch path calls Is this the best way to solve the issue? No for this branch: the one-line Telegram fix is plausible, but the best maintainable path is the narrower superseding Telegram PR plus the separate UI config-save PR, not a mixed duplicate branch. Security review: Security review cleared: No concrete security or supply-chain concern was found; the diff touches Telegram message retention and UI config coercion, with no dependency, workflow, secret, or package-resolution changes. What I checked:
Likely related people:
Codex review notes: model gpt-5.5, reasoning high; reviewed against cbdc24895e11. |
|
ClawSweeper applied the proposed close for this PR.
|
|
My apologies for the confusion. I made two mistakes here:
Thanks to @NianJiuZst for the original fix, and to @steipete for the clean rebuild in #85878. |
Fixes #85807
Summary
Added
retain: trueto theonSupersededPreviewcall in the generation-mismatch block ofdraft-stream.ts. This prevents Telegram preview messages from being deleted whenforceNewMessage()races with an in-flight send.Problem
When Telegram streaming (
streaming.mode = partial/progress) delivers multiple response segments, the first streamed message can be silently deleted due to a race condition:sendMessageis in-flightforceNewMessage()is called →generationincrementsmessage_idsendGeneration !== generation→onSupersededPreviewcalled withoutretain: trueSolution
Added
retain: trueto match the behavior of the text-splitting superseded path (line 215-220), which already correctly retains overflow preview pages.params.onSupersededPreview?.({ messageId: normalizedMessageId, textSnapshot: renderedText, parseMode: renderedParseMode, visibleSinceMs, + retain: true, });Testing
draft-stream.test.tsto verifyretain: trueis setReal behavior proof
Behavior addressed: Telegram preview messages are no longer deleted when generation mismatch occurs during streaming.
Real environment tested: Unit tests verify the fix. The generation-mismatch test now expects
retain: truein thesupersededPreviewcallback.Evidence after fix: Test output shows 32 tests passed, including the updated generation-mismatch test.
Observed result after fix: Preview messages will be retained when
forceNewMessage()races with in-flight sends, matching the documented behavior for overflow pages.What was not tested: Live Telegram streaming test (requires Telegram bot setup).