From 8214f9c244dcf21c25558dd281a38891e9d66dc4 Mon Sep 17 00:00:00 2001 From: 3nd3r Date: Sun, 12 Apr 2026 13:03:34 -0500 Subject: [PATCH] Enter key sends messages; admins can chat with Violet - Add keydown listener: Enter submits, Shift+Enter inserts newline - Allow admin users (even guests) to PM Violet --- app.py | 2 +- static/chat.js | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index 45a1954..b9c3ce9 100644 --- a/app.py +++ b/app.py @@ -601,7 +601,7 @@ def on_pm_message(data): # Route to AI if recipient is Violet if room.endswith(f":{AI_BOT_NAME.lower()}"): - if not user.get("user_id"): + if not user.get("user_id") and not user.get("is_admin"): emit("error", {"msg": "You must be registered to chat with Violet."}); return if not user.get("has_ai_access") and user.get("ai_messages_used", 0) >= AI_FREE_LIMIT: emit("pm_message", {"from": AI_BOT_NAME, "text": "ai_limit_reached", "room": room, "system": True}, to=sid) diff --git a/static/chat.js b/static/chat.js index a7efa8c..7acf933 100644 --- a/static/chat.js +++ b/static/chat.js @@ -428,6 +428,14 @@ messageForm.addEventListener("submit", async (e) => { messageInput.style.height = "auto"; }); +// Enter to send, Shift+Enter for newline +messageInput.addEventListener("keydown", (e) => { + if (e.key === "Enter" && !e.shiftKey) { + e.preventDefault(); + messageForm.requestSubmit(); + } +}); + // Auto-expand textarea messageInput.addEventListener("input", () => { messageInput.style.height = "auto";