Skip to content

fix(trajectory-replay): show absent step durations as a dash - #226

Merged
lanyue-llk merged 3 commits into
mainfrom
fix/replay-step-duration-dash
Nov 4, 2026
Merged

lanyue-llk merged 3 commits into
mainfrom
fix/replay-step-duration-dash

Conversation

@lanyue-llk

@lanyue-llk lanyue-llk commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

What, why and how of this PR

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_ms rendered as 0.00 s in both languages, which reads as a measurement. It now shows a dash. A measured zero stays 0.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 and Actual status: pass · 0.00 s for 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_fixture now takes step_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 in trajectory-replay-pass and trajectory-replay-fail, and in trajectory-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 with diff -r. Four routes differ, and the step duration is the only value that changes:

Route Sample Old expression Fix
en/result/moli-old-29.html missing 0.00 s —
en/result/moli-fixed-29.html null 0.00 s —
result/moli-old-29.html missing 0.00 s —
result/moli-fixed-29.html null 0.00 s —

result/chromium-29.html and en/result/chromium-29.html hold the measured zero, and they are identical in both builds.

Test plan

  • New test_step_shows_absent_duration_as_dash_and_real_zero_as_zero covers missing, null, integer zero, float zero, a measured value and a step that never ran, in both languages, against literal strings.
  • New test_built_result_pages_keep_absent_and_zero_step_durations_apart checks the same values on the built English and Chinese result pages.
  • New test_step_dialog_keeps_absent_and_zero_durations_apart runs the built assets/app.js in 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.
  • Negative control: with the old row expression, the missing and null cases fail in both languages, as do the built-page test and the new snapshot. The other cases, including the measured zero, pass.
  • Negative control: with the old dialog expression, the new dialog test fails on the missing and null samples, checked separately for each language, and the measured zero still matches.
  • pytest tests/test_golden_reports.py tests/trajectory_replay -n 2: 2294 passed, 5 skipped.
  • ruff check (both lint gate commands): passed.
  • CI on Linux runs the full suite.

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.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Review complete · d836122

No findings in this review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 and Actual status: ... · 0.00 s in the dialog for the same step.
  • Reproduced: I built build_replay_fixture(..., step_samples=STEP_DURATION_SAMPLES), read the first step from each data/evidence/<method>-29.json, and ran that expression on it in Node. The built pages have the dialog and data-evidence-url, and the built assets/app.js contains 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 alters assets/app.js, so regenerate trajectory-replay-pass, trajectory-replay-fail and trajectory-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.0 and 1234 render as before. A step that never ran still gives a dash. An empty-string duration_ms would now raise instead of rendering zero, but neither replay executor writes one: executor.py starts at None and 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.py and tests/trajectory_replay/test_webarena_report.py gave 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.

@lanyue-llk

Copy link
Copy Markdown
Contributor Author

Review round 1:

Fixed in 3b958b0: the step dialog rendered an absent duration_ms as 0.00 s in both languages. It now shows a dash, and a measured zero stays 0.00 s. A new test runs the built assets/app.js in Node on the built evidence for missing, null and zero samples in both languages, and it fails on the old expression. The assets/app.js hash moved in trajectory-replay-pass, trajectory-replay-fail and trajectory-replay-step-durations, and no other route in those snapshots changed. The PR's Moved snapshots section is updated.

Disputed: nothing.

@lexmount-ocr lexmount-ocr Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Re-review complete · 3b958b0

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')

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style · low
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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@lexmount-ocr lexmount-ocr Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Re-review complete · 78e1e8b

No findings in this incremental review.

@lanyue-llk lanyue-llk left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ms and 0.00 s for 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 s in the old code and now raises. No writer produces that value: executor.py and the public WebArena executor write only None or 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 s instead of 0.00 s, but the same writers cannot produce one.
  • Scope of Closes #221: complete for the replay result page. In webarena_report.py and the report assets, the row and the dialog are the only per-step duration displays. report.py already 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-pass and trajectory-replay-fail move only on assets/app.js.
    • The new trajectory-replay-step-durations snapshot 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, each 0.00 s to —.
  • 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 2 gave 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.

lanyue-llk added a commit that referenced this pull request Nov 4, 2026
@lanyue-llk
lanyue-llk merged commit e7f8d2f into main Nov 4, 2026
7 checks passed
@lanyue-llk
lanyue-llk deleted the fix/replay-step-duration-dash branch November 4, 2026 05:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(trajectory-replay): show absent step durations as a dash

1 participant