fix: mark in-place created chats as read on new chat (#25782)

A chat created in place (new chat -> first message) keeps chatIdProp
undefined because the URL is swapped via history.replaceState without a
remount, so none of the chatIdProp-gated updateLastReadAt paths fire and
the chat is never persisted with a last_read_at. Starting another new
chat via initNewChat reset $chatId without marking the outgoing chat
read, so on refresh updated_at > last_read_at (NULL) and the chat shows
as unread in the sidebar.

Mark the outgoing chat read in initNewChat, mirroring navigateHandler.


Fixes #25108

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Classic298
2026-06-29 09:32:00 +02:00
committed by GitHub
parent 6ea591491e
commit 2414dfca70

View File

@@ -1199,6 +1199,13 @@
const initNewChat = async () => {
console.log('initNewChat');
// Mark the outgoing chat as read before resetting; in-place created chats
// keep chatIdProp undefined, so navigateHandler never marks them read.
if ($chatId && !$temporaryChatEnabled) {
updateLastReadAt($chatId);
}
if ($user?.role !== 'admin' && $user?.permissions?.chat?.temporary_enforced) {
await temporaryChatEnabled.set(true);
}