Workspaces

VS Code Workspaces

VS Code workspace files preserve your editor state, allowing you to pick up exactly where you left off.

How VS Code State Works

VS Code maintains state through two mechanisms:

  1. Directory-based: Running code . in a directory, opening files, then quitting allows the same directory to restore those files upon reopening. The state is directory-path dependent.
  2. Workspace files: A .code-workspace file explicitly stores state, can incorporate multiple folders, and remains portable across systems.

Workspace Integration

wa associates each worktree with a VS Code workspace file. This means:

  • Each branch/worktree gets its own editor state
  • Open files, terminal sessions, and settings persist
  • Switching worktrees means switching complete contexts

Workspace Commands

Command Description
wa code Launch VS Code with workspace for current worktree
wa set ws --filename=myproject Set workspace filename for current worktree
wa set ws --path=/full/path/to/file.code-workspace Set full workspace path
wa get ws --filename Get current workspace filename

Workspace Storage

Workspace files are stored in a central directory:

# Default location
~/.workareas/workspaces/

# Or set custom location
export WORKAREAS_WORKSPACE_DIR=/path/to/workspaces

When you run wa code, wa looks up the workspace file and launches VS Code with it, restoring your complete editor context.

Workspace File Format

VS Code workspace files are JSON. wa can create these automatically when you associate a workspace with a worktree:

{
  "folders": [
    {"path": "/home/user/projects/myproject"}
  ],
  "settings": {
    "editor.fontSize": 14
  }
}

Typical Workflow

# Create a worktree (workspace is auto-created)
wa add --bn=feature-x --alias=fx

# Navigate and open VS Code
cdwa fx
wa code

# ... work on feature-x, open files, set breakpoints ...

# Switch to another worktree
cdwa main
wa code     # VS Code opens with main's state

# Come back to feature-x later
cdwa fx
wa code     # Everything restored: open files, cursor positions, terminals