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
4 changes: 2 additions & 2 deletions scripts/harness-analysis/renderers/html-interactions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,14 @@ export function renderHtmlInteractionScript(language) {
? {
copy: "复制 AI 修复",
copied: "已复制",
copySuccess: "已复制,请粘贴到 Codex 输入框。",
copySuccess: "已复制,请粘贴到当前 Coding Agent 输入框。",
manualCopy: "自动复制被阻止,请手动复制已选中的提示词。",
missingPrompt: "这个问题没有可用的 AI 修复提示词。",
}
: {
copy: "Copy AI Fix",
copied: "Copied",
copySuccess: "Copied. Paste into the Codex input.",
copySuccess: "Copied. Paste into your coding agent input.",
manualCopy: "Automatic copy was blocked. Copy the selected prompt manually.",
missingPrompt: "No AI Fix prompt is available for this finding.",
};
Expand Down
4 changes: 2 additions & 2 deletions scripts/harness-analysis/renderers/html.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,7 @@ function renderHtmlBody(reportData) {

return `<header class="hero" data-section="overview">
<div class="hero-copy">
<span class="eyebrow">${renderVisibleText(copy(language, "Harness Insights · Codex HTML", "Harness 洞察 · Codex HTML"), language)}</span>
<span class="eyebrow">${renderVisibleText(copy(language, "Harness Insights · Portable HTML", "Harness 洞察 · 便携式 HTML"), language)}</span>
<h1>${renderVisibleText(projectName, language)}</h1>
<p>${renderVisibleText(overview, language)}</p>
<div class="hero-tags"><span class="pill accent">${renderVisibleText(summary.modelId ?? "Harness", language)}</span><span class="pill muted">${renderVisibleText(copy(language, "Evidence-bound", "证据有界"), language)}</span></div>
Expand Down Expand Up @@ -656,7 +656,7 @@ export function renderHtml(reportData, actionContext) {
<div id="copy-status" class="sr-only" role="status" aria-live="polite"></div>
<main id="harness-report" data-report-mode="codex-html">
${renderHtmlBody(reportData)}
<footer>${renderVisibleText(copy(reportData.language, "Generated from one reviewed Harness source · self-contained Codex HTML", "由同一份已复核 Harness source 生成 · 自包含 Codex HTML"), language)}</footer>
<footer>${renderVisibleText(copy(reportData.language, "Generated from one reviewed Harness source · self-contained portable HTML", "由同一份已复核 Harness source 生成 · 自包含便携式 HTML"), language)}</footer>
</main>
<dialog id="manual-copy-dialog" class="manual-copy-dialog" aria-labelledby="manual-copy-title" aria-describedby="manual-copy-description">
<div class="dialog-heading">
Expand Down
56 changes: 56 additions & 0 deletions test/reporting/harness-report-render-cli.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ function embeddedJson(html, id) {
return JSON.parse(payload);
}

function visibleHtmlText(html) {
return String(html)
.replace(/<(?:script|style)\b[^>]*>[\s\S]*?<\/(?:script|style)>/giu, " ")
.replace(/<[^>]+>/gu, "")
.replace(/\s+/gu, " ")
.trim();
}

function reviewedTaskLoopSource() {
const source = buildTaskLoopSourceCandidate({
scope: { platform: "qoder", workspace: "/tmp/render-source-project" },
Expand Down Expand Up @@ -1224,6 +1232,49 @@ test("DSH reuses portable HTML report data, target root, and exact artifact cont
});
});

test("generated DSH HTML uses host-neutral visible copy in both locales", async () => {
await withTempDir("better-harness-dsh-portable-copy-", async (root) => {
const findingsPath = path.join(root, "reviewed.findings.json");
await writeJson(findingsPath, dshReviewedFindings());

for (const row of [{
language: "en",
eyebrow: "Harness Insights · Portable HTML",
footer: "Generated from one reviewed Harness source · self-contained portable HTML",
copySuccess: "Copied. Paste into your coding agent input.",
oldCopySuccess: "Copied. Paste into the Codex input.",
}, {
language: "zh-CN",
eyebrow: "Harness 洞察 · 便携式 HTML",
footer: "由同一份已复核 Harness source 生成 · 自包含便携式 HTML",
copySuccess: "已复制,请粘贴到当前 Coding Agent 输入框。",
oldCopySuccess: "已复制,请粘贴到 Codex 输入框。",
}]) {
const result = runNode([
renderPath,
"--findings", findingsPath,
"--mode", "html",
"--platform", "dsh",
"--target", root,
"--run-dir", `copy-${row.language}`,
"--language", row.language,
"--validate",
"--json",
], { cwd: root });

assert.equal(result.status, 0, `${row.language}: ${result.stderr || result.stdout}`);
const payload = parseRun(result.stdout);
const html = readFileSync(path.join(payload.runDir, "report.html"), "utf8");
const visibleText = visibleHtmlText(html);
assert.equal(visibleText.includes(row.eyebrow), true, row.language);
assert.equal(visibleText.includes(row.footer), true, row.language);
assert.equal(visibleText.includes("Codex"), false, row.language);
assert.equal(html.includes(row.copySuccess), true, row.language);
assert.equal(html.includes(row.oldCopySuccess), false, row.language);
}
});
});

test("render routes html output by host id and fails closed on unknown platforms", async () => {
await withTempDir("better-harness-render-platform-", async (root) => {
const findingsPath = path.join(root, "input.findings.json");
Expand All @@ -1238,6 +1289,11 @@ test("render routes html output by host id and fails closed on unknown platforms
const payload = parseRun(routed.stdout);
assert.equal(payload.outputLocation.requestedOut, `.${platform}/better-harness`);
assert.equal(payload.runDir.includes(path.join(`.${platform}`, "better-harness")), true);
const html = readFileSync(path.join(payload.runDir, "report.html"), "utf8");
const visibleText = visibleHtmlText(html);
assert.equal(visibleText.includes("Harness Insights · Portable HTML"), true, platform);
assert.equal(visibleText.includes("Codex HTML"), false, platform);
assert.equal(html.includes("Paste into the Codex input"), false, platform);
}

const rejected = runNode(
Expand Down
4 changes: 2 additions & 2 deletions test/reporting/html-report-interactions.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const ACTION_PROMPT = actionPrompt();
const LABELS = {
copy: "Copy AI Fix",
copied: "Copied",
copySuccess: "Copied. Paste into the Codex input.",
copySuccess: "Copied. Paste into your coding agent input.",
manualCopy: "Automatic copy was blocked. Copy the selected prompt manually.",
missingPrompt: "No AI Fix prompt is available for this finding.",
};
Expand Down Expand Up @@ -421,6 +421,6 @@ test("rendered interaction controller localizes labels without host coupling", (

assert.match(script, /id="harness-report-interactions"/u);
assert.match(script, /复制 AI 修复/u);
assert.match(script, /已复制,请粘贴到 Codex 输入框。/u);
assert.match(script, /已复制,请粘贴到当前 Coding Agent 输入框。/u);
assert.doesNotMatch(script, /window\.openai|codex:\/\/|chatgpt:\/\//iu);
});