Repository navigation
Architecture
A tour of the code for anyone who wants to change it. Everything lives in extension/src. It's plain TypeScript with no runtime dependencies: it talks to Flagsmith with fetch.
flowchart TB
subgraph VSCode["Inside VS Code"]
EXT["extension.ts<br/>commands, dialogs, notifications"]
ED["editor.ts<br/>code lenses, hovers, warnings, quick fixes"]
VW["views.ts<br/>Flags and Code audit sidebars"]
ST["store.ts<br/>state, polling, incidents, restore records"]
US["usage.ts<br/>where each flag is read in the workspace"]
LOC["local.ts<br/>start a local Flagsmith with Docker"]
end
subgraph Pure["No VS Code (unit tested, reused by the CLI and e2e)"]
OPS["incidentOps.ts<br/>kill switch + restore"]
API["api.ts<br/>Flagsmith client"]
SC["scanner.ts<br/>finds flag keys in code"]
REP["report.ts<br/>code vs Flagsmith"]
INC["incident.ts<br/>who's still on, incident summary"]
AR["alertRule.ts<br/>Prometheus rule + receiver"]
TM["timing.ts<br/>flag change vs alert time"]
MD["markdown.ts<br/>safe hover text"]
CR["coderefs.ts / gitInfo.ts / gitUrl.ts<br/>code references, permalinks"]
end
CLI["cli.ts<br/>scan / check / publish-refs"]
FS[("Flagsmith<br/>self-hosted")]
EXT --> ST
ED --> ST
VW --> ST
ED --> US
US --> SC
ST --> OPS
ST --> API
OPS --> API
EXT --> INC
EXT --> AR
ED --> MD
CLI --> SC
CLI --> REP
CLI --> API
API --> FS
The split is deliberate. Anything that decides or talks to Flagsmith sits in the "no VS Code" half, so it runs under node --test and in the CLI, and the live tests exercise the exact code users run.
store.ts refreshes every flaglens.pollSeconds (15 by default), and after every change you make:
sequenceDiagram
participant S as store.ts
participant F as Flagsmith
S->>F: features, tags, environments, Feature Health events (in parallel)
S->>F: per environment: default states + override counts
S->>F: per environment: A/B tests, and results for running ones
Note over S: newest health event per flag and environment
S->>F: for flags with an open alert: every state + segment links (who is still on?)
Note over S: new UNHEALTHY → incident, new HEALTHY → offer restore
S-->>S: fire change event → lenses, hovers, sidebars, status bar redraw
Errors in optional parts (tags, experiments, results) don't stop a refresh. If the refresh itself fails, the status bar shows a warning and the last good data stays on screen.
| What | Where |
|---|---|
| API key | VS Code secret storage (OS keychain) |
| Flagsmith URL and chosen project (the saved connection) | VS Code global state, so every window reconnects |
| Restore records ("what the kill switch turned off") | VS Code workspace state, key flaglens.restorePlans
|
| Last "Check a user" input | VS Code workspace state |
| Flags, states, events, tests | Memory, rebuilt on each refresh |
Hovers contain command links (toggle, kill switch, check a user), so VS Code has to trust them. Flag names, values, environment names and alert text come from Flagsmith, and alert text comes from whoever can call the webhook. markdown.ts escapes all of it, so that text can never become a command link. It has its own tests.
- Add the Flagsmith call to
api.ts(and a unit test with a scriptedfetchintest/api.test.ts). - If it decides something, put that logic in a pure module and test it.
- Wire it into
store.ts(data) andeditor.ts/extension.ts(UI). - Add a live case to
demo-app/e2e.mjsif it writes to Flagsmith. -
npm test, thennpm run packageand install the.vsix.
Repository · Latest release · Report an issue · Wiki sources live in docs/wiki: edit them there and republish.