Skip to content

Commit 3ae68c2

Browse files
committed
refactor(renderer): remove IdeaNanoDSLBubble and update renderers
Deleted unused IdeaNanoDSLBubble and refactored related renderer components for improved code organization and maintainability.
1 parent a8c6b7c commit 3ae68c2

File tree

15 files changed

+10
-562
lines changed

15 files changed

+10
-562
lines changed

mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/render/CodingAgentRenderer.kt

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -128,23 +128,4 @@ interface CodingAgentRenderer {
128128
// Default: return error for renderers that don't support async sessions
129129
return ToolResult.Error("Async session not supported by this renderer")
130130
}
131-
132-
/**
133-
* Render generated NanoDSL UI code.
134-
* Called when NanoDSLAgent generates UI code.
135-
*
136-
* JVM platforms (Compose, Jewel) can render a live UI preview using NanoIR.
137-
* Non-JVM platforms (CLI, VSCode) show the source code with syntax highlighting.
138-
*
139-
* @param source The generated NanoDSL source code
140-
* @param irJson Optional IR JSON for rendering (available on JVM platforms)
141-
* @param metadata Additional metadata (componentName, attempts, isValid, etc.)
142-
*/
143-
fun renderNanoDSL(
144-
source: String,
145-
irJson: String? = null,
146-
metadata: Map<String, String> = emptyMap()
147-
) {
148-
// Default: no-op for renderers that don't support NanoDSL rendering
149-
}
150131
}

mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/render/RendererModels.kt

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -190,36 +190,6 @@ sealed class TimelineItem(
190190
fun isSuccess(): Boolean = exitCode == 0
191191
}
192192

193-
/**
194-
* NanoDSL generated UI item - displays generated NanoDSL code with optional live preview.
195-
*
196-
* On JVM platforms with xuiper-ui available, the irJson can be used to render
197-
* a live UI preview using NanoRenderer.
198-
*
199-
* On non-JVM platforms or when irJson is null, shows the source code only.
200-
*/
201-
data class NanoDSLItem(
202-
/** The generated NanoDSL source code */
203-
val source: String,
204-
/** Optional IR JSON for rendering (JVM platforms only) */
205-
val irJson: String? = null,
206-
/** Component name extracted from source */
207-
val componentName: String? = null,
208-
/** Number of generation attempts (1 = first try succeeded) */
209-
val generationAttempts: Int = 1,
210-
/** Whether the generated code passed validation */
211-
val isValid: Boolean = true,
212-
/** Validation warnings (if any) */
213-
val warnings: List<String> = emptyList(),
214-
override val timestamp: Long = Platform.getCurrentTimestamp(),
215-
override val id: String = generateId()
216-
) : TimelineItem(timestamp, id) {
217-
/**
218-
* Check if live preview is available (requires IR JSON)
219-
*/
220-
fun hasLivePreview(): Boolean = irJson != null
221-
}
222-
223193
companion object {
224194
/**
225195
* Thread-safe counter for generating unique IDs.

mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/subagent/NanoDSLAgent.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ data class NanoDSLContext(
374374
* Schema for NanoDSL Agent tool
375375
*/
376376
object NanoDSLAgentSchema : DeclarativeToolSchema(
377-
description = "Generate NanoDSL UI code from natural language description",
377+
description = "Generate NanoDSL UI code from natural language description, will return nano DSL code for you, you can" +
378+
"directly show code to the User with nano as language",
378379
properties = mapOf(
379380
"description" to string(
380381
description = "Natural language description of the UI to generate",

mpp-core/src/jsMain/kotlin/cc/unitmesh/agent/RendererExports.kt

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,6 @@ data class JsPlanSummaryData(
8484
}
8585
}
8686

87-
/**
88-
* JS-friendly NanoDSL rendering data
89-
*/
90-
@JsExport
91-
data class JsNanoDSLData(
92-
val source: String,
93-
val irJson: String?,
94-
val componentName: String?,
95-
val generationAttempts: Int,
96-
val isValid: Boolean,
97-
val warnings: Array<String>
98-
)
99-
10087
/**
10188
* JS-friendly renderer interface
10289
* Allows TypeScript to provide custom rendering implementations
@@ -125,9 +112,6 @@ interface JsCodingAgentRenderer {
125112

126113
// Plan summary bar (optional - default no-op in BaseRenderer)
127114
fun renderPlanSummary(summary: JsPlanSummaryData) {}
128-
129-
// NanoDSL rendering (optional - default no-op in BaseRenderer)
130-
fun renderNanoDSL(data: JsNanoDSLData) {}
131115
}
132116

133117
/**
@@ -199,17 +183,5 @@ class JsRendererAdapter(private val jsRenderer: JsCodingAgentRenderer) : CodingA
199183
override fun renderPlanSummary(summary: PlanSummaryData) {
200184
jsRenderer.renderPlanSummary(JsPlanSummaryData.from(summary))
201185
}
202-
203-
override fun renderNanoDSL(source: String, irJson: String?, metadata: Map<String, String>) {
204-
val data = JsNanoDSLData(
205-
source = source,
206-
irJson = irJson,
207-
componentName = metadata["componentName"],
208-
generationAttempts = metadata["attempts"]?.toIntOrNull() ?: 1,
209-
isValid = metadata["isValid"]?.toBoolean() ?: true,
210-
warnings = metadata["warnings"]?.split(";")?.toTypedArray() ?: emptyArray()
211-
)
212-
jsRenderer.renderNanoDSL(data)
213-
}
214186
}
215187

mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaNanoDSLBubble.kt

Lines changed: 0 additions & 163 deletions
This file was deleted.

mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/components/timeline/IdeaTimelineContent.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,6 @@ fun IdeaTimelineItemView(
8686
onCancel = onProcessCancel
8787
)
8888
}
89-
is TimelineItem.NanoDSLItem -> {
90-
IdeaNanoDSLBubble(item, project)
91-
}
9289
}
9390
}
9491

mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/renderer/JewelRenderer.kt

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -536,35 +536,6 @@ class JewelRenderer : BaseRenderer() {
536536
)
537537
}
538538

539-
/**
540-
* Render generated NanoDSL UI code.
541-
* On IntelliJ, this adds a NanoDSLItem to the timeline with optional live preview.
542-
*/
543-
override fun renderNanoDSL(
544-
source: String,
545-
irJson: String?,
546-
metadata: Map<String, String>
547-
) {
548-
// Extract component name from source if not in metadata
549-
val componentName = metadata["componentName"]
550-
?: Regex("""component\s+(\w+):""").find(source)?.groupValues?.get(1)
551-
552-
val attempts = metadata["attempts"]?.toIntOrNull() ?: 1
553-
val isValid = metadata["isValid"]?.toBoolean() ?: true
554-
val warnings = metadata["warnings"]?.split(";")?.filter { it.isNotBlank() } ?: emptyList()
555-
556-
addTimelineItem(
557-
TimelineItem.NanoDSLItem(
558-
source = source,
559-
irJson = irJson,
560-
componentName = componentName,
561-
generationAttempts = attempts,
562-
isValid = isValid,
563-
warnings = warnings
564-
)
565-
)
566-
}
567-
568539
override fun updateTokenInfo(tokenInfo: TokenInfo) {
569540
_lastMessageTokenInfo = tokenInfo
570541
_totalTokenInfo.update { current ->

mpp-idea/src/main/kotlin/cc/unitmesh/devins/idea/toolwindow/knowledge/IdeaKnowledgeContent.kt

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -797,52 +797,6 @@ private fun ChatMessageItem(item: TimelineItem) {
797797
}
798798
}
799799
}
800-
801-
is TimelineItem.NanoDSLItem -> {
802-
// NanoDSL item display
803-
Box(
804-
modifier = Modifier
805-
.fillMaxWidth()
806-
.background(AutoDevColors.Energy.aiDim)
807-
.padding(8.dp)
808-
) {
809-
Column {
810-
Row(
811-
horizontalArrangement = Arrangement.spacedBy(6.dp),
812-
verticalAlignment = Alignment.CenterVertically
813-
) {
814-
Text(
815-
text = "🎨",
816-
style = JewelTheme.defaultTextStyle
817-
)
818-
Text(
819-
text = item.componentName ?: "Generated UI",
820-
style = JewelTheme.defaultTextStyle.copy(
821-
fontWeight = FontWeight.Bold,
822-
fontSize = 12.sp
823-
)
824-
)
825-
if (item.generationAttempts > 1) {
826-
Text(
827-
text = "(${item.generationAttempts} attempts)",
828-
style = JewelTheme.defaultTextStyle.copy(
829-
color = AutoDevColors.Neutral.c400,
830-
fontSize = 11.sp
831-
)
832-
)
833-
}
834-
}
835-
Spacer(modifier = Modifier.height(4.dp))
836-
Text(
837-
text = item.source.take(300) + if (item.source.length > 300) "..." else "",
838-
style = JewelTheme.defaultTextStyle.copy(
839-
fontSize = 11.sp,
840-
fontFamily = androidx.compose.ui.text.font.FontFamily.Monospace
841-
)
842-
)
843-
}
844-
}
845-
}
846800
}
847801
}
848802

0 commit comments

Comments
 (0)