@@ -42,6 +42,11 @@ var chatCancels sync.Map // map[int64]context.CancelFunc
4242// interrupted task.
4343var chatRunInfos sync.Map // map[int64]loop.IterationInfo
4444
45+ // clarifyMsgIDs stores the message ID of the active clarify prompt
46+ // per chat, so the callback handler can edit/remove it after the user
47+ // responds. Cleared when the clarify tool completes or times out.
48+ var clarifyMsgIDs sync.Map // map[int64]int
49+
4550// pendingSuggestions stores SkillSuggestion values keyed by skill name,
4651// awaiting user approval via inline keyboard callbacks.
4752var pendingSuggestions sync.Map // map[string]skills.SkillSuggestion
@@ -400,7 +405,14 @@ func telegramCmd(args []string) error {
400405 // Channel full or closed — clarify already resolved.
401406 }
402407 }
403- return "✅ You chose **" + answer + "**" , nil
408+ // Remove the inline keyboard and update text to show the answer.
409+ if msgID , ok := clarifyMsgIDs .Load (chatID ); ok {
410+ bot .EditMessageText (chatID , msgID .(int ),
411+ "✅ *User answered:* " + answer ,
412+ & telegram.SendOpts {ParseMode : telegram .ParseModeMarkdownV2 , ReplyMarkup : & telegram.InlineKeyboardMarkup {InlineKeyboard : [][]telegram.InlineKeyboardButton {}}})
413+ clarifyMsgIDs .Delete (chatID )
414+ }
415+ return "" , nil
404416 }
405417
406418 // Route skill suggestion callbacks — Save or Skip.
@@ -1072,9 +1084,12 @@ func handleChatMessage(
10721084 },
10731085 },
10741086 }
1075- if _ , err := bot .SendMessage (chatID , "❓ " + question ,
1087+ if msg , err := bot .SendMessage (chatID , "❓ " + question ,
10761088 & telegram.SendOpts {ReplyMarkup : replyMarkup , ParseMode : "Markdown" , ReplyToMessageID : messageID }); err != nil {
10771089 return "" , fmt .Errorf ("clarify: send message: %w" , err )
1090+ } else {
1091+ clarifyMsgIDs .Store (chatID , msg .ID )
1092+ defer clarifyMsgIDs .Delete (chatID )
10781093 }
10791094
10801095 // Wait for the user to click a button (or timeout).
0 commit comments