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 in two ways:

  1. Directory-based: Run code . in a directory, open files, quit. Re-run code . in the same directory and your files reopen. State is tied to the directory path.
  2. Workspace files: A .code-workspace file explicitly stores state, can include multiple folders, and is portable.

Workspace Integration

Workareas 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

CommandDescription
wa codeLaunch VS Code with workspace for current worktree
wa set ws --filename=myprojectSet workspace filename for current worktree
wa set ws --path=/full/path/to/file.code-workspaceSet full workspace path
wa get ws --filenameGet 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, Workareas 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:

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

Workareas can create these automatically when you associate a workspace with a worktree.