From 51d909c567007c4859274e471983d02c62581765 Mon Sep 17 00:00:00 2001 From: Codex Date: Wed, 8 Jul 2026 08:14:52 +0200 Subject: [PATCH] fix: preserve monitor check catalog titles --- .../web-probe-sentinel-monitor-web/monitor-web.js | 8 +++++++- scripts/src/hwlab-node-web-sentinel-p5.ts | 11 +++++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/scripts/assets/web-probe-sentinel-monitor-web/monitor-web.js b/scripts/assets/web-probe-sentinel-monitor-web/monitor-web.js index 6e1a6d03..042e5737 100644 --- a/scripts/assets/web-probe-sentinel-monitor-web/monitor-web.js +++ b/scripts/assets/web-probe-sentinel-monitor-web/monitor-web.js @@ -1767,7 +1767,7 @@ function safeDetailValue(value) { function safeDisplayTitle(...values) { for (const value of values) { - const title = safeUserText(value); + const title = safeTitleText(value); if (title && title !== "未登记监测项") return title; } return ""; @@ -1820,6 +1820,12 @@ function safeUserText(value) { return text; } +function safeTitleText(value) { + const text = String(value || "").replace(/\s+/g, " ").trim(); + if (text.length === 0 || text === "未登记监测项") return ""; + return text; +} + function detailSummaryText(detail) { return detailSummaryRows(detail).map((row) => `${row.label}: ${row.value}`).join("\n"); } diff --git a/scripts/src/hwlab-node-web-sentinel-p5.ts b/scripts/src/hwlab-node-web-sentinel-p5.ts index 2beb0ae4..572d9b9a 100644 --- a/scripts/src/hwlab-node-web-sentinel-p5.ts +++ b/scripts/src/hwlab-node-web-sentinel-p5.ts @@ -1220,10 +1220,13 @@ if (expectedErrorId) { const dialog = document.querySelector("[data-check-dialog='true']"); const dialogErrorId = dialog?.getAttribute("data-error-id") || ""; const title = String(document.querySelector("#check-dialog-title")?.textContent || "").replace(/\s+/g, " ").trim(); - if (dialog instanceof HTMLElement && dialogErrorId === errorId && title && title !== "未登记监测项") return { requestedErrorId: errorId, ok: true, reason: "dialog-open-registered" }; - const row = document.querySelector('[data-error-id="' + CSS.escape(errorId) + '"]'); - if (row instanceof HTMLElement) row.click(); - await wait(150); + const dialogMatches = dialog instanceof HTMLElement && dialogErrorId === errorId; + if (dialogMatches && title && title !== "未登记监测项") return { requestedErrorId: errorId, ok: true, reason: "dialog-open-registered" }; + if (!dialogMatches) { + const row = document.querySelector('[data-error-id="' + CSS.escape(errorId) + '"]'); + if (row instanceof HTMLElement) row.click(); + } + await wait(250); } return { requestedErrorId: errorId, ok: false, reason: "dialog-missing" }; }, expectedErrorId).catch((error) => ({ requestedErrorId: expectedErrorId, ok: false, reason: "selection-error", error: String(error?.message || error).slice(0, 300) }));