From b759bb0c8f211575e5b18eefce95fbbefebd8739 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 20 Feb 2026 11:41:18 +0000 Subject: [PATCH] fix: guard stopThinking cleanup inside !SkipPlaceholder in Telegram Send() Co-authored-by: dj-oyu <68707227+dj-oyu@users.noreply.github.com> --- pkg/channels/telegram.go | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/pkg/channels/telegram.go b/pkg/channels/telegram.go index abcc941ba..8e4afc64a 100644 --- a/pkg/channels/telegram.go +++ b/pkg/channels/telegram.go @@ -185,23 +185,24 @@ func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) err return fmt.Errorf("invalid chat ID: %w", err) } - // Stop thinking animation - if stop, ok := c.stopThinking.Load(msg.ChatID); ok { - if cf, ok := stop.(*thinkingCancel); ok && cf != nil { - cf.Cancel() - } - c.stopThinking.Delete(msg.ChatID) - } - cleanContent := sanitizeTelegramOutgoingContent(msg.Content) chunks := utils.SplitMessage(cleanContent, telegramMaxMessageChars) if len(chunks) == 0 { chunks = []string{cleanContent} } - // Try to edit placeholder + // Slash-command responses (SkipPlaceholder=true) must not touch the + // stopThinking/placeholders state that belongs to the ongoing LLM task. firstChunkSent := false if !msg.SkipPlaceholder { + // Stop thinking animation + if stop, ok := c.stopThinking.Load(msg.ChatID); ok { + if cf, ok := stop.(*thinkingCancel); ok && cf != nil { + cf.Cancel() + } + c.stopThinking.Delete(msg.ChatID) + } + if pID, ok := c.placeholders.Load(msg.ChatID); ok { c.placeholders.Delete(msg.ChatID) editMsg := tu.EditMessageText(tu.ID(chatID), pID.(int), markdownToTelegramHTML(chunks[0]))