fix(telegram): draft stream preview not threaded when replyToMode is on (#17880) (#17928)

Merged via /review-pr -> /prepare-pr -> /merge-pr.

Prepared head SHA: cfd4181a23
Co-authored-by: yinghaosang <261132136+yinghaosang@users.noreply.github.com>
Co-authored-by: obviyus <22031114+obviyus@users.noreply.github.com>
Reviewed-by: @obviyus
This commit is contained in:
yinghaosang
2026-02-16 20:40:24 +08:00
committed by GitHub
parent b2aa6e094d
commit 244ed9db39
5 changed files with 211 additions and 33 deletions

View File

@@ -17,6 +17,7 @@ export function createTelegramDraftStream(params: {
chatId: number;
maxChars?: number;
thread?: TelegramThreadSpec | null;
replyToMessageId?: number;
throttleMs?: number;
log?: (message: string) => void;
warn?: (message: string) => void;
@@ -28,6 +29,10 @@ export function createTelegramDraftStream(params: {
const throttleMs = Math.max(250, params.throttleMs ?? DEFAULT_THROTTLE_MS);
const chatId = params.chatId;
const threadParams = buildTelegramThreadParams(params.thread);
const replyParams =
params.replyToMessageId != null
? { ...threadParams, reply_to_message_id: params.replyToMessageId }
: threadParams;
let streamMessageId: number | undefined;
let lastSentText = "";
@@ -64,7 +69,7 @@ export function createTelegramDraftStream(params: {
await params.api.editMessageText(chatId, streamMessageId, trimmed);
return;
}
const sent = await params.api.sendMessage(chatId, trimmed, threadParams);
const sent = await params.api.sendMessage(chatId, trimmed, replyParams);
const sentMessageId = sent?.message_id;
if (typeof sentMessageId !== "number" || !Number.isFinite(sentMessageId)) {
stopped = true;