Skip to content

Build your personal knowledge base with Trilium Notes

feat(llm): show that the chat waits for the reply until it starts

Elian Doran5102d69098a0
diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index dfef9ad412..d4498eea1d 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -2652,7 +2652,8 @@
"attachment_upload_failed": "Failed to upload \"{{name}}\".",
"attachment_unsupported_type": "\"{{name}}\" isn't a supported attachment type. Use an image (PNG, JPEG, GIF, WebP), a PDF, or a text/source file.",
"stream_status": {
- "starting_agent": "Starting the agent. This can take a while."
+ "starting_agent": "Starting the agent. This can take a while.",
+ "waiting_for_reply": "Waiting for the reply…"
}
},
"sidebar_chat": {
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.css b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.css
index dad39a547d..950a930009 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.css
@@ -73,4 +73,15 @@
gap: 0.5em;
color: var(--muted-text-color);
font-size: 0.9em;
+
+ /* Fades in after a delay, so a reply that starts quickly never flashes it. */
+ &.chat-stream-status-waiting {
+ animation: chat-stream-status-appear 0.2s ease-out 0.6s backwards;
+ }
+}
+
+@keyframes chat-stream-status-appear {
+ from {
+ opacity: 0;
+ }
}
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.spec.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.spec.tsx
index 7052470dff..1f33dd0e86 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.spec.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.spec.tsx
@@ -24,13 +24,13 @@ afterEach(() => {
});
/** Render the list for a streaming turn with nothing stored yet. */
-function renderStreamingTurn(streamingBlocks: ContentBlock[]) {
+function renderStreamingTurn(streamingBlocks: ContentBlock[], streamingStatus: string | null = "starting_agent") {
host = document.body.appendChild(document.createElement("div"));
const target = host;
const chat = {
messages: [],
isStreaming: true,
- streamingStatus: "starting_agent",
+ streamingStatus,
streamingThinking: "",
streamingBlocks,
pendingCitations: [],
@@ -56,4 +56,11 @@ describe("ChatMessageList stream status", () => {
expect(replying.querySelector(".markdown-stub")?.textContent).toContain("Hello");
expect(replying.querySelector(".chat-stream-status")).toBeNull();
});
+
+ it("says it waits for the reply when the server names nothing slower", () => {
+ const row = renderStreamingTurn([], null).querySelector(".chat-stream-status");
+ expect(row?.textContent).toBe("llm_chat.stream_status.waiting_for_reply");
+ // The delayed fade-in keeps a quick reply from flashing the row.
+ expect(row?.classList.contains("chat-stream-status-waiting")).toBe(true);
+ });
});
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.tsx
index 1e0e72ddc6..4dc5846449 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.tsx
@@ -67,10 +67,12 @@ export default function ChatMessageList({ chat, emptyStateText, className }: Cha
<NoItems icon="bx bx-conversation" text={emptyStateText} />
)}
{storedMessages}
- {isStreaming && chat.streamingStatus && !thinkingMessage && !streamingMessage && (
- <div className="chat-stream-status" role="status">
+ {isStreaming && !thinkingMessage && !streamingMessage && (
+ <div className={`chat-stream-status ${chat.streamingStatus ? "" : "chat-stream-status-waiting"}`} role="status">
<LoadingSpinner />
- {t(`llm_chat.stream_status.${chat.streamingStatus}`)}
+ {chat.streamingStatus
+ ? t(`llm_chat.stream_status.${chat.streamingStatus}`)
+ : t("llm_chat.stream_status.waiting_for_reply")}
</div>
)}
{isStreaming && thinkingMessage && (