on main help sign in
fix(chat): expose copy key binding
6b54574Ayman Bagabas
internal/tui/components/chat/messages/messages.go+3−2
@@ -25,7 +25,8 @@ import (
25 "github.com/charmbracelet/crush/internal/tui/util"
25 "github.com/charmbracelet/crush/internal/tui/util"
26)
26)
27
27
28+// CopyKey is the key binding for copying message content to the clipboard.
28−var copyKey = key.NewBinding(key.WithKeys("c", "y", "C", "Y"), key.WithHelp("c/y", "copy"))
29+var CopyKey = key.NewBinding(key.WithKeys("c", "y", "C", "Y"), key.WithHelp("c/y", "copy"))
29
30
30// MessageCmp defines the interface for message components in the chat interface.
31// MessageCmp defines the interface for message components in the chat interface.
31// It combines standard UI model interfaces with message-specific functionality.
32// It combines standard UI model interfaces with message-specific functionality.
@@ -99,7 +100,7 @@ func (m *messageCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
99 return m, cmd
100 return m, cmd
100 }
101 }
101 case tea.KeyPressMsg:
102 case tea.KeyPressMsg:
102− if key.Matches(msg, copyKey) {
103+ if key.Matches(msg, CopyKey) {
103 err := clipboard.WriteAll(m.message.Content().Text)
104 err := clipboard.WriteAll(m.message.Content().Text)
104 if err != nil {
105 if err != nil {
105 return m, util.ReportError(fmt.Errorf("failed to copy message content to clipboard: %w", err))
106 return m, util.ReportError(fmt.Errorf("failed to copy message content to clipboard: %w", err))
internal/tui/components/chat/messages/tool.go+1−1
@@ -165,7 +165,7 @@ func (m *toolCallCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
165 }
165 }
166 return m, tea.Batch(cmds...)
166 return m, tea.Batch(cmds...)
167 case tea.KeyPressMsg:
167 case tea.KeyPressMsg:
168− if key.Matches(msg, copyKey) {
168+ if key.Matches(msg, CopyKey) {
169 return m, m.copyTool()
169 return m, m.copyTool()
170 }
170 }
171 }
171 }
internal/tui/page/chat/chat.go+2−4
@@ -19,6 +19,7 @@ import (
19 "github.com/charmbracelet/crush/internal/tui/components/chat"
19 "github.com/charmbracelet/crush/internal/tui/components/chat"
20 "github.com/charmbracelet/crush/internal/tui/components/chat/editor"
20 "github.com/charmbracelet/crush/internal/tui/components/chat/editor"
21 "github.com/charmbracelet/crush/internal/tui/components/chat/header"
21 "github.com/charmbracelet/crush/internal/tui/components/chat/header"
22+ "github.com/charmbracelet/crush/internal/tui/components/chat/messages"
22 "github.com/charmbracelet/crush/internal/tui/components/chat/sidebar"
23 "github.com/charmbracelet/crush/internal/tui/components/chat/sidebar"
23 "github.com/charmbracelet/crush/internal/tui/components/chat/splash"
24 "github.com/charmbracelet/crush/internal/tui/components/chat/splash"
24 "github.com/charmbracelet/crush/internal/tui/components/completions"
25 "github.com/charmbracelet/crush/internal/tui/components/completions"
@@ -865,10 +866,7 @@ func (p *chatPage) Help() help.KeyMap {
865 key.WithKeys("up", "down"),
866 key.WithKeys("up", "down"),
866 key.WithHelp("↑↓", "scroll"),
867 key.WithHelp("↑↓", "scroll"),
867 ),
868 ),
868− key.NewBinding(
869+ messages.CopyKey,
869− key.WithKeys("c", "y"),
870− key.WithHelp("c/y", "copy"),
871− ),
872 )
870 )
873 fullList = append(fullList,
871 fullList = append(fullList,
874 []key.Binding{
872 []key.Binding{