Skip to content

feat: add Phase 2 hover provider + Phase 1.5 robustness - #241

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

feat: add Phase 2 hover provider + Phase 1.5 robustness#241
j4rviscmd merged 1 commit into
mainfrom
feat/language-host-hover

Conversation

@j4rviscmd

Copy link
Copy Markdown
Owner

Summary

Phase 2 of the native (Rust) Language Host: tree-sitter-backed hover provider (function/method/class/interface/type/typed-variable signatures + JSDoc), plus Phase 1.5 robustness, plus a SymbolKind off-by-one fix for the Phase 1 documentSymbol icons.

Phase 2 — Hover

  • Message::Hover { uri, line, column }HoverResponse { signature, documentation, range }
  • UTF-16 → UTF-8 column reconciliation for hover positions (renderer Position.column is UTF-16 code units; tree-sitter Point.column is a UTF-8 byte offset). Phase 1 symbol/fold stay byte-column + 1 with the retained TODO.
  • Signature via source-slice of the declaration header (keeps async / generics / params / return-type verbatim — no reconstruction); JSDoc collected from leading /** comment siblings.
  • Name-token gate (hover fires only on the identifier, not the body); variable_declarator / public_field_definition require a type annotation.
  • CodermHoverProvider registered for the configured languages; renderer wraps signature in a ```typescript MarkdownString and renders JSDoc as a second markdown string.

Phase 1.5 — Robustness

  • Reject all pending requests on MessagePort close (no 30s timeout wait).
  • onDidChangeLanguage re-sync: document/open re-sent with the new languageId.

Fix

  • SymbolKind off-by-one: documentSymbol kind values now match VS Code's SymbolKind enum (Class=4, Method=5, Enum=9, Interface=10, Function=11, TypeParameter=25), not LSP's off-by-one numbers. Outline icons now render correctly.

How to verify

  1. `cd rust && cargo build`
  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:
    • Outline icons (`Cmd+Shift+O`) render correctly per kind
    • Hover a function/class/interface name → signature + JSDoc; hover inside a body → nothing; `const x: number` shows, `const x = 1` doesn't
    • Change language mode → host re-syncs

Verified end-to-end via Playwright CDP (hover signature + JSDoc render, source-slice keeps generics).

Phase 2 — tree-sitter-backed HoverProvider: Message::Hover { uri, line, column } -> HoverResponse { signature, documentation, range }. UTF-16 to UTF-8 column reconciliation for hover positions (renderer Position.column is UTF-16 code units; tree-sitter Point.column is a UTF-8 byte offset). Signature via source-slice of the declaration header (keeps async/generics/params/return-type verbatim); JSDoc collected from leading /** comment siblings. Name-token gate (hover fires only on the identifier, not the body); variable_declarator/public_field_definition require a type annotation. CodermHoverProvider registered for the configured languages; renderer wraps signature in a typescript MarkdownString and renders JSDoc as a second markdown string.

Phase 1.5 — robustness: reject all pending requests on MessagePort close (no 30s timeout wait); onDidChangeLanguage re-sync (document/open re-sent with the new languageId).

Fix: SymbolKind off-by-one — documentSymbol kind values now match VS Code's SymbolKind enum (Class=4, Method=5, Enum=9, Interface=10, Function=11, TypeParameter=25), not LSP's off-by-one numbers, so outline icons render correctly.

Co-Authored-By: Claude <noreply@anthropic.com>
@j4rviscmd j4rviscmd added the enhancement New feature or request label Jul 25, 2026
@j4rviscmd
j4rviscmd merged commit f1e0700 into main Jul 25, 2026
3 checks passed
@j4rviscmd
j4rviscmd deleted the feat/language-host-hover branch July 25, 2026 14:45
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