mirror of
https://github.com/charmbracelet/crush.git
synced 2025-08-02 05:20:46 +03:00
chore: add copy message
also fix the status
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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, "…")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user