Editor Module
Purpose
- Detect available editors, build launch commands, and open worktree paths for attempts.
- Validate editor executables to ensure they are accessible and executable.
- Emit editor open events so the UI can reflect success or failure.
Data & Event Flow
- Detection (
detect.ts)detectEditorsinspects registered adapters and reports installed editors.getAdapterForKeyresolves a concrete adapter from an editor key with sensible fallback.- Returns editor suggestions with key, label, and binary path for UI selection.
- Validation (
validate.ts)validateEditorExecutablechecks if a given executable path exists and is executable.- Provides detailed error messages for invalid configurations.
- Environment (
env.ts)createDesktopEnvderives a baseline GUI-friendly environment (PATH, DISPLAY, XDG runtime, DBUS).loadUserSessionEnvandapplySessionEnvmerge in session environment (e.g. systemd user env on Linux).buildEditorEnvproduces the final environment for a specific editor key.
- Open (
open.ts)openEditorAtPathresolves the preferred editor from settings, builds the command, and spawns it detached with a fallback shell command when needed.- Supports custom editor commands specified via settings.
- Service façade (
service.ts)- Re-exports
detectEditors,openEditorAtPath, and related helpers for external callers.
- Re-exports
- Routes (
routes.ts)GET /editors/suggestionslists detected installed editors.POST /editors/validatevalidates an editor executable path.POST /editors/openopens a path in a configured editor./attempts/:id/open-editor(in attempts module) wraps this service and emitseditor.open.requested/succeeded/failedaround the call.
Supported Editors
The following editor adapters are supported:- VS Code
- Cursor
- IntelliJ IDEA
- WebStorm
- Neovim
- Vim
Key Entry Points
detect.ts/validate.ts/env.ts/open.ts: editor detection, validation, environment preparation, and launch logic.service.ts: stable façade re-exported to other modules.- Integrated via attempts route for launching worktrees.
- File browser integration allows users to browse for editor executables via the filesystem module.
Open Tasks
- Capture PID/metadata on successful launches (when available) and include in events.
- Add listener to surface failure events in the UI with user-friendly messaging.
- Provide tests around command resolution and environment detection.