Skip to content

Commit 80bec60

Browse files
committed
refactor(chat): simplify code and improve readability
- Remove redundant null check in `selectAgent` method. - Use direct property assignment for icons in `AutoDevInputSection`. - Clean up button initialization by removing unnecessary line breaks.
1 parent 1269b48 commit 80bec60

File tree

3 files changed

+5
-12
lines changed

3 files changed

+5
-12
lines changed

core/src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInput.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class AutoDevInput(
6464
object : AnAction() {
6565
override fun actionPerformed(actionEvent: AnActionEvent) {
6666
val editor = editor ?: return
67-
6867
// Insert a new line
6968
CommandProcessor.getInstance().executeCommand(project, {
7069
val eol = "\n"

core/src/main/kotlin/cc/unitmesh/devti/gui/chat/AutoDevInputSection.kt

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
8686

8787
init {
8888
val sendButtonPresentation = Presentation(AutoDevBundle.message("chat.panel.send"))
89-
sendButtonPresentation.setIcon(AutoDevIcons.Send)
89+
sendButtonPresentation.icon = AutoDevIcons.Send
9090
this.sendButtonPresentation = sendButtonPresentation
9191

9292
val stopButtonPresentation = Presentation("Stop")
93-
stopButtonPresentation.setIcon(AutoDevIcons.Stop)
93+
stopButtonPresentation.icon = AutoDevIcons.Stop
9494
this.stopButtonPresentation = stopButtonPresentation
9595

9696
sendButton = ActionButton(
@@ -101,9 +101,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
101101
}
102102
}.actionPerformed(it)
103103
},
104-
this.sendButtonPresentation,
105-
"",
106-
Dimension(20, 20)
104+
this.sendButtonPresentation, "", Dimension(20, 20)
107105
)
108106

109107
stopButton = ActionButton(
@@ -114,9 +112,7 @@ class AutoDevInputSection(private val project: Project, val disposable: Disposab
114112
}
115113
}.actionPerformed(it)
116114
},
117-
this.stopButtonPresentation,
118-
"",
119-
Dimension(20, 20)
115+
this.stopButtonPresentation, "", Dimension(20, 20)
120116
)
121117

122118
input = AutoDevInput(project, listOf(), disposable, this)

core/src/main/kotlin/cc/unitmesh/devti/gui/chat/ChatCodingPanel.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,7 @@ class ChatCodingPanel(private val chatCodingService: ChatCodingService, val disp
302302
}
303303

304304
fun selectAgent(config: CustomAgentConfig) {
305-
inputSection.let {
306-
it?.selectAgent(config)
307-
}
305+
inputSection.selectAgent(config)
308306
}
309307

310308
fun appendWebView(content: String, project: Project) {

0 commit comments

Comments
 (0)