Notify when LikeC4 language server is missing and offer npm install#63
Conversation
📝 WalkthroughWalkthroughAdds 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
Sequence DiagramsequenceDiagram
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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/.likec4files 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:
- Mentions the need to reopen files, or
- Provides an action to restart the LSP for open files.
* 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>
Qodana Community for JVM3 new problems were found
💡 Qodana analysis was run in the pull request mode: only the changed files were checked View the detailed Qodana reportTo be able to view the detailed Qodana report, you can either:
To get - name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2025.2.3
with:
upload-result: trueContact Qodana teamContact us at qodana-support@jetbrains.com
|
Motivation
likec4-language-serveris onPATHand attempted to start LSP unconditionally, which yields unclear failures when the server is not installed.Description
LikeC4LanguageServerInstallerwhich detects thelikec4-language-serverexecutable usingPathEnvironmentVariableUtiland exposesensureAvailable(project: Project): Booleanto gate startup.LikeC4notificationGroupinplugin.xml) when the server is missing with actions toInstall with npm(prompts confirmation then runsnpm install -g @likec4/language-serveron a pooled thread) andCopy install command(copiesnpm install -g @likec4/language-serverto clipboard).LikeC4LspServerSupportProviderto callLikeC4LanguageServerInstaller.ensureAvailable(project)before callingserverStarter.ensureServerStarted(...), preventing LSP startup until the server is available.Testing
Codex Task
Summary by CodeRabbit
New Features
Chores