on main help sign in
refactor(hyper): a couple of small adjustments
commitcddb306ab52dd6c24b11cb972def396a6a8e02ad authorAndrey Nering <andreynering@users.noreply.github.com> dateWed 17 Dec 2025, 11:21 (1 year ago) parentab057fd
1 file changed+9−6
internal/tui/components/dialogs/hyper/device_flow.go+9−6
internal/tui/components/dialogs/hyper/device_flow.go+9−6
@@ -9,7 +9,6 @@ import (
99 "charm.land/bubbles/v2/spinner"
1010 tea "charm.land/bubbletea/v2"
1111 "charm.land/lipgloss/v2"
12− hyperp "github.com/charmbracelet/crush/internal/agent/hyper"
1312 "github.com/charmbracelet/crush/internal/oauth"
1413 "github.com/charmbracelet/crush/internal/oauth/hyper"
1514 "github.com/charmbracelet/crush/internal/tui/styles"
@@ -47,7 +46,6 @@ type DeviceFlowErrorMsg struct {
4746type DeviceFlow struct {
4847 State DeviceFlowState
4948 width int
50− baseURL string
5149 deviceCode string
5250 userCode string
5351 verificationURL string
@@ -64,7 +62,6 @@ func NewDeviceFlow() *DeviceFlow {
6462 s.Style = lipgloss.NewStyle().Foreground(styles.CurrentTheme().GreenLight)
6563 return &DeviceFlow{
6664 State: DeviceFlowStateDisplay,
67− baseURL: hyperp.BaseURL(),
6865 spinner: s,
6966 }
7067}
@@ -103,6 +100,7 @@ func (d *DeviceFlow) View() string {
103100 whiteStyle := lipgloss.NewStyle().Foreground(t.White)
104101 primaryStyle := lipgloss.NewStyle().Foreground(t.Primary)
105102 greenStyle := lipgloss.NewStyle().Foreground(t.GreenLight)
103+ linkStyle := lipgloss.NewStyle().Foreground(t.GreenDark).Underline(true)
106104 errorStyle := lipgloss.NewStyle().Foreground(t.Error)
107105 mutedStyle := lipgloss.NewStyle().Foreground(t.FgMuted)
108106
@@ -121,7 +119,6 @@ func (d *DeviceFlow) View() string {
121119 Margin(1, 1, 0, 1).
122120 Width(d.width - 2).
123121 Render(
124−
125122 whiteStyle.Render("Press ") +
126123 primaryStyle.Render("enter") +
127124 whiteStyle.Render(" to copy the code below and open the browser."),
@@ -140,7 +137,7 @@ func (d *DeviceFlow) View() string {
140137 Render(d.userCode),
141138 )
142139
143− link := lipgloss.NewStyle().Hyperlink(d.verificationURL, "id=hyper-verify").Render(d.verificationURL)
140+ link := linkStyle.Hyperlink(d.verificationURL, "id=hyper-verify").Render(d.verificationURL)
144141 url := mutedStyle.
145142 Margin(0, 1).
146143 Width(d.width - 2).
@@ -165,7 +162,7 @@ func (d *DeviceFlow) View() string {
165162 case DeviceFlowStateError:
166163 return lipgloss.NewStyle().
167164 Margin(0, 1).
168− Width(d.width).
165+ Width(d.width - 2).
169166 Render(errorStyle.Render("Authentication failed."))
170167
171168 default:
@@ -183,6 +180,9 @@ func (d *DeviceFlow) Cursor() *tea.Cursor { return nil }
183180
184181// CopyCodeAndOpenURL copies the user code to the clipboard and opens the URL.
185182func (d *DeviceFlow) CopyCodeAndOpenURL() tea.Cmd {
183+ if d.State != DeviceFlowStateDisplay {
184+ return nil
185+ }
186186 return tea.Sequence(
187187 tea.SetClipboard(d.userCode),
188188 func() tea.Msg {
@@ -197,6 +197,9 @@ func (d *DeviceFlow) CopyCodeAndOpenURL() tea.Cmd {
197197
198198// CopyCode copies just the user code to the clipboard.
199199func (d *DeviceFlow) CopyCode() tea.Cmd {
200+ if d.State != DeviceFlowStateDisplay {
201+ return nil
202+ }
200203 return tea.Sequence(
201204 tea.SetClipboard(d.userCode),
202205 util.ReportInfo("Code copied to clipboard"),