generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 480
feat(desktop): Integrate KCEF WebView with Background Download #505
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2f6bc06
feat(mpp-idea): add chart rendering support using Compose Canvas API
phodal 68b84cb
feat(desktop): integrate KCEF WebView with background download and coβ¦
phodal a07e2e8
feat(kcef): rename MermaidPreview to MermaidWebViewPreview and updateβ¦
phodal 52819e3
Merge branch 'master' into feat/kcef-webview-integration
phodal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -13,7 +13,11 @@ import androidx.compose.ui.text.font.FontWeight | |
| import androidx.compose.ui.unit.dp | ||
| import androidx.compose.ui.unit.sp | ||
| import cc.unitmesh.agent.render.TimelineItem | ||
| import cc.unitmesh.devins.idea.renderer.sketch.chart.IdeaChartRenderer | ||
| import cc.unitmesh.devins.idea.renderer.sketch.IdeaMermaidRenderer | ||
| import com.intellij.openapi.Disposable | ||
| import com.intellij.openapi.project.Project | ||
| import com.intellij.openapi.util.Disposer | ||
| import org.jetbrains.jewel.foundation.theme.JewelTheme | ||
| import org.jetbrains.jewel.ui.component.Text | ||
|
|
||
|
|
@@ -91,18 +95,21 @@ fun IdeaTimelineItemView( | |
| } | ||
| is TimelineItem.AgentSketchBlockItem -> { | ||
| // Agent-generated sketch block (chart, nanodsl, mermaid, etc.) | ||
| IdeaAgentSketchBlockBubble(item) | ||
| IdeaAgentSketchBlockBubble(item, project = project) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Agent-generated sketch block bubble (chart, nanodsl, mermaid, etc.) | ||
| * Uses appropriate renderer based on language type. | ||
| */ | ||
| @Composable | ||
| fun IdeaAgentSketchBlockBubble(item: TimelineItem.AgentSketchBlockItem) { | ||
| val lines = item.code.lines() | ||
|
|
||
| fun IdeaAgentSketchBlockBubble( | ||
| item: TimelineItem.AgentSketchBlockItem, | ||
| project: Project? = null, | ||
| parentDisposable: Disposable? = null | ||
| ) { | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
|
|
@@ -144,59 +151,89 @@ fun IdeaAgentSketchBlockBubble(item: TimelineItem.AgentSketchBlockItem) { | |
|
|
||
| Spacer(modifier = Modifier.height(8.dp)) | ||
|
|
||
| // Code content | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .background( | ||
| JewelTheme.globalColors.panelBackground, | ||
| shape = RoundedCornerShape(4.dp) | ||
| // Render content based on language type | ||
| when (item.language.lowercase()) { | ||
| "chart", "graph" -> { | ||
| IdeaChartRenderer( | ||
| chartCode = item.code, | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) | ||
| .padding(8.dp) | ||
| ) { | ||
| Column { | ||
| lines.take(20).forEachIndexed { index, line -> | ||
| Row( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| horizontalArrangement = Arrangement.spacedBy(8.dp) | ||
| ) { | ||
| Text( | ||
| text = "${index + 1}", | ||
| style = JewelTheme.defaultTextStyle.copy( | ||
| fontSize = 10.sp, | ||
| color = JewelTheme.globalColors.text.info.copy(alpha = 0.4f) | ||
| ), | ||
| modifier = Modifier.width(24.dp) | ||
| ) | ||
| Text( | ||
| text = line, | ||
| style = JewelTheme.defaultTextStyle.copy(fontSize = 11.sp) | ||
| ) | ||
| } | ||
| } | ||
| if (lines.size > 20) { | ||
| Text( | ||
| text = "... (${lines.size - 20} more lines)", | ||
| style = JewelTheme.defaultTextStyle.copy( | ||
| fontSize = 10.sp, | ||
| color = JewelTheme.globalColors.text.info.copy(alpha = 0.5f) | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
| "mermaid", "mmd" -> { | ||
| val disposable = parentDisposable ?: Disposer.newDisposable("AgentSketchBlock") | ||
| IdeaMermaidRenderer( | ||
| mermaidCode = item.code, | ||
| project = project, | ||
| isDarkTheme = true, | ||
| parentDisposable = disposable, | ||
| modifier = Modifier.fillMaxWidth() | ||
| ) | ||
| } | ||
|
Comment on lines
+162
to
+171
|
||
| else -> { | ||
| // Fallback: display raw code | ||
| RenderCodeFallback(item.code, item.language) | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Footer with line count | ||
| Spacer(modifier = Modifier.height(4.dp)) | ||
| Text( | ||
| text = "${lines.size} lines of ${item.language} code", | ||
| style = JewelTheme.defaultTextStyle.copy( | ||
| fontSize = 10.sp, | ||
| color = JewelTheme.globalColors.text.info.copy(alpha = 0.5f) | ||
| ) | ||
| /** | ||
| * Fallback renderer for code content when no specific renderer is available. | ||
| */ | ||
| @Composable | ||
| private fun RenderCodeFallback(code: String, language: String) { | ||
| val lines = code.lines() | ||
| Box( | ||
| modifier = Modifier | ||
| .fillMaxWidth() | ||
| .background( | ||
| JewelTheme.globalColors.panelBackground, | ||
| shape = RoundedCornerShape(4.dp) | ||
| ) | ||
| .padding(8.dp) | ||
| ) { | ||
| Column { | ||
| lines.take(20).forEachIndexed { index, line -> | ||
| Row( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| horizontalArrangement = Arrangement.spacedBy(8.dp) | ||
| ) { | ||
| Text( | ||
| text = "${index + 1}", | ||
| style = JewelTheme.defaultTextStyle.copy( | ||
| fontSize = 10.sp, | ||
| color = JewelTheme.globalColors.text.info.copy(alpha = 0.4f) | ||
| ), | ||
| modifier = Modifier.width(24.dp) | ||
| ) | ||
| Text( | ||
| text = line, | ||
| style = JewelTheme.defaultTextStyle.copy(fontSize = 11.sp) | ||
| ) | ||
| } | ||
| } | ||
| if (lines.size > 20) { | ||
| Text( | ||
| text = "... (${lines.size - 20} more lines)", | ||
| style = JewelTheme.defaultTextStyle.copy( | ||
| fontSize = 10.sp, | ||
| color = JewelTheme.globalColors.text.info.copy(alpha = 0.5f) | ||
| ) | ||
| ) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Footer with line count | ||
| Spacer(modifier = Modifier.height(4.dp)) | ||
| Text( | ||
| text = "${lines.size} lines of $language code", | ||
| style = JewelTheme.defaultTextStyle.copy( | ||
| fontSize = 10.sp, | ||
| color = JewelTheme.globalColors.text.info.copy(alpha = 0.5f) | ||
| ) | ||
| ) | ||
| } | ||
|
|
||
| /** | ||
|
|
||
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
81 changes: 81 additions & 0 deletions
81
mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/sketch/chart/IdeaChartData.kt
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| package cc.unitmesh.devins.idea.renderer.sketch.chart | ||
|
|
||
| /** | ||
| * Chart type enumeration | ||
| */ | ||
| enum class ChartType { | ||
| PIE, | ||
| LINE, | ||
| COLUMN, | ||
| ROW | ||
| } | ||
|
|
||
| /** | ||
| * Base chart configuration | ||
| */ | ||
| data class ChartConfig( | ||
| val type: ChartType, | ||
| val title: String? = null, | ||
| val width: Int? = null, | ||
| val height: Int? = null, | ||
| val data: ChartDataContent | ||
| ) | ||
|
|
||
| /** | ||
| * Chart data content - polymorphic based on chart type | ||
| */ | ||
| sealed class ChartDataContent { | ||
| data class PieData( | ||
| val items: List<PieItem>, | ||
| val style: PieStyle = PieStyle.FILL | ||
| ) : ChartDataContent() | ||
|
|
||
| data class LineData( | ||
| val lines: List<LineItem>, | ||
| val showDots: Boolean = true, | ||
| val curvedEdges: Boolean = true, | ||
| val minValue: Double? = null, | ||
| val maxValue: Double? = null | ||
| ) : ChartDataContent() | ||
|
|
||
| data class ColumnData( | ||
| val bars: List<BarGroup>, | ||
| val minValue: Double? = null, | ||
| val maxValue: Double? = null | ||
| ) : ChartDataContent() | ||
|
|
||
| data class RowData( | ||
| val bars: List<BarGroup>, | ||
| val minValue: Double? = null, | ||
| val maxValue: Double? = null | ||
| ) : ChartDataContent() | ||
| } | ||
|
|
||
| data class PieItem( | ||
| val label: String, | ||
| val value: Double, | ||
| val color: String? = null | ||
| ) | ||
|
|
||
| enum class PieStyle { | ||
| FILL, | ||
| STROKE | ||
| } | ||
|
|
||
| data class LineItem( | ||
| val label: String, | ||
| val values: List<Double>, | ||
| val color: String? = null | ||
| ) | ||
|
|
||
| data class BarGroup( | ||
| val label: String, | ||
| val values: List<BarValue> | ||
| ) | ||
|
|
||
| data class BarValue( | ||
| val label: String? = null, | ||
| val value: Double, | ||
| val color: String? = null | ||
| ) | ||
|
|
Oops, something went wrong.
Oops, something went wrong.
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.
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.
Resource leak: orphan Disposable is never disposed.
When
parentDisposableis null, a newDisposableis created but never registered for cleanup. This leaks resources on every recomposition. The disposable should be tied to the composable's lifecycle usingDisposableEffector require a non-nullparentDisposable."mermaid", "mmd" -> { - val disposable = parentDisposable ?: Disposer.newDisposable("AgentSketchBlock") + val disposable = parentDisposable + ?: return@Column // Skip rendering if no parent disposable available IdeaMermaidRenderer( mermaidCode = item.code, project = project, isDarkTheme = true, parentDisposable = disposable, modifier = Modifier.fillMaxWidth() ) }Alternatively, manage the disposable lifecycle properly:
π€ Prompt for AI Agents