Add multi-language code execution (Python, C/C++, Go, Ruby, Lua)#4
Merged
dreamteam-mobile merged 2 commits intomainfrom Feb 20, 2026
Merged
Conversation
Expand in-browser code execution from JS/TS-only to 7 languages using a persistent Web Worker architecture with lazy-loaded runtimes. New language runtimes: - Python: Pyodide (CPython compiled to WASM, ~5MB from jsDelivr CDN) - C/C++: Compiler Explorer / Godbolt API (GCC 14.2, server-side compilation) - Go: Go Playground API (play.golang.org/compile, server-side compilation) - Ruby: ruby.wasm (@ruby/3.3-wasm-wasi, ~36MB WASM from jsDelivr CDN) - Lua: Wasmoon (Lua 5.4 compiled to WASM, ~300KB) Architecture: - Persistent workers per language (loaded once, reused across executions) - Lazy loading: no WASM downloaded until user selects a language - Progress tracking for large downloads (Python, Ruby) via fetch interception - Runtime status store (Zustand) drives UI state for run button and output panel UI changes: - Run button shows progress ring while runtime downloads, error icon on failure - Output panel shows download progress percentage for WASM runtimes - Language selector triggers background preload on switch - All executable languages marked with ▶ prefix in dropdown - Lua added as 16th language option with Prism syntax highlighting Fixes: - Vite optimizeDeps.include prevents page reload on first worker dep import
Vite's default worker format (iife) doesn't support code-splitting, which is needed by our WASM runtime workers that use dynamic imports. Setting worker.format to 'es' fixes the Rollup build error.
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.
Summary
Expands in-browser code execution from JS/TS-only to 7 languages using a persistent Web Worker architecture with lazy-loaded runtimes. No WASM is downloaded until the user selects a language — runtimes load in the background while the user types.
New Language Runtimes
Architecture
ReadableStream.getReader()fetch interceptionidle → loading → ready → errorstatus per language, drives UI stateNew Files
src/stores/runtimeStore.ts— Zustand store for runtime download/loading statesrc/services/wasm-runtime-manager.ts— Central orchestrator managing persistent workerssrc/services/runtimes/*.worker.ts— 5 worker files (one per new language runtime)Modified Files
src/services/code-executor.ts— Routes WASM languages to runtime managersrc/hooks/useExecutionSync.ts— Preloads runtimes on language switch, handles loading statessrc/components/TabBar.tsx— Progress ring on run button during downloadsrc/components/CodeEditor/LanguageSelector.tsx— Triggers preload, marks executable languagessrc/components/CodeEditor/OutputPanel.tsx— Shows download progress in output areasrc/components/CodeEditor/CodeEditor.tsx— Added Prism Lua syntax highlightingsrc/services/code-editor-logic.ts— Added Lua code templatesrc/styles.css— Progress ring animation stylesvite.config.ts—optimizeDeps.includefor WASM runtime dependenciesUX
Test plan
print("Hello Python!")→ output in 5msstd::cout << "Hello C++!" << std::endl→ output in ~2sfmt.Println("Hello Go!")→ output in ~850msputs "Hello Ruby!"→ output in 1msprint("Hello Lua!")→ output in 4ms🤖 Generated with Claude Code