Skip to content
Draft
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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
OSV config contains a narrow temporary ignore because OSV Scanner
v2.3.8 still reports 2.22.1 even though the advisory text names it as
patched. -->
<jackson-bom.version>2.22.1</jackson-bom.version>
<jackson-bom.version>2.22.2</jackson-bom.version>
<!-- Security override: GHSA-jhq6-gfmj-v8fx fixes logback-core in 1.5.35. -->
<logback.version>1.5.35</logback.version>
<!-- Security override: CVE-2025-68161 / CVE-2026-34477 / CVE-2026-34478 / CVE-2026-34480. -->
Expand Down
36 changes: 22 additions & 14 deletions src/main/resources/static/assets/viewer/demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ function renderHistory(history = loadHistory()) {
el.historyBody.textContent = "";
el.emptyHistory.hidden = history.length > 0;

// ⚡ Bolt: Use DocumentFragment to batch DOM insertions
// Impact: Reduces DOM reflows from O(n) to O(1), improving render performance for large history lists.
const fragment = document.createDocumentFragment();
for (const job of history) {
const row = document.createElement("tr");
const fileCell = document.createElement("td");
Expand Down Expand Up @@ -143,18 +146,19 @@ function renderHistory(history = loadHistory()) {
}

row.append(fileCell, statusCell, submittedCell, actionsCell);
el.historyBody.appendChild(row);
fragment.appendChild(row);
}
el.historyBody.appendChild(fragment);

renderRecoveryEvidence(history);
}

function addDetailRow(label, value) {
function addDetailRow(fragment, label, value) {
const term = document.createElement("dt");
const description = document.createElement("dd");
term.textContent = label;
description.textContent = formatDetailValue(value);
el.jobDetailBody.append(term, description);
fragment.append(term, description);
}

function formatDetailValue(value) {
Expand All @@ -177,17 +181,21 @@ function renderJobDetail(detail) {
: "Operational evidence";
el.jobDetailBody.textContent = "";

addDetailRow("Job ID", detail.jobId);
addDetailRow("Tenant", detail.tenantId);
addDetailRow("Status", detail.status);
addDetailRow("Message", detail.message);
addDetailRow("Attempts", `${detail.attemptCount ?? 0} / ${detail.maxAttempts ?? "n/a"}`);
addDetailRow("Dead-lettered", Boolean(detail.deadLettered));
addDetailRow("Retry at", detail.retryAt);
addDetailRow("Created", detail.createdAt);
addDetailRow("Started", detail.startedAt);
addDetailRow("Completed", detail.completedAt);
addDetailRow("Artifact", detail.convertedResourcePath);
// ⚡ Bolt: Use DocumentFragment to batch DOM insertions for detail rows
// Impact: Prevents multiple layout recalculations by applying all detail rows in a single DOM update.
const fragment = document.createDocumentFragment();
addDetailRow(fragment, "Job ID", detail.jobId);
addDetailRow(fragment, "Tenant", detail.tenantId);
addDetailRow(fragment, "Status", detail.status);
addDetailRow(fragment, "Message", detail.message);
addDetailRow(fragment, "Attempts", `${detail.attemptCount ?? 0} / ${detail.maxAttempts ?? "n/a"}`);
addDetailRow(fragment, "Dead-lettered", Boolean(detail.deadLettered));
addDetailRow(fragment, "Retry at", detail.retryAt);
addDetailRow(fragment, "Created", detail.createdAt);
addDetailRow(fragment, "Started", detail.startedAt);
addDetailRow(fragment, "Completed", detail.completedAt);
addDetailRow(fragment, "Artifact", detail.convertedResourcePath);
el.jobDetailBody.appendChild(fragment);

el.retryJobBtn.hidden = !detail.deadLettered;
}
Expand Down
5 changes: 4 additions & 1 deletion src/test/js/demo-integration.test.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import assert from "node:assert/strict";
import test from "node:test";

import { MockElement } from "./mock-dom.mjs";
import { MockElement, MockDocumentFragment } from "./mock-dom.mjs";

const elementIds = [
"upload-form",
Expand Down Expand Up @@ -54,6 +54,9 @@ test("the executable demo renders inert actions and blocks repeated status activ
createElement(tagName) {
return new MockElement(tagName);
},
createDocumentFragment() {
return new MockDocumentFragment();
}
};
globalThis.window = {
confirm() {
Expand Down
5 changes: 4 additions & 1 deletion src/test/js/dom-utils.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,14 @@ import {
createLink,
setBusyState
} from "../../main/resources/static/assets/viewer/dom-utils.js";
import { MockElement, MockTextNode } from "./mock-dom.mjs";
import { MockElement, MockTextNode, MockDocumentFragment } from "./mock-dom.mjs";

globalThis.document = {
createElement(tagName) {
return new MockElement(tagName);
},
createDocumentFragment() {
return new MockDocumentFragment();
}
};

Expand Down
25 changes: 25 additions & 0 deletions src/test/js/mock-dom.mjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,23 @@
export class MockDocumentFragment {
constructor() {
this.childNodes = [];
}

appendChild(node) {
if (node && node.constructor && node.constructor.name === "MockDocumentFragment") {
this.childNodes.push(...node.childNodes);
node.childNodes = []; // DocumentFragment gets emptied when appended
return node;
}
this.childNodes.push(node);
return node;
}

append(...nodes) {
this.childNodes.push(...nodes);
}
}

export class MockTextNode {
constructor(text) {
this.type = "text";
Expand Down Expand Up @@ -31,6 +51,11 @@ export class MockElement {
}

appendChild(node) {
if (node && node.constructor && node.constructor.name === "MockDocumentFragment") {
this.childNodes.push(...node.childNodes);
node.childNodes = []; // DocumentFragment gets emptied when appended
return node;
}
this.childNodes.push(node);
return node;
}
Expand Down
Loading