Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions experimental/air/cmd/list_tui.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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":
Expand Down Expand Up @@ -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)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A data race occurs and is printed by pressing Enter twice quickly. Bubble Tea runs both browser commands concurrently, while openDefault mutates global browserpkg.Stderr. Please guard the save/set/open/restore sequence

return nil
}
}
Expand Down
Loading