fix: decouple sandbox resolution from browser breakpoints#38
Open
ondraulehla wants to merge 1 commit into
Open
fix: decouple sandbox resolution from browser breakpoints#38ondraulehla wants to merge 1 commit into
ondraulehla wants to merge 1 commit into
Conversation
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>
|
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' |
|
@ondraulehla is attempting to deploy a commit to the E2B Team on Vercel. A member of the Team first needs to authorize it. |
Author
|
@cla-bot check |
|
The cla-bot has been summoned, and re-checked this pull request! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
lib/resolution.tswithgetSandboxResolution(): large viewports are scaled down proportionally into the existingMAX_RESOLUTION_*bounds (preserving the panel's aspect ratio), while viewports belowMIN_RESOLUTION_*(i.e. mobile breakpoints) fall back toDEFAULT_RESOLUTION(1024x720) instead of shrinking the VM.app/page.tsx), replacing the two duplicated breakpoint-dependent measurement blocks inonSubmitandhandleExampleClick.app/api/chat/route.tsbeforeSandbox.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/desktopdefault), 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].