Skip to content

Commit a415fa6

Browse files
Cobb04codex
andauthored
fix(reporting): use host-neutral portable HTML copy (#116)
Replace Codex-specific header, footer, and copy-success text in the shared portable HTML renderer with host-neutral English and Chinese wording. Add generated DSH and cross-host control coverage for Bug #115. Validated with the literal npm run check gate on Node 24.15.0 and the focused renderer suites on Node 22.20.0 and Node 24.15.0. Co-authored-by: Codex (GPT 5.6 Sol) <codex@openai.com>
1 parent 6e0d68b commit a415fa6

4 files changed

Lines changed: 62 additions & 6 deletions

File tree

scripts/harness-analysis/renderers/html-interactions.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -265,14 +265,14 @@ export function renderHtmlInteractionScript(language) {
265265
? {
266266
copy: "复制 AI 修复",
267267
copied: "已复制",
268-
copySuccess: "已复制,请粘贴到 Codex 输入框。",
268+
copySuccess: "已复制,请粘贴到当前 Coding Agent 输入框。",
269269
manualCopy: "自动复制被阻止,请手动复制已选中的提示词。",
270270
missingPrompt: "这个问题没有可用的 AI 修复提示词。",
271271
}
272272
: {
273273
copy: "Copy AI Fix",
274274
copied: "Copied",
275-
copySuccess: "Copied. Paste into the Codex input.",
275+
copySuccess: "Copied. Paste into your coding agent input.",
276276
manualCopy: "Automatic copy was blocked. Copy the selected prompt manually.",
277277
missingPrompt: "No AI Fix prompt is available for this finding.",
278278
};

scripts/harness-analysis/renderers/html.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ function renderHtmlBody(reportData) {
580580

581581
return `<header class="hero" data-section="overview">
582582
<div class="hero-copy">
583-
<span class="eyebrow">${renderVisibleText(copy(language, "Harness Insights · Codex HTML", "Harness 洞察 · Codex HTML"), language)}</span>
583+
<span class="eyebrow">${renderVisibleText(copy(language, "Harness Insights · Portable HTML", "Harness 洞察 · 便携式 HTML"), language)}</span>
584584
<h1>${renderVisibleText(projectName, language)}</h1>
585585
<p>${renderVisibleText(overview, language)}</p>
586586
<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>
@@ -656,7 +656,7 @@ export function renderHtml(reportData, actionContext) {
656656
<div id="copy-status" class="sr-only" role="status" aria-live="polite"></div>
657657
<main id="harness-report" data-report-mode="codex-html">
658658
${renderHtmlBody(reportData)}
659-
<footer>${renderVisibleText(copy(reportData.language, "Generated from one reviewed Harness source · self-contained Codex HTML", "由同一份已复核 Harness source 生成 · 自包含 Codex HTML"), language)}</footer>
659+
<footer>${renderVisibleText(copy(reportData.language, "Generated from one reviewed Harness source · self-contained portable HTML", "由同一份已复核 Harness source 生成 · 自包含便携式 HTML"), language)}</footer>
660660
</main>
661661
<dialog id="manual-copy-dialog" class="manual-copy-dialog" aria-labelledby="manual-copy-title" aria-describedby="manual-copy-description">
662662
<div class="dialog-heading">

test/reporting/harness-report-render-cli.test.mjs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ function embeddedJson(html, id) {
202202
return JSON.parse(payload);
203203
}
204204

205+
function visibleHtmlText(html) {
206+
return String(html)
207+
.replace(/<(?:script|style)\b[^>]*>[\s\S]*?<\/(?:script|style)>/giu, " ")
208+
.replace(/<[^>]+>/gu, "")
209+
.replace(/\s+/gu, " ")
210+
.trim();
211+
}
212+
205213
function reviewedTaskLoopSource() {
206214
const source = buildTaskLoopSourceCandidate({
207215
scope: { platform: "qoder", workspace: "/tmp/render-source-project" },
@@ -1224,6 +1232,49 @@ test("DSH reuses portable HTML report data, target root, and exact artifact cont
12241232
});
12251233
});
12261234

1235+
test("generated DSH HTML uses host-neutral visible copy in both locales", async () => {
1236+
await withTempDir("better-harness-dsh-portable-copy-", async (root) => {
1237+
const findingsPath = path.join(root, "reviewed.findings.json");
1238+
await writeJson(findingsPath, dshReviewedFindings());
1239+
1240+
for (const row of [{
1241+
language: "en",
1242+
eyebrow: "Harness Insights · Portable HTML",
1243+
footer: "Generated from one reviewed Harness source · self-contained portable HTML",
1244+
copySuccess: "Copied. Paste into your coding agent input.",
1245+
oldCopySuccess: "Copied. Paste into the Codex input.",
1246+
}, {
1247+
language: "zh-CN",
1248+
eyebrow: "Harness 洞察 · 便携式 HTML",
1249+
footer: "由同一份已复核 Harness source 生成 · 自包含便携式 HTML",
1250+
copySuccess: "已复制,请粘贴到当前 Coding Agent 输入框。",
1251+
oldCopySuccess: "已复制,请粘贴到 Codex 输入框。",
1252+
}]) {
1253+
const result = runNode([
1254+
renderPath,
1255+
"--findings", findingsPath,
1256+
"--mode", "html",
1257+
"--platform", "dsh",
1258+
"--target", root,
1259+
"--run-dir", `copy-${row.language}`,
1260+
"--language", row.language,
1261+
"--validate",
1262+
"--json",
1263+
], { cwd: root });
1264+
1265+
assert.equal(result.status, 0, `${row.language}: ${result.stderr || result.stdout}`);
1266+
const payload = parseRun(result.stdout);
1267+
const html = readFileSync(path.join(payload.runDir, "report.html"), "utf8");
1268+
const visibleText = visibleHtmlText(html);
1269+
assert.equal(visibleText.includes(row.eyebrow), true, row.language);
1270+
assert.equal(visibleText.includes(row.footer), true, row.language);
1271+
assert.equal(visibleText.includes("Codex"), false, row.language);
1272+
assert.equal(html.includes(row.copySuccess), true, row.language);
1273+
assert.equal(html.includes(row.oldCopySuccess), false, row.language);
1274+
}
1275+
});
1276+
});
1277+
12271278
test("render routes html output by host id and fails closed on unknown platforms", async () => {
12281279
await withTempDir("better-harness-render-platform-", async (root) => {
12291280
const findingsPath = path.join(root, "input.findings.json");
@@ -1238,6 +1289,11 @@ test("render routes html output by host id and fails closed on unknown platforms
12381289
const payload = parseRun(routed.stdout);
12391290
assert.equal(payload.outputLocation.requestedOut, `.${platform}/better-harness`);
12401291
assert.equal(payload.runDir.includes(path.join(`.${platform}`, "better-harness")), true);
1292+
const html = readFileSync(path.join(payload.runDir, "report.html"), "utf8");
1293+
const visibleText = visibleHtmlText(html);
1294+
assert.equal(visibleText.includes("Harness Insights · Portable HTML"), true, platform);
1295+
assert.equal(visibleText.includes("Codex HTML"), false, platform);
1296+
assert.equal(html.includes("Paste into the Codex input"), false, platform);
12411297
}
12421298

12431299
const rejected = runNode(

test/reporting/html-report-interactions.test.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ const ACTION_PROMPT = actionPrompt();
4949
const LABELS = {
5050
copy: "Copy AI Fix",
5151
copied: "Copied",
52-
copySuccess: "Copied. Paste into the Codex input.",
52+
copySuccess: "Copied. Paste into your coding agent input.",
5353
manualCopy: "Automatic copy was blocked. Copy the selected prompt manually.",
5454
missingPrompt: "No AI Fix prompt is available for this finding.",
5555
};
@@ -421,6 +421,6 @@ test("rendered interaction controller localizes labels without host coupling", (
421421

422422
assert.match(script, /id="harness-report-interactions"/u);
423423
assert.match(script, / AI /u);
424-
assert.match(script, / Codex /u);
424+
assert.match(script, / Coding Agent /u);
425425
assert.doesNotMatch(script, /window\.openai|codex:\/\/|chatgpt:\/\//iu);
426426
});

0 commit comments

Comments
 (0)