diff --git a/coverage/lcov-report/chat-view.ts.html b/coverage/lcov-report/chat-view.ts.html index 0b4f0d0..ad0b4ab 100644 --- a/coverage/lcov-report/chat-view.ts.html +++ b/coverage/lcov-report/chat-view.ts.html @@ -23,16 +23,16 @@
- 90.36% + 92.55% Statements - 197/218 + 199/215
- 80.28% + 85.71% Branches - 57/71 + 60/70
@@ -44,9 +44,9 @@
- 92.15% + 94.52% Lines - 188/204 + 190/201
@@ -565,22 +565,22 @@   1x   -31x +36x       -31x -31x -31x -31x -31x -31x -31x -31x -31x -31x -31x -31x +36x +36x +36x +36x +36x +36x +36x +36x +36x +36x +36x +36x       @@ -596,11 +596,11 @@       -31x -31x -31x -31x -31x +36x +36x +36x +36x +36x       @@ -640,8 +640,8 @@       -136x -23x +146x +28x       @@ -649,71 +649,71 @@       -33x -33x +43x +43x   -33x +43x     -33x +43x 4x   -33x +43x 4x     4x     -33x +43x   -22x +27x   -22x +27x     -22x -22x +27x +27x       -33x +43x     +282x +  +  +43x +  +43x 262x +262x +109x +  +153x     -33x -  -33x -247x -247x -104x -  -143x -  -  -143x -143x +153x +153x         -33x -128x -3656x +43x +133x +3661x 24x         -262x -33x -  +282x +43x +1x     -  -  +1x +1x       @@ -787,59 +787,61 @@       -138x -9x -9x +292x +26x +26x         -9x +26x       -146x -13x -8x +158x +19x +12x     -8x +12x   -13x -13x +19x +19x         -16x -16x +21x +21x   -16x +21x   -16x -16x +21x +21x     -14x -14x +19x +19x     -14x -14x +19x +19x       -14x +19x +  +  +19x       -14x -14x +19x         -14x +19x       @@ -852,7 +854,7 @@       -14x +19x       @@ -873,20 +875,20 @@       -14x +19x   -14x -14x +19x +19x     -14x +19x             -14x +19x       @@ -895,109 +897,107 @@       -14x +19x   -14x -14x +19x +19x   -14x -14x -14x -14x -14x -12x -12x +19x +19x +19x +19x +19x +17x +17x       -12x -12x +17x +17x     -12x -1x +17x +4x     -12x +17x       -8x +13x           -8x +13x   -1x -1x +4x +4x         -1x -1x +4x +6x     -1x -1x -1x -1x -  -  -  -  -  -  -  -1x -  -1x -  -  -1x -  -  -  -  -  -1x -1x -1x -  -  -1x -  -  -  -  -  -  -  -  -  -  -  -  -  -  -8x -7x -7x -7x -7x -  -  -  -  -8x +4x +4x +6x 2x   -8x +  +4x     -14x +  +  +4x +  +2x +  +  +2x +  +  +  +  +  +2x +2x +2x +  +  +2x +  +  +  +  +  +  +2x +  +  +  +  +  +  +  +13x +9x +  +  +  +  +  +13x +2x +  +13x +  +  +19x       @@ -1011,8 +1011,8 @@   6x   -16x -16x +21x +21x       @@ -1185,12 +1185,12 @@ export class ChatView extends ItemView {   // Re-attach streaming message if it exists const streamingMessage = messagesSnapshot.find((msg) => msg.isStreaming); - Iif (streamingMessage && this.lastMessageEl) { - const existingStreamingEl = container.querySelector( + if (streamingMessage && this.lastMessageEl) { + const existingStreamingEl = container.querySelector( `.ollama-message[data-msg-id="${streamingMessage.id}"]` ); - Iif (!existingStreamingEl) { - container.appendChild(this.lastMessageEl); + if (!existingStreamingEl) { + container.appendChild(this.lastMessageEl); } } } @@ -1306,14 +1306,16 @@ export class ChatView extends ItemView { context = context.substring(0, MAX_CONTEXT_LENGTH) + '\n\n... (truncated)'; }   + const systemContent = context + ? `You are a helpful assistant.\n\nRelevant vault context:\n${context}` + : 'You are a helpful assistant.'; const systemMessage: OllamaMessage = { role: 'system', - content: 'You are a helpful assistant.', + content: systemContent, }; - const userContent = context ? `${context}\n\n${userMessage}` : userMessage; const userMessageWithContext: OllamaMessage = { role: 'user', - content: userContent, + content: userMessage, };   const messages: OllamaMessage[] = [ @@ -1421,9 +1423,9 @@ export class ChatView extends ItemView { for (const result of settledResults) { if (result.status === 'fulfilled') { toolResults.push(result.value); - } else E{ + } else { // Use centralized error handler for tool errors - ErrorHandler.handleError(result.reason, 'ChatView.handleUserInput'); + ErrorHandler.handleError(result.reason, 'ChatView.handleUserInput'); } }   @@ -1448,23 +1450,21 @@ export class ChatView extends ItemView { content: fullResponse, isStreaming: false, }); - } else E{ + } else { // Even if no tool results were successful, mark streaming as complete // to prevent the assistant message from disappearing - this.updateMessageById(assistantMessageId, { + this.updateMessageById(assistantMessageId, { content: fullResponse, isStreaming: false, }); } }   - // Update last message immutably — only if no tool calls were processed + // Update assistant message immutably — only if no tool calls were processed if (toolCalls.length === 0) { - const lastMessageIndex = this.messages.length - 1; - if (lastMessageIndex >= 0) { - const lastMessage = { ...this.messages[lastMessageIndex], isStreaming: false }; - this.messages = [...this.messages.slice(0, lastMessageIndex), lastMessage]; - } + this.updateMessageById(assistantMessageId, { + isStreaming: false, + }); }   // Limit conversation history to prevent memory issues @@ -1501,7 +1501,7 @@ export class ChatView extends ItemView {