Fix Violet PM: echo user message + add session restore on refresh

This commit is contained in:
3nd3r 2026-04-12 13:33:46 -05:00
parent 1d6413cfd6
commit 389415f04d
2 changed files with 22 additions and 6 deletions

3
app.py
View File

@ -620,6 +620,9 @@ def on_pm_message(data):
emit("pm_message", {"from": AI_BOT_NAME, "text": "ai_limit_reached", "room": room, "system": True}, to=sid)
return
# Echo the user's own message back so it appears in their chat
emit("pm_message", payload, to=sid)
transit_key = data.get("transit_key", "")
if not all([ciphertext, nonce_val, transit_key]):
# Plaintext fallback for admins without crypto keys

View File

@ -118,12 +118,25 @@ joinForm.addEventListener("submit", async (e) => {
window.addEventListener("DOMContentLoaded", () => {
const token = localStorage.getItem("sexychat_token");
if (token) {
// We have a token, notify the join screen but wait for user to click "Enter"
// to derive crypto key if they want to. Actually, for UX, if we have a token
// we can try a "restore" join which might skip password entry.
// But for encryption, we NEED that password to derive the key.
// Let's keep it simple: if you have a token, you still need to log in to
// re-derive your E2E key.
// Auto-restore session from stored JWT
joinBtn.disabled = true;
joinBtn.innerText = "Restoring session...";
socket.connect();
socket.emit("join", { mode: "restore" });
// If restore fails, reset the form so user can log in manually
const restoreTimeout = setTimeout(() => {
joinBtn.disabled = false;
joinBtn.innerText = "Enter the Room";
}, 5000);
const origJoined = socket.listeners("joined");
socket.once("joined", () => clearTimeout(restoreTimeout));
socket.once("error", () => {
clearTimeout(restoreTimeout);
joinBtn.disabled = false;
joinBtn.innerText = "Enter the Room";
});
}
});