Skip to content

Fix TypeScript LSP startup without global binary#57

Merged
BunsDev merged 4 commits into
mainfrom
fix/typescript-lsp-resolution
May 18, 2026
Merged

Fix TypeScript LSP startup without global binary#57
BunsDev merged 4 commits into
mainfrom
fix/typescript-lsp-resolution

Conversation

@BunsDev

@BunsDev BunsDev commented May 18, 2026

Copy link
Copy Markdown
Member

Summary

  • Resolve TypeScript LSP startup from custom, workspace-local, CastCodes-managed, then PATH sources instead of requiring a global typescript-language-server.
  • Detect workspace-local node_modules/.bin/typescript-language-server and package CLI installs before falling back.
  • Surface an actionable Codebase Indexing repair state/button when the TypeScript language server is missing.

Temporary workaround

Until this ships, users can install the TypeScript server locally in the target repo:

npm install -D typescript typescript-language-server

After this change, users can also use Settings > Codebase Indexing > Install/repair TypeScript language server; no global PATH install is required.

Verification

  • rustfmt --check app/src/settings_view/code_page.rs crates/lsp/src/config.rs crates/lsp/src/servers/typescript_language_server.rs crates/lsp/src/supported_servers.rs
  • git diff --cached --check
  • cargo test -p lsp --features local_fs supported_servers::tests
  • cargo check -p warp-app --bin cast-codes --features gui,cast-agent

Note: the app compile gate passes with existing warnings in unrelated modules.

Copilot AI review requested due to automatic review settings May 18, 2026 09:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR changes the TypeScript LSP startup path so a globally installed typescript-language-server is no longer required. Resolution now walks user-configured → workspace-local (node_modules/.bin wrapper or the package's cli.mjs) → CastCodes-managed install → PATH, and the Codebase Indexing settings page surfaces an "Install/repair" affordance when the TypeScript server is missing.

Changes:

  • Introduce resolve_lsp_binary_config plus LspBinarySource/ResolvedLspBinaryConfig and an actionable missing-binary error message, and add TypeScriptLanguageServerCandidate::find_workspace_binary_config to discover workspace-local installs.
  • Rework LspServerConfig::command_and_params to use the new four-source resolution order and carry an optional user-configured CustomBinaryConfig.
  • In the Code settings page, detect a repairable TypeScript failure via error-string matching and render an "Install/repair" button, replacing the badge text accordingly.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
crates/lsp/src/supported_servers.rs Adds resolution types, the actionable error message, the per-server workspace probe dispatch, and unit tests.
crates/lsp/src/servers/typescript_language_server.rs Adds workspace-local discovery for node_modules/.bin/typescript-language-server and cli.mjs, with --version verification.
crates/lsp/src/config.rs Stores an optional custom binary on LspServerConfig and rewrites startup resolution to use resolve_lsp_binary_config.
app/src/settings_view/code_page.rs Adds the repair button + status text for the missing-binary failure and tears down the server before reinstall.
Comments suppressed due to low confidence (1)

app/src/settings_view/code_page.rs:2105

  • The repairable-failure detection relies on substring-matching the error message against the human-readable label TYPESCRIPT_LSP_REPAIR_LABEL ("Install/repair TypeScript language server"). This creates a brittle coupling: any future change to the wording in actionable_missing_binary_message (e.g., localization, rephrasing) will silently break the UI's ability to surface the repair button, and conversely any unrelated failure message that happens to contain this phrase will spuriously show the repair UI. Consider propagating this state structurally — for example, by exposing a typed reason on LspState::Failed (a MissingBinary kind or a dedicated error code) — rather than parsing a free-form error string.
    fn is_repairable_lsp_failure(
        &self,
        server_model: Option<&warpui::ModelHandle<LspServerModel>>,
        server_type: LSPServerType,
        app: &AppContext,
    ) -> bool {
        server_type == LSPServerType::TypeScriptLanguageServer
            && server_model.is_some_and(|model| {
                matches!(
                    model.as_ref(app).state(),
                    LspState::Failed { error } if error.contains(TYPESCRIPT_LSP_REPAIR_LABEL)
                )
            })
    }

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread crates/lsp/src/supported_servers.rs Outdated
Comment thread app/src/settings_view/code_page.rs
Comment thread crates/lsp/src/servers/typescript_language_server.rs
Comment thread crates/lsp/src/config.rs
BunsDev and others added 2 commits May 18, 2026 05:04
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@BunsDev

BunsDev commented May 18, 2026

Copy link
Copy Markdown
Member Author

@copilot apply changes based on the comments in this thread

@BunsDev
BunsDev merged commit b4bb92e into main May 18, 2026
11 checks passed
@BunsDev
BunsDev deleted the fix/typescript-lsp-resolution branch May 18, 2026 11:55
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.

2 participants