Skip to content

chore(agent-browser): drop redundant viewportWidth/Height status cast#171

Open
dormouse-bot wants to merge 1 commit into
mainfrom
chore/agent-browser-drop-redundant-status-cast
Open

chore(agent-browser): drop redundant viewportWidth/Height status cast#171
dormouse-bot wants to merge 1 commit into
mainfrom
chore/agent-browser-drop-redundant-status-cast

Conversation

@dormouse-bot

Copy link
Copy Markdown
Collaborator

Surfaced by the nightly code-quality survey.

The status event payload in AgentBrowserPanel's connection subscription is already typed AgentBrowserStreamStatus (imported as StreamStatus), and that interface declares viewportWidth?: number and viewportHeight?: number (agent-browser-connection.ts#L27-L28). The status branch nonetheless re-cast event.status to StreamStatus & { viewportWidth?: number; viewportHeight?: number } before reading those fields — an intersection that adds nothing the base type doesn't already provide.

This reads the fields directly off event.status, dropping the cast and the intermediate maybeStatus local. Pure simplification — no behavior change; the typeof … === 'number' guards are unchanged.

No regression test: this is a type-level cleanup with no runtime behavior change, validated by the tsc -b step in CI.

The `status` event payload is already typed `AgentBrowserStreamStatus`
(aliased `StreamStatus`), which declares `viewportWidth?: number` and
`viewportHeight?: number` (agent-browser-connection.ts:27-28). The
intersection cast at the status branch added nothing, so read the fields
directly off `event.status`.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying mouseterm with  Cloudflare Pages  Cloudflare Pages

Latest commit: 9d010ce
Status: ✅  Deploy successful!
Preview URL: https://871a5449.mouseterm.pages.dev
Branch Preview URL: https://chore-agent-browser-drop-red.mouseterm.pages.dev

View logs

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.

1 participant