feat(lsp): resolve tsserver path from main repo in git worktrees - #916
feat(lsp): resolve tsserver path from main repo in git worktrees#916cast-vytautas wants to merge 2 commits into
Conversation
|
📚 No documentation changes were needed for this PR. |
Kimchi Code Review
Summary📊 Review Score: 87/100 (overall code quality — 0 lowest, 100 highest) 🧪 Tests: yes — New unit tests in 📝 Found 2 issue(s). See inline comments for details. What to expectKimchi will analyze the changes in this pull request and post:
The review typically completes within a few minutes. This comment will be updated once the review is ready. Interact with Kimchi
ConfigurationReviews are configured by your organization admin. Powered by Kimchi — AI-powered code review by CAST AI |
There was a problem hiding this comment.
📊 Review Score: 87/100 (overall code quality — 0 lowest, 100 highest)
⏱️ Estimated effort to review: 2/5 (1 = trivial, 5 = very complex)
🧪 Tests: yes — New unit tests in src/extensions/lsp/servers.test.ts cover findMainRepoRoot and resolveTsserverPath comprehensively, including local preference, worktree fallback, missing TypeScript, non-worktree repos, and submodule exclusion.
📝 Found 2 issue(s). See inline comments for details.
f768d02 to
a72eaa1
Compare
|
This PR has been marked as stale because it has not had recent activity. It will be closed tomorrow if no further activity occurs. |
Linked issue
Closes #917
What does this PR do?
When running kimchi in a git worktree that has no
node_modules, thetypescript-language-servercould not resolvetsserver.jsand failed to provide TypeScript intelligence.This PR resolves
tsserver.jsfrom the main repository root when the cwd is a git worktree:src/extensions/lsp/servers.ts— addsfindMainRepoRoot(cwd)which detects a git worktree by reading<cwd>/.git(a file in worktrees, a directory in normal repos), parsing thegitdir:line, and extracting the main repo root. AddsresolveTsserverPath(cwd)which checks the localnode_modules/typescript/lib/tsserver.jsfirst, then falls back to the main repo root copy if cwd is a worktree.src/extensions/lsp/client.ts— wiresresolveTsserverPathintogetOrCreateClient: whenconfig.command === "typescript-language-server", it setsinitOptions.tsserver.pathto the resolved path before the LSPinitializerequest. ExistinginitOptionsare preserved.src/extensions/lsp/servers.test.ts— new test file coveringfindMainRepoRoot(5 cases: valid worktree, .git is a directory, no .git, no gitdir pattern, non-worktrees gitdir) andresolveTsserverPath(5 cases: local tsserver, main repo fallback, not-a-worktree, .git directory, local preference).Local preference is preserved: if
node_modules/typescriptexists in the worktree itself, it is used over the main repo copy.Checklist
pnpm run test)pnpm run check)