fix: add monitor run detail deep links

This commit is contained in:
Codex
2026-07-01 02:57:19 +00:00
parent fc733ca3b6
commit 0fdd05a90a
3 changed files with 88 additions and 13 deletions
+29 -8
View File
@@ -415,11 +415,12 @@ export function runSentinelDashboard(state: SentinelCicdState, options: Extract<
export function probeSentinelDashboardBrowser(state: SentinelCicdState, options: Extract<WebProbeSentinelOptions, { kind: "dashboard" }>): Record<string, unknown> {
const publicBaseUrl = stringAt(state.publicExposure, "publicBaseUrl").replace(/\/$/u, "");
const dashboardUrl = sentinelDashboardUrl(publicBaseUrl, options.runId);
const [widthRaw, heightRaw] = options.viewport.split("x");
const screenshotName = options.action === "screenshot" ? dashboardScreenshotName(options, state) : "";
const script = [
"set -eu",
`export UNIDESK_SENTINEL_DASHBOARD_URL=${shellQuote(`${publicBaseUrl}/`)}`,
`export UNIDESK_SENTINEL_DASHBOARD_URL=${shellQuote(dashboardUrl)}`,
`export UNIDESK_SENTINEL_DASHBOARD_SCREENSHOT="$UNIDESK_WEB_PROBE_ARTIFACT_REMOTE_DIR"/${shellQuote(screenshotName)}`,
`export UNIDESK_SENTINEL_DASHBOARD_CAPTURE=${shellQuote(options.action === "screenshot" ? "1" : "0")}`,
`export UNIDESK_SENTINEL_DASHBOARD_WIDTH=${shellQuote(widthRaw ?? "1440")}`,
@@ -499,6 +500,15 @@ export function probeSentinelDashboardBrowser(state: SentinelCicdState, options:
};
}
function sentinelDashboardUrl(publicBaseUrl: string, runId: string | null): string {
const url = new URL(`${publicBaseUrl.replace(/\/$/u, "")}/`);
if (runId !== null && runId.length > 0) {
url.searchParams.set("run", runId);
url.searchParams.set("focus", "memory");
}
return url.toString();
}
function sentinelDashboardBrowserModule(): string {
return String.raw`import { pathToFileURL } from "node:url";
@@ -574,17 +584,28 @@ if (requestedRunId) {
const wait = (ms) => new Promise((resolve) => window.setTimeout(resolve, ms));
const rowForRun = () => document.querySelector('.run-list .run-row[data-run-id="' + CSS.escape(runId) + '"]');
const row = rowForRun();
if (!(row instanceof HTMLElement)) return { requestedRunId: runId, ok: false, reason: "run-row-missing" };
row.click();
for (let index = 0; index < 40; index += 1) {
if (row instanceof HTMLElement) row.click();
for (let index = 0; index < 80; index += 1) {
const memoryChart = document.querySelector("[data-run-memory-chart='true']");
const selected = rowForRun();
const pageCount = Number(memoryChart?.getAttribute("data-memory-page-count") || 0);
const curveCount = document.querySelectorAll(".memory-chart .memory-line").length;
const axesOk = Boolean(memoryChart?.querySelector("[data-memory-axis-x='true']"))
&& Boolean(memoryChart?.querySelector("[data-memory-axis-y='true']"))
&& document.querySelectorAll(".memory-chart [data-memory-axis-x-tick='true']").length >= 3
&& document.querySelectorAll(".memory-chart [data-memory-axis-y-tick='true']").length >= 3;
const pageLinesOk = pageCount > 0 && curveCount === pageCount;
if (memoryChart?.getAttribute("data-memory-run-id") === runId
&& selected instanceof HTMLElement
&& selected.classList.contains("selected")) {
return { requestedRunId: runId, ok: true, reason: "selected" };
&& (!(selected instanceof HTMLElement) || selected.classList.contains("selected"))
&& axesOk
&& pageLinesOk) {
if (memoryChart instanceof HTMLElement) {
memoryChart.scrollIntoView({ block: "center", inline: "nearest", behavior: "auto" });
await wait(250);
}
return { requestedRunId: runId, ok: true, reason: "selected-memory-ready" };
}
await wait(100);
await wait(150);
}
return { requestedRunId: runId, ok: false, reason: "detail-switch-timeout" };
}, requestedRunId).catch((error) => ({ requestedRunId, ok: false, reason: "selection-error", error: String(error?.message || error).slice(0, 300) }));