Skip to content

feat(sweep): stop language servers with their tree - #52

Merged
fredericrous merged 1 commit into
mainfrom
feat/sweep-stops-language-servers
Oct 29, 2026
Merged

fredericrous merged 1 commit into
mainfrom
feat/sweep-stops-language-servers

Conversation

@fredericrous

Copy link
Copy Markdown
Owner

fleet-lsp starts one language server per worktree it's asked about: rust-analyzer, gopls, pyright, and the TypeScript server under node. Nothing stopped a server when its worktree went away. On 2026-10-29, twelve rust-analyzers of deleted worktrees had pushed swap to 20 of 21.5 GB, with about 17 MB of free RAM and the load near 900. Every timing test on the machine flaked.

Change (~/.claude/tools/worktree-sweep/sweep.py):

  • On removal: remove() reads, before git worktree remove, the fleet-lsp servers whose working directory is inside the worktree. It stops them after the removal succeeds: SIGTERM to the server and its descendants (tsserver runs under node), then SIGKILL after 3 s.
  • Orphans: every sweep lists ORPHAN-LSP servers whose working directory no longer exists, and --apply stops them. Each stop is logged as LSP-STOPPED.
  • --lsp: does only that, with no forge lookups, for use right after a git worktree remove by hand.
  • Scope: only direct children of a fleet-lsp process are touched, never an editor's own servers. fleet-lsp starts a stopped server again if that checkout is asked about.
  • The worktree-sweep skill documents this. worktree-task's teardown says the sweep stops them, and its abandon path calls --lsp --apply.

Verification:

  • Live dry run: --lsp listed 4 orphans whose directories were confirmed gone, and not the 3 servers of live worktrees.
  • Live --apply: stopped those 4 and their 4 tsserver children. All 8 were gone, the stops were logged, and a re-run found none. The live servers were untouched.
  • Removal path: a throwaway repo, a worktree, and a fake fleet-lsp (a symlink to sh) with a child in that worktree. remove() found the server, removed the worktree and stopped it, matching /tmp against /private/tmp.
  • chezmoi --source <this branch> cat renders all three laptop files byte-identical, with the template directive counts unchanged (3 and 1). No secret-shaped strings in the diff.

🤖 Generated with Claude Code

fleet-lsp starts one language server per worktree and nothing stopped
it when the worktree went away: on 2026-10-29 twelve rust-analyzers of
deleted worktrees had swap at 20 of 21.5 GB. worktree-sweep now stops
the
fleet-lsp children rooted in a worktree it removes, and every run lists
(with --apply, stops) the ones whose working directory no longer exists.
--lsp does only that, without forge lookups; worktree-task's teardown
and
abandon paths call it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fredericrous
fredericrous merged commit a844878 into main Oct 29, 2026
2 checks passed
@fredericrous
fredericrous deleted the feat/sweep-stops-language-servers branch October 29, 2026 09:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant