fix(ego-browser): reject an unrecordable viewport instead of a 0x0 screencast - #252
fix(ego-browser): reject an unrecordable viewport instead of a 0x0 screencast#252Hotragn wants to merge 1 commit into
Conversation
|
Flagging this myself rather than leaving it to a reviewer to discover: I believe this PR is superseded on the That branch adds The defect is real on |
codeCraft-Ritik
left a comment
There was a problem hiding this comment.
Great job on the CI validation as well. Adding a targeted validate-reference-links.js check is a strong follow-up because it prevents the same class of broken links from silently returning later without turning the validator into an overly broad Markdown path linter.
Summary
page.screencast.start()validates an explicitly passedsize(rejecting anything under 2 pixels with a clear message) but never validates the size it derives itself. Two reachable states make that derived size0x0, which reaches ffmpeg asscale=0:0and fails with an encoder error that says nothing about the real cause:page.info()then returns{ dialog }with now/h, soMath.min(1, 800 / Math.max(undefined, undefined))isNaN, andNaN & ~1is0.w: 0/h: 0state SKILL.md already warns agents about ("stop screenshot/coordinate work until the real tab or viewport is restored").A third case needs no zero at all: an extreme aspect ratio such as
1000x2scales to a height of1, again below the floor the explicit path enforces.Related issue
No existing issue — found while auditing the screencast path alongside #251 (the other half of "recording fails for a reason the agent cannot act on").
Changes
src/driver/screencast.ts—defaultSize()now fails fast with an actionable message instead of handing a degenerate size to the encoder:size;w: 0, h: 0), so the agent can tell "no usable tab" from "encoder problem".The check runs on the computed size, so the extreme-aspect-ratio case is covered too, and it happens before the recorder is created — no encoder process is started and nothing needs cleaning up.
src/driver/screencast.test.mjs— 3 tests: the dialog case (also asserting no encoder is created), the zero-viewport case, and the1000x2scale-below-minimum case.No behavior change for any viewport that already produced a valid recording: the arithmetic is untouched, only a guard is added after it.
Verification
Run from
package/ego-browser(Windows 11, Node 24; tests injectpageInfovia the existing__testing.setOverridesseam, so they are platform-neutral):Degenerate-size arithmetic confirmed directly before writing the fix:
Revert-check: with
src/driver/screencast.tsreverted and the new tests kept, all three fail (17 pass / 3 fail); with the fix, 20 pass.Impact
A start that previously produced a broken recording (or a confusing ffmpeg error) now fails immediately with the reason. Recordings that worked before are unaffected — the guard only rejects sizes the encoder could not have used. Independent of #251; both touch the screencast failure path but different files, and either can merge first.
Checklist
devfor normal changes; onlydevmay targetmain).fix).