Skip to content

Add VS Code Dev Containers plugin for Fresh editor#1110

Open
sinelaw wants to merge 6 commits intomasterfrom
claude/vscode-devcontainers-plugin-1EMcV
Open

Add VS Code Dev Containers plugin for Fresh editor#1110
sinelaw wants to merge 6 commits intomasterfrom
claude/vscode-devcontainers-plugin-1EMcV

Conversation

@sinelaw
Copy link
Copy Markdown
Owner

@sinelaw sinelaw commented Feb 24, 2026

Summary

This PR introduces a comprehensive Dev Containers plugin for Fresh that detects and provides in-editor support for VS Code Dev Container configurations (.devcontainer/devcontainer.json). The plugin surfaces container metadata, lifecycle commands, port forwarding info, and feature listings within Fresh's existing plugin UI patterns.

Key Changes

  • New Plugin: crates/fresh-editor/plugins/devcontainer.ts - A full-featured plugin (~760 lines) that:

    • Automatically detects .devcontainer/devcontainer.json configurations on workspace load
    • Parses JSONC (JSON with Comments) format without external dependencies
    • Displays a comprehensive info panel showing image, features, ports, environment variables, mounts, users, and lifecycle commands
    • Provides command palette integration for running lifecycle commands (onCreateCommand, postCreateCommand, etc.)
    • Allows quick access to open the devcontainer.json configuration file
    • Renders rich, syntax-highlighted virtual buffers using Fresh's existing panel patterns
  • Design Documentation: docs/internal/DEVCONTAINER_PLUGIN_DESIGN.md - Detailed 800-line design document covering:

    • Architecture and user flows
    • Dev Container specification background
    • Configuration parsing strategy
    • Command palette commands and their behaviors
    • Implementation details and code examples
  • Internationalization: crates/fresh-editor/plugins/devcontainer.i18n.json - Multi-language support (English, Czech, German, Spanish, French, Italian, Japanese, Portuguese, Russian, Chinese Simplified/Traditional) for all UI strings and status messages

Notable Implementation Details

  • JSONC Parser: Minimal inline implementation that strips comments and trailing commas without adding dependencies
  • Config Discovery: Priority-based search for .devcontainer/devcontainer.json, .devcontainer.json, and subdirectory configs
  • Virtual Buffer UI: Uses Fresh's createVirtualBufferInSplit() API with custom mode definition and syntax highlighting via overlays
  • Lifecycle Command Runner: Integrates with editor.spawnProcess() to execute container lifecycle scripts with live output
  • Zero External Dependencies: Pure TypeScript using only Fresh's existing spawnProcess, readFile, and buffer management APIs
  • Read-only Info Panel: Custom mode with keybindings (r: run lifecycle, o: open config, q: close) for interactive navigation

The plugin remains dormant if no devcontainer configuration is found, ensuring zero overhead for non-containerized workspaces.

https://claude.ai/code/session_01H3A1ru38B68gxZpbt7cSJK

Describes a TypeScript plugin that detects .devcontainer/devcontainer.json
and provides in-editor info panels, lifecycle command execution, and
feature/port browsing — all using existing Fresh plugin APIs.

https://claude.ai/code/session_01H3A1ru38B68gxZpbt7cSJK
TypeScript plugin that detects .devcontainer/devcontainer.json and provides:
- Status bar summary showing container name, image, features, and ports
- Info panel (virtual buffer) with full config details and keybindings
- Lifecycle command runner (onCreateCommand, postCreateCommand, etc.)
- Feature and port browsing via command palette prompts
- Quick open for the devcontainer.json config file
- Optional rebuild command via devcontainer CLI

Includes JSONC parser for comment/trailing-comma support and i18n
translations for en, cs, de, es, fr, ja, ko, and zh-CN.

https://claude.ai/code/session_01H3A1ru38B68gxZpbt7cSJK
- Fix: Use `devcontainer up --remove-existing-container` instead of the
  non-existent `devcontainer rebuild` subcommand
- Add: Action popup when devcontainer CLI is not found, offering to copy
  the install command (npm i -g @devcontainers/cli) or dismiss
- Add: Activation popup on editor startup when a devcontainer.json is
  detected, offering Show Info / Open Config / Dismiss
- Add i18n strings for all new popups across all 8 locales

https://claude.ai/code/session_01H3A1ru38B68gxZpbt7cSJK
On startup, the activation popup now checks for the devcontainer CLI:
- If found: offers "Rebuild Container" (default) / "Show Info" / "Dismiss"
- If not found: offers "Copy: npm i -g @devcontainers/cli" / "Show Info" / "Dismiss"

This mirrors VS Code's behavior of prompting "Reopen in Container" as the
primary action when a devcontainer.json is detected.

https://claude.ai/code/session_01H3A1ru38B68gxZpbt7cSJK
New command palette entry "Dev Container: Open Terminal" that:
1. Checks for the devcontainer CLI (shows install popup if missing)
2. Probes the container with `devcontainer exec ... echo` to verify it's running
3. Opens a Fresh terminal split and sends `devcontainer exec` to get
   an interactive shell inside the container

This completes the host-side workflow: detect -> rebuild -> open terminal.

https://claude.ai/code/session_01H3A1ru38B68gxZpbt7cSJK
…g rebuild

Info panel now has interactive buttons (Run Lifecycle, Open Config, Rebuild,
Close) rendered with [bracket] focus indicators. Tab/Shift-Tab cycles between
buttons, Enter activates the focused button. Alt+r/Alt+o/Alt+b provide direct
keyboard shortcuts. Rebuild command now opens a terminal split streaming live
build output instead of blocking silently.

https://claude.ai/code/session_01H3A1ru38B68gxZpbt7cSJK
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.

2 participants