Skip to content

feat(vscode-desktop): add extensions and settings pre-installation#926

Open
lsrtech wants to merge 1 commit into
coder:mainfrom
lsrtech:feat/vscode-desktop-extensions
Open

feat(vscode-desktop): add extensions and settings pre-installation#926
lsrtech wants to merge 1 commit into
coder:mainfrom
lsrtech:feat/vscode-desktop-extensions

Conversation

@lsrtech

@lsrtech lsrtech commented Jun 16, 2026

Copy link
Copy Markdown

feat(vscode-desktop): add extensions and settings pre-installation

Description

Closes #207

Adds the ability to pre-install VS Code extensions and apply machine-level settings on the remote host when a Coder workspace starts. Extensions are ready when the user opens VS Code Desktop for the first time — no manual installation needed.

Type of Change

  • Feature/enhancement

Module Information

Path: registry/coder/modules/vscode-desktop
New version: v1.3.0
Breaking change: [ ] Yes [x] No

What Changed

New Variables

Variable Type Default Description
extensions list(string) [] Extension IDs to pre-install (e.g. ms-python.python)
settings map(any) {} Machine-level VS Code settings, merged with existing
extensions_dir string "" Override extensions storage directory

How It Works

A coder_script resource (install-extensions.sh) runs on workspace start when extensions or settings are specified:

  1. Settings — Written to ~/.vscode-server/data/Machine/settings.json. Merges with existing settings using jq or python3 (with overwrite fallback).

  2. Extensions — Installed to ~/.vscode-server/extensions/:

    • First checks for an existing VS Code CLI (from a previous Desktop connection or the vscode-web module)
    • If no CLI found, downloads VS Code Server temporarily
    • Installs each extension with --install-extension --force
  3. No-op when unused — The script resource is not created when both extensions and settings are empty (count = 0).

Architecture Decision

All new functionality is contained in the vscode-desktop wrapper module — no changes to vscode-desktop-core. This is intentional and addresses the "let's solve this systematically for all VS Code-based IDEs" point raised in #207:

  • Each IDE stores extensions in a different server directory: VS Code Desktop uses ~/.vscode-server/, Cursor uses ~/.cursor-server/, Windsurf uses ~/.windsurf-server/, etc. A single core-level implementation cannot cleanly handle these divergent paths.
  • This PR follows the exact same per-module pattern already shipped in the vscode-web and code-server modules (each installs extensions via --install-extension and merges machine settings in its own run.sh). Consistency with the existing, merged approach.
  • The extensions_dir variable is exposed (per maintainer request in Feature: Pre-Install VS Code extensions in desktop VS Code module #218) so the same script can be reused by Cursor/Windsurf/Kiro wrappers in follow-up PRs simply by pointing at their server directory.

This keeps the shared core module stable while resolving #207 directly.

Addressing #218's review feedback

The previous attempt (#218, closed) was blocked because it assumed the VS Code CLI was already present. This implementation:

  • Detects an existing VS Code CLI (from a prior connection or the vscode-web module) and reuses it
  • Falls back to downloading VS Code Server when no CLI is found — so extension installation works on a fresh workspace

Usage

module "vscode" {
  count    = data.coder_workspace.me.start_count
  source   = "registry.coder.com/coder/vscode-desktop/coder"
  version  = "1.3.0"
  agent_id = coder_agent.main.id
  folder   = "/home/coder/project"
  extensions = [
    "ms-python.python",
    "esbenp.prettier-vscode",
    "dbaeumer.vscode-eslint",
  ]
  settings = {
    "editor.fontSize"    = 14
    "editor.tabSize"     = 2
    "editor.formatOnSave" = true
  }
}

Testing & Validation

  • Tests pass (bun test)
  • No extensions/settings → no script created (zero overhead)
  • Extensions specified → script includes extension IDs
  • Settings specified → base64-encoded and decoded correctly
  • Settings written to correct machine settings path
  • Settings merged with existing (jq deep merge tested)
  • Backward compatible — all existing variables and behavior unchanged

Closes coder#207

Add the ability to pre-install VS Code extensions and apply machine-level
settings on the remote host when the workspace starts.

New variables:
- extensions: list of extension IDs to pre-install (e.g. ms-python.python)
- settings: map of machine-level VS Code settings, merged with existing
- extensions_dir: override the extensions storage directory

The installation script:
- Reuses an existing VS Code CLI if found (from previous connection or
  vscode-web module), otherwise downloads VS Code Server
- Installs extensions to ~/.vscode-server/extensions/
- Writes settings to ~/.vscode-server/data/Machine/settings.json
- Merges with existing settings using jq or python3, with fallback

No changes to vscode-desktop-core; all new functionality is contained
in the wrapper module, following the pattern used by the cursor module
for MCP configuration.

@matifali matifali left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each IDE stores extensions in a different server directory: VS Code Desktop uses ~/.vscode-server/, Cursor uses ~/.cursor-server/, Windsurf uses ~/.windsurf-server/, etc. A single core-level implementation cannot cleanly handle these divergent paths.

I believe that it's possible to handle the per IDE path in the vscode-desktop-core module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pre-install VS Code extensions in desktop VS Code module

2 participants