Overview
Code artifacts render syntax-highlighted code with live preview and execution.Supported Languages
Code Previews
Code Runtime
HTML
React / JSX
Vue
JavaScript
Python
JSON
SVG
CSV / TSV
tsv for tab-separated data:
Smart Diff
Usesmartdiff for structured diffs with language-aware syntax highlighting:
Plain Text
Files with unknown extensions automatically fall back to plain text rendering in the code panel:txt panel type. This means any file type can be opened — if no specific panel exists for the language, it renders as plain text with the code viewer.
Programmatic API
Open code artifacts directly without processing AI message content.openFile
Auto-detects language from the file extension:openCode
Specify the language explicitly:updateFile
Updates an existing artifact’s code and refreshes the panel without creating a duplicate tab:Options
Both methods accept an options object:clearArtifacts
Remove all artifacts and close the panel:Edit Tab
The edit tab provides an in-panel code editor powered by CodeMirror 6. It’s optional — you must provide CodeMirror modules via config to enable it.Setup
Install the required CodeMirror packages plus any language packages you need:Supported Language Packages
Pass the modules in your SDK config:
- Vue
- React
Using the Edit Tab
Once configured, include'edit' in the tabs array:
Handling Saves
When the user clicks the Save button in the edit tab, anedit:save event fires:
Console Output
HTML artifacts captureconsole.log, console.warn, console.error, console.info, and uncaught exceptions from user code. A collapsible console footer appears in the panel when entries exist, auto-expanding on errors.
The console header includes filter toggles for each log type (error, warn, info, log). Click a filter to hide/show entries of that type. Filters only appear when entries of that type exist.
Listen for console events to send errors back to your AI agent:
consolePanel: false in config or per-artifact options to hide the footer UI while still receiving events.
Editor Theme
The editor theme is independent of the SDK theme and controlled viaeditor.theme:
Without the
editor config, the edit tab button won’t appear — the feature degrades gracefully. Language modules (e.g. langJavascript, langPython, langHtml) and lezerHighlight are optional but recommended for syntax highlighting. Only include the language packages you need — languages without a matching module fall back to plain text editing.