Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 27 additions & 5 deletions pm-stack/aggregator/src/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,28 @@ document.addEventListener("submit", async (ev) => {
* inputs carry the payload. A stop form must have its confirm box
* ticked before the script will send it (two-step confirm).
*/
/** Shell fragment watchdog (#1503): the shell pages stream their real
* content in as Datastar fragments; if a fragment request fails or stalls
* there is no error path in the markup, so the page would sit on its
* skeleton forever. Ten seconds after the shell renders, any [data-frag]
* container still holding its .skel skeleton gets the skeleton swapped for
* an inline notice linking the ?full=1 server render (the no-JS path).
* A fragment that lands in time removes the skeleton itself, so the
* watchdog no-ops; a fragment that lands late replaces the notice. */
export const FRAG_WATCHDOG_MS = 10_000;
export const FRAG_WATCHDOG_SCRIPT = `<script>
setTimeout(function () {
document.querySelectorAll("[data-frag]").forEach(function (c) {
var skel = c.querySelector(".skel");
if (!skel) return;
var p = document.createElement("p");
p.className = "frag-failed";
p.innerHTML = "the live view did not arrive &mdash; <a href="" + location.pathname + "?full=1">load the full page</a>";
skel.replaceWith(p);
});
}, ${FRAG_WATCHDOG_MS});
</script>`;

const ACTION_SCRIPT = `<script>${DASH_AFTER_JS}
document.addEventListener("submit", async (ev) => {
const form = ev.target;
Expand Down Expand Up @@ -1666,7 +1688,7 @@ export function renderBoardShell(provenance: Provenance, detail?: ProvenanceDeta
`<h1>Cross-repo WIP board</h1><p class="muted">What is being worked on now is the <strong>in-flight</strong> lane: synthetic entries from the orchestrator's lined-up tasks (the fleet feed's orchestration section), not Kaneo cards.</p><noscript><meta http-equiv="refresh" content="0; url=/board"></noscript><div id="board-main" data-frag data-on-load="@get('${fragBoard}')" data-on:dashrefresh__window="@get('${fragBoard}')"><div class="skel">Loading the board…</div></div>`,
provenance,
"/board",
ACTION_SCRIPT,
ACTION_SCRIPT + FRAG_WATCHDOG_SCRIPT,
detail ? freshnessChips(detail, ["board", "items", "orchestration"]) : "",
);
}
Expand Down Expand Up @@ -3509,7 +3531,7 @@ ${attentionFragment("sessions", skel("sessions"), refsQuery)}${questionsHtml}`;
body,
provenance,
"/attention",
ACTION_SCRIPT + COMMENT_SCRIPT + BULK_SCRIPT,
ACTION_SCRIPT + COMMENT_SCRIPT + BULK_SCRIPT + FRAG_WATCHDOG_SCRIPT,
detail ? freshnessChips(detail, ["orchestration", "attention", "registry"]) : "",
);
}
Expand Down Expand Up @@ -3747,7 +3769,7 @@ export function renderTodayShell(
`<h1>Today</h1><noscript><meta http-equiv="refresh" content="0; url=/today?full=1"></noscript><div id="today-main" data-frag data-on-load="@get('/frag/today')" data-on:dashrefresh__window="@get('/frag/today')">${todayHealthStrip(health, quota, quotaUnavailable)}<div class="skel">Loading today…</div></div>${questionsHtml}`,
provenance,
"/today",
"",
FRAG_WATCHDOG_SCRIPT,
detail ? freshnessChips(detail, ["orchestration", "quota", "attention"]) : "",
);
}
Expand Down Expand Up @@ -3824,7 +3846,7 @@ export function renderQueueShell(provenance: Provenance, detail?: ProvenanceDeta
`<h1>Queue visibility</h1><noscript><meta http-equiv="refresh" content="0; url=/queue?full=1"></noscript><div id="queue-main" data-frag data-on-load="@get('/frag/queue')" data-on:dashrefresh__window="@get('/frag/queue')"><div class="skel">Loading queue…</div></div>`,
provenance,
"/queue",
"",
FRAG_WATCHDOG_SCRIPT,
detail ? freshnessChips(detail, ["board", "orchestration", "items"]) : "",
);
}
Expand Down Expand Up @@ -4015,7 +4037,7 @@ export function renderOverviewShell(provenance: Provenance, detail?: ProvenanceD
`<h1>Overview</h1><noscript><meta http-equiv="refresh" content="0; url=/?full=1"></noscript><div id="overview-main" data-frag data-on-load="@get('/frag/overview')" data-on:dashrefresh__window="@get('/frag/overview')"><div class="skel">Loading the overview…</div></div>`,
provenance,
"/",
"",
FRAG_WATCHDOG_SCRIPT,
detail ? freshnessChips(detail, ["board", "quota", "attention"]) : "",
);
}
Expand Down
5 changes: 3 additions & 2 deletions pm-stack/aggregator/src/ui.css
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ pre { max-width: 100%; overflow-x: auto; }
.qblock .qanswered { color: #3fb950; font-size: 12px; }
.qblock .qremaining { color: #e3b341; font-size: 12px; }
.skel { border: 1px dashed #30363d; border-radius: 8px; padding: 14px 12px; margin: 8px 0; color: #8b949e; background: #0d1117; }
.frag-failed { border: 1px solid #9a6700; border-radius: 8px; padding: 14px 12px; margin: 8px 0; color: #e3b341; background: #0d1117; }
.orderctl { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0; font-size: 12.5px; color: #8b949e; }
.bulkbar { border: 1px solid #30363d; border-radius: 8px; padding: 10px 12px; margin: 10px 0; background: #0d1117; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.bulkbar select, .bulkbar input[type="text"] { background: #161b22; color: #e6edf3; border: 1px solid #30363d; border-radius: 6px; padding: 7px 9px; font: inherit; min-height: 44px; }
Expand Down Expand Up @@ -290,7 +291,7 @@ body.xp-plan .xpl-costcol { display: none; }
.dot.off, .dot.unknown { background: #59636e; }
.dot.fixtures { background: transparent; border-color: #8250df; }
.cmt { background: #f6f8fa; border-left-color: #d1d9e0; }
.cov, .cform, .actbox, .skel { background: #f6f8fa; border-color: #d1d9e0; }
.cov, .cform, .actbox, .skel, .frag-failed { background: #f6f8fa; border-color: #d1d9e0; }
/* Charts keep their authored dark surface in light mode: the SVG
foregrounds are generated for dark (model labels #c9d1d9, the
Pareto frontier #e6edf3), so a light chart background would wash
Expand Down Expand Up @@ -392,7 +393,7 @@ html[data-theme="light"] .dot.stale, html[data-theme="light"] .dot.absent { back
html[data-theme="light"] .dot.off, html[data-theme="light"] .dot.unknown { background: #59636e; }
html[data-theme="light"] .dot.fixtures { background: transparent; border-color: #8250df; }
html[data-theme="light"] .cmt { background: #f6f8fa; border-left-color: #d1d9e0; }
html[data-theme="light"] .cov, html[data-theme="light"] .cform, html[data-theme="light"] .actbox, html[data-theme="light"] .skel { background: #f6f8fa; border-color: #d1d9e0; }
html[data-theme="light"] .cov, html[data-theme="light"] .cform, html[data-theme="light"] .actbox, html[data-theme="light"] .skel, html[data-theme="light"] .frag-failed { background: #f6f8fa; border-color: #d1d9e0; }
html[data-theme="light"] .chart { background: #0d1117; border-color: #30363d; color: #e6edf3; }
html[data-theme="light"] .chart .muted { color: #8b949e; }
html[data-theme="light"] .chart .xpl-ctl button, html[data-theme="light"] .chart .xpl-ctl select { background: #161b22; color: #e6edf3; border-color: #30363d; }
Expand Down
54 changes: 54 additions & 0 deletions pm-stack/aggregator/test/frag-watchdog-1503.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { describe, expect, test } from "bun:test";
import { fixtureSource } from "../src/sources/fixtures.ts";
import {
FRAG_WATCHDOG_MS,
renderAttentionShell,
renderBoardShell,
renderOverviewShell,
renderQueueShell,
renderTodayShell,
} from "../src/render.ts";

// Shell fragment watchdog (#1503): a stalled/failed fragment must surface,
// not spin — every shell page carries the watchdog script, which swaps a
// still-loading skeleton for a notice with a ?full=1 link after 10 s.
describe("shell fragment watchdog (#1503)", () => {
test("watchdog bound is 10 seconds", () => {
expect(FRAG_WATCHDOG_MS).toBe(10_000);
});

test("every shell page carries the watchdog and keeps its fragment load", async () => {
const src = fixtureSource();
const shells = [
renderBoardShell(src.provenance()),
renderAttentionShell(src.provenance()),
renderTodayShell(src.provenance(), undefined, null, await src.quota()),
renderQueueShell(src.provenance()),
renderOverviewShell(src.provenance()),
];
expect(shells).toHaveLength(5);
for (const html of shells) {
expect(html).toContain("frag-failed");
expect(html).toContain("the live view did not arrive");
expect(html).toContain("?full=1");
expect(html).toContain("data-on-load=\"@get('");
expect(html).toContain('class="skel"');
}
});

test("attention shell watchdog covers all three fragment containers", () => {
const src = fixtureSource();
const html = renderAttentionShell(src.provenance());
expect(html).toContain('id="attn-header"');
expect(html).toContain('id="attn-queues"');
expect(html).toContain('id="attn-sessions"');
expect(html).toContain("frag-failed");
});

test("today shell keeps its health strip ahead of the skeleton", async () => {
const src = fixtureSource();
const html = renderTodayShell(src.provenance(), undefined, null, await src.quota());
expect(html).toContain("frag-failed");
expect(html.indexOf('class="today-health-strip"')).toBeLessThan(html.indexOf('class="skel"'));
});
});