Files
skills/orchestrator/templates/page-alerts.js
T
Kevin Veen-BirkenbachandClaude Opus 5.5 a388c6ef77 fix(orchestrator): S1 fit, rename once, Deutschlandfunk e2e, squelch, tree cause
Requirement 001 phase 6, S1:

- Fit: Agents and Artifacts in a graph view fill the window from 861 px
  up (body.fit flex column); the e2e walk probes #agents/orbit at every
  width for a page no taller than the window.
- Rename once: a session seen under two names by one source (two claims)
  flipped its name on every state build, so the Stream logged a rename
  each poll. Names.observe keeps only the newest sighting per session
  and source, and the timeline emits each (session, before, after) pair
  once.
- Deutschlandfunk: root cause was the signed media-src, which never
  listed the redirect target f111.rndfnk.com that st01.sslstream.dlf.de
  answers with (fixed in ba97f7c). The e2e now replays that chain, a
  302 from one https origin to a second, in Chromium and Firefox, with
  self-signed throwaway certificates the drivers accept.
- Squelch: a settings slider 0..1 scales every tone; at 0 no beep plays,
  music on or off (Voice.beep skips a silent tone). Stored settings
  without the key load with 1.0.
- Tree: the missing tree file error names `pkgmgr branch tree` and the
  release and install step that makes the timer write it.

Evidence: make test 655 OK, ruff and markdownlint clean
(/tmp/s1-make-test-1.log); e2e 17 OK, none skipped (/tmp/s1-e2e-3.log);
MEDUSA 14 files, 0 findings.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-08 13:37:02 +00:00

79 lines
3.7 KiB
JavaScript

function play(kind, volume) {
const sound = context();
if (!sound) {
return;
}
const level = Math.max(volume * 0.5, 0.0002);
duck(Math.max(...TONES[kind].map(([, at, length]) => at + length)));
for (const [frequency, at, length] of TONES[kind]) {
const oscillator = sound.createOscillator();
const gain = sound.createGain();
const start = sound.currentTime + at;
oscillator.type = kind === "mayday" ? "square" : "sine";
oscillator.frequency.value = frequency;
gain.gain.setValueAtTime(0.0001, start);
gain.gain.exponentialRampToValueAtTime(level, start + 0.02);
gain.gain.exponentialRampToValueAtTime(0.0001, start + length);
oscillator.connect(gain).connect(sound.destination);
oscillator.start(start);
oscillator.stop(start + length + 0.05);
}
}
function notifyLabel() {
const button = document.getElementById("notify");
if (!button) {
return;
}
const permission = "Notification" in window ? Notification.permission : "unsupported";
const labels = {granted: "Benachrichtigungen an", denied: "Benachrichtigungen blockiert", default: "Benachrichtigungen aktivieren", unsupported: "Benachrichtigungen fehlen im Browser"};
relabel(button, "bi-bell", labels[permission] || labels.default);
button.disabled = permission !== "default";
}
async function askNotify() {
if ("Notification" in window) {
await Notification.requestPermission();
}
notifyLabel();
}
function announce() {
const alarms = new Map(alarmRows().map((row) => [`${row.ts}|${row.from}`, row]));
const radio = new Set(state.radio.map((row) => `${row.ts}|${row.from}|${row.text.slice(0, 40)}`));
if (known.inbox !== null && live()) {
const fresh = state.inbox.filter((item) => !known.inbox.has(keyOf(item)));
const newAlarms = [...alarms].filter(([key]) => !known.alarms.has(key)).map(([, row]) => row);
const newRadio = state.radio.filter((row) => !known.radio.has(`${row.ts}|${row.from}|${row.text.slice(0, 40)}`));
const direct = newRadio.filter((row) => row.to.includes(HUMAN));
const present = {mayday: newAlarms.length > 0, review: fresh.some((item) => item.kind !== "operator"), direct: direct.length > 0, radio: newRadio.length > 0};
const kind = Voice.beep(present, settings, SOUND_KINDS.map(([id]) => id));
if (kind) {
play(kind, loudness(kind));
}
const lead = kind ? Math.max(...TONES[kind].map(([, at, length]) => at + length)) : 0;
window.setTimeout(() => speakRows(newRadio), lead * 1000);
if (settings.notify && "Notification" in window && Notification.permission === "granted") {
for (const row of newAlarms) {
new Notification(`${row.class === "mayday" ? "Mayday" : "Pan-Pan"} von ${dash(row.from)}`, {body: row.text.slice(0, 200), tag: `alarm-${row.ts}`, requireInteraction: row.class === "mayday"});
}
for (const item of fresh) {
new Notification(`${ITEM_LABELS[item.kind]} wartet`, {body: item.title.slice(0, 200), tag: `item-${keyOf(item)}`, requireInteraction: item.kind === "ask"});
}
for (const row of direct) {
new Notification(`Funk von ${dash(row.from)}`, {body: row.text.slice(0, 200), tag: `direct-${row.ts}`});
}
}
}
known.inbox = new Set(state.inbox.map(keyOf));
known.alarms = new Set(alarms.keys());
known.radio = radio;
for (const batch of state.pending) {
if (!known.batches.has(batch.id)) {
known.batches.add(batch.id);
const source = batch.source.startsWith("rule:") ? "Regel" : "Freigabe";
undoToast(batch, `${source}: ${batch.items.map((item) => short(item.title)).join(", ")}`);
}
}
}