@@ -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 ( / < (?: s c r i p t | s t y l e ) \b [ ^ > ] * > [ \s \S ] * ?< \/ (?: s c r i p t | s t y l e ) > / giu, " " )
208+ . replace ( / < [ ^ > ] + > / gu, "" )
209+ . replace ( / \s + / gu, " " )
210+ . trim ( ) ;
211+ }
212+
205213function 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+
12271278test ( "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 (
0 commit comments