Skip to content

Commit

Permalink
feat(terminal): improve shell command suggestion output formatting an…
Browse files Browse the repository at this point in the history
…d 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.
  • Loading branch information
phodal committed Apr 4, 2024
1 parent 35bed12 commit c37ef91
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 5 deletions.
Expand Up @@ -39,7 +39,7 @@ private const val OUTLINE_PROPERTY = "JComponent.outline"
private const val ERROR_VALUE = "error"


class ShellCommandSuggestionAction : AnAction() {
class ShellCommandSuggestAction : AnAction() {
override fun actionPerformed(e: AnActionEvent) {
val project = e.project ?: return

Expand Down Expand Up @@ -69,7 +69,11 @@ class ShellCommandSuggestionAction : AnAction() {

try {
stringFlow.collect {
widget.writePlainMessage(it)
if (it.contains("\n")) {
throw Exception("Shell command suggestion failed")
}

widget.terminalStarter?.sendString(it, true)
}
} finally {
AutoDevStatusService.notifyApplication(AutoDevStatus.Ready)
Expand Down
Expand Up @@ -6,7 +6,7 @@

<actions>
<action id="ShellSuggestionAction"
class="cc.unitmesh.terminal.ShellCommandSuggestionAction"
class="cc.unitmesh.terminal.ShellCommandSuggestAction"
description="Suggestions for shell commands"
text="Shell Command Suggestions"
icon="cc.unitmesh.devti.AutoDevIcons.AI_COPILOT">
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/genius/en/practises/shell-suggest.vm
Expand Up @@ -4,6 +4,6 @@ will be passed to subprocess.check_output() directly.

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

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

User asks: ${context.question}
2 changes: 1 addition & 1 deletion src/main/resources/genius/zh/practises/shell-suggest.vm
Expand Up @@ -4,6 +4,6 @@ will be passed to subprocess.check_output() directly.

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

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

User asks: ${context.question}

0 comments on commit c37ef91

Please sign in to comment.