Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): line up "Still working…" with the thoughts and tool calls

Elian Doran4ad84ddeaabc
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
index 59f6fa7252..0b9721eb13 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
@@ -239,6 +239,18 @@ body.background-effects.theme-supports-background-effects .llm-chat-message-user
white-space: nowrap;
}
+/* Spaced like `.llm-chat-thinking` and `.llm-chat-tool-calls`, the lines it follows. */
+.llm-chat-stream-idle {
+ margin: 0.25rem 0;
+ animation: llm-chat-stream-idle-appear 0.2s ease-out;
+}
+
+@keyframes llm-chat-stream-idle-appear {
+ from {
+ opacity: 0;
+ }
+}
+
/* The text after the last thought or tool call, set apart from the steps that led to it. */
.llm-chat-reply {
margin-top: 1rem;
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
index 964d5ab895..02ed5c5f54 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.tsx
@@ -54,6 +54,8 @@ interface Props {
isStreaming?: boolean;
/** When set on an error message, renders a Retry button that re-runs the failed turn. */
onRetry?: () => void;
+ /** A progress line under the streamed blocks, such as the one a stalled reply shows. */
+ streamStatus?: string;
}
type ContentGroup =
@@ -183,7 +185,7 @@ function ThinkingLine({ label }: { label: string }) {
);
}
-function ChatMessage({ message, isStreaming, onRetry }: Props) {
+function ChatMessage({ message, isStreaming, onRetry, streamStatus }: Props) {
const isError = message.type === "error";
const isThinking = message.type === "thinking";
const textContent = typeof message.content === "string" ? message.content : getMessageText(message.content);
@@ -261,6 +263,14 @@ function ChatMessage({ message, isStreaming, onRetry }: Props) {
) : (
<MarkdownContent html={renderedContent || ""} isStreaming={isStreaming && message.role === "assistant"} />
)}
+ {streamStatus && (
+ <div className="expandable-line llm-chat-stream-idle" role="status">
+ <div className="expandable-line-header">
+ <LoadingSpinner />
+ <span>{streamStatus}</span>
+ </div>
+ </div>
+ )}
</div>
{message.citations && message.citations.length > 0 && (
<CitationsSection citations={message.citations} />
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 f84db9310a..950a930009 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.css
@@ -78,11 +78,6 @@
&.chat-stream-status-waiting {
animation: chat-stream-status-appear 0.2s ease-out 0.6s backwards;
}
-
- &.chat-stream-status-idle {
- margin-top: 0.5rem;
- animation: chat-stream-status-appear 0.2s ease-out;
- }
}
@keyframes chat-stream-status-appear {
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 906885584c..7e251130a7 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
@@ -78,7 +78,7 @@ describe("ChatMessageList idle stream", () => {
beforeEach(() => vi.useFakeTimers());
afterEach(() => vi.useRealTimers());
- const idleRow = (target: HTMLElement) => target.querySelector(".chat-stream-status");
+ const idleRow = (target: HTMLElement) => target.querySelector(".llm-chat-stream-idle");
it("says it is still working once the reply stops changing, until it moves again", () => {
const target = renderStreamingTurn([ { type: "text", content: "Hello" } ], null);
@@ -86,7 +86,10 @@ describe("ChatMessageList idle stream", () => {
expect(idleRow(target)).toBeNull();
act(() => { vi.advanceTimersByTime(100); });
- expect(idleRow(target)?.textContent).toBe("llm_chat.stream_status.still_working");
+ // A line of the reply itself, shaped like the streaming thought and the tool calls above it.
+ const row = target.querySelector(".llm-chat-message-content > .expandable-line.llm-chat-stream-idle > .expandable-line-header");
+ expect(row?.textContent).toBe("llm_chat.stream_status.still_working");
+ expect(row?.firstElementChild?.classList.contains("bx-spin")).toBe(true);
rerenderStreamingTurn([ { type: "text", content: "Hello there" } ]);
expect(idleRow(target)).toBeNull();
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 e77dc8dbe7..66d529502d 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessageList.tsx
@@ -75,14 +75,11 @@ export default function ChatMessageList({ chat, emptyStateText, className }: Cha
<ChatMessage
message={streamingMessage}
isStreaming
+ streamStatus={isStreamIdle && !showsOwnProgress(chat.streamingBlocks)
+ ? t("llm_chat.stream_status.still_working")
+ : undefined}
/>
)}
- {isStreaming && streamingMessage && isStreamIdle && !showsOwnProgress(chat.streamingBlocks) && (
- <div className="chat-stream-status chat-stream-status-idle" role="status">
- <LoadingSpinner />
- {t("llm_chat.stream_status.still_working")}
- </div>
- )}
<div ref={chat.messagesEndRef} className="chat-messages-end" aria-hidden="true" />
<div ref={chat.bottomSpacerRef} className="chat-bottom-spacer" aria-hidden="true" />
</div>