Sonic Pi VS Code Extension — Architecture Overview¶
How the extension's functional components fit together: the component map, a reading order for the design documents, and the cross-cutting disposable, error-reporting and event-flow patterns.
The numbered documents beside this one hold the detailed design of each functional component of the vs-sonic-pi extension. Each is self-contained: it describes a module's purpose, public interface, internal design, configuration, data flow, error handling, and testing strategy. Every document is listed, with its summary, in the docs index.
For the high-level product requirements, see PRD.md.
Component Map¶
extension.ts (entry point)
│
├── ConnectionManager ·········· 02-connection-manager.md
│ ├── OscTransport ······· 01-osc-transport.md
│ ├── Heartbeat ·········· 02-connection-manager.md (§ Health Monitoring)
│ ├── PortDiscovery ······ 08-daemon-spawner.md (Part 1)
│ └── DaemonSpawner ······ 08-daemon-spawner.md (Part 2)
│
├── CommandHandler ············· 03-command-handler.md
│ ├── Run (buffer)
│ ├── Run (selection)
│ ├── Stop
│ ├── Record
│ └── Beautify
│
├── LanguageProvider ··········· 04-language-provider.md
│ ├── TextMate Grammar
│ ├── Snippets
│ ├── CompletionProvider
│ ├── HoverProvider
│ ├── DiagnosticsProvider
│ └── LiveLoopLensProvider
│
├── LogManager ················· 05-log-manager.md
│ └── LogFormatter
│
├── StatusBarManager ··········· 06-status-bar.md
│
└── ConfigManager ·············· 07-config-manager.md
Reading Order¶
For someone new to the codebase, the recommended reading order is:
- PRD.md — Start here for the big picture: vision, architecture diagrams, requirements, and phased delivery plan.
- 01 — OSC Transport — Understand the networking foundation.
- 02 — Connection Manager — Understand the state machine that everything else depends on.
- 07 — Configuration — Understand how settings flow into all modules.
- 03 — Command Handler — Understand how user actions become OSC messages.
- 05 — Log Manager — Understand how server output reaches the user.
- 04 — Language Provider — Understand the editor experience (syntax, completion, hover, diagnostics).
- 06 — Status Bar — Small but important UI piece.
- 08 — Daemon Spawner — Advanced: auto-starting the server.
Cross-Cutting Concerns¶
Disposable Pattern¶
Every module implements vscode.Disposable. All disposables are pushed to context.subscriptions in activate() so VS Code cleans them up automatically on deactivation. Modules that create sub-disposables (e.g., event listeners, timers) track them internally and dispose them in their own dispose() method.
Error Reporting¶
Errors are surfaced to the user through three channels:
| Channel | Used for | Example |
|---|---|---|
vscode.window.showErrorMessage |
Connection failures, missing server | "Cannot reach Sonic Pi server." |
Output channel (Sonic Pi Log) |
Server-reported errors, warnings | Runtime error with line number |
| Problems panel (Diagnostics) | Parsed errors with file/line info | Inline squiggle on the error line |
Event Flow¶
User presses F5
│
▼
CommandHandler.runBuffer()
│
├── checks ConnectionManager.getState() → Connected?
│ └── No → show error, offer to connect
│
├── reads editor text
│
└── OscTransport.send('/save-and-run-buffer', ...)
│
▼
Sonic Pi Server evaluates code
│
├── /multi_message → OscTransport → LogManager → Output channel
├── /error → OscTransport → LogManager + DiagnosticsProvider
└── (audio output via scsynth)
The phased delivery plan these components were built to is in PRD.md § 11.