Skip to content

Migrate codesandbox to e2b equivalent#2452

Closed
Kitenite wants to merge 2 commits into
mainfrom
cursor/migrate-codesandbox-to-e2b-equivalent-a53a
Closed

Migrate codesandbox to e2b equivalent#2452
Kitenite wants to merge 2 commits into
mainfrom
cursor/migrate-codesandbox-to-e2b-equivalent-a53a

Conversation

@Kitenite

@Kitenite Kitenite commented Jul 15, 2025

Copy link
Copy Markdown
Contributor

%23%23 Description

This PR migrates the entire codebase from using the CodeSandbox SDK to the E2B SDK. This involves updating dependencies, constants, and core components responsible for sandbox management, file operations, terminal sessions, and deployments.

A key improvement in this migration is the adoption of E2B's native file watching API, replacing a previous polling-based solution for better performance and reliability.

%23%23 Related Issues

%23%23 Type of Change

  • Bug fix
  • New feature
  • Documentation update
  • Release
  • Refactor
  • Other (please describe):

%23%23 Testing

This migration involves a fundamental change in the underlying sandbox provider. Comprehensive functional testing of all features relying on sandbox interactions (e.g., project creation, file editing, terminal usage, deployments, preview loading) is required.

%23%23 Screenshots (if applicable)

%23%23 Additional Notes

  • Environment Variable Update: Users will need to update their .env file to replace CSB_API_KEY with E2B_API_KEY.
  • Dependency Update: Run bun install after pulling this PR.
  • E2B API Key: An E2B API key is required from https://e2b.dev.
  • API Differences: The E2B SDK has a different API structure for file operations and process management compared to CodeSandbox.
  • File Watching: Now leverages E2B's native files.watchDir() for real-time file change detection.

Important

Migrate codebase from CodeSandbox to E2B, updating dependencies, file operations, sandbox management, and documentation.

  • Migration:
    • Replace CodeSandbox SDK with E2B SDK across the codebase.
    • Update package.json dependencies to use @e2b/sdk.
    • Change environment variable from CSB_API_KEY to E2B_API_KEY in env.ts.
  • File Operations:
    • Use E2B's filesystem API for file operations in file-operations.ts and index.ts.
    • Implement uploadToSandbox() in index.tsx to handle file uploads to E2B.
  • Sandbox Management:
    • Refactor SessionManager in session.ts to manage E2B sessions.
    • Update sandboxRouter in sandbox.ts to handle E2B sandbox operations.
  • File Watching:
    • Use E2B's files.watchDir() for file watching in file-watcher.ts.
  • Terminal Sessions:
    • Refactor CLISessionImpl in terminal.ts to use E2B's ProcessManager.
  • Documentation:
    • Update documentation to reflect migration to E2B in README.md and other docs.
  • Miscellaneous:
    • Remove CodeSandbox-specific constants and replace with E2B equivalents in e2b.ts.
    • Update test cases in path.test.ts to reflect new file paths.

This description was created by Ellipsis for 9c393d2. You can customize this summary. It will automatically update as commits are pushed.

cursoragent and others added 2 commits July 15, 2025 05:08
Co-authored-by: hoakiet98 <hoakiet98@gmail.com>
…operations

Co-authored-by: hoakiet98 <hoakiet98@gmail.com>
@vercel

vercel Bot commented Jul 15, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 15, 2025 6:10am
web ❌ Failed (Inspect) Jul 15, 2025 6:10am

@supabase

supabase Bot commented Jul 15, 2025

Copy link
Copy Markdown

This pull request has been ignored for the connected project wowaemfasoptxrdjhilu because there are no changes detected in apps/backend/supabase directory. You can change this behaviour in Project Integrations Settings ↗︎.


Preview Branches by Supabase.
Learn more about Supabase Branching ↗︎.

Comment on lines +407 to +410
isJsxFile(filePath: string): boolean {
const ext = path.extname(filePath).toLowerCase();
return JSX_FILE_EXTENSIONS.includes(ext);
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current implementation of isJsxFile() doesn't check if the file has an extension before checking if it's in JSX_FILE_EXTENSIONS. The original implementation included this check. Without it, files with no extension might cause unexpected behavior.

Consider adding a null check:

isJsxFile(filePath: string): boolean {
    const ext = path.extname(filePath).toLowerCase();
    return ext && JSX_FILE_EXTENSIONS.includes(ext);
}

This ensures the function only returns true when the file has a valid extension that's in the allowed list.

Suggested change
isJsxFile(filePath: string): boolean {
const ext = path.extname(filePath).toLowerCase();
return JSX_FILE_EXTENSIONS.includes(ext);
}
isJsxFile(filePath: string): boolean {
const ext = path.extname(filePath).toLowerCase();
return ext && JSX_FILE_EXTENSIONS.includes(ext);
}

Spotted by Diamond

Is this helpful? React 👍 or 👎 to let us know.

@Kitenite
Kitenite marked this pull request as draft July 15, 2025 06:15
@Kitenite Kitenite closed this Jul 31, 2025
@Kitenite
Kitenite deleted the cursor/migrate-codesandbox-to-e2b-equivalent-a53a branch August 1, 2025 20:57
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.

2 participants