From d57274b2a3c34de6b00abe142b0a0a65af935550 Mon Sep 17 00:00:00 2001 From: HanishKVC Date: Tue, 21 May 2024 16:48:32 +0530 Subject: [PATCH] SimpleChat:MCUI: Delay enabling user-input to avoid race Re-enable user-input, only after response to a user query has been updated to the chat-div. This ensures that if user tries to switch chat session, it wont be allowed till chat-request-response flow is done. --- examples/server/public_simplechat/simplechat.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/server/public_simplechat/simplechat.js b/examples/server/public_simplechat/simplechat.js index 998d0a2b2..57876cf8b 100644 --- a/examples/server/public_simplechat/simplechat.js +++ b/examples/server/public_simplechat/simplechat.js @@ -265,8 +265,6 @@ class MultiChatUI { body: theBody, }); - this.elInUser.value = ""; - this.elInUser.disabled = false; let respBody = await resp.json(); console.debug(`DBUG:MCUI:${chatId}:HandleUserSubmit:RespBody:${JSON.stringify(respBody)}`); let assistantMsg; @@ -288,6 +286,8 @@ class MultiChatUI { if ((apiEP == ApiEP.Completion) && (gbCompletionFreshChatAlways)) { chat.xchat.length = 0; } + this.elInUser.value = ""; + this.elInUser.disabled = false; this.elInUser.focus(); }