Skip to content

feat: show pending idle stops in LSP consoles - #2359

Open
sohamsakhare76-ai wants to merge 2 commits into
redhat-developer:mainfrom
sohamsakhare76-ai:feat/2025-pending-stop-display
Open

sohamsakhare76-ai wants to merge 2 commits into
redhat-developer:mainfrom
sohamsakhare76-ai:feat/2025-pending-stop-display

Conversation

@sohamsakhare76-ai

Copy link
Copy Markdown
Contributor

Closes #2025

Summary

Implements Option E for pending idle stops in the LSP Consoles tree.

When the last document closes and a stop is scheduled, the tree displays information such as:

idle, stops after 10 h at 20:15

The server remains in ServerStatus.started while the pending stop is active.

Implementation

  • Track the scheduled stop instant in LanguageServerWrapper.
  • Notify lifecycle listeners when pending-stop state changes.
  • Display the configured timeout and local stop time in the server and process tree nodes.
  • Add tooltip details explaining lastDocumentDisconnectedTimeout.
  • Handle document reconnects, keep-alive leases, reconnecting servers, and multiple instances.
  • Schedule long timeouts in safe chunks and prevent callbacks from stopping the server early.
  • Avoid countdowns and continuously running repaint timers.

Tests

  • compileTestJava — successful.
  • KeepAliveDuringPendingStopTest — 25 passed.
  • Focused console explorer and wrapper tests — 96 passed.
  • Broader affected tests — 170 passed.
  • git diff --check — passed.

The read-only information-panel redesign from #1953 is intentionally outside this PR's scope.

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • New Features
    • The language server explorer now displays when an idle language server is scheduled to stop, including the expected stop time and timeout. Tooltips provide additional details for individual instances when their schedules differ. The displayed information updates as stop schedules change.
  • Bug Fixes
    • Idle-stop timers now update reliably when cancelled or rescheduled. Servers remain available when documents reconnect or the server restarts during a pending stop, and longer timeouts are handled without stopping servers early.

The wrapper now tracks pending idle-stop deadlines and reports changes through lifecycle listeners. The language-server tree displays pending-stop times and timeout details for process nodes and aggregates information across server instances.

Changes: Pending idle-stop state and display

Layer / File(s) Summary
Track deadlines and notify lifecycle listeners
src/main/java/com/redhat/devtools/lsp4ij/LanguageServerWrapper.java, src/main/java/com/redhat/devtools/lsp4ij/lifecycle/*, src/test/java/com/redhat/devtools/lsp4ij/KeepAliveDuringPendingStopTest.java
The wrapper records and clears pending-stop deadlines, splits long delays into alarm-sized chunks, and ignores stale callbacks. Lifecycle listeners receive deadline changes. Tests cover timer replacement, expiration, reconnection, and deterministic clock behavior.
Refresh and display process pending stops
src/main/java/com/redhat/devtools/lsp4ij/console/explorer/LanguageServerExplorerLifecycleListener.java, src/main/java/com/redhat/devtools/lsp4ij/console/explorer/LanguageServerProcessTreeNode.java, src/main/java/com/redhat/devtools/lsp4ij/console/explorer/LanguageServerTreeRenderer.java, src/test/java/com/redhat/devtools/lsp4ij/console/LanguageServerProcessNodesTest.java, src/test/java/com/redhat/devtools/lsp4ij/console/explorer/LanguageServerProcessTreeNodeTest.java, src/test/java/com/redhat/devtools/lsp4ij/console/explorer/LanguageServerTreeRendererTest.java
The explorer refreshes process nodes when pending-stop state changes. Process and language-server nodes show the formatted stop time and timeout in tree text and tooltips. Tests cover rendering, tooltip clearing, and tree refresh events.
Aggregate pending stops across instances
src/main/java/com/redhat/devtools/lsp4ij/console/explorer/LanguageServerTreeNode.java, src/test/java/com/redhat/devtools/lsp4ij/console/explorer/LanguageServerProcessTreeNodeTest.java
The language-server tree shows one shared pending-stop entry when instance states and deadlines match. Otherwise, it lists pending entries separately. Tests cover mixed states and differing stop times.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

sequenceDiagram
  participant LanguageServerWrapper
  participant LanguageServerLifecycleManager
  participant LanguageServerExplorerLifecycleListener
  participant LanguageServerProcessTreeNode
  participant LanguageServerTreeRenderer
  LanguageServerWrapper->>LanguageServerLifecycleManager: Notify pending-stop change
  LanguageServerLifecycleManager->>LanguageServerExplorerLifecycleListener: Call handlePendingStopChanged
  LanguageServerExplorerLifecycleListener->>LanguageServerProcessTreeNode: Refresh process node on UI thread
  LanguageServerTreeRenderer->>LanguageServerProcessTreeNode: Read pending-stop text for rendering
Loading

Suggested reviewers: lagergren

Merge Risk: Minimal · up to f7a40

The change adds display of the scheduled idle-stop time in the language server tree and keeps the server status as started. No concrete merge-blocking risk was found, and the tests described cover the main timing and reconnection cases.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title 'feat: show pending idle stops in LSP consoles' names the main change. The changeset adds pending idle-stop tracking in LanguageServerWrapper and displays pending-stop text and tooltips in t…
Description check Passed The description explains the feature: showing pending idle stops in the LSP Consoles tree with timeout and local stop time. It lists the implementation points (wrapper tracking, lifecycle notification…
Linked Issues check Passed Issue #2025 asks for the LSP Consoles tree to show a pending idle stop while the server keeps status started. It favors Option E, which shows the timeout and the local stop time, with no repaint timer…
Out of Scope Changes check Passed Each changed area relates to the pending idle-stop display for #2025:

- LanguageServerWrapper: deadline tracking, chunked scheduling, stale-callback invalidation, change notification, and the test-on…
Full details: Title check

Explanation

The title 'feat: show pending idle stops in LSP consoles' names the main change. The changeset adds pending idle-stop tracking in LanguageServerWrapper and displays pending-stop text and tooltips in the LSP Consoles tree nodes. The title is short, specific, and matches the primary feature.

Full details: Description check

Explanation

The description explains the feature: showing pending idle stops in the LSP Consoles tree with timeout and local stop time. It lists the implementation points (wrapper tracking, lifecycle notifications, tree node display, tooltips, long-timeout chunking) and the test results. These match the raw summary of changed files.

Full details: Linked Issues check

Explanation

Issue #2025 asks for the LSP Consoles tree to show a pending idle stop while the server keeps status started. It favors Option E, which shows the timeout and the local stop time, with no repaint timer, and a tooltip that names lastDocumentDisconnectedTimeout. The whole-PR summary (merge base d1d8df5 to head f7a4006) supports each point:

  • Stop time tracking [#2025]: LanguageServerWrapper records the stop deadline (getPendingStopAt) using an injectable Clock. It clears the deadline when a document reconnects or the timer is removed. Changes notify listeners through LanguageServerLifecycleManager.onPendingStopChanged and LanguageServerLifecycleListener.handlePendingStopChanged.
  • Option E display [#2025]: LanguageServerProcessTreeNode.getPendingStopText and LanguageServerTreeNode.getPendingStopText return text of the form 'idle, stops after <timeout> at <HH:mm>'. LanguageServerTreeRenderer draws it in grey beside server and process nodes. Renderer and node tests cover the text.
  • Tooltip [#2025]: the tooltip explains the timeout and names lastDocumentDisconnectedTimeout.
  • No new status [#2025]: no ServerStatus value is added. The server stays in started.
  • No repaint timer [#2025]: the text is static. Listeners are notified only on pending-state changes.
  • Keep-alive and zero timeout [#2025]: KeepAliveDuringPendingStopTest covers a delayed stop that comes due while a client keeps the server alive, and the pending time is cleared. A nonpositive timeout stops immediately, and no pending text is shown.
  • Long timeouts, reconnects, and restarts [#2025]: chunked scheduling above Integer.MAX_VALUE milliseconds, stale-callback invalidation, and reconnect or restart cases are covered by tests.

No unmet coding requirement is evident. The evidence is the AI-generated change summary and test descriptions. I did not read the source or run the tests in this assessment. The rendered text and tooltip wording are not checked against source directly.

Full details: Out of Scope Changes check

Explanation

Each changed area relates to the pending idle-stop display for #2025:

  • LanguageServerWrapper: deadline tracking, chunked scheduling, stale-callback invalidation, change notification, and the test-only setClock. These implement the stop-time requirement and its tests.
  • Lifecycle listener and manager: the handlePendingStopChanged callback and onPendingStopChanged. These carry change notifications to the tree.
  • Explorer lifecycle listener, nodes, and renderer: pending-stop text, tooltip, and the refresh handler. These implement the display requirement.
  • Tests (KeepAliveDuringPendingStopTest, LanguageServerProcessNodesTest, LanguageServerProcessTreeNodeTest, LanguageServerTreeRendererTest): they cover the new behavior.

The PR description excludes the #1953 information-panel redesign. The summary shows no panel changes. The new public getPendingStopAt and getClockZone methods serve the tree display. The aggregated tooltip logic in LanguageServerTreeNode is more complex than a single-instance display, but it still serves the same pending-stop display. No unrelated change is evident.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 16ac6486-597e-4d63-a820-1128a4c985bc
Commits

Reviewing files that changed from the base of the PR and between c40ea0c and f7a4006.

Files selected for processing: 1

  • src/test/java/com/redhat/devtools/lsp4ij/KeepAliveDuringPendingStopTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.08333% with 44 lines in your changes missing coverage. Please review.
✅ Project coverage is 58.95%. Comparing base (d1d8df5) to head (f7a4006).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../redhat/devtools/lsp4ij/LanguageServerWrapper.java 78.75% 9 Missing and 8 partials ⚠️
...lorer/LanguageServerExplorerLifecycleListener.java 30.76% 5 Missing and 4 partials ⚠️
...sp4ij/console/explorer/LanguageServerTreeNode.java 83.92% 3 Missing and 6 partials ⚠️
...p4ij/lifecycle/LanguageServerLifecycleManager.java 22.22% 6 Missing and 1 partial ⚠️
...onsole/explorer/LanguageServerProcessTreeNode.java 89.47% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2359      +/-   ##
==========================================
+ Coverage   58.86%   58.95%   +0.08%     
==========================================
  Files         849      849              
  Lines       36719    36899     +180     
  Branches     5767     5811      +44     
==========================================
+ Hits        21614    21752     +138     
- Misses      12102    12128      +26     
- Partials     3003     3019      +16     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren lagergren added this to the 0.30.3 milestone Nov 30, 2026
@lagergren lagergren added enhancement New feature or request lsp-console labels Nov 30, 2026

@lagergren lagergren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thank you for picking up #2025, @sohamsakhare76-ai, and for Option E, as the issue suggested: no repaint timer, and the text answers "will it stop, when, and why that late". The generation counter against stale alarm callbacks, the injectable clock in the tests instead of sleeps, and the chunks for timeouts that don't fit in an int of milliseconds are all nice touches.

I ran the four changed test classes five times each with --rerun, on IC 2024.2 and on IC 2025.3, where testAScheduledStopThatFiresWhileReconnectingClearsPendingStopAndDefersIdleStop failed in the first CI run: 83 tests each time, 0 failures. So f7a4006 looks like it fixed that race.

A few things:

  1. The time of the stop has no day, and ignores the IDE's time format. HH:mm is always 24-hour, whatever Settings | Appearance & Behavior | System Settings | Date Formats says. It also shows no date: Liberty's 10 hours from 20:15 show at 06:15, which is tomorrow, and a timeout of more than a day shows a time on the wrong day. Your test with two stops a day apart and the same 20:15 shows that the day matters. DateFormatUtil.formatTime(long) for a stop today, and DateFormatUtil.formatDateTime(long) otherwise, would follow the IDE's format and show the date when it's another day. Both are in 2024.2.

  2. The fix for long timeouts deserves a commit of its own. Before this PR, (int) TimeUnit.SECONDS.toMillis(...) overflowed for a lastDocumentDisconnectedTimeout above 2,147,483 seconds (about 24.8 days), and such a server stopped at once. Your chunks fix that, which is a behaviour change of its own. Could it go into a fix: commit, before the feat: one, so that the release notes name it? The PR would then be rebase-merged.

  3. A server that something keeps alive (LSPClientFeatures#keepServerAlive(), or a lease): the tree shows a stop time, and at that time nothing stops, the text just goes away. #2025 left this case open, and it's fine with me for now. The tooltip could say that the stop doesn't happen if something keeps the server running. What do you think?

  4. (optional) When a server node is expanded, its process node shows the same text right below it. #2025 suggested that the server node shows it while collapsed; customizeCellRenderer gets expanded.

The PR is on the 0.30.3 milestone, which opens once 0.30.2 is released this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request lsp-console

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LSP Consoles: show when a language server without files will stop

2 participants