fix: guard stopThinking cleanup inside !SkipPlaceholder in Telegram Send()

Co-authored-by: dj-oyu <68707227+dj-oyu@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-20 11:41:18 +00:00
parent 12c6137331
commit b759bb0c8f

View file

@ -185,6 +185,16 @@ func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) err
return fmt.Errorf("invalid chat ID: %w", err) return fmt.Errorf("invalid chat ID: %w", err)
} }
cleanContent := sanitizeTelegramOutgoingContent(msg.Content)
chunks := utils.SplitMessage(cleanContent, telegramMaxMessageChars)
if len(chunks) == 0 {
chunks = []string{cleanContent}
}
// 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 // Stop thinking animation
if stop, ok := c.stopThinking.Load(msg.ChatID); ok { if stop, ok := c.stopThinking.Load(msg.ChatID); ok {
if cf, ok := stop.(*thinkingCancel); ok && cf != nil { if cf, ok := stop.(*thinkingCancel); ok && cf != nil {
@ -193,15 +203,6 @@ func (c *TelegramChannel) Send(ctx context.Context, msg bus.OutboundMessage) err
c.stopThinking.Delete(msg.ChatID) 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
firstChunkSent := false
if !msg.SkipPlaceholder {
if pID, ok := c.placeholders.Load(msg.ChatID); ok { if pID, ok := c.placeholders.Load(msg.ChatID); ok {
c.placeholders.Delete(msg.ChatID) c.placeholders.Delete(msg.ChatID)
editMsg := tu.EditMessageText(tu.ID(chatID), pID.(int), markdownToTelegramHTML(chunks[0])) editMsg := tu.EditMessageText(tu.ID(chatID), pID.(int), markdownToTelegramHTML(chunks[0]))