fix: remove tab switching, filter AI thinking from responses
All checks were successful
CI / build (push) Successful in 1m44s
All checks were successful
CI / build (push) Successful in 1m44s
- Remove Tab/Shift+Tab for tab switching (use only Ctrl+T) - Tab key now inserts tab character in chat/terminal input - Filter <think...> blocks from AI responses (MiniMax etc.) - Filter << >> reasoning blocks from AI responses 💘 Generated with Crush Assisted-by: GLM-5.1 via Crush <crush@charm.land>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@@ -127,7 +128,7 @@ func (o *Orchestrator) Send(userMessage string) (string, error) {
|
|||||||
return "", fmt.Errorf("no response from AI")
|
return "", fmt.Errorf("no response from AI")
|
||||||
}
|
}
|
||||||
|
|
||||||
content := chatResp.Choices[0].Message.Content
|
content := cleanAIResponse(chatResp.Choices[0].Message.Content)
|
||||||
o.history = append(o.history, Message{
|
o.history = append(o.history, Message{
|
||||||
Role: "assistant",
|
Role: "assistant",
|
||||||
Content: content,
|
Content: content,
|
||||||
@@ -222,6 +223,31 @@ func (o *Orchestrator) ClearHistory() {
|
|||||||
o.Workflow.Reset()
|
o.Workflow.Reset()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func cleanAIResponse(content string) string {
|
||||||
|
thinkRe := regexp.MustCompile(`(?s)<[Tt]hink[^>]*>.*?</[Tt]hink>`)
|
||||||
|
content = thinkRe.ReplaceAllString(content, "")
|
||||||
|
lines := strings.Split(content, "\n")
|
||||||
|
var clean []string
|
||||||
|
inBlock := false
|
||||||
|
for _, line := range lines {
|
||||||
|
trimmed := strings.TrimSpace(line)
|
||||||
|
if trimmed == "<<" || trimmed == "<<<" {
|
||||||
|
inBlock = true
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if trimmed == ">>" || trimmed == ">>>" {
|
||||||
|
inBlock = false
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if inBlock {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
clean = append(clean, line)
|
||||||
|
}
|
||||||
|
result := strings.TrimSpace(strings.Join(clean, "\n"))
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
func getProviderBaseURL(name string) string {
|
func getProviderBaseURL(name string) string {
|
||||||
switch name {
|
switch name {
|
||||||
case "minimax":
|
case "minimax":
|
||||||
|
|||||||
@@ -207,11 +207,11 @@ type keyMap struct {
|
|||||||
var keys = keyMap{
|
var keys = keyMap{
|
||||||
Tab: key.NewBinding(
|
Tab: key.NewBinding(
|
||||||
key.WithKeys("tab"),
|
key.WithKeys("tab"),
|
||||||
key.WithHelp("tab", "next tab"),
|
key.WithHelp("tab", "indent"),
|
||||||
),
|
),
|
||||||
Prev: key.NewBinding(
|
Prev: key.NewBinding(
|
||||||
key.WithKeys("shift+tab"),
|
key.WithKeys("shift+tab"),
|
||||||
key.WithHelp("shift+tab", "prev tab"),
|
key.WithHelp("shift+tab", "unindent"),
|
||||||
),
|
),
|
||||||
Quit: key.NewBinding(
|
Quit: key.NewBinding(
|
||||||
key.WithKeys("ctrl+c"),
|
key.WithKeys("ctrl+c"),
|
||||||
@@ -490,14 +490,6 @@ func (m Model) handleKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
m.tabMenuCursor = int(m.activeTab)
|
m.tabMenuCursor = int(m.activeTab)
|
||||||
m.viewport.SetContent(m.renderContent())
|
m.viewport.SetContent(m.renderContent())
|
||||||
return m, nil
|
return m, nil
|
||||||
case "tab":
|
|
||||||
m.activeTab = (m.activeTab + 1) % tabCount
|
|
||||||
m.resizeViewport()
|
|
||||||
return m, nil
|
|
||||||
case "shift+tab":
|
|
||||||
m.activeTab = (m.activeTab - 1 + tabCount) % tabCount
|
|
||||||
m.resizeViewport()
|
|
||||||
return m, nil
|
|
||||||
case "enter":
|
case "enter":
|
||||||
if (m.activeTab == tabChat || m.activeTab == tabWorkflow) && m.chatInput != "" && !m.chatLoading {
|
if (m.activeTab == tabChat || m.activeTab == tabWorkflow) && m.chatInput != "" && !m.chatLoading {
|
||||||
return m.handleChatSubmit()
|
return m.handleChatSubmit()
|
||||||
@@ -597,13 +589,10 @@ func (m Model) handleTerminalKey(msg tea.KeyMsg) (tea.Model, tea.Cmd) {
|
|||||||
}
|
}
|
||||||
return m, nil
|
return m, nil
|
||||||
case "tab":
|
case "tab":
|
||||||
m.activeTab = (m.activeTab + 1) % tabCount
|
if m.activeTab == tabChat || m.activeTab == tabWorkflow {
|
||||||
m.resizeViewport()
|
m.chatInput += "\t"
|
||||||
return m, nil
|
m.viewport.SetContent(m.renderContent())
|
||||||
case "shift+tab":
|
}
|
||||||
m.activeTab = (m.activeTab - 1 + tabCount) % tabCount
|
|
||||||
m.resizeViewport()
|
|
||||||
return m, nil
|
|
||||||
default:
|
default:
|
||||||
if len(msg.String()) == 1 {
|
if len(msg.String()) == 1 {
|
||||||
m.termInput += msg.String()
|
m.termInput += msg.String()
|
||||||
@@ -1685,13 +1674,13 @@ func (m Model) renderFooter() string {
|
|||||||
case tabDashboard:
|
case tabDashboard:
|
||||||
helpText = "[i] install [u] update [s] scan"
|
helpText = "[i] install [u] update [s] scan"
|
||||||
case tabChat, tabWorkflow:
|
case tabChat, tabWorkflow:
|
||||||
helpText = "[ctrl+t] tabs [tab] next [ctrl+c] quit"
|
helpText = "[ctrl+t] switch tab [ctrl+c] quit"
|
||||||
case tabTerminal:
|
case tabTerminal:
|
||||||
helpText = "[enter] run [ctrl+c] kill [clear] clear"
|
helpText = "[enter] run [ctrl+c] kill [clear] clear"
|
||||||
case tabAgents:
|
case tabAgents:
|
||||||
helpText = "[c] crush [l] claude"
|
helpText = "[c] crush [l] claude"
|
||||||
default:
|
default:
|
||||||
helpText = "[ctrl+t] tabs [tab] next [ctrl+c] quit"
|
helpText = "[ctrl+t] switch tab [ctrl+c] quit"
|
||||||
}
|
}
|
||||||
rightR := statusBarStyle.Render(helpText)
|
rightR := statusBarStyle.Render(helpText)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user