Skip to content

refactor(lsp): unify command detection - #775

Closed
beruro wants to merge 1 commit into
developfrom
junyu/unify-lsp-command-detection
Closed

refactor(lsp): unify command detection#775
beruro wants to merge 1 commit into
developfrom
junyu/unify-lsp-command-detection

Conversation

@beruro

@beruro beruro commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Problem

The LSP crate had three independent implementations for checking whether a command exists. One explicitly forwarded the app-adjusted PATH while the lint and workspace-scan copies did not, so installed-tool results could differ by surface and future platform fixes had to be repeated.

Solution

Introduce one crate-owned command detection helper and route LSP discovery, package-manager selection, install preflight, lint-tool detection, and both workspace scan paths through it. The helper explicitly forwards the current PATH, preserves Windows console suppression, and keeps the existing public commands::discovery::command_exists entry point as a re-export for compatibility. Regression tests cover a known platform shell and a guaranteed-missing command.

Potential risks

Tool availability now consistently uses the explicit-PATH behavior that discovery already used. This could make a previously inconsistent lint surface recognize a tool added to the app process PATH, which is the intended convergence. Command execution count and timing remain unchanged; no cache was added, avoiding stale results after PATH changes. Rollback is a single-commit revert.

Architecture and performance

  • Covered ownership, public API compatibility, platform behavior, dependency direction, scan/install consumers, and test boundaries.
  • Intentionally skipped wire types, persistence, FSM, UI/rendering, and initialization parity because they are unchanged.
  • Performance verdict: pass/neutral. Foreground and orchestrated scans make the same number of lookup processes as before; no polling, retry loop, timer, subscription, cache, or retained state was added.
  • Lifecycle matrix: active scan behavior is unchanged; idle, hidden, closed, and repeated-open states retain no command-detection resources.

Verification

  • cargo fmt --all -- --check — passed after formatting.
  • cargo test -p lsp --lib — 112 passed.
  • cargo clippy -p lsp --all-targets --no-deps -- -D warnings — passed.
  • Repository commit hook — scoped LSP Cargo clippy passed.
  • git diff --check — passed.
  • No TypeScript or UI files changed, so frontend typecheck and visual evidence are not applicable.

@beruro

beruro commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

Superseded by #780, which preserves this change as an independent commit and has passed the consolidated CI suite. The source branch is retained for recovery.

@beruro beruro closed this Aug 11, 2026
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.

1 participant