Skip to content
tavlean edited this page May 28, 2026 · 2 revisions

Paths

Every user-supplied path flows through canonicalCwd(p) in src/servers.ts before being used as a key.

canonicalCwd is a fs.realpathSync wrapper with a graceful fallback.

Why

lsof reports realpath for a process's cwd. Finder, Form.FilePicker, and package.json-derived paths may not be realpath (aliases, symlinks, ~/tmp/private/tmp, iCloud paths). Without canonicalization, string comparison returns false negatives:

  • "Is this project already running?" → fails to match, spawns a duplicate
  • "Is this recents entry currently running?" → fails to filter, picker shows running rows
  • "Did the just-spawned server appear?" → fails, toast spins forever

The bug was silent: different OS/shell/Finder configurations produced different surface paths for the same directory, and the mismatch only showed up for symlinked setups.

Entry points

Anything that produces a path used as a key should canonicalize:

  • findProjectRoot(startPath): walks up to nearest package.json, returns canonical
  • recordSeenBatch (in recents.ts): canonicalizes on every write and passively merges entries that resolve to the same realpath

Rule

If you add code that compares paths across boundaries (Finder/lsof/LocalStorage), route them through canonicalCwd first.

Clone this wiki locally