# In-browser code editor Pressing `.` on any repository page, or opening `///edit/`, opens a workspace editor for that ref. It plays the role github.dev plays on GitHub: browse the tree, edit many files, stage the changes in the browser and commit them in one go. It costs nothing while nobody is typing. ## Options considered | | (a) VS Code for the Web, static | (b) Monaco in the React app | (c) openvscode-server in a Container | | ------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------- | | Runtime cost | Static assets only (R2 or Workers static assets). No compute while idle. | None beyond the app. | A container per session: CPU and RAM billed while it runs, plus cold starts of several seconds. | | Latency | One-time download of about 15–25 MB (cached and immutable), then local. | Monaco is about 3–5 MB on first load. | Every keystroke round-trips to the container. Cold starts are slow. | | Features | Full workbench: explorer, search, SCM view, multi-cursor, keybindings, settings sync, web extensions. | Just the editor widget. Tree, tabs, SCM and search must all be built in React. | Everything, including a terminal, tasks, debuggers and language servers. | | Extensions | Web extensions from Open VSX. | None. | Every Open VSX extension, including native ones. | | Licensing | VSCodium and openvscode builds are MIT. They must not ship the Microsoft marketplace or Microsoft branding, so we point `extensionsGallery` at Open VSX. | Monaco is MIT. | openvscode-server is MIT, with Open VSX only. | | Offline | Works offline once loaded. Edits stay staged in the page, and only reads of uncached blobs and commits need the network. | The same. | Doesn't work offline. | | Isolation | Must run on an isolated origin, because extensions run arbitrary JavaScript. | Runs in the app origin unless sandboxed. | The container is isolated, but its HTTP endpoint needs auth. | ### Licensing notes - The "Visual Studio Code" product (vscode.dev, github.dev) is under the Microsoft licence. Its marketplace terms forbid use from non-Microsoft products, so we can't ship Microsoft's build or connect to `marketplace.visualstudio.com`. - The `microsoft/vscode` source is MIT. Gitpod's openvscode builds and VSCodium both produce MIT builds with an empty gallery. We set `product.json` to: `extensionsGallery: { serviceUrl: "https://open-vsx.org/vscode/gallery", itemUrl: "https://open-vsx.org/vscode/item" }`. - Open VSX is run by the Eclipse Foundation. Each extension keeps its own licence. Some popular Microsoft extensions, such as Pylance, the C# Dev Kit and Remote-*, aren't on Open VSX and are licensed for Microsoft products only. Users won't get them, and we document that. ### Decision **We pick (a).** It is the github.dev model with no backend container, so it costs no compute for each idle session. That beats Codespaces on cost, and it beats Codespaces on latency because typing never leaves the browser. (b) is a fallback, not a target: we'd end up rebuilding the workbench badly. (c) becomes an opt-in **"Run in container"** mode for the one thing github.dev can't do, which is a terminal. See below. ## Architecture ``` forge origin (cookies) isolated origin (no cookies) ┌──────────────────────────────┐ postMessage ┌────────────────────────────────────┐ │ ///edit/ │────token───▶│ /editor-frame (sandboxed iframe) │ │ WorkspaceEditor.tsx │◀──committed─│ workbench + FileSystemProvider │ │ mintEditorSession() server fn│ │ fetch /api/editor/* with Bearer │ └──────────────────────────────┘ └────────────────────────────────────┘ │ /api/editor/{session,tree,blob,commit} ▼ src/server/editor/api.ts → commitFileChanges() ``` ### Isolation and authentication - The frame is `