[BUG] pyright-lsp plugin changes cwd, breaking Kitty new-tab

Resolved 💬 3 comments Opened Mar 30, 2026 by Numeri Closed May 3, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

When the pyright-lsp@claude-plugins-official plugin is enabled, Claude Code spawns pyright-langserver --stdio as a child process in the same process group as the main Claude Code process. Pyright internally calls chdir('/usr/lib/node_modules/pyright/dist/') (or wherever it's installed).

Kitty determines the cwd for new tabs by finding the highest-PID process in the foreground process group and reading its /proc/<pid>/cwd. Since pyright-langserver has a higher PID than Claude Code and is in the same process group, new terminal tabs open in pyright's dist directory instead of the user's working directory.

What Should Happen?

Opening a new terminal tab while Claude Code is running should land in the directory where Claude Code was launched, regardless of what LSP plugins are active. LSP subprocesses should be spawned in their own process group (e.g., detached: true in Node's child_process.spawn, or via setsid) so they don't pollute the foreground process group.

Error Messages/Logs

Steps to Reproduce

  1. Install the pyright-lsp plugin: claude plugins install pyright-lsp@claude-plugins-official
  2. Open Kitty, making sure you have map kitty_mod+t new_tab_with_cwd in your Kitty config
  3. Start Claude Code in a directory with a .py file
  4. Have Claude Code edit the .py file
  5. Wait for pyright diagnostics to appear (confirms the LSP is running)
  6. Open a new terminal tab in kitty with Ctrl+Shift+T (or whatever you mapped to new_tab_with_cwd)
  7. Run pwd in the new tab — it will show /usr/lib/node_modules/pyright/dist/ instead of /tmp/test

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.1.86 (Claude Code)

Platform

Anthropic API

Operating System

Other Linux

Terminal/Shell

Other

Additional Information

The easiest fix would be to spawn LSP server subprocesses in their own process group (e.g., via setsid or equivalent), so they are invisible to terminal emulators' foreground-process-group-based cwd detection.

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗