Skip to content

Notify when LikeC4 language server is missing and offer npm install#63

Merged
davydkov merged 3 commits into
mainfrom
codex/enhance-plugin-to-check-likec4-language-server
Feb 5, 2026
Merged

Notify when LikeC4 language server is missing and offer npm install#63
davydkov merged 3 commits into
mainfrom
codex/enhance-plugin-to-check-likec4-language-server

Conversation

@davydkov

@davydkov davydkov commented Feb 5, 2026

Copy link
Copy Markdown
Member

Motivation

  • The plugin previously assumed likec4-language-server is on PATH and attempted to start LSP unconditionally, which yields unclear failures when the server is not installed.
  • Provide a clear user-facing warning and a convenient way to install the language server to improve UX and reduce support friction.

Description

  • Add LikeC4LanguageServerInstaller which detects the likec4-language-server executable using PathEnvironmentVariableUtil and exposes ensureAvailable(project: Project): Boolean to gate startup.
  • Show a balloon notification (registered a LikeC4 notificationGroup in plugin.xml) when the server is missing with actions to Install with npm (prompts confirmation then runs npm install -g @likec4/language-server on a pooled thread) and Copy install command (copies npm install -g @likec4/language-server to clipboard).
  • Update LikeC4LspServerSupportProvider to call LikeC4LanguageServerInstaller.ensureAvailable(project) before calling serverStarter.ensureServerStarted(...), preventing LSP startup until the server is available.

Testing

  • No automated tests were run for this change.

Codex Task

Summary by CodeRabbit

  • New Features

    • Verifies language server availability when opening supported files and prevents startup if missing.
    • If missing, shows a notification with "Install with npm" or "Copy install command"; installation runs in background and reports success or failure.
  • Chores

    • Added a dedicated notification group to plugin configuration for these messages.

@coderabbitai

coderabbitai Bot commented Feb 5, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Adds a LikeC4LanguageServerInstaller singleton that checks PATH for the LikeC4 language server, notifies users if missing with “Install with npm” or “Copy install command” actions, performs async npm installation, and gates LSP server startup on installer availability.

Changes

Cohort / File(s) Summary
Language Server Installer
src/main/kotlin/dev/likec4/jetbrainsplugin/lsp/LikeC4LanguageServerInstaller.kt
New Kotlin object LikeC4LanguageServerInstaller with ensureAvailable(project): Boolean. Checks PATH for executable, shows notification with two actions, runs npm install -g @likec4/language-server`` asynchronously via ExecUtil, and reports success/failure.
Server Integration
src/main/kotlin/dev/likec4/jetbrainsplugin/lsp/LikeC4LspServerSupportProvider.kt
Server startup call now conditional on LikeC4LanguageServerInstaller.ensureAvailable(project); skips starting the LSP if unavailable.
Plugin Configuration
src/main/resources/META-INF/plugin.xml
Adds a notificationGroup entry with id LikeC4 (displayType BALLOON, isLogByDefault="false") for installer notifications.

Sequence Diagram

sequenceDiagram
    participant IDE as IDE/Project
    participant Provider as LikeC4LspServerSupportProvider
    participant Installer as LikeC4LanguageServerInstaller
    participant PATH as System/PATH
    participant Notif as Notification System
    participant Exec as npm / ExecUtil

    IDE->>Provider: open file (supported ext)
    Provider->>Installer: ensureAvailable(project)
    Installer->>PATH: search for language-server executable

    alt found
        PATH-->>Installer: executable path
        Installer-->>Provider: return true
        Provider->>Provider: start LSP server
    else not found
        PATH-->>Installer: not found
        Installer->>Notif: show warning with actions (Install, Copy)
        Notif-->>IDE: display notification

        alt "Install with npm" chosen
            IDE->>Notif: confirm install
            Notif->>Installer: installLanguageServer()
            Installer->>Exec: run `npm install -g `@likec4/language-server`` (background)
            Exec-->>Installer: exit code / output
            Installer->>Notif: show success or failure notification
        else "Copy install command" chosen
            IDE->>Notif: copy action
            Notif->>IDE: copy command to clipboard
        end

        Installer-->>Provider: return false
        Provider->>Provider: skip LSP startup
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐇 I sniffed the PATH with eager nose,
Found no server where the green grass grows.
"npm or copy?" I twitched my ear,
I hop to install, or save the clear.
Async hops — the LSP soon appears!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding notification and npm install capability when the LikeC4 language server is missing.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/enhance-plugin-to-check-likec4-language-server

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In
`@src/main/kotlin/dev/likec4/jetbrainsplugin/lsp/LikeC4LanguageServerInstaller.kt`:
- Around line 65-93: installLanguageServer uses GeneralCommandLine("npm", ...)
which fails on Windows (CreateProcess error=193) because PATHEXT resolution
isn't applied; update the ExecUtil.execAndGetOutput call to invoke npm via
cmd.exe on Windows or set the command to use cmd.exe /c on Windows and preserve
existing behavior on other OSes (detect via SystemInfo.isWindows), and set
ParentEnvironmentType.CONSOLE when constructing GeneralCommandLine so npm.cmd is
found and executed correctly; change the call sites around
ExecUtil.execAndGetOutput and GeneralCommandLine in installLanguageServer
accordingly.
🧹 Nitpick comments (1)
src/main/kotlin/dev/likec4/jetbrainsplugin/lsp/LikeC4LspServerSupportProvider.kt (1)

15-17: Consider prompting user to reopen files after successful installation.

The gating logic is correct, but after successful installation via the notification action, users must close and reopen .c4/.likec4 files to trigger LSP startup. This could be confusing since the notification doesn't mention this step.

Consider adding a follow-up action in the success notification (in LikeC4LanguageServerInstaller.installLanguageServer) that either:

  1. Mentions the need to reopen files, or
  2. Provides an action to restart the LSP for open files.

davydkov and others added 2 commits February 5, 2026 11:51
* Initial plan

* Replace PathEnvironmentVariableUtil with standard JDK APIs

Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>

* Add Windows executable extension handling for better cross-platform support

Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: davydkov <824903+davydkov@users.noreply.github.com>
@github-actions

github-actions Bot commented Feb 5, 2026

Copy link
Copy Markdown
Contributor

Qodana Community for JVM

3 new problems were found

Inspection name Severity Problems
Call to 'System.getProperty(str)' could be simplified 🔶 Warning 1
Const property naming convention ◽️ Notice 2

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2025.2.3
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

@davydkov davydkov merged commit 31873b3 into main Feb 5, 2026
9 of 10 checks passed
@davydkov davydkov deleted the codex/enhance-plugin-to-check-likec4-language-server branch February 5, 2026 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants