Skip to content

Commit c37ef91

Browse files
committed
feat(terminal): improve shell command suggestion output formatting and add support for line commands
This commit enhances the shell command suggestion feature by introducing a more concise output format and adding support for line commands, improving the user experience and functionality of the terminal extension.
1 parent 35bed12 commit c37ef91

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/ShellCommandSuggestionAction.kt renamed to exts/ext-terminal/src/main/kotlin/cc/unitmesh/terminal/ShellCommandSuggestAction.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ private const val OUTLINE_PROPERTY = "JComponent.outline"
3939
private const val ERROR_VALUE = "error"
4040

4141

42-
class ShellCommandSuggestionAction : AnAction() {
42+
class ShellCommandSuggestAction : AnAction() {
4343
override fun actionPerformed(e: AnActionEvent) {
4444
val project = e.project ?: return
4545

@@ -69,7 +69,11 @@ class ShellCommandSuggestionAction : AnAction() {
6969

7070
try {
7171
stringFlow.collect {
72-
widget.writePlainMessage(it)
72+
if (it.contains("\n")) {
73+
throw Exception("Shell command suggestion failed")
74+
}
75+
76+
widget.terminalStarter?.sendString(it, true)
7377
}
7478
} finally {
7579
AutoDevStatusService.notifyApplication(AutoDevStatus.Ready)

exts/ext-terminal/src/main/resources/cc.unitmesh.terminal.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<actions>
88
<action id="ShellSuggestionAction"
9-
class="cc.unitmesh.terminal.ShellCommandSuggestionAction"
9+
class="cc.unitmesh.terminal.ShellCommandSuggestAction"
1010
description="Suggestions for shell commands"
1111
text="Shell Command Suggestions"
1212
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT">

src/main/resources/genius/en/practises/shell-suggest.vm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ will be passed to subprocess.check_output() directly.
44

55
For example, if the user asks: undo last git commit
66

7-
You return only: git reset --soft HEAD~1
7+
You return only line command: git reset --soft HEAD~1
88

99
User asks: ${context.question}

src/main/resources/genius/zh/practises/shell-suggest.vm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ will be passed to subprocess.check_output() directly.
44

55
For example, if the user asks: undo last git commit
66

7-
You return only: git reset --soft HEAD~1
7+
You return only line command: git reset --soft HEAD~1
88

99
User asks: ${context.question}

0 commit comments

Comments
 (0)