Author: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com> Date: Sat Oct 25 18:29:38 2025 +0100 Fix builder status UI and taskreport data This commit addresses several issues related to the builder task reports and the frontend UI that displays builder status. - **Fix `taskreport` data:** - Correctly fetches resource estimates (RAM, disk) from the `build_metrics` database on the server. - Fixes the `cpu_percent` calculation in the builder to prevent incorrect values like 255 from being reported. - Removes the unused `est_cpu_load_pct` field from the task report. - Adds a NULL check for `task->taskname` in `s-task-helpers.c` to prevent potential crashes. - **Fix builder status UI:** - Corrects the scaling of the CPU usage percentage in `assets/sai.js` to properly reflect the value from the backend. - Ensures that the RAM and disk usage bars in the UI display at least one segment if any resources are reserved, even if the amount is a small fraction of the total. diff --git a/assets/sai.js b/assets/sai.js index d305542..74ba59d 100644 --- a/assets/sai.js +++ b/assets/sai.js @@ -1710,7 +1710,7 @@ function ws_open_sai() const diskBar = builderDiv.querySelector(".res-bar-disk"); if (cpuBar) { - let cpu_percentage = (jso.cpu_percent / (jso.core_count * 1000)) * 100; + let cpu_percentage = jso.cpu_percent / 10; if (cpu_percentage > 100) cpu_percentage = 100; if (cpu_percentage < 0) cpu_percentage = 0; let width_class = `w-${Math.round(cpu_percentage / 5) * 5}`; @@ -1725,7 +1725,12 @@ function ws_open_sai() } if (ram_percentage > 100) ram_percentage = 100; if (ram_percentage < 0) ram_percentage = 0; - let width_class = `w-${Math.round(ram_percentage / 5) * 5}`; + + let width = Math.round(ram_percentage / 5) * 5; + if (width === 0 && ram_percentage > 0) + width = 5; + + let width_class = `w-${width}`; ramBar.classList.forEach(c => { if (c.startsWith('w-')) ramBar.classList.remove(c); }); ramBar.classList.add(width_class); @@ -1737,7 +1742,12 @@ function ws_open_sai() } if (disk_percentage > 100) disk_percentage = 100; if (disk_percentage < 0) disk_percentage = 0; - let width_class = `w-${Math.round(disk_percentage / 5) * 5}`; + + let width = Math.round(disk_percentage / 5) * 5; + if (width === 0 && disk_percentage > 0) + width = 5; + + let width_class = `w-${width}`; diskBar.classList.forEach(c => { if (c.startsWith('w-')) diskBar.classList.remove(c); }); diskBar.classList.add(width_class); diff --git a/src/server/s-task-helpers.c b/src/server/s-task-helpers.c index a4776ea..81cd6ad 100644 --- a/src/server/s-task-helpers.c +++ b/src/server/s-task-helpers.c @@ -43,7 +43,7 @@ sais_get_task_metrics_estimates(struct vhd *vhd, sai_task_t *task) if (!vhd->pdb_metrics) return; - if (!task->repo_name || !task->platform[0]) + if (!task->repo_name || !task->platform[0] || !task->taskname[0]) return; if (lws_genhash_init(&ctx, LWS_GENHASH_TYPE_SHA256) || diff --git a/src/server/s-webops.c b/src/server/s-webops.c index 72ae57d..82bc57c 100644 --- a/src/server/s-webops.c +++ b/src/server/s-webops.c @@ -61,8 +61,8 @@ _sais_websrv_broadcast(struct lws_ss_handle *h, void *arg) info->head_upstream = &m->bl_srv_to_web; info->private_heads = m->private_heads; - lwsl_ss_notice(h, "Queueing %u bytes, ridx %d, ff_flags: %u\n", - (unsigned int)info->len, info->private_source_idx, info->ss_flags); + // lwsl_ss_notice(h, "Queueing %u bytes, ridx %d, ff_flags: %u\n", + // (unsigned int)info->len, info->private_source_idx, info->ss_flags); *pi = info->ss_flags;