From 593a09cf0da90cd4b2b261b18caa9b0e897a3d9e Mon Sep 17 00:00:00 2001 From: Dogfather Date: Thu, 5 Nov 2026 10:53:44 +0100 Subject: [PATCH] =?UTF-8?q?Was=20hab=20ich=20verpasst=3F=20=C3=9Cberblick?= =?UTF-8?q?=20f=C3=BCr=20Sp=C3=A4tkommer=20und=20nach=20L=C3=BCcken,=20KI-?= =?UTF-8?q?Satz=20nur=20mit=20fertigem=20Modell=20auf=20dem=20Ger=C3=A4t;?= =?UTF-8?q?=20Chat=20bleibt=20unten,=20wenn=20sich=20seine=20H=C3=B6he=20?= =?UTF-8?q?=C3=A4ndert?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 5.5 --- server/pruef-verpasst-blick.mjs | 272 ++++++++++++++++++++++++++++++ workspace/anleitung.html | 28 +-- workspace/anruf-probe.html | 10 +- workspace/app.webmanifest | 8 +- workspace/assets/css/verpasst.css | 21 +++ workspace/assets/js/nachholen.js | 7 + workspace/assets/js/verpasst.js | 169 +++++++++++++++++++ workspace/aufgaben.html | 38 ++--- workspace/automation.html | 32 ++-- workspace/befinden.html | 34 ++-- workspace/bereich.html | 48 +++--- workspace/bewerben.html | 38 ++--- workspace/bewerbungen.html | 36 ++-- workspace/buehne.html | 10 +- workspace/calls.html | 34 ++-- workspace/chat.html | 48 +++--- workspace/content.html | 34 ++-- workspace/crew-index.html | 12 +- workspace/crew.webmanifest | 8 +- workspace/dateien.html | 34 ++-- workspace/dogtags.html | 38 ++--- workspace/entwicklung.html | 36 ++-- workspace/fernbedienung.html | 20 +-- workspace/hilfe.html | 30 ++-- workspace/index.html | 10 +- workspace/kalender.html | 34 ++-- workspace/koppeln.html | 14 +- workspace/leistung.html | 32 ++-- workspace/manager-ziele.html | 30 ++-- workspace/material.html | 32 ++-- workspace/nachbericht.html | 20 +-- workspace/notizen.html | 28 +-- workspace/personen.html | 32 ++-- workspace/probesaal.html | 14 +- workspace/profil.html | 36 ++-- workspace/reaktion-foyer.html | 34 ++-- workspace/reaktion.html | 181 ++++++++++---------- workspace/rechte.html | 34 ++-- workspace/report.html | 36 ++-- workspace/scouting.html | 32 ++-- workspace/start.html | 40 ++--- workspace/startcheck.html | 34 ++-- workspace/steckbrief.html | 36 ++-- workspace/support.html | 32 ++-- workspace/tafel.html | 10 +- workspace/talente.html | 36 ++-- workspace/team.html | 32 ++-- workspace/teamlage.html | 34 ++-- workspace/teilen.html | 30 ++-- workspace/treff-moderation.html | 32 ++-- workspace/treff-regeln.html | 32 ++-- workspace/uebersicht.html | 32 ++-- workspace/unsere-seiten.html | 30 ++-- workspace/unterstuetzen.html | 32 ++-- workspace/werdegang.html | 32 ++-- workspace/willkommen.html | 2 +- workspace/wissen.html | 34 ++-- 57 files changed, 1313 insertions(+), 841 deletions(-) create mode 100644 server/pruef-verpasst-blick.mjs create mode 100644 workspace/assets/css/verpasst.css create mode 100644 workspace/assets/js/verpasst.js diff --git a/server/pruef-verpasst-blick.mjs b/server/pruef-verpasst-blick.mjs new file mode 100644 index 00000000..29ac5664 --- /dev/null +++ b/server/pruef-verpasst-blick.mjs @@ -0,0 +1,272 @@ +/* ===================================================================== + WAS HAB ICH VERPASST? (05.11.2026, Neuplan E13) + Spät kommen und Lücke: Knopf über der Schwelle (Gegenprobe darunter), + Überblick zählt richtig, meistbeantworteter Beitrag vorn, KI-Satz nur mit + fertigem Modell (Attrappe; Gegenprobe „downloadable“ lädt nichts). + DREI AUSGÄNGE: 0 in Ordnung · 1 Befund · 3 konnte nicht nachsehen. + Bilder: VP_BILDER= node server/pruef-verpasst-blick.mjs + ===================================================================== */ +import { mkdtempSync, rmSync, readFileSync } from "node:fs"; +import { tmpdir } from "node:os"; +import { join, dirname } from "node:path"; +import { fileURLToPath } from "node:url"; +import { request } from "node:http"; +import { createServer as httpsServer } from "node:https"; +import { zertifikatBauen } from "./helfer-openssl.mjs"; +import { notbremse } from "./helfer-notbremse.mjs"; +import { eigenerPort } from "./helfer-port.mjs"; + +const HIER = dirname(fileURLToPath(import.meta.url)); +const ordner = mkdtempSync(join(tmpdir(), "pruef-verpasst-")); +process.env.WORKSPACE_DB = join(ordner, "workspace.db"); + +const PORT = await eigenerPort(import.meta); +const HTTPS_PORT = await eigenerPort(import.meta, "pruef-verpasst-blick (HTTPS)", 1); +process.env.PORT = `${PORT}`; +process.env.SITE_ACCESS_SECRET = "lokaler-test"; +process.env.SITE_PUBLIC_LAUNCH_AT = "2020-01-01T00:00:00+01:00"; + +const express = (await import("express")).default; +/* Der Sitzungskeks ist `secure`. Der Vorbau unten spricht https, der + Server dahinter nicht -- ohne diesen Griff setzt er den Keks und + der Browser verwirft ihn. */ +const ec = express.response.cookie; +express.response.cookie = function (n, w, o) { return ec.call(this, n, w, { ...(o || {}), secure: false }); }; +await import("./index.js"); +notbremse(300_000, "pruef-verpasst-blick"); +await new Promise((r) => setTimeout(r, 1000)); + +const CREW = "crew.dogfather-universe.com"; + +/* ---------- Leute ------------------------------------------------------- */ +const { DatabaseSync } = await import("node:sqlite"); +const { scryptSync, randomBytes, createHmac } = await import("node:crypto"); +const d = new DatabaseSync(process.env.WORKSPACE_DB); +const kenn = randomBytes(32).toString("hex"); +d.prepare("INSERT INTO einstellungen (schluessel, wert, geaendert, von)" + + " VALUES (?,?,?,NULL) ON CONFLICT(schluessel) DO NOTHING") + .run("code_kennung_schluessel", kenn, new Date().toISOString()); +const ALT = new Date(Date.now() - 200 * 86400000).toISOString(); +function anlegen(name, rolle, code) { + const salt = randomBytes(16).toString("hex"); + const hash = scryptSync(code, salt, 64, + { N: 32768, r: 8, p: 1, maxmem: 96 * 1024 * 1024 }).toString("hex"); + d.prepare("INSERT INTO personen (name, rolle, code_hash, code_salt, code_n," + + " code_kennung, aktiv, erstellt) VALUES (?,?,?,?,?,?,1,?)") + .run(name, rolle, hash, salt, 32768, + createHmac("sha256", kenn).update(code).digest("hex"), ALT); +} +const CODES = { + admin: "CODE-M00-000001", hand: "CODE-M01-000001", + gast: "CODE-M02-000001", gast2: "CODE-M03-000001", +}; +/* VANVAN IST DIE RECHTE HAND und wird mitgemessen, nicht nur + DogFather: Filipe hat "nur ich und vanvan" gesagt, und ob die + zweite Haelfte davon stimmt, sieht man nur, wenn sie dabei ist. */ +anlegen("DogFather", "admin", CODES.admin); +anlegen("VanVan", "hand", CODES.hand); +anlegen("Nachtfalter", "gast", CODES.gast); +anlegen("Lenny", "gast", CODES.gast2); +d.close(); + +function roh(pfad, { method = "GET", keks = "", rumpf = null } = {}) { + return new Promise((fertig, schief) => { + const daten = rumpf === null ? null : Buffer.from(JSON.stringify(rumpf)); + const a = request({ + host: "127.0.0.1", port: PORT, path: pfad, method, + headers: { + Host: CREW, Origin: `https://${CREW}`, + ...(keks ? { Cookie: keks } : {}), + ...(daten ? { "Content-Type": "application/json", "Content-Length": daten.length } : {}), + }, + }, (antwort) => { + const teile = []; + antwort.on("data", (s) => teile.push(s)); + antwort.on("end", () => { + const text = Buffer.concat(teile).toString("utf8"); + let j = null; try { j = JSON.parse(text); } catch { /* kein JSON */ } + fertig({ code: antwort.statusCode, text, j, kopf: antwort.headers }); + }); + }); + a.on("error", schief); + if (daten) a.write(daten); + a.end(); + }); +} +async function anmelden(wer) { + const a = await roh("/workspace/api/anmelden", { + method: "POST", + rumpf: { rolle: wer === "gast2" ? "gast" : wer, code: CODES[wer], alter_ok: true }, + }); + return [].concat(a.kopf["set-cookie"] || []).map((z) => z.split(";")[0]).join("; "); +} +const k = { + admin: await anmelden("admin"), + hand: await anmelden("hand"), + gast: await anmelden("gast"), + gast2: await anmelden("gast2"), +}; + +/* ---------- Zaehlwerk --------------------------------------------------- */ +let fehler = 0; +let geprueft = 0; +const ok = (b, t) => { + geprueft++; + console.log((b ? " ok " : " FEHL ") + t); + if (!b) fehler++; +}; +function nichtNachsehbar(grund) { + console.log("\n -- NICHT NACHSEHBAR"); + console.log(` ${grund}`); + console.log(" Das ist KEIN Befund am Code -- es heisst nur, dass"); + console.log(" gerade niemand nachsehen konnte.\n"); + try { rmSync(ordner, { recursive: true, force: true }); } catch { /* egal */ } + process.exit(3); +} + +/* ---------- Die Buehne fuellen ------------------------------------------ */ +/* ZWEI STUECKE IN DER WARTESCHLANGE, EINES MIT TERMIN UND EINES OHNE. + Genau das ist die Aussage der linken Reihe ("was keinen hat, steht + unten"), und mit nur einem Eintrag liesse sie sich nicht messen. */ +for (const adresse of ["https://youtu.be/9bZkp7q19f0", + "https://www.youtube.com/watch?v=kJQP7kiw5Fk"]) { + const a = await roh("/workspace/api/reaktion/liste", { + method: "POST", keks: k.admin, rumpf: { video: adresse }, + }); + if (a.code >= 400) nichtNachsehbar(`Die Warteschlange nimmt nichts an (HTTP ${a.code}).`); +} +const liste0 = (await roh("/workspace/api/reaktion", { keks: k.admin })).j?.liste || []; +if (liste0.length !== 2) { + nichtNachsehbar(`In der Warteschlange stehen ${liste0.length} Stuecke statt 2.`); +} + +/* Der Termin liegt in der ZUKUNFT und wird relativ gerechnet. Ein + festes Datum waere eine Zeitbombe: Es ist richtig, bis der Kalender + es einholt -- und dann schlaegt "ueberfaellig" an, ohne dass etwas + kaputt ist. */ +{ + const a = await roh(`/workspace/api/reaktion/liste/${liste0[0].id}/wann`, { + method: "PUT", keks: k.admin, + rumpf: { wann: new Date(Date.now() + 3 * 86400000).toISOString() }, + }); + if (a.code >= 400) nichtNachsehbar(`Der Termin laesst sich nicht setzen (HTTP ${a.code}).`); +} +await roh("/workspace/api/reaktion", { + method: "PUT", keks: k.admin, + rumpf: { + titel: "Wir schauen den neuen Trailer", + video: "https://www.youtube.com/watch?v=dQw4w9WgXcQ", + beginnt_am: new Date(Date.now() + 7 * 60_000).toISOString(), + }, +}); + +/* ---------- Der Vorbau -------------------------------------------------- */ +const schluesselDatei = join(ordner, "p.key"); +const zertDatei = join(ordner, "p.crt"); +try { + zertifikatBauen(schluesselDatei, zertDatei, CREW); +} catch (f) { + nichtNachsehbar(`Kein Zertifikat zu bauen: ${f?.message}\n` + + " openssl liegt bei Git in mingw64/bin -- im System-PATH\n" + + " steht oft nur Git/cmd."); +} +const vorbau = httpsServer({ + key: readFileSync(schluesselDatei), cert: readFileSync(zertDatei), +}, (von, nach) => { + const weiter = request({ + host: "127.0.0.1", port: PORT, path: von.url, method: von.method, + headers: { ...von.headers, host: `${CREW}:${HTTPS_PORT}` }, + }, (antwort) => { + nach.writeHead(antwort.statusCode || 502, antwort.headers); + antwort.pipe(nach); + }); + weiter.on("error", () => { try { nach.writeHead(502); nach.end(); } catch { /* egal */ } }); + von.pipe(weiter); +}); +await new Promise((r) => vorbau.listen(HTTPS_PORT, "127.0.0.1", r)); +const BASIS = `https://${CREW}:${HTTPS_PORT}`; +for (const st of ["vorbereitung", "live"]) await roh("/workspace/api/reaktion/stand", { method: "POST", keks: k.admin, rumpf: { stand: st } }); +const standNun = (await roh("/workspace/api/reaktion", { keks: k.admin })).j?.stand; +if (standNun !== "live") nichtNachsehbar(`Die Sendung geht nicht live (${standNun}).`); +for (const [w, t] of [["gast", "Erster im Saal"], ["gast2", "Zweite Nachricht"]]) await roh("/workspace/api/reaktion/chat", { method: "POST", keks: k[w], rumpf: { text: t } }); + +let pw = null; +try { pw = await import("file:///C:/Users/qciga/Documents/Obelix/Analyse/node_modules/playwright/index.mjs"); } catch (f) { nichtNachsehbar(`Playwright fehlt: ${f?.message}`); } +const browser = await pw.chromium.launch({ args: [`--host-resolver-rules=MAP ${CREW} 127.0.0.1`, "--ignore-certificate-errors", "--use-fake-ui-for-media-stream", "--use-fake-device-for-media-stream", "--autoplay-policy=no-user-gesture-required"] }); +const BILDER = process.env.VP_BILDER || ""; +const warte = (ms) => new Promise((r) => setTimeout(r, ms)); +const konsole = []; +async function als(rolle, init) { + const kx = await browser.newContext({ viewport: { width: 1280, height: 800 }, ignoreHTTPSErrors: true }); + await kx.addCookies(k[rolle].split("; ").filter(Boolean).map((z) => { const [n, ...r] = z.split("="); return { name: n, value: r.join("="), domain: CREW, path: "/" }; })); + const s = await kx.newPage(); + s.on("pageerror", (f) => konsole.push(String(f?.message || f))); + s.on("console", (m) => { if (m.type() === "error" && !/compute-pressure|youtube|ytimg|googlevideo|livekit|ERR_|net::|NotAllowed|NotFound/i.test(m.text())) konsole.push(m.text()); }); + if (init) await s.addInitScript(init); + await s.goto(`${BASIS}/workspace/reaktion.html`, { waitUntil: "domcontentloaded" }); + await s.waitForSelector("body[data-stand]", { timeout: 20000 }); + await s.waitForTimeout(3000); + return s; +} +const sichtbar = (s, id) => s.evaluate((i) => { const e = document.getElementById(i); return !!e && !e.hidden && e.getBoundingClientRect().height > 0; }, id); + +/* Gegenprobe zuerst: nur zwei Beiträge vorher – kein „Verpasst?“. */ +const wenig = await als("gast2"); +ok(!(await sichtbar(wenig, "vp-knopf")), "bei zwei Beiträgen vorher gibt es kein „Verpasst?“ (unter der Schwelle)"); +await wenig.context().close(); + +/* Jetzt ist viel los: 18 Beiträge, auf einen wird zweimal geantwortet. */ +const texte = ["Der Trailer ist da!", "Wie lange noch?", "Gleich!", "Popcorn ist fertig", "Wer kommt noch?"]; +let frage = null; +for (let i = 0; i < 18; i++) { + const wer = i % 3 === 0 ? "admin" : "gast"; + const rumpf = { text: `${texte[i % texte.length]} (${i + 1})` }; + if (frage && (i === 6 || i === 9)) rumpf.antwort_auf = frage; + const a = await roh("/workspace/api/reaktion/chat", { method: "POST", keks: k[wer], rumpf }); + if (i === 4) frage = a.j?.id || a.j?.beitrag?.id || null; +} +if (!frage) { const l = (await roh("/workspace/api/reaktion/chat", { keks: k.admin })).j?.beitraege || []; frage = l.find((b) => /Wer kommt noch\? \(5\)/.test(b.text))?.id; } +ok(!!frage, `ein Beitrag zum Antworten ist da (#${frage})`); + +/* Mit einer Attrappe für Chromes Zusammenfasser (der Prüfbrowser hat Gemini Nano nicht). */ +const KI = () => { self.Summarizer = { availability: async () => "available", create: async () => ({ summarize: async (t) => (t.includes("Trailer") ? "Alle warten gespannt auf den Trailer, es gibt Popcorn." : "?"), destroy() {} }) }; }; +const viel = await als("gast2", KI); +ok(await sichtbar(viel, "vp-knopf"), "wer spät kommt, bekommt im Chat-Kopf „Verpasst?“"); +await viel.click("#vp-knopf"); +await warte(900); +const inhalt = await viel.evaluate(() => ({ satz: document.querySelector("#vp-inhalt .vp-satz")?.textContent, ki: document.getElementById("vp-ki")?.hidden ? "" : document.getElementById("vp-ki")?.textContent, beachtet: [...document.querySelectorAll("#vp-inhalt .vp-beitrag")].map((x) => x.textContent) })); +console.log(" Überblick:", JSON.stringify(inhalt)); +ok(/Bevor du kamst: 20 Beiträge von 3 Leuten/.test(inhalt.satz || "") && !/1 Minuten/.test(inhalt.satz || ""), `der Überblick zählt richtig („${inhalt.satz}“)`); +ok(inhalt.beachtet.length >= 1 && /Wer kommt noch\? \(5\)/.test(inhalt.beachtet[0]) && /2 Antworten/.test(inhalt.beachtet[0]), `vorn steht der Beitrag mit den meisten Antworten (${inhalt.beachtet[0]})`); +ok(/auf deinem Gerät zusammengefasst/.test(inhalt.ki) && /Trailer/.test(inhalt.ki), `kann Chrome zusammenfassen, steht ein KI-Satz darüber (${inhalt.ki})`); +const lage = await viel.evaluate(() => { const t = document.getElementById("vp-tafel").getBoundingClientRect(); const s = document.getElementById("schiene").getBoundingClientRect(); return t.left >= s.left - 1 && t.right <= s.right + 1; }); +ok(lage, "die Tafel lebt in der Chat-Spalte, nicht über dem Bild"); +if (BILDER) await viel.locator("#vp-tafel").screenshot({ path: `${BILDER}/verpasst-1280.png` }); +await viel.keyboard.press("Escape"); +ok(!(await sichtbar(viel, "vp-tafel")) && !(await sichtbar(viel, "vp-knopf")), "gelesen: Tafel und Knopf gehen weg"); + +/* Gegenprobe KI: „downloadable“ heißt NICHT laden – der Satz fehlt einfach. */ +const ohneKi = await als("gast2", () => { self.Summarizer = { availability: async () => "downloadable", create: async () => { window.__geladen = true; return { summarize: async () => "x" }; } }; }); +await ohneKi.click("#vp-knopf"); +await warte(900); +const ok2 = await ohneKi.evaluate(() => ({ ki: document.getElementById("vp-ki")?.hidden, geladen: !!window.__geladen, satz: !!document.querySelector("#vp-inhalt .vp-satz") })); +ok(ok2.ki === true && !ok2.geladen && ok2.satz, `ohne fertiges Modell: kein KI-Satz, nichts geladen, der Überblick steht trotzdem (${JSON.stringify(ok2)})`); + +/* Eine Lücke: weg, in der Zeit wird geschrieben, wieder da. */ +await viel.evaluate(() => { window.__verpasstLueckeMs = 0; window.dispatchEvent(new Event("saal:strom-weg")); }); +await warte(300); +for (let i = 0; i < 6; i++) await roh("/workspace/api/reaktion/chat", { method: "POST", keks: k.gast, rumpf: { text: `Während der Lücke ${i + 1}` } }); +await warte(300); +await viel.evaluate(() => window.dispatchEvent(new Event("saal:strom-auf"))); +await warte(900); +ok(await sichtbar(viel, "vp-knopf"), "nach einer Lücke mit genug Beiträgen kommt „Verpasst?“ wieder"); +await viel.click("#vp-knopf"); +await warte(900); +const l2 = await viel.evaluate(() => document.querySelector("#vp-inhalt .vp-satz")?.textContent || ""); +ok(/Während du weg warst: 6 Beiträge/.test(l2), `… und zählt nur die Lücke („${l2}“)`); +ok(!konsole.length, `keine Fehler in der Konsole (${konsole.slice(0, 3).join(" | ")})`); +await browser.close(); +vorbau.close(); +console.log(`\n${geprueft} Pruefungen, ${fehler} Fehler`); +try { rmSync(ordner, { recursive: true, force: true }); } catch { /* egal */ } +process.exit(fehler ? 1 : 0); diff --git a/workspace/anleitung.html b/workspace/anleitung.html index 787e5ca0..c1debd1f 100644 --- a/workspace/anleitung.html +++ b/workspace/anleitung.html @@ -7,17 +7,17 @@ - - - - - + + + + + - - + + @@ -289,16 +289,16 @@ Und anleitung.js braucht es doppelt: Symbol, Farbe, Name und Adresse jeder Karte kommen von dort, nicht vom Server. --> - + - - - - - - + + + + + + diff --git a/workspace/anruf-probe.html b/workspace/anruf-probe.html index 245c21ed..20a2dfe5 100644 --- a/workspace/anruf-probe.html +++ b/workspace/anruf-probe.html @@ -16,8 +16,8 @@ verdeckt. Gefunden hat es pruef-struktur. Richtig sind `gate.css` (die Farbwerte des Hauses) und `haus.css`. --> - - + + - +