Rohan Godha 8 месяцев назад
Родитель
Сommit
6674c6083a
2 измененных файлов с 23 добавлено и 1 удалено
  1. 5 1
      packages/tui/internal/tui/tui.go
  2. 18 0
      packages/tui/internal/util/util.go

+ 5 - 1
packages/tui/internal/tui/tui.go

@@ -44,7 +44,11 @@ type appModel struct {
 
 func (a appModel) Init() tea.Cmd {
 	var cmds []tea.Cmd
-	cmds = append(cmds, tea.RequestBackgroundColor)
+	// https://github.com/charmbracelet/bubbletea/issues/1440
+	// https://github.com/sst/opencode/issues/127
+	if !util.IsWsl() {
+		cmds = append(cmds, tea.RequestBackgroundColor)
+	}
 	cmds = append(cmds, a.app.InitializeProvider())
 	cmds = append(cmds, a.editor.Init())
 	cmds = append(cmds, a.messages.Init())

+ 18 - 0
packages/tui/internal/util/util.go

@@ -1,6 +1,9 @@
 package util
 
 import (
+	"os"
+	"strings"
+
 	tea "github.com/charmbracelet/bubbletea/v2"
 )
 
@@ -17,3 +20,18 @@ func Clamp(v, low, high int) int {
 	}
 	return min(high, max(low, v))
 }
+
+func IsWsl() bool {
+	// Check for WSL environment variables
+	if os.Getenv("WSL_DISTRO_NAME") != "" {
+		return true
+	}
+
+	// Check /proc/version for WSL signature
+	if data, err := os.ReadFile("/proc/version"); err == nil {
+		version := strings.ToLower(string(data))
+		return strings.Contains(version, "microsoft") || strings.Contains(version, "wsl")
+	}
+
+	return false
+}