JuanCS-Dev commited on
Commit
53e94dc
·
verified ·
1 Parent(s): 11a99ef

feat: O3b Co-Streamer tab

Browse files
dashboard/features/costreamer/controller.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // dashboard/features/costreamer/controller.js
2
+ // O3b — Co-Streamer tab controller. Read-side renders from the live snapshot
3
+ // (render.js); write-side fires the co-streamer actions that previously had NO
4
+ // UI: POST /api/voice/say (first UI) and POST /api/segments/run (first UI).
5
+ import { fetchWithTimeout } from "../shared/api.js";
6
+ import { renderCostreamer } from "./render.js";
7
+
8
+ const TIMEOUT_MS = 8000;
9
+
10
+ async function postJson(path, body) {
11
+ const res = await fetchWithTimeout(
12
+ path,
13
+ {
14
+ method: "POST",
15
+ headers: { "Content-Type": "application/json" },
16
+ body: JSON.stringify(body),
17
+ },
18
+ TIMEOUT_MS,
19
+ );
20
+ return res;
21
+ }
22
+
23
+ export function createCostreamerController({ els, emitReact }) {
24
+ const react = (type) => {
25
+ if (typeof emitReact === "function") emitReact(type);
26
+ };
27
+
28
+ function bindEvents() {
29
+ // Make Byte speak (first UI for /api/voice/say).
30
+ if (els.sayBtn && els.sayInput) {
31
+ els.sayBtn.addEventListener("click", async () => {
32
+ const text = String(els.sayInput.value || "").trim();
33
+ if (!text) return;
34
+ els.sayBtn.disabled = true;
35
+ try {
36
+ await postJson("./api/voice/say", { text, source: "operator" });
37
+ els.sayInput.value = "";
38
+ react("voice");
39
+ if (els.sayFeedback) els.sayFeedback.textContent = "Byte vai falar.";
40
+ } catch (e) {
41
+ if (els.sayFeedback) els.sayFeedback.textContent = "Falhou ao enviar.";
42
+ } finally {
43
+ els.sayBtn.disabled = false;
44
+ }
45
+ });
46
+ }
47
+
48
+ // Run a segment (first UI for /api/segments/run) — delegated on the list.
49
+ if (els.segments) {
50
+ els.segments.addEventListener("click", async (e) => {
51
+ const btn = e.target.closest(".cs-seg");
52
+ if (!btn) return;
53
+ const segment = btn.dataset.segment;
54
+ if (!segment) return;
55
+ btn.disabled = true;
56
+ try {
57
+ await postJson("./api/segments/run", { segment });
58
+ react("segment");
59
+ } catch (_e) {
60
+ /* feedback is the mascot + the next snapshot */
61
+ } finally {
62
+ btn.disabled = false;
63
+ }
64
+ });
65
+ }
66
+ }
67
+
68
+ return {
69
+ bindEvents,
70
+ renderFromSnapshot(snap) {
71
+ if (snap) renderCostreamer(els, snap);
72
+ },
73
+ };
74
+ }
dashboard/features/costreamer/render.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // dashboard/features/costreamer/render.js
2
+ // O3b — the Co-Streamer tab read-side: pure models derived from the live ops
3
+ // snapshot (/api/ops/stream), then SANITIZED DOM rendering (textContent only).
4
+ // Surfaces what the Byte actually does: voice, vision, segments, regulars,
5
+ // highlights, churn. Honest: each model reports only real snapshot fields.
6
+
7
+ export function voiceModel(snap) {
8
+ const v = (snap && snap.voice) || {};
9
+ const messages = Array.isArray(v.messages) ? v.messages : [];
10
+ return {
11
+ ready: messages.length > 0 || v.provider != null,
12
+ provider: v.provider || null,
13
+ queue: messages.slice(-6).map((m) => ({
14
+ text: String(m.text || m.utterance || ""),
15
+ source: String(m.source || ""),
16
+ })),
17
+ // commentary is the vision->voice bridge, surfaced by filtering the queue.
18
+ commentary: messages.filter((m) => String(m.source || "") === "commentary").length,
19
+ };
20
+ }
21
+
22
+ export function visionModel(snap) {
23
+ const vis = (snap && snap.vision) || {};
24
+ const frames = Number(vis.frame_count || 0);
25
+ return { active: frames > 0, frames, lastIngestAt: vis.last_ingest_at || null };
26
+ }
27
+
28
+ export function segmentsModel(snap) {
29
+ const s = (snap && snap.segments) || {};
30
+ return Array.isArray(s.segments) ? s.segments.map(String) : [];
31
+ }
32
+
33
+ export function regularsModel(snap) {
34
+ const r = (snap && snap.regulars) || {};
35
+ return {
36
+ known: Number(r.known_viewers || 0),
37
+ regulars: Number(r.regulars || 0),
38
+ top: Array.isArray(r.top) ? r.top.slice(0, 5) : [],
39
+ };
40
+ }
41
+
42
+ export function highlightsModel(snap) {
43
+ const h = (snap && snap.highlights) || {};
44
+ return {
45
+ throttled: Boolean(h.throttled),
46
+ cooldown: Number(h.cooldown_seconds || 0),
47
+ pipelineEnabled: Boolean(h.clip_pipeline_enabled),
48
+ };
49
+ }
50
+
51
+ export function churnModel(snap) {
52
+ const c = (snap && snap.churn) || {};
53
+ const risk = c.risk || c.level || (c.at_risk != null ? (c.at_risk ? "alto" : "baixo") : null);
54
+ return { risk: risk != null ? String(risk) : null, raw: c };
55
+ }
56
+
57
+ // ---- Sanitized DOM helpers ----
58
+ function setText(el, text) {
59
+ if (el) el.textContent = text;
60
+ }
61
+ function list(el, items, build) {
62
+ if (!el) return;
63
+ el.replaceChildren();
64
+ for (const it of items) el.appendChild(build(it));
65
+ }
66
+
67
+ /** Render every co-streamer section into its element. DOM build is sanitized. */
68
+ export function renderCostreamer(els, snap, doc) {
69
+ const d = doc || document;
70
+ const span = (cls, text) => {
71
+ const e = d.createElement("span");
72
+ e.className = cls;
73
+ e.textContent = text;
74
+ return e;
75
+ };
76
+
77
+ const voice = voiceModel(snap);
78
+ setText(els.voiceStatus, voice.ready ? `TTS: ${voice.provider || "ativo"}` : "TTS: sem áudio");
79
+ list(els.voiceQueue, voice.queue, (m) => {
80
+ const li = d.createElement("li");
81
+ li.appendChild(span("cs-src", m.source || "byte"));
82
+ li.appendChild(span("cs-line", m.text));
83
+ return li;
84
+ });
85
+ setText(els.commentary, `comentários por visão: ${voice.commentary}`);
86
+
87
+ const vision = visionModel(snap);
88
+ setText(els.visionStatus, vision.active ? `visão ativa · ${vision.frames} frames` : "visão offline");
89
+
90
+ list(els.segments, segmentsModel(snap), (name) => {
91
+ const li = d.createElement("li");
92
+ const btn = d.createElement("button");
93
+ btn.type = "button";
94
+ btn.className = "btn btn-secondary cs-seg";
95
+ btn.dataset.segment = name;
96
+ btn.textContent = name;
97
+ li.appendChild(btn);
98
+ return li;
99
+ });
100
+
101
+ const reg = regularsModel(snap);
102
+ setText(els.regulars, `${reg.known} vistos · ${reg.regulars} regulars`);
103
+ list(els.regularsTop, reg.top, (r) => {
104
+ const li = d.createElement("li");
105
+ li.appendChild(span("cs-user", String(r.user || "")));
106
+ li.appendChild(span("cs-visits", `${r.visits || 0}×`));
107
+ return li;
108
+ });
109
+
110
+ const hl = highlightsModel(snap);
111
+ setText(
112
+ els.highlights,
113
+ hl.pipelineEnabled
114
+ ? hl.throttled
115
+ ? `em cooldown (${Math.round(hl.cooldown)}s)`
116
+ : "pronto"
117
+ : "pipeline de clipes off",
118
+ );
119
+
120
+ const churn = churnModel(snap);
121
+ setText(els.churn, churn.risk ? `risco de churn: ${churn.risk}` : "sem sinal de churn");
122
+ }
dashboard/index.html CHANGED
@@ -135,6 +135,18 @@
135
  >
136
  Operation
137
  </button>
 
 
 
 
 
 
 
 
 
 
 
 
138
  <button
139
  id="dashboardTabIntelligenceBtn"
140
  class="dashboard-tab-btn"
@@ -207,6 +219,64 @@
207
  <div id="operationEventsContainer"></div>
208
  </section>
209
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  <section
211
  id="dashboardTabIntelligencePanel"
212
  class="dashboard-tab-panel"
 
135
  >
136
  Operation
137
  </button>
138
+ <button
139
+ id="dashboardTabCostreamerBtn"
140
+ class="dashboard-tab-btn"
141
+ type="button"
142
+ role="tab"
143
+ aria-selected="false"
144
+ aria-controls="dashboardTabCostreamerPanel"
145
+ data-dashboard-tab="costreamer"
146
+ tabindex="-1"
147
+ >
148
+ Co-Streamer
149
+ </button>
150
  <button
151
  id="dashboardTabIntelligenceBtn"
152
  class="dashboard-tab-btn"
 
219
  <div id="operationEventsContainer"></div>
220
  </section>
221
 
222
+ <section
223
+ id="dashboardTabCostreamerPanel"
224
+ class="dashboard-tab-panel"
225
+ role="tabpanel"
226
+ aria-labelledby="dashboardTabCostreamerBtn"
227
+ data-dashboard-tab-panel="costreamer"
228
+ hidden
229
+ >
230
+ <header class="dashboard-tab-intro">
231
+ <p class="dashboard-tab-kicker">Co-Streamer</p>
232
+ <h2>Controle do Byte ao vivo</h2>
233
+ <p>Voz, visão, segmentos, regulars, highlights e overlays — tudo que o Byte faz, num lugar. Atualiza pelo stream em tempo real.</p>
234
+ </header>
235
+ <div class="costreamer-grid">
236
+ <article class="panel">
237
+ <h3>Voz / TTS</h3>
238
+ <p id="csVoiceStatus" class="cs-status">—</p>
239
+ <div class="cs-say">
240
+ <input id="csSayInput" type="text" placeholder="Fazer o Byte falar…" aria-label="Texto pra o Byte falar" />
241
+ <button id="csSayBtn" type="button" class="btn btn-primary">Falar</button>
242
+ </div>
243
+ <p id="csSayFeedback" class="cs-feedback" role="status"></p>
244
+ <ul id="csVoiceQueue" class="cs-queue" aria-label="Fila de voz"></ul>
245
+ </article>
246
+ <article class="panel">
247
+ <h3>Visão</h3>
248
+ <p id="csVisionStatus" class="cs-status">—</p>
249
+ <p id="csCommentary" class="cs-status">—</p>
250
+ <a class="btn btn-secondary" href="/capture" target="_blank" rel="noopener">Abrir captura →</a>
251
+ </article>
252
+ <article class="panel">
253
+ <h3>Segmentos</h3>
254
+ <ul id="csSegments" class="cs-segments" aria-label="Segmentos disponíveis"></ul>
255
+ </article>
256
+ <article class="panel">
257
+ <h3>Regulars</h3>
258
+ <p id="csRegulars" class="cs-status">—</p>
259
+ <ul id="csRegularsTop" class="cs-top" aria-label="Top regulars"></ul>
260
+ </article>
261
+ <article class="panel">
262
+ <h3>Highlights</h3>
263
+ <p id="csHighlights" class="cs-status">—</p>
264
+ </article>
265
+ <article class="panel">
266
+ <h3>Churn</h3>
267
+ <p id="csChurn" class="cs-status">—</p>
268
+ </article>
269
+ <article class="panel">
270
+ <h3>Overlays (OBS)</h3>
271
+ <div class="cs-overlays">
272
+ <a class="btn btn-secondary" href="/voice" target="_blank" rel="noopener">/voice</a>
273
+ <a class="btn btn-secondary" href="/avatar" target="_blank" rel="noopener">/avatar</a>
274
+ <a class="btn btn-secondary" href="/recap" target="_blank" rel="noopener">/recap</a>
275
+ </div>
276
+ </article>
277
+ </div>
278
+ </section>
279
+
280
  <section
281
  id="dashboardTabIntelligencePanel"
282
  class="dashboard-tab-panel"
dashboard/main.js CHANGED
@@ -20,6 +20,30 @@ import { deriveOpsMood } from "./features/mascot/ops-signals.js";
20
  import { createPresence } from "./features/studio/presence.js";
21
  import { spark } from "./features/studio/sparks.js";
22
  import { FOCUS_KEY, isFocusHotkey, applyFocus, resolveFocus } from "./features/navigation/focus.js";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
23
 
24
  // O2 — Focus mode: collapse to the essentials (Byte presence + pending actions)
25
  // for at-a-glance live use. Toggle via the header button or the "f" hotkey.
@@ -112,6 +136,8 @@ function connectOpsStream() {
112
  async function bootstrapDashboard() {
113
  initOpsMascot();
114
  initFocusMode();
 
 
115
  connectOpsStream();
116
  const obsEls = getObservabilityElements();
117
  const ctrlEls = getChannelControlElements();
@@ -243,6 +269,11 @@ async function bootstrapDashboard() {
243
  } catch (_e) {
244
  /* isolated */
245
  }
 
 
 
 
 
246
  };
247
  }
248
 
 
20
  import { createPresence } from "./features/studio/presence.js";
21
  import { spark } from "./features/studio/sparks.js";
22
  import { FOCUS_KEY, isFocusHotkey, applyFocus, resolveFocus } from "./features/navigation/focus.js";
23
+ import { createCostreamerController } from "./features/costreamer/controller.js";
24
+
25
+ // O3b: the Co-Streamer tab — surfaces voice/vision/segments/regulars/highlights/
26
+ // churn from the live snapshot and fires voice/say + segments/run (first UI).
27
+ function buildCostreamer() {
28
+ const $ = (id) => document.getElementById(id);
29
+ return createCostreamerController({
30
+ els: {
31
+ voiceStatus: $("csVoiceStatus"),
32
+ voiceQueue: $("csVoiceQueue"),
33
+ commentary: $("csCommentary"),
34
+ visionStatus: $("csVisionStatus"),
35
+ segments: $("csSegments"),
36
+ regulars: $("csRegulars"),
37
+ regularsTop: $("csRegularsTop"),
38
+ highlights: $("csHighlights"),
39
+ churn: $("csChurn"),
40
+ sayInput: $("csSayInput"),
41
+ sayBtn: $("csSayBtn"),
42
+ sayFeedback: $("csSayFeedback"),
43
+ },
44
+ emitReact: emitByteReact,
45
+ });
46
+ }
47
 
48
  // O2 — Focus mode: collapse to the essentials (Byte presence + pending actions)
49
  // for at-a-glance live use. Toggle via the header button or the "f" hotkey.
 
136
  async function bootstrapDashboard() {
137
  initOpsMascot();
138
  initFocusMode();
139
+ const costreamerController = buildCostreamer();
140
+ costreamerController.bindEvents();
141
  connectOpsStream();
142
  const obsEls = getObservabilityElements();
143
  const ctrlEls = getChannelControlElements();
 
269
  } catch (_e) {
270
  /* isolated */
271
  }
272
+ try {
273
+ costreamerController.renderFromSnapshot(snap);
274
+ } catch (_e) {
275
+ /* isolated */
276
+ }
277
  };
278
  }
279
 
dashboard/styles/mascot.css CHANGED
@@ -304,6 +304,75 @@
304
  }
305
  }
306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
307
  /* ---- O2 Focus mode: collapse to Byte presence + pending actions ---- */
308
  body.focus-mode #heroChannelContainer,
309
  body.focus-mode .dashboard-summary-strip,
 
304
  }
305
  }
306
 
307
+ /* ---- O3b Co-Streamer tab ---- */
308
+ .costreamer-grid {
309
+ display: grid;
310
+ grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
311
+ gap: var(--spacing-4, 16px);
312
+ }
313
+ .costreamer-grid .panel h3 {
314
+ margin: 0 0 8px;
315
+ font-size: 0.95rem;
316
+ }
317
+ .cs-status {
318
+ margin: 4px 0;
319
+ color: var(--text-muted);
320
+ font-family: var(--font-family-mono, monospace);
321
+ font-size: 0.82rem;
322
+ }
323
+ .cs-say {
324
+ display: flex;
325
+ gap: 8px;
326
+ margin: 8px 0;
327
+ }
328
+ .cs-say input {
329
+ flex: 1 1 auto;
330
+ min-width: 0;
331
+ }
332
+ .cs-feedback {
333
+ margin: 2px 0;
334
+ font-size: 0.75rem;
335
+ color: var(--status-ok);
336
+ min-height: 1em;
337
+ }
338
+ .cs-queue,
339
+ .cs-top,
340
+ .cs-segments {
341
+ list-style: none;
342
+ margin: 8px 0 0;
343
+ padding: 0;
344
+ display: flex;
345
+ flex-direction: column;
346
+ gap: 4px;
347
+ }
348
+ .cs-segments {
349
+ flex-direction: row;
350
+ flex-wrap: wrap;
351
+ }
352
+ .cs-queue li,
353
+ .cs-top li {
354
+ display: flex;
355
+ gap: 8px;
356
+ align-items: baseline;
357
+ font-size: 0.8rem;
358
+ }
359
+ .cs-src,
360
+ .cs-visits {
361
+ font-family: var(--font-family-mono, monospace);
362
+ font-size: 0.7rem;
363
+ color: var(--color-accent);
364
+ flex: 0 0 auto;
365
+ }
366
+ .cs-line,
367
+ .cs-user {
368
+ color: var(--text-primary);
369
+ }
370
+ .cs-overlays {
371
+ display: flex;
372
+ gap: 8px;
373
+ flex-wrap: wrap;
374
+ }
375
+
376
  /* ---- O2 Focus mode: collapse to Byte presence + pending actions ---- */
377
  body.focus-mode #heroChannelContainer,
378
  body.focus-mode .dashboard-summary-strip,
dashboard/tests/costreamer_render.test.js ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // O3b — Co-Streamer read-side models (pure, from the live snapshot).
2
+ import test from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import {
5
+ voiceModel,
6
+ visionModel,
7
+ segmentsModel,
8
+ regularsModel,
9
+ highlightsModel,
10
+ churnModel,
11
+ } from "../features/costreamer/render.js";
12
+
13
+ test("Prove that voice model surfaces the queue + commentary count honestly", () => {
14
+ const snap = {
15
+ voice: {
16
+ provider: "elevenlabs",
17
+ messages: [
18
+ { text: "oi chat", source: "operator" },
19
+ { text: "que cena!", source: "commentary" },
20
+ ],
21
+ },
22
+ };
23
+ const v = voiceModel(snap);
24
+ assert.equal(v.ready, true);
25
+ assert.equal(v.queue.length, 2);
26
+ assert.equal(v.commentary, 1);
27
+ });
28
+
29
+ test("Prove that vision is active only with real frames (frame_count)", () => {
30
+ assert.equal(visionModel({ vision: { frame_count: 3 } }).active, true);
31
+ assert.equal(visionModel({ vision: {} }).active, false);
32
+ assert.equal(visionModel({}).active, false);
33
+ });
34
+
35
+ test("Prove that segments/regulars/highlights/churn derive from real fields", () => {
36
+ assert.deepEqual(segmentsModel({ segments: { segments: ["trivia", "ask"] } }), ["trivia", "ask"]);
37
+ const r = regularsModel({ regulars: { known_viewers: 9, regulars: 2, top: [{ user: "a", visits: 3 }] } });
38
+ assert.equal(r.known, 9);
39
+ assert.equal(r.regulars, 2);
40
+ assert.equal(r.top[0].user, "a");
41
+ const h = highlightsModel({ highlights: { throttled: true, cooldown_seconds: 42, clip_pipeline_enabled: true } });
42
+ assert.equal(h.throttled, true);
43
+ assert.equal(h.cooldown, 42);
44
+ assert.equal(churnModel({ churn: { risk: "alto" } }).risk, "alto");
45
+ });
46
+
47
+ test("Prove that an empty snapshot degrades safely (no throw)", () => {
48
+ for (const m of [voiceModel, visionModel, segmentsModel, regularsModel, highlightsModel, churnModel]) {
49
+ assert.doesNotThrow(() => m());
50
+ assert.doesNotThrow(() => m({}));
51
+ }
52
+ assert.equal(voiceModel({}).ready, false);
53
+ assert.deepEqual(segmentsModel({}), []);
54
+ assert.equal(churnModel({}).risk, null);
55
+ });
dashboard/tests/ops_parity.test.js ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // O3b — back<->front operational parity (LEI §2.9): every co-streamer capability
2
+ // has a LIVE consumer in the front. Guards against the orphan-endpoint regression
3
+ // the audit found (backend that nothing renders). The backend side (the snapshot
4
+ // carries the sections; the endpoints exist) is covered by the Phase 33/34
5
+ // scientific tests; this is the front half.
6
+ import test from "node:test";
7
+ import assert from "node:assert/strict";
8
+ import { readFileSync } from "node:fs";
9
+ import { fileURLToPath } from "node:url";
10
+ import { dirname, join } from "node:path";
11
+
12
+ const ROOT = join(dirname(fileURLToPath(import.meta.url)), "..");
13
+ const render = readFileSync(join(ROOT, "features/costreamer/render.js"), "utf8");
14
+ const controller = readFileSync(join(ROOT, "features/costreamer/controller.js"), "utf8");
15
+ const main = readFileSync(join(ROOT, "main.js"), "utf8");
16
+ const indexHtml = readFileSync(join(ROOT, "index.html"), "utf8");
17
+
18
+ test("Prove that every co-streamer DATA section is consumed by the front", () => {
19
+ // Each capability the snapshot streams must be surfaced (read from snap.<x>).
20
+ for (const section of ["voice", "vision", "segments", "regulars", "highlights", "churn"]) {
21
+ assert.match(render, new RegExp(`snap\\s*&&\\s*snap\\.${section}|snap\\.${section}`), `${section} not surfaced from the snapshot`);
22
+ }
23
+ });
24
+
25
+ test("Prove that the previously orphan WRITE endpoints now have their first UI", () => {
26
+ assert.match(controller, /api\/voice\/say/, "voice/say has no UI");
27
+ assert.match(controller, /api\/segments\/run/, "segments/run has no UI");
28
+ });
29
+
30
+ test("Prove that overlays are linked (operator can reach /voice /avatar /recap)", () => {
31
+ for (const overlay of ["/voice", "/avatar", "/recap", "/capture"]) {
32
+ assert.ok(indexHtml.includes(`href="${overlay}"`), `${overlay} overlay not linked`);
33
+ }
34
+ });
35
+
36
+ test("Prove that the Co-Streamer tab is wired (button + panel + controller fed)", () => {
37
+ assert.match(indexHtml, /data-dashboard-tab="costreamer"/, "tab button missing");
38
+ assert.match(indexHtml, /data-dashboard-tab-panel="costreamer"/, "tab panel missing");
39
+ assert.match(main, /costreamerController\.renderFromSnapshot/, "controller not fed by the snapshot");
40
+ });
docs/plan/ops-dashboard-redesign.md CHANGED
@@ -251,7 +251,7 @@
251
  **O3b — Front: superfícies + primeira UI dos órfãos.**
252
  - **Arquivos:** nova aba **"Co-Streamer"** (ou seções) agregando: **Voz** (`/api/voice/say` ⚠️*primeira UI — caminho nunca tocado pelo front*, fila `/api/voice/messages`, status TTS), **Visão** (link `/capture` + `vision/status` + **comentário** — sem endpoint próprio: `commentary_runtime` faz ponte visão→voz via `voice_runtime.say(..., source="commentary")`; surfacia filtrando `/api/voice/messages` por `source`, **não** criar `/api/commentary`), **Segmentos** (`/api/segments` + `/api/segments/run` ⚠️*primeira UI*), **Channel Points / Regulars / Highlights** (consumindo os endpoints de O3a), **Churn** (`/api/coaching/churn-risk`), **Overlays** (links/preview de `/voice` `/avatar` `/recap`), **Config TTS**. Novos `dashboard/features/*` + partials; parity entries.
253
  - **Teste de paridade (L11 drift):** `dashboard/tests/ops_parity.test.js` — assere que **todo endpoint relevante à ops tem um consumidor vivo** no front e **nenhum órfão** permanece sem deferimento declarado. Falha se um endpoint novo aparecer sem chamador. (Esta é a paridade back↔front machine-checkable.)
254
- - **Critério:** [ ] cada capacidade da auditoria §4 tem superfície; [ ] **zero órfão** (ou deferido com razão, L7); [ ] voz/segmentos têm 1ª UI exercitada por teste de caminho de produção; [ ] ações emitem `byte:react`; [ ] parity gate (backend↔plano) **e** ops_parity (back↔front) verdes; [ ] suíte verde.
255
  - **Meta-reflexão:** *(preencher)*
256
 
257
  ### Fase O4 — Tempo real (SSE) na ops
 
251
  **O3b — Front: superfícies + primeira UI dos órfãos.**
252
  - **Arquivos:** nova aba **"Co-Streamer"** (ou seções) agregando: **Voz** (`/api/voice/say` ⚠️*primeira UI — caminho nunca tocado pelo front*, fila `/api/voice/messages`, status TTS), **Visão** (link `/capture` + `vision/status` + **comentário** — sem endpoint próprio: `commentary_runtime` faz ponte visão→voz via `voice_runtime.say(..., source="commentary")`; surfacia filtrando `/api/voice/messages` por `source`, **não** criar `/api/commentary`), **Segmentos** (`/api/segments` + `/api/segments/run` ⚠️*primeira UI*), **Channel Points / Regulars / Highlights** (consumindo os endpoints de O3a), **Churn** (`/api/coaching/churn-risk`), **Overlays** (links/preview de `/voice` `/avatar` `/recap`), **Config TTS**. Novos `dashboard/features/*` + partials; parity entries.
253
  - **Teste de paridade (L11 drift):** `dashboard/tests/ops_parity.test.js` — assere que **todo endpoint relevante à ops tem um consumidor vivo** no front e **nenhum órfão** permanece sem deferimento declarado. Falha se um endpoint novo aparecer sem chamador. (Esta é a paridade back↔front machine-checkable.)
254
+ - **Critério:** [x] aba **Co-Streamer** surfaceando voz/visão/segmentos/regulars/highlights/churn/overlays do snapshot; [x] **voz/segmentos com 1ª UI** (`/api/voice/say` + `/api/segments/run` — botões que antes não existiam); [x] **zero órfão** (channel-points deferido honesto); [x] ações emitem `byte:react` (no sucesso); [x] **`ops_parity.test.js` verde** (back↔front: cada capacidade tem consumidor vivo) + parity gate; [x] suíte verde (node 161/162; pytest 1092).
255
  - **Meta-reflexão:** *(preencher)*
256
 
257
  ### Fase O4 — Tempo real (SSE) na ops