Enha: spinner to indicate llm response

This commit is contained in:
Grail Finder
2026-02-24 18:05:05 +03:00
parent 1c728ec7a7
commit 27288e2aaa

18
bot.go
View File

@@ -826,8 +826,26 @@ func chatWatcher(ctx context.Context) {
} }
} }
// inpired by https://github.com/rivo/tview/issues/225
func showSpinner() {
spinners := []string{"⠋", "⠙", "⠹", "⠸", "⠼", "⠴", "⠦", "⠧", "⠇", "⠏"}
var i int
for botRespMode {
time.Sleep(100 * time.Millisecond)
spin := i % len(spinners)
app.QueueUpdateDraw(func() {
textArea.SetTitle(spinners[spin] + " input")
})
i++
}
app.QueueUpdateDraw(func() {
textArea.SetTitle("input")
})
}
func chatRound(r *models.ChatRoundReq) error { func chatRound(r *models.ChatRoundReq) error {
botRespMode = true botRespMode = true
go showSpinner()
updateStatusLine() updateStatusLine()
botPersona := cfg.AssistantRole botPersona := cfg.AssistantRole
if cfg.WriteNextMsgAsCompletionAgent != "" { if cfg.WriteNextMsgAsCompletionAgent != "" {