summaryrefslogtreecommitdiff
path: root/tui.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2026-01-14 09:42:11 +0300
committerGrail Finder <wohilas@gmail.com>2026-01-14 09:42:11 +0300
commite120a629397a8c594497bd61b8b1d9e5c0babf78 (patch)
treea55b414b70721494a8bc465985d035e53ded30e8 /tui.go
parent93de9f7bd9cdf52c1835ccb181d9f68ec619a11d (diff)
Feat: shellmode to chat history
Diffstat (limited to 'tui.go')
-rw-r--r--tui.go25
1 files changed, 21 insertions, 4 deletions
diff --git a/tui.go b/tui.go
index 72d456f..a7570cf 100644
--- a/tui.go
+++ b/tui.go
@@ -221,20 +221,37 @@ func executeCommandAndDisplay(cmdText string) {
output, err := cmd.CombinedOutput()
// Add the command being executed to the chat
fmt.Fprintf(textView, "\n[yellow]$ %s[-:-:-]\n", cmdText)
+ var outputContent string
if err != nil {
// Include both output and error
- fmt.Fprintf(textView, "[red]Error: %s[-:-:-]\n", err.Error())
+ errorMsg := "Error: " + err.Error()
+ fmt.Fprintf(textView, "[red]%s[-:-:-]\n", errorMsg)
if len(output) > 0 {
- fmt.Fprintf(textView, "[red]%s[-:-:-]\n", string(output))
+ outputStr := string(output)
+ fmt.Fprintf(textView, "[red]%s[-:-:-]\n", outputStr)
+ outputContent = errorMsg + "\n" + outputStr
+ } else {
+ outputContent = errorMsg
}
} else {
// Only output if successful
if len(output) > 0 {
- fmt.Fprintf(textView, "[green]%s[-:-:-]\n", string(output))
+ outputStr := string(output)
+ fmt.Fprintf(textView, "[green]%s[-:-:-]\n", outputStr)
+ outputContent = outputStr
} else {
- fmt.Fprintf(textView, "[green]Command executed successfully (no output)[-:-:-]\n")
+ successMsg := "Command executed successfully (no output)"
+ fmt.Fprintf(textView, "[green]%s[-:-:-]\n", successMsg)
+ outputContent = successMsg
}
}
+ // Combine command and output in a single message for chat history
+ combinedContent := "$ " + cmdText + "\n\n" + outputContent
+ combinedMsg := models.RoleMsg{
+ Role: cfg.ToolRole,
+ Content: combinedContent,
+ }
+ chatBody.Messages = append(chatBody.Messages, combinedMsg)
// Scroll to end and update colors
if scrollToEndEnabled {
textView.ScrollToEnd()