Skip to content

feat: add Phase 1 Language Host with tree-sitter features - #240

Merged
j4rviscmd merged 1 commit into
mainfrom
feat/language-host
Jul 25, 2026
Merged

feat: add Phase 1 Language Host with tree-sitter features#240
j4rviscmd merged 1 commit into
mainfrom
feat/language-host

Conversation

@j4rviscmd

Copy link
Copy Markdown
Owner

Summary

Phase 1 of the native (Rust) Language Host: tree-sitter-backed documentSymbol and foldingRange for the configured languages, replacing the Phase 0 echo probe.

Changes

  • Wire protocol (languageHostProtocol.ts): unified the frame to 8 bytes [reqId(4)][len(4)][payload] across renderer, electron-main relay, and Rust. Added a request-id multiplexer — notifications (reqId=0, no response) for document sync, requests (reqId>0, response awaited) for language features.
  • Document sync (documentSync.ts): didOpen / didChange / didClose over notifications. Phase 1 sends the full text on every change (full-text replace) to avoid an incremental range-merge engine.
  • Language features (languageFeatures.ts): documentSymbol and foldingRange providers registered with ILanguageFeaturesService for the configured languages.
  • electron-main relay (languageHostServerService.ts): simplified to a transparent 8-byte-frame pass-through. The Phase 0 relay's 4-byte length header misread the renderer's reqId as the payload length, which broke the path.
  • Rust host (main.rs): tree-sitter + tree-sitter-typescript parse the document and emit symbols (function / class / method / interface / enum / type) and foldable block ranges.
  • Removed the Phase 0 echo probe; the documentSymbol / foldingRange path now carries the wire validation.

How to verify

  1. `cd rust && cargo build` (binary lands at `rust/target/debug/coderm-language-host`)
  2. `npm run watch` + `./scripts/code.sh`
  3. Enable `coderm.languageHost.enabled` and set `coderm.languageHost.languages` (e.g. `["typescript", "tsx"]`)
  4. Open a `.ts` file → check Outline (`Cmd+Shift+O`) and folding

Default remains off; with an empty `languages` array the feature is inert.

Notes

  • Pinned to `tree-sitter` / `tree-sitter-typescript` 0.23 (the grammar's 0.22 is not on crates.io).
  • Known Phase 1 limitations (documented inline): full-text replace on change, flat symbol list (VS Code re-hierarchizes by range overlap), 1 MiB max payload, and a +1 column conversion that is ASCII-only (non-ASCII reconciliation is deferred to Phase 2).

Unify the wire frame to 8 bytes [reqId(4)][len(4)][payload] across the renderer, the electron-main relay, and the Rust host. The Phase 0 relay's 4-byte length header misread the renderer's reqId as the payload length, breaking the path.

Add a request-id multiplexer: notifications (reqId=0, no response) for document sync (didOpen/didChange/didClose with full-text replace), and requests (reqId>0, response awaited) for language features. The electron-main relay becomes a transparent 8-byte-frame pass-through.

Register tree-sitter-typescript backed documentSymbol and foldingRange providers for the configured languages. The documentSymbol/foldingRange path now carries the wire validation that the Phase 0 echo probe provided; echo is removed.

Co-Authored-By: Claude <noreply@anthropic.com>
@j4rviscmd j4rviscmd added the enhancement New feature or request label Jul 25, 2026
@j4rviscmd
j4rviscmd merged commit aa1dbf1 into main Jul 25, 2026
3 checks passed
@j4rviscmd
j4rviscmd deleted the feat/language-host branch July 25, 2026 05:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant