Files
skills/orchestrator/templates/page-load.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 07d28a62c6 fix(orchestrator): keep polling while text stays selected
The hub page skipped every 10 s state poll while any text was selected, so operator rows that operator.py run had closed stayed on screen until the selection ended (2026-11-12: no /api/state from 09:29 to 09:54 while the CLI closed 19 rows). A selection now holds the poll back for at most 20 s, and returning to the window reloads at once.

🎯 Fix: 90 %
💥 Break: 3 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 87
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 10:20:31 +00:00

49 lines
1.4 KiB
JavaScript

async function load() {
try {
const response = await fetch(`/api/state?${windowQuery()}`, {cache: "no-store"});
if (!response.ok) {
throw new Error(String(response.status));
}
const next = await response.json();
const previous = state.now;
state = next;
ui.offline = false;
if (JSON.stringify(state.settings) !== settingsSig) {
adoptSettings(state.settings);
}
tuneMusic(FADE / 1000);
drawSky();
announce();
render(false);
drawTime();
drawAgent();
drawStream();
if (motion.current.size === 0 || ui.asOf !== motion.asOf) {
const first = motion.current.size === 0;
motion.asOf = ui.asOf;
relayout(first ? 0 : ui.playing ? 450 : MOVE);
}
pulses(state.radio.filter((row) => row.ts > previous));
} catch {
ui.offline = true;
tick();
}
}
const SELECTION_HOLD = 20000;
let selectedSince = 0;
function refresh() {
const selected = String(window.getSelection()).length > 0;
selectedSince = selected ? selectedSince || Date.now() : 0;
if (!ui.busy && !ui.playing && !document.hidden && (!selected || Date.now() - selectedSince >= SELECTION_HOLD)) {
load();
}
}
function follow() {
if (ui.screen === "stream" && live() && !document.hidden) {
fetchEvents();
}
}