diff options
| author | Rohan Godha <[email protected]> | 2025-06-19 18:08:56 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-19 20:08:56 -0500 |
| commit | 6674c6083a4f5f6c2a66eeb13bceaaf47d0fc185 (patch) | |
| tree | 2e7dea8f4a97b18a9d29b858674bbb01b8aadd64 | |
| parent | f6afa2c6bb20d7b6714bce9dbf6cf0bd157440d2 (diff) | |
| download | opencode-6674c6083a4f5f6c2a66eeb13bceaaf47d0fc185.tar.gz opencode-6674c6083a4f5f6c2a66eeb13bceaaf47d0fc185.zip | |
fix: phantom input bug on wsl (#200)
| -rw-r--r-- | packages/tui/internal/tui/tui.go | 6 | ||||
| -rw-r--r-- | packages/tui/internal/util/util.go | 18 |
2 files changed, 23 insertions, 1 deletions
diff --git a/packages/tui/internal/tui/tui.go b/packages/tui/internal/tui/tui.go index b913e5898..e1f3aa1b1 100644 --- a/packages/tui/internal/tui/tui.go +++ b/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()) diff --git a/packages/tui/internal/util/util.go b/packages/tui/internal/util/util.go index 537d852d6..c7fd98a8c 100644 --- a/packages/tui/internal/util/util.go +++ b/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 +} |
