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 # Configuration
STATUS_FILE = Path(__file__).parent / "status.json" STATUS_FILE = Path(__file__).parent / "status.json"
DEFAULT_NOTIFY_TTL = 10 # Default TTL for Priority 3 (Notify) events 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 CELEBRATION_DURATION = 5 # Seconds to show celebration after recovery
IDLE_EXPRESSION_CHANCE = 0.15 # Chance of a brief blink/wink on wake IDLE_EXPRESSION_CHANCE = 0.15 # Chance of a brief blink/wink on wake
DEFAULT_NOTIFY_DURATION = 5 # Default duration for /notify events DEFAULT_NOTIFY_DURATION = 5 # Default duration for /notify events
@@ -230,11 +231,13 @@ def post_event():
"timestamp": time.time(), "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: if "ttl" in data:
event["ttl"] = time.time() + int(data["ttl"]) event["ttl"] = time.time() + int(data["ttl"])
elif priority == 3: elif priority == 3:
event["ttl"] = time.time() + DEFAULT_NOTIFY_TTL event["ttl"] = time.time() + DEFAULT_NOTIFY_TTL
else:
event["ttl"] = time.time() + DEFAULT_EVENT_TTL
with events_lock: with events_lock:
active_events[event_id] = event active_events[event_id] = event

View File

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