How nicollasricas/vscode-deck works
Purpose and Entry Points
This is a Visual Studio Code extension that receives Stream Deck-originated messages over a configurable network server and translates them into VS Code actions: command execution, terminal creation/commands, snippet insertion, and folder opening. Extension activation starts in src/extension.ts; lifecycle orchestration is concentrated in src/extensionController.ts.
Extension Lifecycle and State
src/extensionController.ts coordinates activation, server startup, VS Code window/session state, and cleanup. src/extensionStatus.ts represents connection or active-session status surfaced to the VS Code status bar. The active VS Code instance is significant: only the focused session is intended to receive Stream Deck commands.
Network Hub Boundary
src/extensionHub.ts is the integration boundary between the external Stream Deck plugin and VS Code. It hosts or manages the message server using configured host/port values, receives inbound requests, and dispatches them into extension behavior. Default and shared protocol values are centralized in src/constants.ts.
Configuration
src/configuration.ts reads VS Code-side settings, including the server host and port that must match the Stream Deck plugin’s settings.ini. The deployment can span remote SSH or WSL environments, so network binding and forwarding are material operational concerns rather than purely local configuration.
Message Protocol and Dispatch
src/messages/message.ts defines the base message abstraction. Concrete message types encode the supported remote operations:
• VS Code command execution: src/messages/executeCommandMessage.ts
• Terminal creation and terminal command execution: src/messages/createTerminalMessage.ts, src/messages/executeTerminalCommandMessage.ts
• Editor snippet insertion: src/messages/insertSnippetMessage.ts
• Workspace folder opening: src/messages/openFolderMessage.ts
The hub/controller layer routes decoded inbound payloads to these message handlers, which invoke VS Code extension APIs.
Active Session and Focus Control
src/messages/activeSessionChangedMessage.ts and src/messages/changeActiveSessionMessage.ts support tracking or selecting the active VS Code session. This separates transport connectivity from command eligibility: multiple instances may connect, but focus/session state determines which instance executes a request. src/messages/changeLanguagMessage.ts indicates language context can also be changed through the protocol.
Runtime, Dependencies, and Observability
The runtime is a TypeScript VS Code extension, compiled according to tsconfig.json and packaged through package.json. Its external counterpart is the Stream Deck plugin, communicating via a configurable TCP/network endpoint (default port documented as 48969). src/logger.ts provides diagnostics around lifecycle, connectivity, and command processing.
Main entry points: extensionController.ts Extension controller · extensionHub.ts Extension hub · message.ts Base message · logger.ts Logger
Components 14
VS Code Extension
- Extension activation
src/extension.ts - Extension controller · Coordinates startup, active-window state, and disposal.
src/extensionController.ts - Extension status · Represents connectivity or active-session state.
src/extensionStatus.ts - Extension hub · Receives requests on the configured endpoint and routes decoded messages.
src/extensionHub.ts - Protocol constants · Centralizes shared protocol values, including defaults.
src/constants.ts - Logger · Records lifecycle, connectivity, and command processing.
src/logger.ts - Extension package · Compiles and packages the extension runtime.
package.json
Protocol Handlers
- Base message
src/messages/message.ts - Action messages · Execute commands, manage terminals, insert snippets, and open folders.
- Session messages · Track or select the focused session eligible for command execution.
- Language message
src/messages/changeLanguagMessage.ts
External Integration
- Stream Deck plugin · Sends remote control requests and shares host/port settings.
- VS Code settings · Must align with the plugin settings.ini, including network binding.
src/configuration.ts - VS Code APIs · Performs editor, workspace, command, and terminal operations.
Connections 17
- Stream Deck plugin → Extension hub: network requests
- VS Code settings → Extension hub: host and port
- Protocol constants → Extension hub: protocol defaults
- Extension activation → Extension controller: activates
- Extension controller → Extension hub: starts and stops
- Extension controller → Extension status: updates
- Extension controller → Session messages: maintains focus state
- Extension hub → Base message: decodes and dispatches
- Base message → Action messages: action variants
- Base message → Session messages: session variants
- Base message → Language message: language variant
- Session messages → Extension controller: changes active session
- Action messages → VS Code APIs: invokes actions
- Language message → VS Code APIs: changes language context
- Logger → Extension controller: lifecycle diagnostics
- Logger → Extension hub: connection diagnostics
- Extension package → Extension activation: packages runtime