Skip to content

fix(config): preserve React language IDs for TSX/JSX#149

Open
dergachoff wants to merge 3 commits into
bug-ops:mainfrom
dergachoff:fix/tsx-language-id
Open

fix(config): preserve React language IDs for TSX/JSX#149
dergachoff wants to merge 3 commits into
bug-ops:mainfrom
dergachoff:fix/tsx-language-id

Conversation

@dergachoff

@dergachoff dergachoff commented May 7, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #148.

This keeps React document language IDs intact for TSX/JSX files and still lets the common single TypeScript or JavaScript server configuration handle them.

  • typescript + .tsx file patterns now map to typescriptreact
  • javascript + .jsx file patterns now map to javascriptreact
  • when no exact react LSP client is configured, typescriptreact routes to the typescript server and javascriptreact routes to the javascript server
  • if an exact react server is configured, it wins over the fallback

The existing C/C++ file-pattern override behavior is unchanged.

Validation

  • cargo +nightly fmt --check
  • cargo +1.95 clippy -p mcpls-core --all-targets --all-features -- -D warnings
  • cargo +1.95 test -p mcpls-core
  • cargo +1.95 nextest run -p mcpls-core
  • cargo +1.95 test -p mcpls-core get_client_for_file
  • Built a local release binary from a combined branch containing this PR plus fix(lsp): omit null diagnostic request fields #147, then ran a standalone MCP stdio probe against a real TSX project using tsgo. get_diagnostics returned empty diagnostics for both a TSX source file and a TSX test file, with no typescriptreact no-server error and no identifier:null protocol error.

@github-actions github-actions Bot added documentation Improvements or additions to documentation rust Rust code changes mcpls-core mcpls-core crate changes labels May 7, 2026
@bug-ops bug-ops requested a review from Copilot May 24, 2026 14:54

Copilot AI 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.

Pull request overview

This PR fixes React TSX/JSX files being opened with non-React LSP language IDs when extension mappings are inferred from LSP server file_patterns, ensuring .tsx uses typescriptreact and .jsx uses javascriptreact while still allowing fallback routing to the base TypeScript/JavaScript server when no React-specific server is configured.

Changes:

  • Derive typescriptreact/javascriptreact language IDs from .tsx/.jsx patterns even when the server’s language_id is typescript/javascript.
  • Add fallback client routing so typescriptreacttypescript and javascriptreactjavascript when no exact React client is registered.
  • Add unit tests covering the new extension-map derivation and client routing behavior.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
crates/mcpls-core/src/config/mod.rs Adds pattern-extension language ID derivation for TSX/JSX and tests for the effective extension map.
crates/mcpls-core/src/bridge/translator.rs Adds fallback routing from React document language IDs to base server clients and tests for client selection.
CHANGELOG.md Documents the fix under Unreleased.

Comment thread CHANGELOG.md Outdated

### Fixed

- **TSX/JSX diagnostics** — Preserve `typescriptreact`/`javascriptreact` language IDs when deriving mappings from TypeScript/JavaScript server `file_patterns`, fixing JSX parse errors when one server handles both plain and React extensions.
@dergachoff dergachoff force-pushed the fix/tsx-language-id branch from a4c9a90 to b107899 Compare July 6, 2026 08:15
@dergachoff

Copy link
Copy Markdown
Contributor Author

Rebased onto main after v0.3.7. Two notes:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation mcpls-core mcpls-core crate changes rust Rust code changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug: TSX files are opened with plain TypeScript language ID

2 participants