Repository navigation
fix: hold edit-triggered publishes until jdtls re-validates (#109) - #111
Merged
Merged
Conversation
After an edit the wrapper re-published jdtls's diagnostics for the previous version 150ms later (and immediately on save), while jdtls needs 0.4-2.4s to re-validate. Agent hosts that attach diagnostics right after the edit showed those stale compile errors as current. - Track per-file "waiting for jdtls" state; release it only on a jdtls publish that arrives after jdtls's minimum debounce since the last forwarded change, with an adaptive deadline (3s floor, 10s ceiling) falling back to the cache. - custom-first mode (Claude Code): publish custom diagnostics at once without the stale jdtls set; hold-all (other editors): publish nothing until fresh. JAVA_FUNCTIONAL_LSP_DIAG_HOLD=off restores the old behavior. - Skip the hold for modules not yet imported and java.diagnostic.filter files. - Key the jdtls cache by normalized URI and publish under the client's URI. - Clear cached diagnostics and release holds when jdtls stops. - JAVA_FUNCTIONAL_LSP_LOG_LEVEL, freshness summary counters, jdtls version and dropped jdtls->client request logging; redact paths in two log lines. - E2E test for the cross-file arity variant: converges with didSave, stays stale without it (xfail, Part B). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Keep the too-early floor fixed at jdtls's 400ms debounce; the adaptive floor ratcheted up after one slow publish and rejected normal ones for the rest of the session. The latency EWMA now only stretches the deadline. - Re-initialize wakes held files like a jdtls stop does. - A failing custom-first publish no longer leaves the file pending with no hold task; a superseded hold task never publishes. - Only hold files in the opened set, since jdtls publishes for other files are gated out and could never release the hold. - Tests: long deadlines in the wiring fixture with polling instead of fixed sleeps, autouse isolation of hold state, and cases for custom-first timeout, cross-file holds, save then release, late correction, didOpen while pending, re-initialize and encoded URIs. The e2e test now judges only post-edit publishes after jdtls goes quiet (it previously passed on pre-edit state). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Guard the superseded-hold-task race (its cleanup no longer removes the live task's event or pending state) and pin it with a test; make the close test wait past a short deadline, drop the last wall-clock upper bound in the timeout test, and let the e2e readiness wait see a publish that landed while the files were opening. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Judge freshness by the file's own last edit: another file's change no longer pushes a fresh publish into the timeout path. The deadline still follows the last change to any file; the ceiling now counts from the file's last edit. - JAVA_FUNCTIONAL_LSP_LOG_LEVEL applies only to this package's loggers (root DEBUG also enabled pygls payload and jdtls stderr logging); README wording corrected. Exception messages with paths are logged as type names. - didOpen while a file waits for jdtls publishes without the stale jdtls set; didClose drops the file's hold event; on_stopped fires once per jdtls death. - Cache _normalize_uri and the per-file module lookup (per-publish and per-keystroke costs on large workspaces); hash diagnostics only when needed. - Typed hold outcomes, constructor timing knobs, a clearer late-correction path, bounded/escaped dropped-request method names, jdtls source permalink. - New real-jdtls e2e through the server with default constants: fixing a missing import never re-publishes the resolved error with the hold, and does with DIAG_HOLD=off. No-didSave cross-file measurement is now opt-in; global pytest timeout. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the stale-diagnostics lag from #109 (Part A of the design).
Problem
After an edit the wrapper republished jdtls's diagnostics from the previous version: 150ms after didChange, and immediately on didSave. jdtls needs 0.4-2.4s to re-validate (one debounced validation job shared by all files, reset by any didChange) and its publishes carry no document version. Claude Code attaches diagnostics right after the edit, so the agent saw the old compile errors ("X cannot be resolved", old constructor arity) as current. Evidence: the local wrapper log shows 19 of 23 edit-triggered publishes followed by a jdtls correction on the same file; Claude Code transcripts show diagnostics attached after the PostToolUse hooks, within ~40ms of the tool result.
Change
custom-firstfor Claude Code (custom diagnostics publish at once without the stale jdtls set, full set when jdtls is fresh),hold-allfor other editors (no flicker),offviaJAVA_FUNCTIONAL_LSP_DIAG_HOLD=offfor the old behavior.java.diagnostic.filter, files outside the opened set, jdtls unavailable/starting/skipped.JAVA_FUNCTIONAL_LSP_LOG_LEVEL, ajdtls freshness:summary line (released / too_early / timeout / late_correction / ineligible), jdtls version at startup, a log line per dropped jdtls-to-client request method. Two log lines no longer print full paths.Cross-file variant (Part B, in #112)
New e2e test with a real jdtls and a two-file Maven project (Foo gains a ctor parameter, Caller updated, both written to disk):
So the follow-up is to make sure jdtls sees a didSave after agent edits, not the dependent-revalidation nudge from the design.
Testing
uv run pytest: 804 passed, 1 skipped (opt-in measurement), including jdtls e2e locally (jdtls 1.61.0 via Homebrew).tests/test_e2e_hold.py): fixing a missing import never re-publishes "Bar cannot be resolved" with the hold, and does withJAVA_FUNCTIONAL_LSP_DIAG_HOLD=off, so the Stale diagnostics lag behind edits (imports/signature changes report false errors until recompile) #109 symptom is reproduced and fixed end to end.Follow-up
#112 (stacked on this PR) gets the fresh result into the edit's own tool result via the plugin hook and fixes the cross-file variant with a didSave.
Before merge
Run the missing-import and signature-change repros in Claude Code on a large Maven repo with
JAVA_FUNCTIONAL_LSP_DIAG_HOLD=custom-firstvsoffandJAVA_FUNCTIONAL_LSP_LOG_LEVEL=DEBUG, and check that no attachment after the fixing edit carries the resolved error.Trade-off
In
hold-all(IDEs) custom diagnostics after typing now appear when jdtls answers (~0.5-2s, max 10s) instead of 150ms.Refs #109
🤖 Generated with Claude Code