Built-in Browser: CDP Emulation.setDeviceMetricsOverride left active; window resize no longer matches layout

Where does the bug appear (feature/product)?

Cursor IDE

Describe the Bug

Environment

  • Cursor Desktop (macOS)
  • Cursor version: 3.21.13 (confirm via About Cursor)
  • Feature: cursor-ide-browser + CDP

Summary
After an Agent uses CDP Emulation.setDeviceMetricsOverride (e.g. 390×844, deviceScaleFactor 2) for mobile screenshots, the override sometimes remains ON. The browser panel can be fullscreen/wide, but window.innerWidth stays ~390 and the page keeps a mobile layout. Resizing the panel does not restore desktop layout.

Actual

  • Override stays active; innerWidth ~390 while the panel is ~1440px wide.
  • clearDeviceMetricsOverride restores ~1445px and desktop layout.

Workarounds

  • CDP clearDeviceMetricsOverride; reload/close the tab; use Playwright/external browser for responsive QA.

Control

  • Same Next.js app in Playwright: scrollWidth === clientWidth from 1440→390 (no document horizontal overflow).

Request

  • Auto-clear device metrics when agent browser sessions end.
  • Visible “device emulation active” indicator in the built-in browser.

Steps to Reproduce

Steps to reproduce

  1. Open a local app in Cursor’s built-in browser (agent: cursor-ide-browser).
  2. CDP: Emulation.setDeviceMetricsOverride width=390, height=844, deviceScaleFactor=2, mobile=true.
  3. End the agent session without Emulation.clearDeviceMetricsOverride.
  4. Expand/fullscreen the Cursor browser and resize it.

Expected Behavior

Expected

  • Override cleared (or scoped) when agent automation ends.
  • innerWidth tracks the actual panel width.

Operating System

MacOS

Version Information

Cursor version ~3.21.13

Does this stop you from using Cursor

Sometimes - I can sometimes use Cursor

Hey, thanks for the detailed report. Playwright control is especially helpful.

You read everything correctly. When the agent sends Emulation.setDeviceMetricsOverride via CDP in the built-in browser, the override is tied to that tab and stays active until something clears it. Resizing the panel doesn’t cancel it, so the page keeps reporting an approx 390px viewport even in a wide panel. I passed this to the team along with your two requests: auto-clear the override when the agent session ends, and an indicator when emulation is active.

For now, the fastest workarounds are:

  1. Ask the agent to run Emulation.clearDeviceMetricsOverride on the tab when it’s done taking mobile screenshots. You can add this to the prompt or a rule so it always clears, or
  2. Close that browser tab and open the page in a new one. A new tab starts without the override.

If you ever see the override survive closing and reopening the tab, let me know and we’ll dig deeper.