Skip to content

Workbench Configuration

Ved Gupta edited this page Dec 4, 2026 · 9 revisions

Workbench Configuration

This guide covers mount options, workspace configuration files, UI extension slots, public repository cloning, instance methods, and keyboard shortcuts for the CodeLab workbench.


Mount Options

Option Type Default Description
id string 'custom-lab' Unique identifier used to persist workspace state in browser storage
title string id Lab title, shown in the tooltip of the ☰ Application Menu button
summary string '' Short description shown in the guide pane when no README is present
mode 'guided' | 'sandbox' 'sandbox' Starts in free-form sandbox mode or guided step-by-step challenge mode
language 'js' | 'ts' | 'cpp' | 'python' | 'sql' | 'sh' 'js' Active workspace language at startup ('sh' needs the Linux extension)
theme 'dark' | 'light' | 'high-contrast' | 'auto' 'auto' Color theme. 'auto' follows the host page's data-theme, then the OS dark-mode preference, and otherwise uses Cursor Light
persistState boolean true Saves edited files across page reloads in IndexedDB or localStorage
files Record<string, string> {} Initial workspace file map from relative path to file contents
starterFiles Record<string, string> {} Starter stubs used in Guided Labs
solutionFiles Record<string, string> {} Reference solution files compared in the side-by-side diff viewer
entry string 'demo.js' Default file executed when clicking Run Code
testEntry string 'test.js' Default test suite executed when running tests or verifying a step
sqlDialect 'postgres' | 'sqlite' 'postgres' Active SQL dialect when running SQL Guided Labs
sqlRunner Function undefined Async callback that executes SQL queries and verifies step results
steps CodeLabStep[] [] Ordered step definitions for Guided Labs
previewCsp 'balanced' | 'strict' | 'permissive' | string 'balanced' Content Security Policy enforced inside Web Preview frames
terminalEngine 'xterm' | 'builtin' 'xterm' Terminal renderer (@xterm/xterm PTY or lightweight built-in fallback)
settings / userSettings Record<string, any> {} Initial user-editable settings seeded on mount (e.g. editor.fontSize, workbench.colorTheme)
overrides Record<string, any> {} Locked Layer 4 runtime setting overrides (cannot be changed in Settings UI)
lockSettings boolean false When true, treats settings as locked Layer 4 overrides instead of editable defaults
plugins CodeLabPlugin[] [] Extensions or declarative plugins installed automatically on mount
extensions Extension[] [] Language extensions installed on mount, such as linuxExtension({ distroUrl })
onRun (result) => void null Callback invoked whenever code execution completes
onTestResult (result) => void null Callback invoked whenever unit test execution completes
onStepComplete (step, index) => void null Callback invoked when all tests for the current guided step pass
onLabComplete (labId) => void null Callback invoked when every step in a Guided Lab is completed
onCodeChange (file, code) => void null Callback invoked whenever a file changes in the editor or filesystem

Language-specific starter and solution maps are also available for TypeScript, C++20, and Python 3.12 workspaces.


Workspace Settings & Keybindings

CodeLab resolves configuration across four scopes in ascending priority: built-in defaults, browser user preferences, workspace configuration files, and runtime overrides. Settings and custom shortcuts stored inside the workspace folder support comments (JSONC) and synchronize live with the built-in Settings modal:

// .codelab/settings.json
{
  "workbench.colorTheme": "dark",
  "editor.fontSize": 14,
  "editor.tabSize": 2,
  "editor.wordWrap": "on",
  "editor.formatOnSave": true,
  "sql.dialect": "postgres"
}

Users can open the visual Settings dialog at any time from the Command Palette, with the Preferences shortcut, or programmatically via the workbench instance.


Layout & Theming

Since 0.8 the workbench follows the VS Code compact layout and has no top navbar. The ☰ button at the top of the Activity Bar opens the File, Edit, View and Help menus as a vertical menu bar. Use the arrow keys to move through it, Right or Enter to open a menu, and Escape to close it. The lab controls (Guided/Sandbox, the language switch, Run or Verify, Stop, Preview, Share and Exit Lab) sit at the right of the editor tab row and collapse to icons when the workbench is narrower than about 760px. Fullscreen is at the bottom of the Activity Bar.

The default light theme is Cursor Light, a cool neutral chrome around a white editor. When the host page defines In-Depth design tokens (--ds-canvas or --ds-surface), the built-in theme stops writing its own colors and the workbench takes the host's tokens instead, so embedded labs match the surrounding site.


Extension Slots & Public Repository Cloning

The workbench layout provides dedicated UI extension slot areas in the editor actions, sidebar, bottom drawer, and status bar that extensions and plugins can populate cleanly.

You can also clone any public GitHub repository directly into the virtual workspace and stream live download progress to your UI:

ide.use(customExtension);

await ide.cloneRepo('owner/repo', {
  branch: 'main',
  targetDir: '/workspace/project',
  onProgress({ phase, percent, path }) {
    console.log(phase, percent, path);
  }
});

Key Instance Methods

Category Methods
Execution & Extensions runDemo(), runTests(), verifyCurrentStep(), stopExecution(), setLanguage(), use(), registerPlugin()
Files & Editor Tabs getFiles(), setFiles(), getFile(), setFile(), deleteFile(), renameFile(), openFile(), closeTab(), importDroppedFiles()
Archives & Source Control exportProjectZip(), importProjectZip(), getGitStatus(), stageGitFile(), commitGitChanges(), cloneRepo()
Dialogs & Lifecycle openSettings(), openCommandPalette(), showDiffModal(), resetLab(), toggleFullscreen(), toggleZenMode(), destroy()

Default Keyboard Shortcuts

Shortcut Action
Cmd / Ctrl + Enter Verify the active step in Guided mode, or run code in Sandbox mode
Cmd / Ctrl + , Open the Settings dialog
Cmd / Ctrl + Shift + P Open the Command Palette
Cmd / Ctrl + P Open Quick Open to switch files by name
Cmd / Ctrl + Shift + F Search and replace text across all workspace files
Shift + Alt + F Format the active document
Cmd / Ctrl + J Toggle the bottom drawer panel
Cmd / Ctrl + B Toggle the primary side bar
Ctrl + C Interrupt the active foreground command in the terminal
Ctrl + R Search previous terminal commands interactively
Ctrl + L Clear the terminal viewport

Clone this wiki locally