From 1ed2455686c17600496c0a1602e21cd9f13cce60 Mon Sep 17 00:00:00 2001 From: dj-oyu <68707227+dj-oyu@users.noreply.github.com> Date: Sun, 22 Feb 2026 16:54:20 +0900 Subject: [PATCH] fix: create placeholder after echo so status bubbles appear below Move placeholder creation from SendCommand to the agent loop, right after the "via MiniApp" echo is sent. This ensures the chat bubble order is: user echo first, then status updates below it. Co-Authored-By: Claude Opus 4.6 --- cmd/picoclaw/cmd_gateway.go | 15 ++------------- pkg/agent/loop.go | 8 ++++++++ 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/cmd/picoclaw/cmd_gateway.go b/cmd/picoclaw/cmd_gateway.go index f8b7a9432..188aac507 100644 --- a/cmd/picoclaw/cmd_gateway.go +++ b/cmd/picoclaw/cmd_gateway.go @@ -233,7 +233,7 @@ func gatewayCmd() { if webAppURL != "" { provider := &agentLoopDataProvider{loop: agentLoop, workspace: cfg.WorkspacePath()} - sender := &telegramCommandSender{bus: msgBus, channelManager: channelManager} + sender := &telegramCommandSender{bus: msgBus} miniappNotifier = miniapp.NewStateNotifier() handler := miniapp.NewHandler(provider, sender, cfg.Channels.Telegram.Token, miniappNotifier) agentLoop.OnStateChange = miniappNotifier.Notify @@ -507,21 +507,10 @@ func collectGitRepoInfo(gitRoot string) miniapp.GitInfo { // telegramCommandSender injects Mini App commands into the message bus. type telegramCommandSender struct { - bus *bus.MessageBus - channelManager *channels.Manager + bus *bus.MessageBus } func (s *telegramCommandSender) SendCommand(senderID, chatID, command string) { - // Create a placeholder so status messages (streaming preview, tool progress) - // are visible to the user while the LLM processes the request. - if s.channelManager != nil { - if ch, ok := s.channelManager.GetChannel("telegram"); ok { - if tc, ok := ch.(*channels.TelegramChannel); ok { - tc.CreatePlaceholder(context.Background(), chatID) - } - } - } - s.bus.PublishInbound(bus.InboundMessage{ Channel: "telegram", SenderID: senderID, diff --git a/pkg/agent/loop.go b/pkg/agent/loop.go index aa0d5d853..953c7aca9 100644 --- a/pkg/agent/loop.go +++ b/pkg/agent/loop.go @@ -259,6 +259,14 @@ func (al *AgentLoop) Run(ctx context.Context) error { Content: "via MiniApp: " + msg.Content, SkipPlaceholder: true, }) + // Create a placeholder AFTER the echo so status updates appear below it. + if al.channelManager != nil { + if ch, ok := al.channelManager.GetChannel(msg.Channel); ok { + if tc, ok := ch.(*channels.TelegramChannel); ok { + tc.CreatePlaceholder(ctx, msg.ChatID) + } + } + } } // Fast path: handle slash commands immediately without blocking the LLM worker.