Skip to content

fix: decouple sandbox resolution from browser breakpoints#38

Open
ondraulehla wants to merge 1 commit into
e2b-dev:mainfrom
ondraulehla:fix/decouple-sandbox-resolution-from-breakpoints
Open

fix: decouple sandbox resolution from browser breakpoints#38
ondraulehla wants to merge 1 commit into
e2b-dev:mainfrom
ondraulehla:fix/decouple-sandbox-resolution-from-breakpoints

Conversation

@ondraulehla

@ondraulehla ondraulehla commented Jul 14, 2026

Copy link
Copy Markdown

Fixes #1

Problem

The sandbox resolution was derived directly from the VNC iframe wrapper's client size, with breakpoint-dependent fallbacks. On small breakpoints (mobile) the Linux desktop was therefore created at viewport-sized resolutions around 350x300. Linux is not usable at these sizes, and since the model receives raw screenshots of that desktop, the agent gets confused. This is exactly the behavior described in #1.

Fix

  • Add lib/resolution.ts with getSandboxResolution(): large viewports are scaled down proportionally into the existing MAX_RESOLUTION_* bounds (preserving the panel's aspect ratio), while viewports below MIN_RESOLUTION_* (i.e. mobile breakpoints) fall back to DEFAULT_RESOLUTION (1024x720) instead of shrinking the VM.
  • Use it on the client (app/page.tsx), replacing the two duplicated breakpoint-dependent measurement blocks in onSubmit and handleExampleClick.
  • Enforce it server-side in app/api/chat/route.ts before Sandbox.create, so the sandbox always gets a desktop-class resolution regardless of what the client sends.

Why no display or coordinate changes are needed

The E2B stream URL uses noVNC's resize=scale (the @e2b/desktop default), which scales the framebuffer down to fit the iframe while preserving the aspect ratio, and translates pointer coordinates itself. On mobile the full 1024x720 desktop is simply displayed smaller. Model actions are unaffected: screenshots and executed actions both use the raw sandbox coordinate space.

Verified with npm run build (Next.js production build passes) and numeric checks of the helper: [343,300] -> [1024,720], [1920,1080] -> [1024,576], [700,500] -> [700,500], invalid or missing input -> [1024,720].

The sandbox resolution was taken directly from the VNC iframe wrapper's
client size, so small breakpoints (e.g. mobile) created Linux desktops at
viewport-sized resolutions (~350x300), which the agent cannot operate
reliably (e2b-dev#1).

Introduce getSandboxResolution() which scales large viewports down
proportionally to the configured max bounds and falls back to
DEFAULT_RESOLUTION whenever the viewport is below the min bounds. The
helper is applied on the client when sending a message and enforced
server-side in the chat route before Sandbox.create, so the sandbox
always gets a desktop-class resolution regardless of the client.

The displayed stream still fits small screens: the E2B stream URL uses
noVNC's resize=scale, which shrinks the framebuffer to the container
while preserving aspect ratio and translating pointer coordinates.
Model coordinates are unaffected since screenshots and actions both use
the raw sandbox coordinate space.

Fixes e2b-dev#1

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@cla-bot

cla-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

We require contributors to sign our Contributor License Agreement, and we don't have @ondraulehla on file. You can sign our CLA at https://e2b.dev/docs/cla . Once you've signed, post a comment here that says '@cla-bot check'

@vercel

vercel Bot commented Jul 14, 2026

Copy link
Copy Markdown

@ondraulehla is attempting to deploy a commit to the E2B Team on Vercel.

A member of the Team first needs to authorize it.

@ondraulehla

Copy link
Copy Markdown
Author

@cla-bot check

@cla-bot cla-bot Bot added the cla-signed label Jul 14, 2026
@cla-bot

cla-bot Bot commented Jul 14, 2026

Copy link
Copy Markdown

The cla-bot has been summoned, and re-checked this pull request!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix agent confusion on small breakpoints

1 participant