From ef0dd74dc183b954bf156ef8324c6f2f13479935 Mon Sep 17 00:00:00 2001 From: "jabber.developer2" Date: Fri, 15 May 2026 19:41:10 +0300 Subject: [PATCH] fix(ui): preserve messages in non-chat windows while scrolled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _win_printf used to drop the buffer append and pad render for any window in paged state, but only WIN_CHAT can recover lost messages via chatwin_db_history on scroll-down. WIN_MUC, WIN_PRIVATE and WIN_AI have no such fallback, so incoming and outgoing messages were silently lost when the user was viewing history. Suppress the buffer/render only for WIN_CHAT; for the rest, still bump unread_msg but let the message land in the buffer so it becomes visible on scroll-down. This also removes the manual paged/unread_msg reset before printing the user message in cl_ev_send_ai_msg — it was a local workaround for the same drop and is no longer needed. The buffer-bottom reset in win_page_down (c167f487) is still required: it is the only path that clears paged and unread_msg for non-chat windows when the user scrolls back to the bottom (WIN_SCROLL_REACHED_BOTTOM is set only on the is_chat DB branch). --- src/event/client_events.c | 6 ------ src/ui/window.c | 9 +++++++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/event/client_events.c b/src/event/client_events.c index 6adfc612..b90218db 100644 --- a/src/event/client_events.c +++ b/src/event/client_events.c @@ -301,12 +301,6 @@ cl_ev_send_ai_msg(ProfAiWin* aiwin, const char* const message, const char* const return; } - /* Reset paged flag before printing user message. - * If the user scrolled up to view history, paged=1 would suppress - * the message in _win_printf(). Reset it here so the message displays. */ - aiwin->window.layout->paged = 0; - aiwin->window.layout->unread_msg = 0; - // Display user message in AI window. win_print_outgoing(&aiwin->window, ">>", id, NULL, message); diff --git a/src/ui/window.c b/src/ui/window.c index 94550f9a..3ee21b43 100644 --- a/src/ui/window.c +++ b/src/ui/window.c @@ -1809,10 +1809,15 @@ static void _win_printf(ProfWin* window, const char* show_char, int pad_indent, GDateTime* timestamp, int flags, theme_item_t theme_item, const char* const display_from, const char* const from_jid, const char* const message_id, const char* const message, ...) { - /* Prevent printing and buffer update when user is viewing message history [SCROLLING]*/ + /* While the user is scrolled, bump the unread indicator. Only WIN_CHAT + * skips the buffer/render entirely — it can recover the message via + * chatwin_db_history on scroll-down. Other window types have no DB + * fallback, so the message must still be appended to the buffer and pad. */ if (window->layout->paged && wins_is_current(window)) { window->layout->unread_msg++; - return; + if (window->type == WIN_CHAT) { + return; + } } if (timestamp == NULL) {