From 5bda4e5945fa45d89b4c163c6bb10186dd033013 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Fri, 18 Sep 2026 09:30:38 +0000 Subject: [PATCH] experimental/air: use libs/browser instead of pkg/browser for BROWSER env var support Replace direct usage of github.com/pkg/browser with github.com/databricks/cli/libs/browser to properly respect the BROWSER environment variable. This allows BROWSER=none and custom browser commands to work correctly. - Convert openURL from a standalone function to a method on listModel to access the context - Use browser.Open(ctx, url) with the proper context from the fetcher - Extract context before creating the closure to avoid use-after-free (closure captures value, not receiver) - Check for nil fetcher at call site, consistent with other interactive key handlers - Preserve best-effort behavior by ignoring errors Co-authored-by: Isaac --- experimental/air/cmd/list_tui.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/experimental/air/cmd/list_tui.go b/experimental/air/cmd/list_tui.go index 4707fd55fce..636836a84a0 100644 --- a/experimental/air/cmd/list_tui.go +++ b/experimental/air/cmd/list_tui.go @@ -9,8 +9,8 @@ import ( "github.com/charmbracelet/bubbles/viewport" tea "github.com/charmbracelet/bubbletea" "github.com/charmbracelet/lipgloss" + "github.com/databricks/cli/libs/browser" "github.com/databricks/cli/libs/cmdio" - "github.com/pkg/browser" "github.com/spf13/cobra" ) @@ -251,9 +251,9 @@ func (m listModel) Update(msg tea.Msg) (tea.Model, tea.Cmd) { m.cursor = len(m.rows) - 1 case "enter": // Open the selected run's MLflow page in the browser. - if len(m.rows) > 0 { + if m.fetcher != nil && len(m.rows) > 0 { if url := m.rows[m.cursor].MLflowURL; url != "" && url != "-" { - return m, openURL(url) + return m, m.openURL(url) } } case "i": @@ -359,9 +359,10 @@ func (m listModel) fetchRunLogs(runID int64) tea.Cmd { } // openURL opens a URL in the user's default browser, best-effort. -func openURL(url string) tea.Cmd { +func (m listModel) openURL(url string) tea.Cmd { + ctx := m.fetcher.ctx return func() tea.Msg { - _ = browser.OpenURL(url) + _ = browser.Open(ctx, url) return nil } }