From 8079618c854bf0ec21357a21fdb7982328dfc450 Mon Sep 17 00:00:00 2001 From: hanishkvc Date: Sun, 9 Nov 2025 19:33:03 +0530 Subject: [PATCH] SimpleChatTC:Alert end user in case emtpy message to ai Currently the logic doesnt allow user to send a empty message to ai, during their term. Previously this path wasnt directly alerting the end user. Now it informs the end user using placeholder property so they can see the alert, while also ensuring that once user enters something, the alert wont interfere. The logic takes care of saving any original placeholder, so that the same is restored, when user switches sessions. --- tools/server/public_simplechat/simplechat.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/server/public_simplechat/simplechat.js b/tools/server/public_simplechat/simplechat.js index 94331d374f..866b8728f0 100644 --- a/tools/server/public_simplechat/simplechat.js +++ b/tools/server/public_simplechat/simplechat.js @@ -917,6 +917,8 @@ class MultiChatUI { this.elInToolName = /** @type{HTMLInputElement} */(document.getElementById("toolname-in")); this.elInToolArgs = /** @type{HTMLInputElement} */(document.getElementById("toolargs-in")); + this.elInUser.dataset.placeholder = this.elInUser.placeholder + this.validate_element(this.elInSystem, "system-in"); this.validate_element(this.elDivChat, "chat-div"); this.validate_element(this.elInUser, "user-in"); @@ -1284,11 +1286,14 @@ class MultiChatUI { chat.promote_tooltemp(content) } else { if (content.trim() == "") { - console.log(`WARN:SimpleChat:MCUI:${chatId}:HandleUserSubmit:Ignoring empty user input...`); + this.elInUser.placeholder = "dont forget to enter a message, before submitting to ai" return; } chat.add(new ChatMessageEx(new NSChatMessage(Roles.User, content))) } + if (this.elInUser.dataset.placeholder) { + this.elInUser.placeholder = this.elInUser.dataset.placeholder; + } this.chat_show(chat.chatId); this.elInUser.dataset.role = "" @@ -1405,6 +1410,9 @@ class MultiChatUI { * @param {string} chatId */ async handle_session_switch(chatId) { + if (this.elInUser.dataset.placeholder) { + this.elInUser.placeholder = this.elInUser.dataset.placeholder; + } let chat = this.simpleChats[chatId]; if (chat == undefined) { console.error(`ERRR:SimpleChat:MCUI:HandleSessionSwitch:${chatId} missing...`);