Fix lint issues

This commit is contained in:
Jason Laster 2025-03-21 12:43:53 -07:00
parent bccd07021e
commit ae60b2a798
2 changed files with 17 additions and 12 deletions

View File

@ -343,6 +343,7 @@ export const ChatImpl = memo(
// Update the repository as soon as it has changed.
const responseRepositoryId = getMessagesRepositoryId(newMessages);
if (responseRepositoryId && existingRepositoryId != responseRepositoryId) {
simulationRepositoryUpdated(responseRepositoryId);
updatedRepository = true;
@ -467,10 +468,12 @@ export const ChatImpl = memo(
// Erase all messages since the last user message.
let rewindMessageId = message.id;
for (let i = messages.length - 2; i >= 0; i--) {
if (messages[i].role == 'user') {
break;
}
rewindMessageId = messages[i].id;
}
await onRewind(rewindMessageId);

View File

@ -47,8 +47,8 @@ class ChatManager {
pageData: SimulationData = [];
// State to ensure that the chat manager is not destroyed until all messages finish.
private pendingMessages = 0;
private mustDestroyAfterChatFinishes = false;
private _pendingMessages = 0;
private _mustDestroyAfterChatFinishes = false;
constructor() {
this.client = new ProtocolClient();
@ -69,16 +69,16 @@ class ChatManager {
return !!this.client;
}
private destroy() {
private _destroy() {
this.client?.close();
this.client = undefined;
}
destroyAfterChatFinishes() {
if (this.pendingMessages == 0) {
this.destroy();
if (this._pendingMessages == 0) {
this._destroy();
} else {
this.mustDestroyAfterChatFinishes = true;
this._mustDestroyAfterChatFinishes = true;
}
}
@ -141,7 +141,7 @@ class ChatManager {
async sendChatMessage(messages: Message[], references: ChatReference[], onResponsePart: ChatResponsePartCallback) {
assert(this.client, 'Chat has been destroyed');
this.pendingMessages++;
this._pendingMessages++;
const responseId = `response-${generateRandomId()}`;
@ -168,8 +168,8 @@ class ChatManager {
removeResponseListener();
if (--this.pendingMessages == 0 && this.mustDestroyAfterChatFinishes) {
this.destroy();
if (--this._pendingMessages == 0 && this._mustDestroyAfterChatFinishes) {
this._destroy();
}
}
}
@ -178,9 +178,11 @@ class ChatManager {
let gChatManager: ChatManager | undefined;
function startChat(repositoryId: string | undefined, pageData: SimulationData) {
// Any existing chat manager won't be used anymore for new messages, but it will
// not close until its messages actually finish and any future repository updates
// occur.
/*
* Any existing chat manager won't be used anymore for new messages, but it will
* not close until its messages actually finish and any future repository updates
* occur.
*/
if (gChatManager) {
gChatManager.destroyAfterChatFinishes();
}