Fix: event TTL and version display - add default TTL for priority 1/2 events, fetch fresh state after version tap

This commit is contained in:
2026-02-26 19:59:03 -06:00
parent aaae20281d
commit dbba288d24
2 changed files with 14 additions and 12 deletions

View File

@@ -19,6 +19,7 @@ ROOT_DIR = Path(__file__).parent
# Configuration
STATUS_FILE = Path(__file__).parent / "status.json"
DEFAULT_NOTIFY_TTL = 10 # Default TTL for Priority 3 (Notify) events
DEFAULT_EVENT_TTL = 60 # Default TTL for Priority 1/2 events without explicit TTL
CELEBRATION_DURATION = 5 # Seconds to show celebration after recovery
IDLE_EXPRESSION_CHANCE = 0.15 # Chance of a brief blink/wink on wake
DEFAULT_NOTIFY_DURATION = 5 # Default duration for /notify events
@@ -230,11 +231,13 @@ def post_event():
"timestamp": time.time(),
}
# Apply TTL if provided, or use default for Priority 3 (Notify)
# Apply TTL if provided, or use default based on priority
if "ttl" in data:
event["ttl"] = time.time() + int(data["ttl"])
elif priority == 3:
event["ttl"] = time.time() + DEFAULT_NOTIFY_TTL
else:
event["ttl"] = time.time() + DEFAULT_EVENT_TTL
with events_lock:
active_events[event_id] = event

View File

@@ -216,7 +216,7 @@
<script>
const emoteEl = document.getElementById("emote");
const messageEl = document.getElementById("message");
const VERSION = "v2.3.0";
const VERSION = "v2.3.1";
// Sound system
let audioCtx = null;
@@ -480,16 +480,15 @@
messageEl.textContent = `Kao ${VERSION}`;
playReactSound();
// Return to normal after 1.5s
setTimeout(() => {
if (lastData) {
updateDisplay(lastData);
} else {
emoteEl.textContent = prevEmote;
emoteEl.style.color = prevColor;
emoteEl.className = prevClass;
messageEl.textContent = prevMsg;
}
// Return to normal after 1.5s - fetch fresh state
setTimeout(async () => {
try {
const resp = await fetch("/status");
if (resp.ok) {
const freshData = await resp.json();
updateDisplay(freshData);
}
} catch (_) {}
isReacting = false;
}, 1500);
}