chore: add copy message

also fix the status
This commit is contained in:
Kujtim Hoxha
2025-07-25 19:15:10 +02:00
parent 426229f1c6
commit 65b92b4e74
3 changed files with 13 additions and 5 deletions

View File

@@ -104,6 +104,7 @@ func (m *messageCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
if err != nil {
return m, util.ReportError(fmt.Errorf("failed to copy message content to clipboard: %w", err))
}
return m, util.ReportInfo("Message copied to clipboard")
}
}
return m, nil

View File

@@ -202,7 +202,7 @@ func (m *toolCallCmp) copyTool() tea.Cmd {
if err != nil {
return util.ReportError(fmt.Errorf("failed to copy tool content to clipboard: %w", err))
}
return nil
return util.ReportInfo("Tool content copied to clipboard")
}
func (m *toolCallCmp) formatToolForCopy() string {
@@ -640,7 +640,7 @@ func (m *toolCallCmp) formatAgentResultForCopy() string {
}
if m.result.Content != "" {
result.WriteString(fmt.Sprintf("```\n%s\n```", m.result.Content))
result.WriteString(fmt.Sprintf("```markdown\n%s\n```", m.result.Content))
}
return result.String()

View File

@@ -7,6 +7,7 @@ import (
tea "github.com/charmbracelet/bubbletea/v2"
"github.com/charmbracelet/crush/internal/tui/styles"
"github.com/charmbracelet/crush/internal/tui/util"
"github.com/charmbracelet/lipgloss/v2"
"github.com/charmbracelet/x/ansi"
)
@@ -72,13 +73,19 @@ func (m *statusCmp) infoMsg() string {
switch m.info.Type {
case util.InfoTypeError:
infoType = t.S().Base.Background(t.Red).Padding(0, 1).Render("ERROR")
message = t.S().Base.Background(t.Error).Width(m.width).Foreground(t.White).Padding(0, 1).Render(m.info.Msg)
widthLeft := m.width - (lipgloss.Width(infoType) + 2)
info := ansi.Truncate(m.info.Msg, widthLeft, "…")
message = t.S().Base.Background(t.Error).Width(widthLeft+2).Foreground(t.White).Padding(0, 1).Render(info)
case util.InfoTypeWarn:
infoType = t.S().Base.Foreground(t.BgOverlay).Background(t.Yellow).Padding(0, 1).Render("WARNING")
message = t.S().Base.Foreground(t.BgOverlay).Width(m.width).Background(t.Warning).Padding(0, 1).Render(m.info.Msg)
widthLeft := m.width - (lipgloss.Width(infoType) + 2)
info := ansi.Truncate(m.info.Msg, widthLeft, "…")
message = t.S().Base.Foreground(t.BgOverlay).Width(widthLeft+2).Background(t.Warning).Padding(0, 1).Render(info)
default:
infoType = t.S().Base.Foreground(t.BgOverlay).Background(t.Green).Padding(0, 1).Render("OKAY!")
message = t.S().Base.Background(t.Success).Width(m.width).Foreground(t.White).Padding(0, 1).Render(m.info.Msg)
widthLeft := m.width - (lipgloss.Width(infoType) + 2)
info := ansi.Truncate(m.info.Msg, widthLeft, "…")
message = t.S().Base.Background(t.Success).Width(widthLeft+2).Foreground(t.White).Padding(0, 1).Render(info)
}
return ansi.Truncate(infoType+message, m.width, "…")
}