fix(line): log loading refresh errors, skip typing without recorder
Address review feedback from @alexhoshina and Codex: - Log sendLoading errors in ticker goroutine instead of discarding - Only start typing indicator when PlaceholderRecorder is available to avoid wasted API calls and unnecessary goroutine creation Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
3dc65ff7d7
commit
84667206b6
1 changed files with 18 additions and 16 deletions
|
|
@ -380,7 +380,9 @@ func (c *LINEChannel) processEvent(event lineEvent) {
|
||||||
|
|
||||||
// Thinking indicator (LINE loading animation is 1:1 only).
|
// Thinking indicator (LINE loading animation is 1:1 only).
|
||||||
// For group/room chats, LINE provides no equivalent API.
|
// For group/room chats, LINE provides no equivalent API.
|
||||||
|
// Only start if PlaceholderRecorder is available to avoid wasted API calls.
|
||||||
if !isGroup {
|
if !isGroup {
|
||||||
|
if rec := c.GetPlaceholderRecorder(); rec != nil {
|
||||||
typingCtx, typingCancel := context.WithTimeout(c.ctx, 5*time.Minute)
|
typingCtx, typingCancel := context.WithTimeout(c.ctx, 5*time.Minute)
|
||||||
stop, err := c.StartTyping(typingCtx, chatID)
|
stop, err := c.StartTyping(typingCtx, chatID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
|
@ -391,16 +393,12 @@ func (c *LINEChannel) processEvent(event lineEvent) {
|
||||||
typingCancel()
|
typingCancel()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
if rec := c.GetPlaceholderRecorder(); rec != nil {
|
|
||||||
rec.RecordTypingStop("line", chatID, stopFn)
|
rec.RecordTypingStop("line", chatID, stopFn)
|
||||||
} else {
|
|
||||||
// No recorder — stop immediately to avoid goroutine leaks.
|
|
||||||
stopFn()
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
typingCancel()
|
typingCancel()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
c.HandleMessage(c.ctx, peer, msg.ID, senderID, chatID, content, mediaPaths, metadata, sender)
|
c.HandleMessage(c.ctx, peer, msg.ID, senderID, chatID, content, mediaPaths, metadata, sender)
|
||||||
}
|
}
|
||||||
|
|
@ -627,7 +625,11 @@ func (c *LINEChannel) StartTyping(ctx context.Context, chatID string) (func(), e
|
||||||
case <-typingCtx.Done():
|
case <-typingCtx.Done():
|
||||||
return
|
return
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
_ = c.sendLoading(typingCtx, chatID)
|
if err := c.sendLoading(typingCtx, chatID); err != nil {
|
||||||
|
logger.DebugCF("line", "Failed to refresh loading indicator", map[string]any{
|
||||||
|
"error": err.Error(),
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue