mirror of
https://github.com/stackblitz-labs/bolt.diy
synced 2025-06-26 18:26:38 +00:00
Fix lint issues
This commit is contained in:
parent
bccd07021e
commit
ae60b2a798
@ -343,6 +343,7 @@ export const ChatImpl = memo(
|
|||||||
|
|
||||||
// Update the repository as soon as it has changed.
|
// Update the repository as soon as it has changed.
|
||||||
const responseRepositoryId = getMessagesRepositoryId(newMessages);
|
const responseRepositoryId = getMessagesRepositoryId(newMessages);
|
||||||
|
|
||||||
if (responseRepositoryId && existingRepositoryId != responseRepositoryId) {
|
if (responseRepositoryId && existingRepositoryId != responseRepositoryId) {
|
||||||
simulationRepositoryUpdated(responseRepositoryId);
|
simulationRepositoryUpdated(responseRepositoryId);
|
||||||
updatedRepository = true;
|
updatedRepository = true;
|
||||||
@ -467,10 +468,12 @@ export const ChatImpl = memo(
|
|||||||
|
|
||||||
// Erase all messages since the last user message.
|
// Erase all messages since the last user message.
|
||||||
let rewindMessageId = message.id;
|
let rewindMessageId = message.id;
|
||||||
|
|
||||||
for (let i = messages.length - 2; i >= 0; i--) {
|
for (let i = messages.length - 2; i >= 0; i--) {
|
||||||
if (messages[i].role == 'user') {
|
if (messages[i].role == 'user') {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
rewindMessageId = messages[i].id;
|
rewindMessageId = messages[i].id;
|
||||||
}
|
}
|
||||||
await onRewind(rewindMessageId);
|
await onRewind(rewindMessageId);
|
||||||
|
|||||||
@ -47,8 +47,8 @@ class ChatManager {
|
|||||||
pageData: SimulationData = [];
|
pageData: SimulationData = [];
|
||||||
|
|
||||||
// State to ensure that the chat manager is not destroyed until all messages finish.
|
// State to ensure that the chat manager is not destroyed until all messages finish.
|
||||||
private pendingMessages = 0;
|
private _pendingMessages = 0;
|
||||||
private mustDestroyAfterChatFinishes = false;
|
private _mustDestroyAfterChatFinishes = false;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.client = new ProtocolClient();
|
this.client = new ProtocolClient();
|
||||||
@ -69,16 +69,16 @@ class ChatManager {
|
|||||||
return !!this.client;
|
return !!this.client;
|
||||||
}
|
}
|
||||||
|
|
||||||
private destroy() {
|
private _destroy() {
|
||||||
this.client?.close();
|
this.client?.close();
|
||||||
this.client = undefined;
|
this.client = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
destroyAfterChatFinishes() {
|
destroyAfterChatFinishes() {
|
||||||
if (this.pendingMessages == 0) {
|
if (this._pendingMessages == 0) {
|
||||||
this.destroy();
|
this._destroy();
|
||||||
} else {
|
} else {
|
||||||
this.mustDestroyAfterChatFinishes = true;
|
this._mustDestroyAfterChatFinishes = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,7 +141,7 @@ class ChatManager {
|
|||||||
async sendChatMessage(messages: Message[], references: ChatReference[], onResponsePart: ChatResponsePartCallback) {
|
async sendChatMessage(messages: Message[], references: ChatReference[], onResponsePart: ChatResponsePartCallback) {
|
||||||
assert(this.client, 'Chat has been destroyed');
|
assert(this.client, 'Chat has been destroyed');
|
||||||
|
|
||||||
this.pendingMessages++;
|
this._pendingMessages++;
|
||||||
|
|
||||||
const responseId = `response-${generateRandomId()}`;
|
const responseId = `response-${generateRandomId()}`;
|
||||||
|
|
||||||
@ -168,8 +168,8 @@ class ChatManager {
|
|||||||
|
|
||||||
removeResponseListener();
|
removeResponseListener();
|
||||||
|
|
||||||
if (--this.pendingMessages == 0 && this.mustDestroyAfterChatFinishes) {
|
if (--this._pendingMessages == 0 && this._mustDestroyAfterChatFinishes) {
|
||||||
this.destroy();
|
this._destroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -178,9 +178,11 @@ class ChatManager {
|
|||||||
let gChatManager: ChatManager | undefined;
|
let gChatManager: ChatManager | undefined;
|
||||||
|
|
||||||
function startChat(repositoryId: string | undefined, pageData: SimulationData) {
|
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
|
* Any existing chat manager won't be used anymore for new messages, but it will
|
||||||
// occur.
|
* not close until its messages actually finish and any future repository updates
|
||||||
|
* occur.
|
||||||
|
*/
|
||||||
if (gChatManager) {
|
if (gChatManager) {
|
||||||
gChatManager.destroyAfterChatFinishes();
|
gChatManager.destroyAfterChatFinishes();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user