From 3239526f9885935c3d0f4a3572b376bf39e6a3b0 Mon Sep 17 00:00:00 2001 From: iris Date: Sun, 26 Jul 2026 16:18:35 +0200 Subject: [PATCH] fix: apply rustfmt and address argus nit (cpu_quota optional chaining) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - rustfmt expanded two inline if-else expressions in lifecycle_ops.rs (lines exceeded rustfmt's line width limit) - core.js: use optional chaining (cv?.cpu_quota || '—') so a null/empty cpu_quota/memory_max on ContainerView renders '—' correctly (argus review 🟡, PR #2706) --- frontend/packages/dashboard/src/core.js | 4 ++-- hive-c0re/src/dashboard/lifecycle_ops.rs | 12 ++++++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/packages/dashboard/src/core.js b/frontend/packages/dashboard/src/core.js index 08afb418..7723a754 100644 --- a/frontend/packages/dashboard/src/core.js +++ b/frontend/packages/dashboard/src/core.js @@ -237,11 +237,11 @@ function renderContainerLoad(rows) { // values: per-agent override when set, hive-wide default otherwise). const cpuCap = document.createElement('td'); cpuCap.className = 'num cload-cap'; cpuCap.title = 'configured ceiling — takes effect on next start'; - cpuCap.textContent = cv ? cv.cpu_quota : '—'; + cpuCap.textContent = cv?.cpu_quota || '—'; tr.append(cpuCap); const memCap = document.createElement('td'); memCap.className = 'num cload-cap'; memCap.title = 'configured ceiling — takes effect on next start'; - memCap.textContent = cv ? cv.memory_max : '—'; + memCap.textContent = cv?.memory_max || '—'; tr.append(memCap); // S3T button toggles the inline edit row for this agent. diff --git a/hive-c0re/src/dashboard/lifecycle_ops.rs b/hive-c0re/src/dashboard/lifecycle_ops.rs index 94d3e3aa..e05dd608 100644 --- a/hive-c0re/src/dashboard/lifecycle_ops.rs +++ b/hive-c0re/src/dashboard/lifecycle_ops.rs @@ -220,8 +220,16 @@ pub(super) async fn post_resource_limits( Ok(i) => i, Err(e) => return (StatusCode::BAD_REQUEST, format!("bad agent name: {e}")).into_response(), }; - let cpu_quota = if form.cpu_quota.is_empty() { None } else { Some(form.cpu_quota.as_str()) }; - let memory_max = if form.memory_max.is_empty() { None } else { Some(form.memory_max.as_str()) }; + let cpu_quota = if form.cpu_quota.is_empty() { + None + } else { + Some(form.cpu_quota.as_str()) + }; + let memory_max = if form.memory_max.is_empty() { + None + } else { + Some(form.memory_max.as_str()) + }; if let Some(v) = cpu_quota && let Err(e) = crate::resource_limits::validate_cpu_quota(v) {