fix(orchestrator): queue every speech row of a poll before one redraw

speakRows queues all speech rows of a poll before the single redraw, so a MAYDAY behind other rows is never lost, and a draw that throws shows a toast instead of stopping the pump. Late and stale rows both bubble. Tests run once on unify/skills-20261114 after the merge (operator order 2026-11-14).

🎯 Fix: 80 %
💥 Break: 5 %
💸 Tokens: 100 %
⏱️ Velocity: 100 %
🛡️ Security: 100 %
🏆 Score: 76
🚦 Gate: ⛔ fix 80 % < 90

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-14 21:23:12 +00:00
1 parent a2a03995cb
commit d882e501c1
10 files changed
+732 -31

No files matched your search

+44 -17
View File
@@ -41,8 +41,11 @@
}
}
function say(item) {
speech.pending = Voice.enqueue(speech.pending, item, SPEECH_QUEUE);
/**
* @param {...object} items the rows to read aloud.
*/
function say(...items) {
speech.pending = items.reduce((pending, item) => Voice.enqueue(pending, item, SPEECH_QUEUE), speech.pending);
pump();
drawBubbles();
}
@@ -52,8 +55,11 @@
speech.current = item;
speech.timer = window.setTimeout(() => {
Object.assign(speech, {current: null, timer: 0});
drawSpeaker();
next();
try {
drawSpeaker();
} finally {
next();
}
}, item.duration * 1000);
drawSpeaker();
}
@@ -77,11 +83,14 @@
let timer = 0;
const ended = () => {
window.clearTimeout(timer);
if (speech.source === source) {
Object.assign(speech, {current: null, source: null});
drawSpeaker();
try {
if (speech.source === source) {
Object.assign(speech, {current: null, source: null});
drawSpeaker();
}
} finally {
resolve();
}
resolve();
};
source.addEventListener("ended", ended, {once: true});
timer = window.setTimeout(() => {
@@ -216,18 +225,26 @@
readSilently(item, next);
return;
}
const voiced = await transmit(item, audio);
let voiced = false;
try {
voiced = await transmit(item, audio);
} catch (error) {
speechFailed([String(error.message || error)]);
}
if (speech.item !== item) {
next();
return;
}
Object.assign(speech, {current: null, source: null, item: null});
drawSpeaker();
if (!voiced && settings.bubbles && item.words) {
readSilently(item, next);
return;
}
next();
try {
drawSpeaker();
} finally {
next();
}
}
function cancelSpeech() {
@@ -243,14 +260,24 @@
drawSpeaker();
}
function speakRows(rows) {
for (const row of rows.filter((entry) => entry.ts >= state.now - SPEECH_FRESH)) {
const steps = RadioSet.plan(row, radioSet, liveSpeech());
if (steps.length || (settings.bubbles && Bubbles.picked(row, radioSet))) {
const line = row.text.split("\n").map((part) => part.trim()).find(Boolean) || "";
say({row, voice: row.voice, tone: Voice.toneOf(row, HUMAN), cls: row.class, who: row.source, sent: Boolean(RadioSet.ledgerOf(row, state.messages)), line: short(line), words: Bubbles.words(row.text), silent: !steps.length});
/**
* @param {Array<object>} rows the radio rows the page has not announced yet.
* @param {boolean} arrived whether they arrived while the page polled without a gap.
*/
function speakRows(rows, arrived) {
const [spoken, quiet] = [[], []];
for (const row of rows) {
const fresh = row.ts >= state.now - SPEECH_FRESH;
const steps = fresh ? RadioSet.plan(row, radioSet, liveSpeech()) : [];
const line = short(row.text.split("\n").map((part) => part.trim()).find(Boolean) || "");
if (fresh && (steps.length || (settings.bubbles && Bubbles.picked(row, radioSet)))) {
spoken.push({row, voice: row.voice, tone: Voice.toneOf(row, HUMAN), cls: row.class, who: row.source, sent: Boolean(RadioSet.ledgerOf(row, state.messages)), line, words: Bubbles.words(row.text), silent: !steps.length});
} else if (settings.bubbles && arrived && row.ts >= state.now - LIVE_GAP) {
quiet.push({who: row.source, cls: row.class, line, words: Bubbles.words(line), quiet: true});
}
}
quietBubbles(quiet);
say(...spoken);
}
function micGap() {