-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Jetbrains - Fix Webview Assets #4222
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jetbrains - Fix Webview Assets #4222
Conversation
🦋 Changeset detectedLatest commit: 7979c5f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes critical webview asset loading issues in the JetBrains plugin by addressing mismatched asset file names and improving path resolution logic.
Key changes:
- Adds a custom Vite plugin (
cssPerEntryPlugin) to generate predictable CSS file names per entry point - Updates asset name references from
index.css/jstomain.css/jsin the WebView manager - Enhances the resource handler with improved path resolution, alternative path fallback, and additional source map MIME types
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
webview-ui/vite.config.ts |
Integrates cssPerEntryPlugin and enables CSS code splitting to generate separate CSS files per entry point |
webview-ui/src/kilocode/vite-plugins/cssPerEntryPlugin.ts |
New custom Vite plugin that merges CSS files per entry point with predictable naming (e.g., main.css) |
jetbrains/plugin/src/main/kotlin/ai/kilocode/jetbrains/webview/WebViewManager.kt |
Replaces index.css/js references with main.css/js to match build output; improves logging granularity |
jetbrains/plugin/src/main/kotlin/ai/kilocode/jetbrains/webview/LocalResHandler.kt |
Enhances path resolution with URL decoding, alternative path fallback, and adds source map MIME types |
.changeset/cool-cycles-jog.md |
Documents the fix for the JetBrains webview in the changeset |
jetbrains/plugin/src/main/kotlin/ai/kilocode/jetbrains/webview/LocalResHandler.kt
Show resolved
Hide resolved
jetbrains/plugin/src/main/kotlin/ai/kilocode/jetbrains/webview/LocalResHandler.kt
Outdated
Show resolved
Hide resolved
jetbrains/plugin/src/main/kotlin/ai/kilocode/jetbrains/webview/LocalResHandler.kt
Outdated
Show resolved
Hide resolved
jetbrains/plugin/src/main/kotlin/ai/kilocode/jetbrains/webview/WebViewManager.kt
Show resolved
Hide resolved
jetbrains/plugin/src/main/kotlin/ai/kilocode/jetbrains/webview/LocalResHandler.kt
Show resolved
Hide resolved
| file = File(filePath) | ||
|
|
||
| // If file doesn't exist, try alternative paths | ||
| if (!file!!.exists()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to throw here if no file exists? Would we not want to have file?.exists() ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I’ve just refactored this logic, so this block is no longer relevant.
Just as a note on the syntax: we couldn't use file?.exists() there because it returns a nullable Boolean, which causes a compilation error inside a standard if statement.
Context
The JetBrains plugin was experiencing issues loading webview assets due to:
Implementation
This commit fixes critical issues with asset loading in the JetBrains plugin's webview implementation, ensuring that CSS, JavaScript, and other static assets are properly served and loaded.
1. Enhanced Resource Handler (
LocalResHandler.kt)webview-ui/build/directory when assets aren't found in the primary location2. WebView Manager Improvements (
WebViewManager.kt)index.css/index.jswithmain.css/main.jsto match actual build output3. Custom Vite Plugin (
cssPerEntryPlugin.ts)main.css)4. Vite Configuration Updates (
vite.config.ts)cssCodeSplit: trueto generate separate CSS filescssPerEntryPlugin()to the plugin chainScreenshots
How to Test