Skip to content

fix(lsp): silent request timeouts, and inlay-hint drift (#2197, #722) - #3159

Merged
sinelaw merged 1 commit into
masterfrom
claude/fix-lsp
Sep 3, 2026
Merged

sinelaw merged 1 commit into
masterfrom
claude/fix-lsp

Conversation

@sinelaw

@sinelaw sinelaw commented Sep 2, 2026 •

Copy link
Copy Markdown
Owner

Fixes #2197. Fixes #722.

Before / after

#2197 — pyright 1.1.408 never answers

  1. npm i [email protected], configure pyright-langserver --stdio for Python, open a file with def add(a, b): … and a call add(1, 2); the status bar reads LSP (python) ready.
  2. Put the cursor on add in the call, press F12. Then Alt+K.
before after
F12 nothing for 30s, then No definition found; status bar still LSP (python) ready jumps to def add immediately
Alt+K nothing for 30s, then No hover information available; still ready hover popup with the signature

The server is unblocked by a workspace/didChangeConfiguration pushed right after initialized, which VS Code, Neovim and Helix all send (details below). For a server that stays silent anyway — a stub that answers initialize and nothing else reproduces it — the timeouts are no longer invisible:

before after
after the first 30s No definition found; status bar still ready LSP (python): 'textDocument/definition' timed out after 30s
after the second No hover information available; still ready pill turns LSP (stuck) (warning colours); Alt+K popup shows ◍ pyright-langserver (not responding) with Restart/Stop
first answered request afterwards — pill back to LSP (on), popup row back to (ready)

#722 — inlay hint jumps to the next line on Enter

  1. Rust project with rust-analyzer and inlay hints on; a line let d = Duration::from_secs(5); shows the hint : Duration after d.
  2. Put the cursor immediately after d (on the hint's anchor) and press Enter.
before, for ~1s until the next inlayHint refresh:     after, first frame:
  5 │     let d                                           5 │     let d : Duration
  6 │     : Duration  = Duration::from_secs(5);           6 │      = Duration::from_secs(5);

The "after" frame is identical to what the refresh produces for the split buffer, which the regression test asserts directly.

The Deno half (#2981) has been removed from this PR. #3111 took that fix and #3168 moved the detection into a plugin; both are on master. configure_lsp_servers here is master's version verbatim.

#2197 — what changed

The hang is pyright 1.1.408's. With the client advertising workspace.workspaceFolders, its initialized handler skipped updateSettingsForAllWorkspaces(), so the workspace created during initialize never resolved its isInitialized promise and every request that awaits it waits forever (microsoft/pyright#11239, shipped in 1.1.409; 1.1.408 was the only affected npm release, Jan 8 – Apr 23, 2026). Other editors never saw it because their clients push a workspace/didChangeConfiguration right after initialized — VS Code via synchronize.configurationSection, Neovim when settings is set, Helix when config is set — and pyright's handler for that notification happens to call the same updateSettingsForAllWorkspaces(). Fresh sent no such notification and hit the bug head-on.

Compatibility push. Fresh now sends workspace/didChangeConfiguration once, right after initialized, with the same object it answers workspace/configuration from (the server's initialization_options, or {}), so a server sees one configuration whichever way it asks. Not required by the spec, but servers are written against the clients that do it. Verified against the real pyright 1.1.408 in tmux: F12 jumps, Alt+K hovers.

Visibility. What was Fresh's bug is that a silent server looked healthy. Requests are cancelled after 30s, which is correct, but the user saw only an empty result, indistinguishable from a symbol that genuinely has no definition, with ready on the status bar throughout. Three surfaces now:

  1. An expired request the user made is named on the status bar. Deliberately not the requests the editor makes on its own — inlay hints, diagnostics, semantic tokens, folds, and (per review) completion and signature help, which fire on ordinary typing. Against a wedged server those would claim the status bar once per keystroke, 30s later. They still count towards the streak; the indicator is their surface.
  2. An empty result that follows an expiry of the same request explains itself — LSP (python): no answer — 'textDocument/definition' timed out after 30s in place of No definition found. Keyed by method, consumed on use, and dropped when the server answers again, so it explains exactly one empty result and never a later, genuine one. Universal servers are matched by scope, since their records are labelled "universal" rather than by language.
  3. Two expiries in a row with nothing answered in between put the server in a new LspServerStatus::Unresponsive: the LSP (stuck) pill (same fixed width, nothing else on the bar shifts) and the (not responding) popup row. The first answered request clears it back to Running, and both transitions re-render an open popup. A server reporting $/progress keeps its spinner, so an indexing rust-analyzer or jdtls is never called stuck. Unresponsive also counts as "was running" for the crash path, so a wedged server that then dies still gets its diagnostics cleared and its auto-restart.

A request the editor cancels itself no longer counts towards that streak: handle_cancel_request withdrew the request from active_requests but left the pending entry in place, so a server that ignores $/cancelRequest parked the requester for the full 30s and the expiry looked exactly like a hang — and the editor cancels superseded completion, definition and semantic-token requests on ordinary cursor movement. Cancelling now drops the pending entry, which also resolves the superseded requester immediately rather than 30s later.

Open question: UNRESPONSIVE_TIMEOUT_STREAK = 2 and the "expired" phrasing are judgement calls, and something louder — a popup, or offering a restart when a server goes quiet — is a product decision I left alone. Also open, from review: classifying requests by method name is a proxy for what we actually want to know (did the user ask for this?), and threading that from the call site would be the real fix.

#722 — what changed

Hints are byte-offset markers, and the marker was carried along by text inserted at the hint's own anchor. The inlay-hint path now asks for a left-gravity marker, so an insertion at the anchor stays behind the hint. Gravity is an explicit MarkerGravity argument rather than something inferred from BeforeChar/AfterChar: the two are not the same question. The async-paste placeholder is also a BeforeChar entry, but its marker is the eventual insertion point, so it must keep travelling with text typed at it. AfterChar hints keep right gravity, which the #1572 end-of-line anchoring relies on.

Gravity travels with the decoration into the wrap index too. IndexDecorations::shift_for_edit keeps its own copy of these anchors and shifted them all with right gravity by contract, so without this the index would have placed the hint on the next line while the renderer drew it on this one — moving the drift from the renderer into the coordinate service (row counts, cursor visual columns, scrollbar extent, h-scroll) for the same ~1s window.

Scope note: this fixes the Enter-at-the-anchor case from the repro. Undo of that split still shows a brief one-column shift before the refresh lands — the marker survives the undo correctly, but the renderer's end-of-line hint padding differs by a space; a smaller artifact of the same class, not addressed here.

Tests

  • issue_2197_lsp_timeout_visible.rs — the settings push follows initialized, precedes the first didOpen, and happens exactly once (logging fake server); a user-invoked timeout reaches the status bar while background and auto-triggered ones do not; an unresponsive server is not rendered as ready, recovers, and is still treated as a crash if it dies while quiet; an empty result after a timeout says the request expired, but only for the method that expired, only once, and not after the server has answered again.
  • issue_722_inlay_hint_split_drift.rs — Enter at a hint anchor keeps the hint on its line and already matches the refreshed rendering; a parameter hint stays in front of text typed at its anchor. Both fail without the fix. view::virtual_text pins the gravity contract, view::wrap_index pins that the index shifts each anchor by its own gravity, and the pre-existing marker-tracking test in state.rs is untouched from master because the paste anchor's behaviour is untouched.
  • services::lsp::async_handler — unit tests for the streak transitions (first expiry, the crossing, reset by an answer, recovery reported once), which had no coverage.
  • app::lsp_status::tests — LSP (stuck) for an unresponsive server, error still outranks it, pill width unchanged.

Both issues were reproduced on master and re-verified after the fix by driving the editor interactively in tmux; the existing LSP handshake and ordering tests pass with the extra notification. cargo fmt --check and cargo clippy -p fresh-editor --all-targets are clean on the touched files. Note for anyone reproducing locally: plain cargo test is not equivalent here — wait_until has no timeout and the orchestrator/SSH tests share process-global env, so they need nextest's process-per-test isolation.

Two new user-facing strings (the timeout messages) are not routed through t!, matching the LSP status messages beside them — including the "LSP ({}) ready" line this issue is about. The locale files are flat with a strict key-parity test, so localizing them means adding them to all fifteen locales; happy to do that if you'd rather they were translated from the start.


🤖 Generated with Claude Code

https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw

@sinelaw sinelaw left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Careful read of the whole diff. Six findings, all posted inline. The Deno detection change (deno_lsp_override + the bounded authority probe) and the LspError { server_command } plumbing look correct to me; the handle_cancel_request fix (dropping the pending entry) is right and the request-id gating on the editor side means the now-immediate empty result is discarded as an outdated response, so that one is safe.

The two I'd treat as blocking are the wrap-index gravity desync (#722 fix moves the drift from the renderer into WrapIndex's decoration snapshot) and the missing Unresponsive case in the crash predicate in handle_lsp_status_update (a stuck server that then dies no longer auto-restarts and leaves stale diagnostics on screen).


Generated by Claude Code

Comment thread crates/fresh-editor/plugins/lsp_help.ts Resolved
@sinelaw sinelaw changed the title fix(lsp): deno detection, silent request timeouts, and inlay-hint drift (#2981, #2197, #722) fix(lsp): silent request timeouts, and inlay-hint drift (#2197, #722) Sep 3, 2026
@sinelaw
sinelaw force-pushed the claude/fix-lsp branch 2 times, most recently from 3d3a5cf to e7bd096 Compare September 3, 2026 19:57
…zed, keep inlay hints in place

Two bugs where the UI told the user something that wasn't true, and one
compatibility push (#2197, #722).

with the client advertising `workspace.workspaceFolders` its `initialized`
handler skipped `updateSettingsForAllWorkspaces()`, so the workspace never
resolved and every request hung (microsoft/pyright#11239, fixed in
1.1.409). Other editors never saw it because their clients push a
`workspace/didChangeConfiguration` right after `initialized` — VS Code,
Neovim, Helix — and pyright's handler for that happens to do the same
setup. Fresh now sends that notification once after `initialized`, with
the same object `workspace/configuration` is answered from, so a server
sees one configuration whichever way it asks. Verified against the real
pyright 1.1.408: F12 jumps, hover works.

What was Fresh's bug is that a silent server looked healthy: requests are
cancelled after 30s, which is right, but the user saw only an empty
result with `LSP (python) ready` on the bar throughout. Now an expired
request the user made is named on the status bar (background traffic —
inlay hints, diagnostics, semantic tokens, auto-triggered completion and
signature help — stays off it); an empty result that follows an expiry of
the same method says so instead of posing as an answer; and two expiries
in a row with nothing answered between them put the server in a new
`Unresponsive` status: `LSP (stuck)` on the pill, `(not responding)` in
the servers popup, cleared by the first answered request. A server
reporting `$/progress` keeps its spinner. `Unresponsive` counts as "was
running" for the crash path. Cancelling a request now also drops its
pending entry, so a superseded request resolves immediately instead of
30s later and never counts towards the streak.

own anchor carried the hint along, so Enter after `d` in
`let d = Duration::from_secs(5);` showed `: Duration` on the next line
until the debounced refresh. The inlay-hint path now asks for a
left-gravity marker (an explicit `MarkerGravity`, not inferred from
`BeforeChar`: the paste placeholder is `BeforeChar` too and must keep
travelling). Gravity travels into the wrap index as well —
`IndexDecorations::shift_for_edit` shifted every anchor right-gravity by
contract, which would have moved the drift into the coordinate service.

Tests: the settings push follows `initialized` and precedes `didOpen`
exactly once; user-invoked timeouts reach the status bar while background
ones do not; an unresponsive server is not rendered as ready, recovers,
and is still a crash if it dies while quiet; an empty result after a
timeout says the request expired, only for that method, only once, and
not after the server answered again; streak transitions; `LSP (stuck)`
composition; Enter at a hint anchor keeps the hint on its line and
matches the refreshed rendering; gravity contract and wrap-index shifting.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SHsuKyMdSZ7soeFzDziRNw
@sinelaw
sinelaw merged commit 147bd98 into master Sep 3, 2026
11 checks passed
@sinelaw
sinelaw deleted the claude/fix-lsp branch September 3, 2026 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants