Merge pull request #1122 from pikasTech/issue1112-monitor-load

fix: wait for monitor-web readiness in screenshots
This commit is contained in:
Lyon
2026-06-27 14:46:07 +08:00
committed by GitHub
2 changed files with 7 additions and 7 deletions
@@ -87,8 +87,8 @@ createApp({
try {
const [overviewPayload, runsPayload, findingsPayload] = await Promise.all([
fetchJson("/api/overview"),
fetchJson("/api/runs?limit=80&sort=updated"),
fetchJson("/api/findings?limit=80&window=24h"),
fetchJson("/api/runs?limit=30&sort=updated"),
fetchJson("/api/findings?limit=30&window=24h"),
]);
overview.value = overviewPayload;
runs.value = Array.isArray(runsPayload.runs) ? runsPayload.runs : Array.isArray(runsPayload.items) ? runsPayload.items : [];
@@ -97,7 +97,7 @@ createApp({
lastAutoRefreshAt = Date.now();
const keepSelected = runs.value.find((run) => run.id === selectedRunId.value);
const nextRun = keepSelected || runs.value[0] || latestRun.value;
if (nextRun?.id) await selectRun(nextRun, true);
if (nextRun?.id) void selectRun(nextRun, true);
} catch (cause) {
error.value = String(cause?.message || cause);
} finally {
+4 -4
View File
@@ -1979,7 +1979,7 @@ for (let attempt = 1; attempt <= maxNavigationAttempts; attempt += 1) {
try {
const response = await page.goto(url, { timeout: perAttemptTimeout, waitUntil: "domcontentloaded" });
httpStatus = response?.status() ?? null;
await page.waitForLoadState("networkidle", { timeout: Math.min(5000, perAttemptTimeout) }).catch(() => {});
await page.waitForLoadState("networkidle", { timeout: Math.min(10000, perAttemptTimeout) }).catch(() => {});
await page.waitForFunction(() => {
const root = document.querySelector("#monitor-web-root");
if (!root) return false;
@@ -1988,10 +1988,10 @@ for (let attempt = 1; attempt <= maxNavigationAttempts; attempt += 1) {
const runs = document.querySelectorAll(".run-list .run-row").length;
const trend = document.querySelector("[data-monitor-trend-curve]");
return ready && (error || runs > 0 || trend);
}, null, { timeout: Math.min(5000, perAttemptTimeout) }).catch(() => {});
}, null, { timeout: Math.min(15000, perAttemptTimeout) }).catch(() => {});
await page.waitForTimeout(500);
const shellReady = await page.evaluate(() => Boolean(document.querySelector("#monitor-web-root"))).catch(() => false);
if (shellReady || attempt === maxNavigationAttempts) break;
const appReady = await page.evaluate(() => document.querySelector("#monitor-web-root")?.getAttribute("data-monitor-ready") === "true").catch(() => false);
if (appReady || attempt === maxNavigationAttempts) break;
} catch (error) {
navigationError = String(error?.message || error).slice(0, 500);
if (attempt === maxNavigationAttempts) break;