Repository navigation
fix(bot): keep multi-line payloads after an @mention; harden budget prompt flows (Refs #123) - #245
Merged
Merged
Conversation
…rompt flows (Refs #123) Mention route: (.+) stopped at the first newline, so the 2026-11-06 12:22 UTC budget list reached the AI as its first line only (chat_messages row 573, 68 chars) and the AI answered «Вы не указали сами лимиты». Extraction moved to extractMentionQuestion with ([\s\S]+); the index.ts wiring is pinned textually (createBot cannot be booted in a unit test). Budget-prompt hardening: suggestion buttons share the typed-path BUDGET_MAX_AMOUNT cap, a lost already_handled race in the text flow is consumed and logged instead of silently dropping the reply, and a successful typed apply strips the prompt's dead buttons via removeInlineKeyboard (best-effort, never thrown).
|
🔁 PR closed. Stage bot switched back to |
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Что случилось (кейс 2026-11-06, 12:22 UTC)
Лена прислала боту @-упоминанием список лимитов на ноябрь (11 строк: «Установи следующие лимиты по бюджету по категориям / Суммы в евро / Аренда 550 / … / Путешествия 800»). Бот ответил «Вы не указали сами лимиты», затем дважды «список … не дошёл» — и лимиты пришлось диктовать построчно.
Корневая причина
Маршрут @-упоминаний в
src/bot/index.tsвытаскивал вопрос регуляркой@bot\s+(.+). В JS.не матчит\n: до ИИ доходила только первая строка («Установи следующие лимиты…», 68 символов — это ровно то, что сохранилось вchat_messages, строка 573). Остальные 10 строк списка терялись до ИИ, поэтому он честно отвечал, что лимитов не видел. Сообщения без упоминания многострочными доходили целиком — потому замена формата (построчная диктовка 12:29–12:31) сразу сработала.Фикс
src/bot/mention-question.ts:extractMentionQuestionс([\s\S]+)— многострочный payload доходит до ИИ целиком; пустое/голое упоминание → обычная маршрутизация.src/bot/index.tsиспользует модуль; wiring закреплён текстовым контрактом в тесте (createBot в юнит-тесте не поднять).Попутно (жёсткость бюджетных промптов, найдено при ревью)
BUDGET_MAX_AMOUNTтак же, как ручной ввод (budget-callbacks.ts).already_handledв текстовом флоу больше не «молча съедает» ответ — логируется сpromptId.removeInlineKeyboard, best-effort, никогда не бросает исключение).Тесты
src/bot/mention-question.test.ts(новый, 8): точный прод-список 2026-11-06, «Суммы в евро», mention в середине, case-insensitivity, голое упоминание, отсутствие упоминания, безстатность + пин wiring'а.src/bot/handlers/message.handler.test.ts: точный 11-строчный список без упоминания доходит до ИИ дословно.budget-prompt.test.ts,callback.handler.test.ts,budget-amount-parser.test.ts(вкл. NBSP-разделители тысяч).Gates:
server-run -- bun run test— 253 файла / 6070 тестов, 0 fail; type-check ✅; lint ✅; knip — без новых замечаний. Машинное ревью: 6 записанных итераций (2 free-сида), финальные вердикты clean.Refs #123