Skip to content

Build your personal knowledge base with Trilium Notes

fix(llm): tools calls not displayed during streaming

Elian Doranbf7070a7dad4
diff --git a/apps/client/src/widgets/sidebar/SidebarChat.tsx b/apps/client/src/widgets/sidebar/SidebarChat.tsx
index 5a972fe4fa..5155126274 100644
--- a/apps/client/src/widgets/sidebar/SidebarChat.tsx
+++ b/apps/client/src/widgets/sidebar/SidebarChat.tsx
@@ -289,12 +289,6 @@ export default function SidebarChat() {
{chat.messages.map(msg => (
<ChatMessage key={msg.id} message={msg} />
))}
- {chat.toolActivity && !chat.streamingThinking && (
- <div className="llm-chat-tool-activity">
- <span className="llm-chat-tool-spinner" />
- {chat.toolActivity}
- </div>
- )}
{chat.isStreaming && chat.streamingThinking && (
<ChatMessage
message={{
@@ -307,12 +301,12 @@ export default function SidebarChat() {
isStreaming
/>
)}
- {chat.isStreaming && chat.streamingContent && (
+ {chat.isStreaming && chat.streamingBlocks.length > 0 && (
<ChatMessage
message={{
id: "streaming",
role: "assistant",
- content: chat.streamingContent,
+ content: chat.streamingBlocks,
createdAt: new Date().toISOString(),
citations: chat.pendingCitations.length > 0 ? chat.pendingCitations : undefined
}}
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 498f2e4cb4..bc5cd05f61 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
+++ b/apps/client/src/widgets/type_widgets/llm_chat/ChatMessage.css
@@ -70,33 +70,6 @@
51%, 100% { opacity: 0; }
}
-/* Tool activity indicator */
-.llm-chat-tool-activity {
- display: flex;
- align-items: center;
- gap: 0.5rem;
- padding: 0.5rem 1rem;
- margin-bottom: 1rem;
- border-radius: 8px;
- background: var(--accented-background-color);
- color: var(--muted-text-color);
- font-size: 0.9rem;
- max-width: 85%;
-}
-
-.llm-chat-tool-spinner {
- width: 16px;
- height: 16px;
- border: 2px solid var(--muted-text-color);
- border-top-color: transparent;
- border-radius: 50%;
- animation: llm-chat-spin 0.8s linear infinite;
-}
-
-@keyframes llm-chat-spin {
- to { transform: rotate(360deg); }
-}
-
/* Citations */
.llm-chat-citations {
margin-top: 0.75rem;
diff --git a/apps/client/src/widgets/type_widgets/llm_chat/LlmChat.tsx b/apps/client/src/widgets/type_widgets/llm_chat/LlmChat.tsx
index 96f7052e43..301141f0d8 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/LlmChat.tsx
+++ b/apps/client/src/widgets/type_widgets/llm_chat/LlmChat.tsx
@@ -65,12 +65,6 @@ export default function LlmChat({ note, ntxId, noteContext }: TypeWidgetProps) {
{chat.messages.map(msg => (
<ChatMessage key={msg.id} message={msg} />
))}
- {chat.toolActivity && !chat.streamingThinking && (
- <div className="llm-chat-tool-activity">
- <span className="llm-chat-tool-spinner" />
- {chat.toolActivity}
- </div>
- )}
{chat.isStreaming && chat.streamingThinking && (
<ChatMessage
message={{
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 ea68ff18fc..faa7448bb6 100644
--- a/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts
+++ b/apps/client/src/widgets/type_widgets/llm_chat/useLlmChat.ts
@@ -2,7 +2,6 @@ import type { LlmCitation, LlmMessage, LlmModelInfo, LlmUsage } from "@triliumne
import { RefObject } from "preact";
import { useCallback, useEffect, useRef, useState } from "preact/hooks";
-import { t } from "../../../services/i18n.js";
import { getAvailableModels, streamChatCompletion } from "../../../services/llm_chat.js";
import { randomString } from "../../../services/utils.js";
import type { ContentBlock, LlmChatContent, StoredMessage } from "./llm_chat_types.js";
@@ -30,7 +29,6 @@ export interface UseLlmChatReturn {
streamingContent: string;
streamingBlocks: ContentBlock[];
streamingThinking: string;
- toolActivity: string | null;
pendingCitations: LlmCitation[];
availableModels: ModelOption[];
selectedModel: string;
@@ -78,7 +76,6 @@ export function useLlmChat(
const [streamingContent, setStreamingContent] = useState("");
const [streamingBlocks, setStreamingBlocks] = useState<ContentBlock[]>([]);
const [streamingThinking, setStreamingThinking] = useState("");
- const [toolActivity, setToolActivity] = useState<string | null>(null);
const [pendingCitations, setPendingCitations] = useState<LlmCitation[]>([]);
const [availableModels, setAvailableModels] = useState<ModelOption[]>([]);
const [selectedModel, setSelectedModel] = useState<string>("");
@@ -154,7 +151,7 @@ export function useLlmChat(
useEffect(() => {
scrollToBottom();
- }, [messages, streamingContent, streamingThinking, toolActivity, scrollToBottom]);
+ }, [messages, streamingContent, streamingThinking, scrollToBottom]);
// Load state from content object
const loadFromContent = useCallback((content: LlmChatContent) => {
@@ -200,7 +197,6 @@ export function useLlmChat(
e.preventDefault();
if (!input.trim() || isStreaming) return;
- setToolActivity(null);
setPendingCitations([]);
const userMessage: StoredMessage = {
@@ -266,18 +262,12 @@ export function useLlmChat(
.map(b => b.content)
.join(""));
setStreamingBlocks([...contentBlocks]);
- setToolActivity(null);
},
onThinking: (text) => {
thinkingContent += text;
setStreamingThinking(thinkingContent);
- setToolActivity(t("llm_chat.thinking"));
},
onToolUse: (toolName, toolInput) => {
- const toolLabel = toolName === "web_search"
- ? t("llm_chat.searching_web")
- : `Using ${toolName}...`;
- setToolActivity(toolLabel);
contentBlocks.push({
type: "tool_call",
toolCall: {
@@ -323,7 +313,6 @@ export function useLlmChat(
setStreamingBlocks([]);
setStreamingThinking("");
setIsStreaming(false);
- setToolActivity(null);
},
onDone: () => {
const finalNewMessages: StoredMessage[] = [];
@@ -359,7 +348,6 @@ export function useLlmChat(
setStreamingThinking("");
setPendingCitations([]);
setIsStreaming(false);
- setToolActivity(null);
}
}
);
@@ -380,7 +368,6 @@ export function useLlmChat(
streamingContent,
streamingBlocks,
streamingThinking,
- toolActivity,
pendingCitations,
availableModels,
selectedModel,