on main help sign in
fix: editor: exclude native clipboard support from linux/386 builds (#1903)
commit3c64ee0ce1989e3f5cc97d7b5df8e97fcc04e90a authorAyman Bagabas <ayman.bagabas@gmail.com> dateFri 16 Jan 2026, 15:59 (9 months ago) parentaa60fbb
4 files changed+37−3
internal/tui/components/chat/editor/clipboard.go+8 internal/tui/components/chat/editor/clipboard_linux_386.go+7 internal/tui/components/chat/editor/clipboard_other.go+15 internal/tui/components/chat/editor/editor.go+7−3
internal/tui/components/chat/editor/clipboard.gonew file+8
@@ -0,0 +1,8 @@
1+package editor
2+
3+type clipboardFormat int
4+
5+const (
6+ clipboardFormatText clipboardFormat = iota
7+ clipboardFormatImage
8+)
internal/tui/components/chat/editor/clipboard_linux_386.gonew file+7
@@ -0,0 +1,7 @@
1+//go:build linux && 386
2+
3+package editor
4+
5+func readClipboard(clipboardFormat) ([]byte, error) {
6+ return nil, errClipboardPlatformUnsupported
7+}
internal/tui/components/chat/editor/clipboard_other.gonew file+15
@@ -0,0 +1,15 @@
1+//go:build !linux || !386
2+
3+package editor
4+
5+import "github.com/aymanbagabas/go-nativeclipboard"
6+
7+func readClipboard(f clipboardFormat) ([]byte, error) {
8+ switch f {
9+ case clipboardFormatText:
10+ return nativeclipboard.Text.Read()
11+ case clipboardFormatImage:
12+ return nativeclipboard.Image.Read()
13+ }
14+ return nil, errClipboardUnknownFormat
15+}
internal/tui/components/chat/editor/editor.go+7−3
@@ -16,7 +16,6 @@ import (
1616 "charm.land/bubbles/v2/textarea"
1717 tea "charm.land/bubbletea/v2"
1818 "charm.land/lipgloss/v2"
19− nativeclipboard "github.com/aymanbagabas/go-nativeclipboard"
2019 "github.com/charmbracelet/crush/internal/app"
2120 "github.com/charmbracelet/crush/internal/filetracker"
2221 "github.com/charmbracelet/crush/internal/fsext"
@@ -35,6 +34,11 @@ import (
3534 "github.com/charmbracelet/x/editor"
3635)
3736
37+var (
38+ errClipboardPlatformUnsupported = fmt.Errorf("clipboard operations are not supported on this platform")
39+ errClipboardUnknownFormat = fmt.Errorf("unknown clipboard format")
40+)
41+
3842type Editor interface {
3943 util.Model
4044 layout.Sizeable
@@ -341,12 +345,12 @@ func (m *editorCmp) Update(msg tea.Msg) (util.Model, tea.Cmd) {
341345 }
342346 // Handle image paste from clipboard
343347 if key.Matches(msg, m.keyMap.PasteImage) {
344− imageData, err := nativeclipboard.Image.Read()
348+ imageData, err := readClipboard(clipboardFormatImage)
345349
346350 if err != nil || len(imageData) == 0 {
347351 // If no image data found, try to get text data (could be file path)
348352 var textData []byte
349− textData, err = nativeclipboard.Text.Read()
353+ textData, err = readClipboard(clipboardFormatText)
350354 if err != nil || len(textData) == 0 {
351355 // If clipboard is empty, show a warning
352356 return m, util.ReportWarn("No data found in clipboard. Note: Some terminals may not support reading image data from clipboard directly.")