Skip to content

Process Detection

tavlean edited this page May 27, 2026 · 1 revision

Process Detection

The dashboard reads OS state directly. No internal "list of servers we started".

Sources

  • ps -A → every process
  • lsof -iTCP -sTCP:LISTEN → listening sockets, grouped by PID
  • lsof -p PID -d cwd → cwd for each PID with a listener
  • git rev-parse --git-common-dir --abbrev-ref HEAD → group worktrees by shared git dir

Implementation in src/servers.ts::fetchServers. ~200–500ms per call.

Why this shape

The dashboard catches servers started in your terminal, via this extension, via any other tool. Anything listening counts. The source of truth is the OS, so we never go out of sync.

Aggregation is pure TypeScript

Earlier versions ran an embedded shell pipeline. The current code is ~3× faster and removes a class of shell-parsing bugs (awk/grep quoting, locale-dependent output, etc.).

Cross-platform port plan

Platform primitives are isolated in named functions: listProcesses, listListeners, listCwds, fetchAliases. Swap them for Windows equivalents and the aggregation logic stays unchanged.

Suggested mapping (untested):

macOS Windows
ps -A Get-CimInstance Win32_Process
lsof -iTCP -sTCP:LISTEN Get-NetTCPConnection -State Listen
lsof -p PID -d cwd Win32_Process cwd via WMI
portless list (via zsh) portless list (via PowerShell)

killServer (SIGKILL + process.kill(pid, 0)) already maps cleanly to TerminateProcess/OpenProcess on Windows.

Future scope

  • Background refresh + a menu-bar command surfacing the running-server count. Would reuse fetchServers directly. Requires a no-view/menu-bar command and the interval manifest field.

Clone this wiki locally