on main help sign in
fix(chat): expose copy key binding
commit6b545747ded24028e506ec8442eff1315bb6c231 authorAyman Bagabas <ayman.bagabas@gmail.com> dateTue 5 Aug 2025, 16:24 (1 year ago) parent7e58d53
3 files changed+6−7
internal/tui/components/chat/messages/messages.go+3−2 internal/tui/components/chat/messages/tool.go+1−1 internal/tui/page/chat/chat.go+2−4
internal/tui/components/chat/messages/messages.go+3−2
@@ -25,7 +25,8 @@ import (
2525 "github.com/charmbracelet/crush/internal/tui/util"
2626)
2727
28−var copyKey = key.NewBinding(key.WithKeys("c", "y", "C", "Y"), key.WithHelp("c/y", "copy"))
28+// CopyKey is the key binding for copying message content to the clipboard.
29+var CopyKey = key.NewBinding(key.WithKeys("c", "y", "C", "Y"), key.WithHelp("c/y", "copy"))
2930
3031// MessageCmp defines the interface for message components in the chat interface.
3132// 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) {
99100 return m, cmd
100101 }
101102 case tea.KeyPressMsg:
102− if key.Matches(msg, copyKey) {
103+ if key.Matches(msg, CopyKey) {
103104 err := clipboard.WriteAll(m.message.Content().Text)
104105 if err != nil {
105106 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) {
165165 }
166166 return m, tea.Batch(cmds...)
167167 case tea.KeyPressMsg:
168− if key.Matches(msg, copyKey) {
168+ if key.Matches(msg, CopyKey) {
169169 return m, m.copyTool()
170170 }
171171 }
internal/tui/page/chat/chat.go+2−4
@@ -19,6 +19,7 @@ import (
1919 "github.com/charmbracelet/crush/internal/tui/components/chat"
2020 "github.com/charmbracelet/crush/internal/tui/components/chat/editor"
2121 "github.com/charmbracelet/crush/internal/tui/components/chat/header"
22+ "github.com/charmbracelet/crush/internal/tui/components/chat/messages"
2223 "github.com/charmbracelet/crush/internal/tui/components/chat/sidebar"
2324 "github.com/charmbracelet/crush/internal/tui/components/chat/splash"
2425 "github.com/charmbracelet/crush/internal/tui/components/completions"
@@ -865,10 +866,7 @@ func (p *chatPage) Help() help.KeyMap {
865866 key.WithKeys("up", "down"),
866867 key.WithHelp("↑↓", "scroll"),
867868 ),
868− key.NewBinding(
869− key.WithKeys("c", "y"),
870− key.WithHelp("c/y", "copy"),
871− ),
869+ messages.CopyKey,
872870 )
873871 fullList = append(fullList,
874872 []key.Binding{