From ae7ab838f450b73b30ade03a87cfdb6ff4b68bd3 Mon Sep 17 00:00:00 2001 From: John Preston Date: Tue, 21 Apr 2026 17:50:58 +0700 Subject: [PATCH] Don't show 406 error messages in AI. --- AGENTS.md | 1 + Telegram/SourceFiles/boxes/compose_ai_box.cpp | 4 ++++ Telegram/SourceFiles/mtproto/mtproto_response.h | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/AGENTS.md b/AGENTS.md index 9fffd0a059..ec1650302b 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -212,6 +212,7 @@ api().request(MTPnamespace_MethodName( ``` - For single constructors, use `.data()` shortcut - Include `.handleFloodErrors()` before `.send()` in rare cases where you want special case flood error handling +- Silently ignore HTTP 406 errors in UI: the server uses 406 to mean "show nothing to the user". Guard toasts with `MTP::IgnoreError(error)` or use `MTP::ShowErrorFallback(show, error)` (both in `mtproto/mtproto_response.h`) which shows `error.type()` as a toast unless the error should be ignored. ## UI Styling diff --git a/Telegram/SourceFiles/boxes/compose_ai_box.cpp b/Telegram/SourceFiles/boxes/compose_ai_box.cpp index 8b20695ee0..0d51c9d322 100644 --- a/Telegram/SourceFiles/boxes/compose_ai_box.cpp +++ b/Telegram/SourceFiles/boxes/compose_ai_box.cpp @@ -1203,6 +1203,10 @@ void ComposeAiContent::request() { return; } weak->_requestId = 0; + if (MTP::IgnoreError(error)) { + weak->resetState(CardState::Waiting); + return; + } weak->showError(error.type()); }); } diff --git a/Telegram/SourceFiles/mtproto/mtproto_response.h b/Telegram/SourceFiles/mtproto/mtproto_response.h index 7bd93f207e..4025f78456 100644 --- a/Telegram/SourceFiles/mtproto/mtproto_response.h +++ b/Telegram/SourceFiles/mtproto/mtproto_response.h @@ -57,6 +57,17 @@ inline bool IsDefaultHandledError(const Error &error) { return IsTemporaryError(error); } +inline bool IgnoreError(const Error &error) { + return error.code() == 406; +} + +template +void ShowErrorFallback(const ShowPtr &show, const Error &error) { + if (!IgnoreError(error)) { + show->showToast(error.type()); + } +} + struct Response { mtpBuffer reply; mtpMsgId outerMsgId = 0;