[BUG] pyright-lsp plugin changes cwd, breaking Kitty new-tab
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
- Install the pyright-lsp plugin:
claude plugins install pyright-lsp@claude-plugins-official - Open Kitty, making sure you have
map kitty_mod+t new_tab_with_cwdin your Kitty config - Start Claude Code in a directory with a
.pyfile - Have Claude Code edit the
.pyfile - Wait for pyright diagnostics to appear (confirms the LSP is running)
- Open a new terminal tab in kitty with
Ctrl+Shift+T(or whatever you mapped tonew_tab_with_cwd) - Run
pwdin 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.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗