feat: hide stack quick-logger unless a poker session is live

Poll /session/data on load, every 10s, and on foreground; show the
stack box only when session.is_live, hide it otherwise (logging with no
live session just errors). Hidden by default until confirmed.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G796GsLCvJQKVN7hwV2cDx
This commit is contained in:
2026-06-30 05:55:33 +00:00
parent fb6b44a82e
commit 865834a8ae
+21 -1
View File
@@ -3,7 +3,7 @@
<head> <head>
<meta charset="UTF-8" /> <meta charset="UTF-8" />
<title>Lyra Core Chat</title> <title>Lyra Core Chat</title>
<link rel="stylesheet" href="style.css?v=7" /> <link rel="stylesheet" href="style.css?v=8" />
<!-- PWA --> <!-- PWA -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
<meta name="mobile-web-app-capable" content="yes" /> <meta name="mobile-web-app-capable" content="yes" />
@@ -252,13 +252,33 @@
} }
}); });
} }
// Only show the stack quick-logger when a poker session is actually live —
// otherwise logging just errors ("no live session").
function updateStackQuickVisibility() {
const box = document.getElementById("stackQuick");
if (!box) return;
fetch("/session/data", { cache: "no-store" })
.then(function (r) { return r.json(); })
.then(function (data) {
const live = !!(data && data.session && data.session.is_live);
box.style.display = live ? "flex" : "none";
})
.catch(function () { box.style.display = "none"; });
}
(function wireStackQuick() { (function wireStackQuick() {
const box = document.getElementById("stackQuick");
const btn = document.getElementById("stackQuickBtn"); const btn = document.getElementById("stackQuickBtn");
const inp = document.getElementById("stackQuickInput"); const inp = document.getElementById("stackQuickInput");
if (box) box.style.display = "none"; // hidden until a live session is confirmed
if (btn) btn.addEventListener("click", stackQuickLog); if (btn) btn.addEventListener("click", stackQuickLog);
if (inp) inp.addEventListener("keydown", function (e) { if (inp) inp.addEventListener("keydown", function (e) {
if (e.key === "Enter") { e.preventDefault(); stackQuickLog(); } if (e.key === "Enter") { e.preventDefault(); stackQuickLog(); }
}); });
updateStackQuickVisibility();
setInterval(updateStackQuickVisibility, 10000);
document.addEventListener("visibilitychange", function () {
if (!document.hidden) updateStackQuickVisibility();
});
})(); })();
function generateSessionId() { function generateSessionId() {