Skip to content

Build your personal knowledge base with Trilium Notes

client/AI chat: fix an issue

Adorian Doran1bfa7e73b580
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts
index a3835c2cd1..43f2fa7af1 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts
+++ b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts
@@ -394,8 +394,10 @@ export function useLlmChat(
// Load state from content object
const loadFromContent = useCallback((content: LlmChatContent) => {
- // Opening an existing chat should land on the most recent message.
- if ((content.messages?.length ?? 0) > 0) {
+ // Opening an existing chat should land on the most recent message — but never
+ // clobber a send/retry that has already queued the reply-anchor positioning
+ // (a content reload can race the layout effect that consumes the pending mode).
+ if ((content.messages?.length ?? 0) > 0 && pendingScrollRef.current !== "anchor") {
pendingScrollRef.current = "bottom";
}
setMessagesInternal(content.messages || []);