Overview
Canvas Host is a local HTTP server that serves interactive HTML/JS/CSS from~/.simpleclaw/state/canvas/ and provides:
- Live reload during development
- WebSocket-based action bridge (A2UI)
- Cross-platform compatibility (iOS, Android, Web)
- Sandboxed file serving
Architecture
The Canvas system has two main components:1. Canvas Host Server
Serves user content from workspace directory (src/canvas-host/server.ts:399):/__simpleclaw__/canvas/- User canvas root/__simpleclaw__/a2ui/- Bundled A2UI demo app/__simpleclaw__/ws- WebSocket for live reload
2. A2UI (App-to-UI) Bridge
Enables mobile apps to send actions to the agent (src/canvas-host/a2ui.ts):Canvas Root Setup
Default canvas location:~/.simpleclaw/state/canvas/
On first run, SimpleClaw creates a default index.html (src/canvas-host/server.ts:58):
Live Reload
Canvas watches for file changes and auto-reloads browsers (src/canvas-host/server.ts:261):Action Bridge API
The A2UI bridge provides JavaScript helpers for mobile/web clients.Sending Actions
Action Status Events
Platform Detection
File Resolution & Security
Canvas uses sandboxed file serving (src/canvas-host/file-resolver.ts):- Path traversal prevention (
../blocked) - Root boundary enforcement
- No directory listings
- Cache-Control: no-store on all responses
Configuration
Canvas Root Directory
Disable Canvas
canvasHost.enabled: false in config.
Development Workflow
-
Edit canvas files:
-
Open in browser:
- Save changes - browser auto-reloads
-
Check logs:
A2UI Demo App
The bundled A2UI demo is served fromsrc/canvas-host/a2ui/ at:
- Hello action
- Time query
- Photo request
- Custom Dalek action
src/canvas-host/a2ui/index.html
Mobile Integration
iOS (Swift)
Android (Kotlin)
Advanced Features
Custom MIME Types
Canvas auto-detects MIME types usingsrc/media/mime.ts:
Live Reload Injection
HTML responses get auto-injected bridge code (src/canvas-host/a2ui.ts:81):Nested Skills Root Detection
Canvas can detect nestedskills/ directories:
Troubleshooting
Canvas not starting? Check if disabled:API Reference
Key functions fromsrc/canvas-host/:
startCanvasHost()- Start canvas server (server.ts:399)createCanvasHostHandler()- Create HTTP handler (server.ts:205)handleA2uiHttpRequest()- Serve A2UI bundle (a2ui.ts:142)injectCanvasLiveReload()- Inject WS client (a2ui.ts:81)resolveFileWithinRoot()- Safe file resolution (file-resolver.ts)