Repository navigation
refactor(browser-use): make English the source of the report renderer - #243
Conversation
Render the English edition directly from t(id, english) lookups, with Chinese in messages.json. Remove the post-render translation tables and the import of the Web Fetch translator. Rendered Chinese and English routes are unchanged.
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| _write_pages(Path(scratch), inputs, automatic_failure_counts) | ||
| write_english_report(Path(scratch), stage) |
There was a problem hiding this comment.
P2 — English result pages advertise hashes for discarded scratch artifacts when a failed execution has publishable screenshots. In this pass, _extract_trace_screenshots writes English label values into the screenshots array in execution-evidence.json; _write_execution_artifacts hashes that JSON, and _execution_evidence_html displays the hash. Only HTML is copied back, while its artifact links still resolve to the Chinese-pass JSON, whose labels—and therefore SHA-256—differ. Reuse the published execution artifact metadata/hashes when rendering English pages (localizing gallery labels separately), and add a failed-execution-with-screenshot test that compares the English page's displayed hash with the linked file.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 1
Reviewed head b9f114ed. One defect found. It is the same bug the OCR bot reported, which I reproduced independently.
P1: English result pages publish a wrong SHA-256 for failed executions with screenshots
- Where:
src/harness/browser_use/report.py:1679(label written into the evidence bundle),report.py:1783(hash shown),report.py:4160-4162(English pass discarded except for HTML). - Problem:
_extract_trace_screenshotswritest(...)intoscreenshots[].label, and_write_execution_artifactsstores that inexecution-evidence.jsonand hashes the file. The English pass therefore produces a JSON with different bytes from the Chinese pass, in a scratch directory that is then deleted. Only its HTML is kept, soen/results/<id>.htmlshows the hash of a file that was never published, next to a link to the Chinese-pass file. - Scope: failed scoring executions whose trace has a publishable frame, which is the normal case for a real failed result. The goldens and the 15-report differential miss it because every fixture trace is placeholder bytes, so no screenshot is extracted.
- Reproduction: I built the
build_browser_use_fixture(language="en", failed=True)report with a real one-frametrace.zip, then compared the publishedexecution-evidence.jsonhash with the hashes on the English page.- Base
2383a20f: match. - This PR: mismatch on
en/results/gpt-5.6-sol-moli-44.html(the file hashes tod31841af6f11…, which the page does not show). Across all pages in that report, this is the only one whose hash set differs between editions.
- Base
- Why it matters: a reader checking evidence against the English page gets a false integrity failure.
_check_execution_artifactsonly reads the Chinese result page, so the release gate does not catch it. The PR's statement that rendered output is unchanged does not hold for these pages. - Suggested fix (about 4 lines, trial-run): keep the bundle independent of the edition and localize only at render time.
- In
_extract_trace_screenshots, write the label with_ZH(...). The public JSON then keeps its current bytes. - In
_screenshot_gallery, render thealtand caption witht("extract_trace_screenshots.final_page_frame", ..., index=index, total=len(screenshots)), iterating withenumerate. - With this applied, the mismatch is gone and the English captions (
Final page frame 1/1) and Chinese captions are as before.
- In
- Test: add a failed-result test with a real trace frame that asserts the English page shows the SHA-256 of the linked file. It should fail on the current head.
Verified with no finding
- Over-design: the two-pass render with a module-level
tadds no new lookup, registry or route table. It reusescatalog_text._Authored,_searchable_rationaleand_PageWriterexist only to keep bytes identical, as the scope requires. - Escaping: no
tsource inreport.pycontains",<or&, so thequote=Falsepath in_efor_Authoredtext does not break the attributes I checked. - Catalog: the 665
zhIDs match the IDs used in both renderers, and no ID has two different English sources. Chinese strings match the old source. The 6 that did not match by mechanical search were strings split across lines in the old code; I confirmed the 4 I read directly. - Table removal: the fields that relied on the deleted table have their own English. All
browser_use_reviewsandbrowser_use_releasesrecords inresearch/report-changes.jsonhavei18n.en, and verified causes are read throughlocalized_cause. I found no comparison that depends on the edition other than the two_ZHchecks for "not recorded". - Issue scope: "Part of #99" is accurate, and the remaining work and known defects are listed. Han-line counts match the PR table (
report.py0,report_check.py0,report_i18n.py1,messages.json690). - Evidence: no files under
evaluation/orresearch/changed, and no golden snapshots were regenerated. - Local runs: both
ruffgates pass.tests/test_golden_reports.py,tests/browser_use/test_report.py,test_report_i18n.py,test_report_check.pyandtests/test_report_software_versions.pygave 190 passed. I did not run the full suite locally. - Not checked: no real Browser Use evidence was available, so I did not build a report from it.
CI on b9f114ed
"Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" pass. ocr-review is red because of the finding above, so it comes from this PR and I did not rerun it.
…dition The frame label was rendered per edition into the hashed evidence bundle, so English result pages showed the hash of a discarded scratch file. Keep the bundle label fixed and render the caption per edition in the gallery.
|
Review round 1: Fixed (2be2d28): English result pages showed a wrong SHA-256 for Added A one-off check on that failed fixture with a trace also found every non-HTML file from the English scratch pass byte-identical to the one kept from the Chinese pass. Disputed: nothing. Golden snapshots passed with no regeneration. |
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| def _rationale(task: dict[str, Any]) -> str: | ||
| """Read the frozen selection rationale, which has no English field of its own.""" | ||
| return _Authored(english_rationale(task["rationale"])) if _language() == "en" else task["rationale"] |
There was a problem hiding this comment.
P2: Apply this helper to the visible task label in _same_task_comparison as well. That function still renders _e(task["rationale"]), so removing the old post-render translation loses the existing English labels for the 28 rationales retained in rationale_en. For example, “Open an authenticated GitLab target page” now appears in English on the dataset page but remains Chinese in the English comparison matrix. Use _rationale(task) for that label and cover a mapped rationale in the English analysis-page test; leave unmapped rationales and measured intents unchanged.
There was a problem hiding this comment.
Disputed: this is not a regression from this PR. The old post-render translation never translated this label, because the text node is #<id> · <rationale>, which the exact-string table did not match.
- I ran base
2383a20f'slocalize_htmlover this cell for all 90 pilot tasks, including the 28 with an entry inrationale_en. All 90 kept their raw Chinese rationale. - I built the English fixture report on base and on
2be2d289, passing and failing, with a real trace. Every HTML file is byte-identical, including#44 · 打开一个需要登录的 GitLab 目标页inen/analysis/index.html.
The suggested change would alter rendered output, which this PR must keep byte-identical. It stays Chinese here, and I added it to the PR's list of existing English-edition defects kept on purpose.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 2
Reviewed head 2be2d289. No P0, P1 or P2 defects found. One P3 note, which does not block.
P3: research/browser-use-failure-analysis.json no longer has a reader
- Where:
research/browser-use-failure-analysis.json - Problem: the import-time read in the old
report_i18n.pywas its only reader. On this head,git grepfinds no reference to it anywhere in the repository. Rendered output is not affected. - Suggested fix: delete it in this PR if it has no other purpose, since AGENTS.md asks for superseded files to be removed with their last caller.
What I verified
- Round 1 fix:
test_english_failed_result_shows_the_hash_of_its_linked_evidence_filepasses. It fails when the bundle label atreport.py:1679goes back tot(...). No other writer of execution artifacts callst, so the JSON those hashes cover no longer depends on the edition. Gallery captions use the same index and total as the old stored label, because the total is the frame count in both. - Disputed OCR finding on
report.py:94: the dispute is sound. Basetranslate_textleaves#44 · 打开一个需要登录的 GitLab 目标页unchanged, so this is not a regression and the suggested change would alter rendered output. I did not repeat the author's HTML comparison between base and head. - Chinese text: every Han fragment in the catalog appears in the base renderers, apart from 6 fragments in 5 entries. I sampled two of those five; their text is still in the base source, split across string concatenations. I did not compare placeholder values against the old f-string expressions call by call.
- English text against the old translator: I ran base
translate_textover each placeholder-free catalog entry and compared it with the new English source. There were 95 differences.- I read them all. Most are strings the old table left Chinese or partly translated, including text the base renderer already kept in English beside it.
- A few are wording changes that do not alter the meaning, such as
Expert-repair originsbecomingExpert-repaired paths. These sit on code paths the fixtures may not reach, so they could change real English pages. The PR body's list of output differences does not name this kind of rewording.
- Data-driven text: I listed every repository JSON string under
research/andevaluation/browser-use/that the old translator rewrote. The reader-facing groups now come fromrationale_en,localized_causeand_record_text. The other groups are the now-unread file above and records for other tracks. - Rendering twice:
- Load-time
tcalls are limited to the three "not recorded" defaults and_automatic_failure_type. All render paths for the defaults go through_recordedor an explicit comparison. The storedautomatic_failure_typeonly reachesdata/results.jsonl. - The page writers do not change shared input fields in ways I could find, and the renderer has no cached translated text.
- Load-time
- Escaping:
_Authoredturns off quote escaping, but no_e(t(...))or_e(_rationale(...))call sits directly in an attribute. A scan of the renderer found none, though it would not catch a value passed through a variable first.- I checked the catalog values passed without
_eat the sites most likely to carry measured text:_failure_brief, the task identity line and the result hero. I did not review each of the other unwrapped values one by one, and I did not compare these sites' escaping with base.
- Scope: the Chinese-line counts in the PR body match what I measured, per file and on base. "Part of #99" is accurate, and the remaining list matches the Han lines left under
src/harness/browser_use/. The diff does not touchtests/golden,evaluation/orresearch/. - Over-design: nothing to remove. The change deletes more than it adds, reuses
catalog_text, and adds no new lookup or registry. The AST catalog tests have the same kind of counterpart in the trajectory replay and web search message tests. - Local runs on this head: both
ruffgates pass, andtests/test_golden_reports.pyplustests/browser_usepass (353) with no snapshot regeneration. I did not run the browser interaction tests or the full suite locally.
CI
- Passing on
2be2d289: Tests and static checks, Installation and packaging, Rendered reference and report checks, Python 3.11, Select check scope and OCR dispatch. - Red:
ocr-review, which reports 1 blocking finding. That is the disputed finding above, so I do not count it as a defect in this PR. - Rerun: my one attempt failed, because
gh run rerunreturned a 404 while looking up the OCR dispatch workflow. The status is still red and needs the owner to clear it or re-trigger the bot.
Issues
Part of #99. Remaining after this PR:
browser_use/report_publish.py(3 lines: the Chinese home-title marker and default site title),browser_use/publication.py(1 line: the truncation note in evidence excerpts) andassets/evidence-viewer.js(1 line, which picks its language at runtime). These are outside this step and have no catalog need worth a rewrite.Summary
The Browser Use report no longer renders Chinese and rewrites it afterwards.
build_reportnow renders the pages twice, once per edition, throught(id, english)from the existingreporting.locales.catalog_text. Chinese lives inbrowser_use/messages.jsonunder semantic IDs. The English pass runs in a scratch directory and only its HTML joins the report underen/; data files still come from the Chinese pass.Deleted:
report-translations.json(1,515 exact strings and phrases), about 130 regex translations,translate_text, the import-time reads ofresearch/*.json, and the dependency on Web Fetch's translator.report_i18n.pykeeps the catalog binding plus the link, navigation and attribute rewrite foren/.report.pyreport_check.pyreport_i18n.py中文language link)report-translations.jsonmessages.jsonreport.pyandreport_check.pyare added to the source policy'sCATALOG_RENDERERS, so inline Chinese fails the existing check.Left in place
evaluation/browser-use/webarena-verified-pilot.json. Its 90 task rationales are project-written Chinese with no English field, and 28 had English in the old table. Those 28 moved tomessages.jsonunderrationale_en; the other 62 stay Chinese on English routes, as they do today.zh/enfields. The renderer now reads the field for the edition instead of going through a table.Existing English-edition defects kept on purpose
Fixing any of these changes rendered bytes, so they are preserved and marked by
_ZH, or by a small helper, in the code:待复核,未分类,处理:, the step label before:on result pages, the evaluator error log, and the diagnosis text in the result search index.#<id> · <rationale>.<span>in both editions.规则becomesRuleinside one task's search index entry (_searchable_rationale).、and;remain in joined model lists and some per-model cells.Output differences that fixtures cannot show
There is no real Browser Use evidence on this machine, so none of this has been checked against a real report:
Test plan
tests/test_golden_reports.py:browser-use-passandbrowser-use-failpass with no snapshot regeneration, and the other tracks are unchanged.browser-eval-version.jsonfiles, which record the source hash.tests/browser_use, source policy, packaging, public language, templates, visual, privacy and publication groups: 694 passed and 1 failed on a mixed-case catalog ID, which I fixed. After that fix I reran onlytest_report_i18n.py,test_report.pyand golden: 126 passed.translate_textmappings. Added catalog tests (semantic IDs, catalog equals used IDs, placeholders supplied, no Chinese in the renderers) and a direct English-edition build test.test_english_failed_result_shows_the_hash_of_its_linked_evidence_filebuilds a failed result from a real one-frame trace and fails without the fix. After the fix,tests/test_golden_reports.py,tests/browser_useandtests/test_report_browser_interactions.pypass (368) with no snapshot regeneration.ruffcommands pass.node_modules, a missing report profile, a stale dataset lock on the shared environment), and I did not triage all of them. CI is the full-suite gate: "Tests and static checks" and "Installation and packaging" both pass on this head.