ui: fix undefined h/j in tick() that left the meetings table empty

This commit is contained in:
Stefano Zini
2026-11-05 15:03:12 +01:00
parent ead33657c7
commit ca36bf3c60
+5 -3
View File
@@ -1,4 +1,6 @@
// Web UI logic: polls /status every 3 s, renders the meetings table, and wires search, Q&A, upload, crop and bulk actions to the local server. // Web UI logic: polls /status every 3 s, renders the meetings table, and wires search, Q&A, upload, crop and bulk actions to the local server.
// Element ids from index.html used as window globals (plus bare addEventListener), declared for ESLint no-undef.
/* global ab addEventListener ar bf bn bulk cdlg ce cgi_ cgo_ cmsg cpr cs ctitle cv llm llma llmr omps pgr q qa qs skp sr t ub ubar ubig ucancel up utitle utxt */
// Escape text for innerHTML (&, <, >, "). // Escape text for innerHTML (&, <, >, ").
const E=value=>String(value??"").replace(/[&<>"]/g,char=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[char])); const E=value=>String(value??"").replace(/[&<>"]/g,char=>({"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;"}[char]));
// Seconds -> mm:ss (minutes can exceed 59; no hour form here). // Seconds -> mm:ss (minutes can exceed 59; no hour form here).
@@ -120,7 +122,7 @@ const clock=seconds=>new Date(Date.now()+seconds*1000).toLocaleTimeString([],{ho
// Per recording: last [timestamp, tokens decoded], used to compute tokens/s between ticks. // Per recording: last [timestamp, tokens decoded], used to compute tokens/s between ticks.
const LT={}; const LT={};
// LLM activity line: prompt reading vs token writing; idle time sets the severity colour. // LLM activity line: prompt reading vs token writing; idle time sets the severity colour.
function live(name,prog){const l=prog.llm;let txt="",act=false; function live(name,prog){const info=prog.llm;let txt="",act=false;
// Model is busy: compare token counts with the previous tick. // Model is busy: compare token counts with the previous tick.
if(info&&info.is_processing){act=true;const key=name,prev=LT[key],now=Date.now(),decoded=info.n_decoded||0; if(info&&info.is_processing){act=true;const key=name,prev=LT[key],now=Date.now(),decoded=info.n_decoded||0;
// Tokens/s from the delta since the previous tick. // Tokens/s from the delta since the previous tick.
@@ -201,13 +203,13 @@ document.querySelectorAll("select[id^=f-]").forEach(select=>sel[select.id]=selec
let html="<thead><tr><th>recording<th>status<th>duration<th>speakers<th>MB<th>links<th>actions</tr></thead>"; let html="<thead><tr><th>recording<th>status<th>duration<th>speakers<th>MB<th>links<th>actions</tr></thead>";
// Pagination: PS meetings per page; clamp the page if recordings were removed, then draw the pager. // Pagination: PS meetings per page; clamp the page if recordings were removed, then draw the pager.
const pages=Math.max(1,Math.ceil(data.recs.length/PS));if(pg_>=pages)pg_=pages-1; const pages=Math.max(1,Math.ceil(data.recs.length/PS));if(pg_>=pages)pg_=pages-1;
pgr.innerHTML=pages>1?`<button ${pg_?"":"disabled"} onclick="goPg(-1)">‹</button><span>pagina ${pg_+1} di ${pages} (${j.recs.length} riunioni)</span><button ${pg_<pages-1?"":"disabled"} onclick="goPg(1)">›</button>`:""; pgr.innerHTML=pages>1?`<button ${pg_?"":"disabled"} onclick="goPg(-1)">‹</button><span>pagina ${pg_+1} di ${pages} (${data.recs.length} riunioni)</span><button ${pg_<pages-1?"":"disabled"} onclick="goPg(1)">›</button>`:"";
// One tbody per recording on the current page; "running" when the status is done but the process is still alive. // One tbody per recording on the current page; "running" when the status is done but the process is still alive.
for(const row of data.recs.slice(pg_*PS,(pg_+1)*PS)){ for(const row of data.recs.slice(pg_*PS,(pg_+1)*PS)){
// Display title, falling back to the upload name. // Display title, falling back to the upload name.
const nm=row.title||row.upload; const nm=row.title||row.upload;
// Main row: checkbox, title and rename buttons; status badge with error text and time since last data. // Main row: checkbox, title and rename buttons; status badge with error text and time since last data.
h+=`<tbody class=rec><tr class=main><td><input type=checkbox class=mg value="${row.name}">${nm?`<b>${E(nm)}</b><br><small>${row.name}</small>`:row.name} <button class=del title="modifica titolo" onclick="setTitle('${row.name}','${E(row.title||row.upload||"").replace(/'/g,"")}')">✎</button>${row.mb&&row.files.includes("report.html")?`<button class=del title="ricalcola titolo" onclick="retitle('${row.name}')">↻</button>`:""}<td><span class="b ${row.status}" title="${E(row.error)}">${row.status}</span>${row.receiving_age_s!=null&&row.status==="recording"?` <small>${row.receiving_age_s}s ago</small>`:""}${row.error?`<br><small>${E(row.error)}</small>`:""}<td>${row.duration_s?fmt(row.duration_s):""}<td>${row.speakers??""}<td>${row.mb} html+=`<tbody class=rec><tr class=main><td><input type=checkbox class=mg value="${row.name}">${nm?`<b>${E(nm)}</b><br><small>${row.name}</small>`:row.name} <button class=del title="modifica titolo" onclick="setTitle('${row.name}','${E(row.title||row.upload||"").replace(/'/g,"")}')">✎</button>${row.mb&&row.files.includes("report.html")?`<button class=del title="ricalcola titolo" onclick="retitle('${row.name}')">↻</button>`:""}<td><span class="b ${row.status}" title="${E(row.error)}">${row.status}</span>${row.receiving_age_s!=null&&row.status==="recording"?` <small>${row.receiving_age_s}s ago</small>`:""}${row.error?`<br><small>${E(row.error)}</small>`:""}<td>${row.duration_s?fmt(row.duration_s):""}<td>${row.speakers??""}<td>${row.mb}
<td>${row.files.includes("report.html")?`<a href="/report?name=${row.name}" target=_blank>report</a><a href="/pdf?name=${row.name}" target=_blank>pdf</a>`:""}${row.flow_run_id?`<a href="http://127.0.0.1:4200/runs/flow-run/${row.flow_run_id}" target=_blank>prefect</a>`:""} <td>${row.files.includes("report.html")?`<a href="/report?name=${row.name}" target=_blank>report</a><a href="/pdf?name=${row.name}" target=_blank>pdf</a>`:""}${row.flow_run_id?`<a href="http://127.0.0.1:4200/runs/flow-run/${row.flow_run_id}" target=_blank>prefect</a>`:""}
<td>${row.mb?`<select id="f-${row.name}">${["audio","transcribe","diarize","speakers","shots","docs","report","memory","render"].map(step=>`<option>${step}`).join("")}</select><button onclick="run('${row.name}')">run</button>`:""}<button onclick="spk('${row.name}')">speakers</button>${row.mb?`<button title="anteprima e ritaglio" onclick="play('${row.name}',${row.duration_s||0},'${E(nm||row.name).replace(/'/g,"")}')">▶ video</button>`:""}${row.mb&&row.status==="done"&&!row.running?`<button title="elimina solo il file video: report, trascrizione e schermate restano, ma non si può più rielaborare" onclick="dropVid('${row.name}',${row.mb})">🎞 elimina video</button>`:""}${row.running||row.status==="queued"?`<button onclick="stopRun('${row.name}')">stop</button>`:`<button class=del title="elimina la riunione" onclick="del_('${row.name}','${E(nm||row.name).replace(/'/g,"")}')">🗑</button>`}`; <td>${row.mb?`<select id="f-${row.name}">${["audio","transcribe","diarize","speakers","shots","docs","report","memory","render"].map(step=>`<option>${step}`).join("")}</select><button onclick="run('${row.name}')">run</button>`:""}<button onclick="spk('${row.name}')">speakers</button>${row.mb?`<button title="anteprima e ritaglio" onclick="play('${row.name}',${row.duration_s||0},'${E(nm||row.name).replace(/'/g,"")}')">▶ video</button>`:""}${row.mb&&row.status==="done"&&!row.running?`<button title="elimina solo il file video: report, trascrizione e schermate restano, ma non si può più rielaborare" onclick="dropVid('${row.name}',${row.mb})">🎞 elimina video</button>`:""}${row.running||row.status==="queued"?`<button onclick="stopRun('${row.name}')">stop</button>`:`<button class=del title="elimina la riunione" onclick="del_('${row.name}','${E(nm||row.name).replace(/'/g,"")}')">🗑</button>`}`;
html+=progPanel(row); html+=progPanel(row);