From 9b9796e52f7186889adc363c2990252e710904ed Mon Sep 17 00:00:00 2001 From: stevef Date: Mon, 13 Apr 2026 21:52:26 +0200 Subject: [PATCH] fix: enforce synchronous typing-stop signaling for Monitor UI stability --- pkg/agent/loop.go | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index 189334f01..b91d2db0d 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -529,24 +529,6 @@ func (al *AgentLoop) Run(ctx context.Context) error { // Process message func() { - defer func() { - if al.channelManager != nil { - al.channelManager.InvokeTypingStop(msg.Channel, msg.ChatID) - } - }() - // TODO: Re-enable media cleanup after inbound media is properly consumed by the agent. - // Currently disabled because files are deleted before the LLM can access their content. - // defer func() { - // if al.mediaStore != nil && msg.MediaScope != "" { - // if releaseErr := al.mediaStore.ReleaseAll(msg.MediaScope); releaseErr != nil { - // logger.WarnCF("agent", "Failed to release media", map[string]any{ - // "scope": msg.MediaScope, - // "error": releaseErr.Error(), - // }) - // } - // } - // }() - drainCanceled := false cancelDrain := func() { if drainCanceled { @@ -577,6 +559,9 @@ func (al *AgentLoop) Run(ctx context.Context) error { if finalResponse != "" { al.PublishResponseIfNeeded(ctx, msg.Channel, msg.ChatID, finalResponse) } + if al.channelManager != nil { + al.channelManager.InvokeTypingStop(msg.Channel, msg.ChatID) + } return } @@ -637,6 +622,9 @@ func (al *AgentLoop) Run(ctx context.Context) error { if finalResponse != "" { al.PublishResponseIfNeeded(ctx, target.Channel, target.ChatID, finalResponse) } + if al.channelManager != nil { + al.channelManager.InvokeTypingStop(target.Channel, target.ChatID) + } }() } }