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 <noreply@anthropic.com>
This commit is contained in:
dj-oyu 2026-02-22 16:54:20 +09:00
parent f78911add4
commit 1ed2455686
2 changed files with 10 additions and 13 deletions

View file

@ -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
@ -508,20 +508,9 @@ func collectGitRepoInfo(gitRoot string) miniapp.GitInfo {
// telegramCommandSender injects Mini App commands into the message bus.
type telegramCommandSender struct {
bus *bus.MessageBus
channelManager *channels.Manager
}
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,

View file

@ -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.