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:
parent
ee47513b4d
commit
cde47cce05
1 changed files with 10 additions and 9 deletions
|
|
@ -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]))
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue