Repository navigation
fix(trajectory-replay): show absent step durations as a dash - #226
Conversation
An executed step without a duration sample rendered as 0.00 s in both languages, which reads as a measurement. It now shows a dash and a measured zero stays 0.00 s. The replay fixture gains an indexed-step mode and its own snapshot, because the existing snapshots never reach this value.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 1
Reviewed head d836122b. One finding blocks the Closes #221 claim.
Findings
P2: src/harness/trajectory_replay/assets/webarena-report.js:234: the step dialog on the same result page still shows an absent duration as 0.00 s.
- Problem: The fix covers the trajectory row in
_detail_page, but each step also has a dialog, opened by the "Fixed arguments" and "Actual arguments, logs and error" buttons. Its status line has the same defect in both languages:((Number(actual.duration_ms)||0)/1000).toFixed(2)+' s'. After this PR, a reader sees—on the row andActual status: ... · 0.00 sin the dialog for the same step. - Reproduced: I built
build_replay_fixture(..., step_samples=STEP_DURATION_SAMPLES), read the first step from eachdata/evidence/<method>-29.json, and ran that expression on it in Node. The built pages have the dialog anddata-evidence-url, and the builtassets/app.jscontains the expression. I did not click through the dialog in a browser.
| Method | duration_ms in evidence |
Row after this PR | Dialog expression |
|---|---|---|---|
chromium |
0 |
0.00 s |
0.00 s |
moli-old |
key missing | — |
0.00 s |
moli-fixed |
null |
— |
0.00 s |
- Why it matters: The defect predates this PR, and #221 only names the Python line. But #221 asks for a dash on an executed step without a duration sample, and this PR closes it, so an absent sample must not still read as a measurement on that page. The two new tests only look at
.aligned-actual-head, and no test covers the dialog text. - Suggested fix: Keep the measured zero and print a dash when the sample is absent:
(actual.duration_ms==null?'—':(Number(actual.duration_ms)/1000).toFixed(2)+' s')
Add a test that runs this path for the missing, null and zero samples in both languages. The change altersassets/app.js, so regeneratetrajectory-replay-pass,trajectory-replay-failandtrajectory-replay-step-durations, and update the "Moved snapshots" section, which currently says no existing snapshot moved.
Verified with no defects
- Python semantics: Compared with the old expression, missing and null now give a dash, while
0,0.0and1234render as before. A step that never ran still gives a dash. An empty-stringduration_mswould now raise instead of rendering zero, but neither replay executor writes one:executor.pystarts atNoneand then stores a rounded float. - Negative control: With the old expression restored, 6 tests fail: the missing and null cases in both languages, the built-page test and the new snapshot. The measured-zero cases still pass.
- Snapshots: The only golden change is the new
trajectory-replay-step-durations.json. The other 16 snapshots pass without being regenerated. - Local runs:
tests/test_golden_reports.pyandtests/trajectory_replay/test_webarena_report.pygave 95 passed. Both lint gate commands passed. - Rules: No hash-bound evidence, compatibility alias or parallel implementation was added, and
src/changes only the one renderer. - CI on this head: "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and "Python 3.11" are all green.
|
Review round 1: Fixed in 3b958b0: the step dialog rendered an absent Disputed: nothing. |
There was a problem hiding this comment.
This review found 1 issue(s), including 1 blocking issue(s).
| } | ||
| stepDialog.querySelector('[data-step-status]').textContent=actual | ||
| ?(zh?'实际状态:':'Actual status: ')+(actual.status||'—')+' · '+((Number(actual.duration_ms)||0)/1000).toFixed(2)+' s' | ||
| ?(zh?'实际状态:':'Actual status: ')+(actual.status||'—')+' · '+(actual.duration_ms==null?'—':(Number(actual.duration_ms)/1000).toFixed(2)+' s') |
There was a problem hiding this comment.
P2 — The new duration expression violates two mandatory Code Quality Checks: it uses loose equality (==null) and adds a ternary nested inside the existing actual ternary. The missing/null/zero behavior is correct, so this is a localized rule-compliance issue, not a runtime defect. Compute the duration text separately using an if and explicit === null / === undefined checks, then concatenate it here; preserve — for absent samples and 0.00 s for measured zero.
There was a problem hiding this comment.
Fixed in 78e1e8b: the duration text now comes from a small helper with an if and explicit === null / === undefined checks, so there is no loose equality or nested ternary. Missing and null samples still show a dash, and a measured zero still shows 0.00 s. The assets/app.js hash moved again in the same three snapshots.
There was a problem hiding this comment.
✅ Re-review complete · 78e1e8b
No findings in this incremental review.
lanyue-llk
left a comment
There was a problem hiding this comment.
Independent review, round 2
Reviewed head 78e1e8bd against main f6559139, which is still the newest main. No defects found.
What I verified
- Round 1 finding: fixed. The step dialog now shows a dash for an absent
duration_msand0.00 sfor a measured zero, in both languages. - Row semantics: I compared the old and new expressions. They differ only for an executed step with a missing or null sample, plus an empty string, which falls back to
0.00 sin the old code and now raises. No writer produces that value:executor.pyand the public WebArena executor write onlyNoneor a rounded float. A step that never ran still shows a dash. - Dialog semantics: the helper has the same scope. A non-numeric value would now show
NaN sinstead of0.00 s, but the same writers cannot produce one. - Scope of
Closes #221: complete for the replay result page. Inwebarena_report.pyand the report assets, the row and the dialog are the only per-step duration displays.report.pyalready renders its own step duration through_show, and the PR does not touch it. - Negative controls, each run on this head and then restored:
- Old row expression: 6 tests fail: missing and null in each language, the built-page test and the new snapshot.
- Old dialog fallback (
durationMs||0): 2 tests fail: the dialog test and the new snapshot. - Zero treated as absent in both places: 7 tests fail, including the measured-zero and float-zero cases and the dialog test.
- Snapshots:
trajectory-replay-passandtrajectory-replay-failmove only onassets/app.js.- The new
trajectory-replay-step-durationssnapshot passes. - The other 14 snapshots pass without being regenerated.
- I rebuilt the new fixture with the old row expression and ran
diff -r. The same four routes named in the PR differ, four changed lines in all, each0.00 sto—.
- Rules: no evidence, profile, receipt or workflow file changed, and the diff adds no alias or parallel implementation. It touches only the existing renderer, its script asset, tests and snapshots.
- Local runs:
pytest tests/test_golden_reports.py tests/trajectory_replay -n 2gave 2294 passed, 5 skipped. Both lint gate commands passed. - CI on this head: all checks pass, including "Tests and static checks", "Installation and packaging", "Rendered reference and report checks" and
ocr-review. CI installs Node, which the dialog test requires.
Issues
Closes #221
Summary
Each step in the replay result page's trajectory section shows its own duration. An executed step with a missing or null
duration_msrendered as0.00 sin both languages, which reads as a measurement. It now shows a dash. A measured zero stays0.00 s, and a step that never ran still shows a dash.The step dialog on the same page had the same defect in
assets/app.js, and it now follows the same rule:Actual status: pass · —for an absent sample andActual status: pass · 0.00 sfor a measured zero, with the matching Chinese label.The existing replay snapshots could not see this line: their trace steps carry no
index, so no step on the page matches an executed record.build_replay_fixturenow takesstep_samples, one duration sample per method, which indexes each trace step. A new snapshot,trajectory-replay-step-durations, uses it with a measured zero, a missing key and a null.Moved snapshots
One route moved:
assets/app.js, because of the step dialog fix. Its hash changes intrajectory-replay-passandtrajectory-replay-fail, and intrajectory-replay-step-durations, the new snapshot this PR adds to record the fixed output. No other route in those files changed, and the other 14 snapshots pass without being regenerated.To show what the row fix changes, I built the new fixture with the old expression and with the fix, using
GOLDEN_KEEP, and compared them withdiff -r. Four routes differ, and the step duration is the only value that changes:en/result/moli-old-29.html0.00 s—en/result/moli-fixed-29.html0.00 s—result/moli-old-29.html0.00 s—result/moli-fixed-29.html0.00 s—result/chromium-29.htmlanden/result/chromium-29.htmlhold the measured zero, and they are identical in both builds.Test plan
test_step_shows_absent_duration_as_dash_and_real_zero_as_zerocovers missing, null, integer zero, float zero, a measured value and a step that never ran, in both languages, against literal strings.test_built_result_pages_keep_absent_and_zero_step_durations_apartchecks the same values on the built English and Chinese result pages.test_step_dialog_keeps_absent_and_zero_durations_apartruns the builtassets/app.jsin Node against a minimal DOM, using each built page's dialog evidence, and checks the dialog status for missing, null and zero samples in both languages.pytest tests/test_golden_reports.py tests/trajectory_replay -n 2: 2294 passed, 5 skipped.ruff check(both lint gate commands): passed.