VS Code Extension

The sonny-vscode extension is a complete Sonny session surface for VS Code. It reuses the same React session UI and daemon client as the desktop application without starting a second agent runtime.

Runtime shape

Opening the Sonny Activity Bar view activates dist/extension.cjs. The extension host then:

  1. resolves a trusted Sonny executable from sonny.executable, an absolute SONNY_BIN development override, or bin/sonny in the packaged extension;
  2. runs sonny supervisor ensure to start or attach to the local shared service and obtain its exact endpoint, executable, and tenant;
  3. starts only sonny editor-rpc --human-attach and bridges its NDJSON frames to the webview; and
  4. exposes the supported VS Code host services — open and reveal files, safe external links, notifications, pickers, and theme updates — over the same message boundary.

Closing the view or deactivating the extension closes that editor connection. It deliberately does not stop the shared supervisor or any running session, so reopening the view reattaches to the existing service.

The browser-only Vite development entry still renders fixture data. That keeps component development deterministic, while the packaged extension always uses live daemon sources.

Commands

CommandDefault keybinding
Sonny: Open SessionsCtrl+Alt+S (Cmd+Alt+S on macOS)
Sonny: Reconnect to Local Service—
Sonny: Show Output—

Settings

SettingBehaviour
sonny.executableMust be an absolute path; the extension never searches PATH
sonny.supervisorEndpointMay override the platform socket or named pipe; normally empty
sonny.tenantMay override the resolved local-profile tenant; normally empty

The PATH rule is deliberate. An editor extension loads in whatever environment your shell left behind, and silently picking up a different sonny than the daemon is running is the exact failure the desktop avoids with its digest-pinned sibling binary.

Building and verifying

From ui/:

pnpm --filter sonny-vscode typecheck
pnpm --filter sonny-vscode test
pnpm --filter sonny-vscode build
pnpm --filter sonny-vscode package

build emits dist/extension.cjs for the Node extension host and dist/webview/ for the CSP-restricted webview. package creates dist/sonny-vscode.vsix; the VSIX contains built output and the Activity Bar icon — not source files, maps, or node_modules.

Development-host validation

  1. Set an absolute SONNY_BIN.
  2. Press F5 with this package as the extension development path.
  3. Open the Sonny view, create or attach to a session, and complete a turn.
  4. Run Developer: Restart Extension Host and reopen the view.

The session remains available after step 4, because only the editor connection was released — the supervisor and the session were never owned by the extension host.

Source of truth

  • ui/apps/vscode/README.md
  • ui/apps/vscode/package.json
  • docs/config/supervisor-daemon-lifecycle.md