microsoft / microsoft/vscode

Use $XDG_STATE_HOME for `APPLICATION_SHARED` storage (`~/.<app>-shared/sharedStorage/state.vscdb`)

Open
#330,061 3 comments 23 reactions 1 assignee Claimed by @sandy081 View on GitHub
debt
Dominant language
TypeScript
Stars
193k
Forks
42.4k
PR merge metrics
PR metrics pending

Description

## Current limitation

PR #311317 introduced `StorageScope.APPLICATION_SHARED`, storing shared state at `~/.-shared/sharedStorage/state.vscdb` (e.g. `~/.vscode-shared/`, `~/.vscode-insiders-shared/`). The path is hardcoded under `$HOME` with no `$XDG_STATE_HOME` resolution. This is configurable via `--shared-data-dir`, but the **default** clutters `$HOME` and violates the [XDG Base Directory Specification](https://specifications.freedesktop.org/basedir-spec/latest/).

## Desired improvement

Default the `appSharedDataHome` path to `${XDG_STATE_HOME:-$HOME/.local/state}/-shared/` instead of `~/-shared/`, with a one-time migration of the existing database and a fallback read of the old path for compatibility.

Per the XDG spec v0.8 (May 2021), `$XDG_STATE_HOME` (default `~/.local/state`) is the correct category for this data:

> The `$XDG_STATE_HOME` contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in `$XDG_DATA_HOME`. It may contain:
> - actions history (logs, history, recently used files, …)
> - current state of the application that can be reused on a restart (view, layout, open files, undo history, …)

The contents of `state.vscdb` (`history.recentlyOpenedPathsList`, workspace trust markers, storage markers) match this definition exactly — it is restart-persisting, non-portable state, not user data or config.

## Workflow example

```bash
# Before (current):
# ~/.vscode-shared/sharedStorage/state.vscdb
# ~/.vscode-insiders-shared/sharedStorage/state.vscdb

# After (XDG-compliant default):
$XDG_STATE_HOME=/home/user/.local/state
# ~/.local/state/vscode-shared/sharedStorage/state.vscdb
# ~/.local/state/vscode-insiders-shared/sharedStorage/state.vscdb

# --shared-data-dir still overrides for users who need a custom path
```

## Impact and context

This is a long-standing XDG compliance gap (see #3884, #162712, #84808, #100988, #126182, #132971). PR #311317 added a **new** hardcoded `~/` path despite community requests in the PR comments to use `~/.local/state/`. Each new `~/.*-shared/` directory perpetuates the problem.

Because `APPLICATION_SHARED` is a **platform-level** feature in VS Code's storage layer (`IEnvironmentService.appSharedDataHome`), every VS Code-derived Electron app inherits this path. The top 5 clones that would benefit from an upstream fix:

| App | Vendor | Inherited path |
|-----|--------|---------------|
| **Cursor** | Anysphere | `~/.cursor-shared/sharedStorage/state.vscdb` |
| **Windsurf / Devin Desktop** | Cognition | `~/.windsurf-shared/`, `~/.devin-shared/sharedStorage/state.vscdb` |
| **Antigravity** | Google | `~/.antigravity-shared/sharedStorage/state.vscdb` |
| **VSCodium** | Community | `~/.vscodium-shared/sharedStorage/state.vscdb` |
| **Trae** | ByteDance | `~/.trae-shared/sharedStorage/state.vscdb` |

Fixing this in VS Code's `appSharedDataLocation` resolution (in `environmentService.ts`) benefits the entire ecosystem without each fork needing to patch the platform independently.

## Related

- #3884 — umbrella issue: "Revisit VS Code folder structure for app data, settings, extensions" (open since 2016)
- #162712 — "Support `XDG_CONFIG_HOME` for the `argv.json` file"
- #311317 — PR that introduced `APPLICATION_SHARED` storage scope (merged, comments request XDG compliance)
- #311337 — original issue for cross-app state sharing

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.