Skip to content

feat(lsp): resolve tsserver path from main repo in git worktrees - #916

Open
cast-vytautas wants to merge 2 commits into
getkimchi:masterfrom
cast-vytautas:feat/lsp-worktree-support
Open

feat(lsp): resolve tsserver path from main repo in git worktrees#916
cast-vytautas wants to merge 2 commits into
getkimchi:masterfrom
cast-vytautas:feat/lsp-worktree-support

Conversation

@cast-vytautas

@cast-vytautas cast-vytautas commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Linked issue

Closes #917

What does this PR do?

When running kimchi in a git worktree that has no node_modules, the typescript-language-server could not resolve tsserver.js and failed to provide TypeScript intelligence.

This PR resolves tsserver.js from the main repository root when the cwd is a git worktree:

  • src/extensions/lsp/servers.ts — adds findMainRepoRoot(cwd) which detects a git worktree by reading <cwd>/.git (a file in worktrees, a directory in normal repos), parsing the gitdir: line, and extracting the main repo root. Adds resolveTsserverPath(cwd) which checks the local node_modules/typescript/lib/tsserver.js first, then falls back to the main repo root copy if cwd is a worktree.
  • src/extensions/lsp/client.ts — wires resolveTsserverPath into getOrCreateClient: when config.command === "typescript-language-server", it sets initOptions.tsserver.path to the resolved path before the LSP initialize request. Existing initOptions are preserved.
  • src/extensions/lsp/servers.test.ts — new test file covering findMainRepoRoot (5 cases: valid worktree, .git is a directory, no .git, no gitdir pattern, non-worktrees gitdir) and resolveTsserverPath (5 cases: local tsserver, main repo fallback, not-a-worktree, .git directory, local preference).

Local preference is preserved: if node_modules/typescript exists in the worktree itself, it is used over the main repo copy.

Checklist

  • I have read CONTRIBUTING.md and agree to the CLA
  • This PR links to an open issue above
  • Tests pass locally (pnpm run test)
  • Lint passes (pnpm run check)
  • Documentation updated if behavior changed

@readme-ai-writer

readme-ai-writer Bot commented Jul 22, 2026

Copy link
Copy Markdown

📚 No documentation changes were needed for this PR.

@kimchi-review

kimchi-review Bot commented Jul 22, 2026

Copy link
Copy Markdown

Kimchi Code Review

Property Value
Commit f768d02
Author @cast-vytautas
Files changed 0
Review status Completed
Comments 2 (1 info, 1 warning)
Duration 61s

Summary

📊 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.

What to expect

Kimchi will analyze the changes in this pull request and post:

  • A summary of the overall changes
  • Inline comments on specific lines with findings categorized by issue type

The review typically completes within a few minutes. This comment will be updated once the review is ready.

Interact with Kimchi
  • @getkimchi review — re-trigger a full review on the latest commit
  • @getkimchi summary — regenerate the PR summary
  • @getkimchi ignore — skip this PR (no review will be posted)
  • Reply to any inline comment to ask follow-up questions or request clarification
Configuration

Reviews are configured by your organization admin.
Review instructions, excluded directories, and severity thresholds can be adjusted per repository in the Kimchi dashboard.


Powered by Kimchi — AI-powered code review by CAST AI

@kimchi-review kimchi-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📊 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.

Comment thread src/extensions/lsp/client.ts
Comment thread src/extensions/lsp/servers.ts
@cast-vytautas
cast-vytautas force-pushed the feat/lsp-worktree-support branch from f768d02 to a72eaa1 Compare July 22, 2026 13:36
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

This PR has been marked as stale because it has not had recent activity. It will be closed tomorrow if no further activity occurs.

@github-actions github-actions Bot added the stale No recent activity label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale No recent activity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP (typescript-language-server) fails to start in git worktrees

1 participant