mirror of
https://github.com/andy-stack/vaultkeeper-ai.git
synced 2026-07-22 06:42:03 +00:00
fix: update token display timing and remove unused imports
- Add 500ms timeout to chat padding recalculation to prevent race conditions - Replace svelte tick() with setTimeout for conversation title updates - Update token display after each conversation save and streaming response - Remove unused svelte/transition and tick imports
This commit is contained in:
parent
fc892c43be
commit
cce2cf9132
3 changed files with 8 additions and 4 deletions
|
|
@ -11,7 +11,6 @@
|
|||
import type AIAgentPlugin from "main";
|
||||
import { Copy } from "Enums/Copy";
|
||||
import { Selector } from "Enums/Selector";
|
||||
import { fade } from "svelte/transition";
|
||||
|
||||
export let messages: ConversationContent[] = [];
|
||||
export let currentThought: string | null = null;
|
||||
|
|
@ -21,7 +20,8 @@
|
|||
export let editModeActive: boolean = false;
|
||||
|
||||
export function onFinishedSubmitting() {
|
||||
if (lastAssistantMessageElement && lastAssistantMessageElement.offsetHeight <
|
||||
setTimeout(() => {
|
||||
if (lastAssistantMessageElement && lastAssistantMessageElement.offsetHeight <
|
||||
chatContainer.offsetHeight - parseFloat(getComputedStyle(chatContainer).padding) * 2) {
|
||||
// Recalculate padding when streaming ends to fix race condition with streaming indicator removal
|
||||
tick().then(() => {
|
||||
|
|
@ -43,6 +43,7 @@
|
|||
}
|
||||
}, 1000);
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
let thoughtElement: HTMLElement | undefined;
|
||||
|
|
|
|||
|
|
@ -8,7 +8,6 @@
|
|||
import type { ConversationHistoryModal } from 'Modals/ConversationHistoryModal';
|
||||
import { openPluginSettings } from 'Helpers/Helpers';
|
||||
import type { ChatService } from 'Services/ChatService';
|
||||
import { tick } from 'svelte';
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
export let leaf: WorkspaceLeaf;
|
||||
|
|
@ -22,7 +21,7 @@
|
|||
|
||||
chatService.onNameChanged = (name: string) => {
|
||||
conversationTitle = "";
|
||||
tick().then(() => conversationTitle = name);
|
||||
setTimeout(() => conversationTitle = name, 500);
|
||||
};
|
||||
|
||||
function startNewConversation() {
|
||||
|
|
|
|||
|
|
@ -70,6 +70,7 @@ export class ChatService {
|
|||
this.onNameChanged?.(conversation.title); // on change for initial conversation name
|
||||
this.namingService.requestName(conversation, userRequest, this.onNameChanged, this.abortController);
|
||||
}
|
||||
this.updateTokenDisplay(conversation);
|
||||
|
||||
// Process AI responses and function calls
|
||||
let response = await this.streamRequestResponse(conversation, allowDestructiveActions, callbacks);
|
||||
|
|
@ -90,6 +91,8 @@ export class ChatService {
|
|||
await this.conversationService.saveConversation(conversation);
|
||||
}
|
||||
|
||||
this.updateTokenDisplay(conversation);
|
||||
|
||||
response = await this.streamRequestResponse(conversation, allowDestructiveActions, callbacks);
|
||||
}
|
||||
|
||||
|
|
@ -212,6 +215,7 @@ export class ChatService {
|
|||
}
|
||||
await this.conversationService.saveConversation(conversation);
|
||||
}
|
||||
this.updateTokenDisplay(conversation);
|
||||
}
|
||||
|
||||
return { functionCall: capturedFunctionCall, shouldContinue: capturedShouldContinue };
|
||||
|
|
|
|||
Loading…
Reference in a new issue