@@ -29,6 +29,12 @@ type SessionSelectedMsg = session.Session
2929
3030type SessionClearedMsg struct{}
3131
32+type SelectionCopyMsg struct {
33+ clickCount int
34+ endSelection bool
35+ x, y int
36+}
37+
3238const (
3339 NotFound = -1
3440)
@@ -134,14 +140,34 @@ func (m *messageListCmp) Update(msg tea.Msg) (tea.Model, tea.Cmd) {
134140 x := msg.X - 1 // Adjust for padding
135141 y := msg.Y - 1 // Adjust for padding
136142 if msg.Button == tea.MouseLeft {
143+ clickCount := m.clickCount
137144 if x < 0 || y < 0 || x >= m.width-2 || y >= m.height-1 {
138− m.listCmp.SelectionStop()
139− } else {
140− m.listCmp.EndSelection(x, y)
141− m.listCmp.SelectionStop()
145+ return m, tea.Tick(doubleClickThreshold, func(time.Time) tea.Msg {
146+ return SelectionCopyMsg{
147+ clickCount: clickCount,
148+ endSelection: false,
149+ }
150+ })
142151 }
152+ return m, tea.Tick(doubleClickThreshold, func(time.Time) tea.Msg {
153+ return SelectionCopyMsg{
154+ clickCount: clickCount,
155+ endSelection: true,
156+ x: x,
157+ y: y,
158+ }
159+ })
143160 }
144161 return m, nil
162+ case SelectionCopyMsg:
163+ if msg.clickCount == m.clickCount && time.Since(m.lastClickTime) >= doubleClickThreshold {
164+ // If the click count matches and within threshold, copy selected text
165+ if msg.endSelection {
166+ m.listCmp.EndSelection(msg.x, msg.y)
167+ }
168+ m.listCmp.SelectionStop()
169+ return m, m.CopySelectedText(true)
170+ }
145171 case pubsub.Event[permission.PermissionNotification]:
146172 return m, m.handlePermissionRequest(msg.Payload)
147173 case SessionSelectedMsg:
@@ -621,13 +647,13 @@ func (m *messageListCmp) GoToBottom() tea.Cmd {
621647 return m.listCmp.GoToBottom()
622648}
623649
650+const (
651+ doubleClickThreshold = 500 * time.Millisecond
652+ clickTolerance = 2 // pixels
653+)
654+
624655// handleMouseClick handles mouse click events and detects double/triple clicks.
625656func (m *messageListCmp) handleMouseClick(x, y int) tea.Cmd {
626− const (
627− doubleClickThreshold = 500 * time.Millisecond
628− clickTolerance = 2 // pixels
629− )
630−
631657 now := time.Now()
632658
633659 // Check if this is a potential multi-click
@@ -664,6 +690,7 @@ func (m *messageListCmp) SelectionClear() tea.Cmd {
664690 m.listCmp.SelectionClear()
665691 m.previousSelected = ""
666692 m.lastClickX, m.lastClickY = 0, 0
693+ m.lastClickTime = time.Time{}
667694 m.clickCount = 0
668695 return nil
669696}