Files
skills/orchestrator/templates/page-load.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 af3555e88b feat(orchestrator): reveal withheld diff content under a passkey signature (019)
staged_diff masks only the secret rule hits and seals each masked file's clear patch apart; reviews and asks store the sealed patches next to their diff, delete them once the item leaves pending, and the hub sweeps orphans. POST /api/diffs/<kind>/<id>/reveal/sign and /reveal hand the clear patches to a signed request; page-diff.js offers Reveal per hidden file and Reveal all, keeps the clear text in the page only and forgets it once the item leaves the inbox. Requirement 019, unit, hub and e2e tests.

Accepted MEDUSA false positives (security.py accept after kvb-think-criticize, 2026-11-17): approval.py FTSCAN-231 WEB-SSRF RH005; permission_hook.py MM-SCAN-058 WEB-SSRF RH005; staged_diff.py SAST-ENV-001 AI-BACKDOOR-006 B603; hub.py MEX-SCAN-1167 INF-SCAN-589; page-load.js EXA002; hub_case.py TC001-TC009 INF-SCAN-2057/2206/2440/2457 EXA002 EXA006 PL002 B603 FTSC-SCAN-089.

🎯 Fix: 92 %
💥 Break: 4 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 88
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 19:04:35 +00:00

75 lines
2.0 KiB
JavaScript

let loadTicket = 0;
let appliedTicket = 0;
let loadsInFlight = 0;
async function load() {
loadTicket += 1;
const ticket = loadTicket;
loadsInFlight += 1;
const abort = new AbortController();
const timer = window.setTimeout(() => abort.abort(), STATE_TIMEOUT);
try {
const response = await fetch(`/api/state?${windowQuery()}`, {cache: "no-store", signal: abort.signal});
if (!response.ok) {
throw new Error(String(response.status));
}
const next = await response.json();
if (ticket < appliedTicket) {
return;
}
appliedTicket = ticket;
const previous = state.now;
const resumed = ui.offline;
state = next;
forgetRevealed();
ui.offline = false;
if (JSON.stringify(state.settings) !== settingsSig) {
adoptSettings(state.settings);
}
tuneMusic(FADE / 1000);
drawSky();
announce(resumed);
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 {
if (ticket > appliedTicket) {
ui.offline = true;
tick();
}
} finally {
window.clearTimeout(timer);
loadsInFlight -= 1;
}
}
function poll() {
if (!loadsInFlight) {
refresh();
}
}
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();
}
}