on main help sign in
feat: add ability to re-authenticate / edit api key
commit1615de50386d14d80b022a3677a6bbb475a80106 authorAndrey Nering <andreynering@users.noreply.github.com> dateMon 9 Feb 2026, 16:46 (8 months ago) parent340ce20
3 files changed+39−22
internal/ui/dialog/actions.go+4−3 internal/ui/dialog/models.go+33−17 internal/ui/model/ui.go+2−2
internal/ui/dialog/actions.go+4−3
@@ -36,9 +36,10 @@ type ActionSelectSession struct {
3636
3737// ActionSelectModel is a message indicating a model has been selected.
3838type ActionSelectModel struct {
39− Provider catwalk.Provider
40− Model config.SelectedModel
41− ModelType config.SelectedModelType
39+ Provider catwalk.Provider
40+ Model config.SelectedModel
41+ ModelType config.SelectedModelType
42+ ReAuthenticate bool
4243}
4344
4445// Messages for commands
internal/ui/dialog/models.go+33−17
@@ -70,7 +70,7 @@ const (
7070// ModelsID is the identifier for the model selection dialog.
7171const ModelsID = "models"
7272
73−const defaultModelsDialogMaxWidth = 70
73+const defaultModelsDialogMaxWidth = 73
7474
7575// Models represents a model selection dialog.
7676type Models struct {
@@ -84,6 +84,7 @@ type Models struct {
8484 Tab key.Binding
8585 UpDown key.Binding
8686 Select key.Binding
87+ Edit key.Binding
8788 Next key.Binding
8889 Previous key.Binding
8990 Close key.Binding
@@ -124,6 +125,10 @@ func NewModels(com *common.Common, isOnboarding bool) (*Models, error) {
124125 key.WithKeys("enter", "ctrl+y"),
125126 key.WithHelp("enter", "confirm"),
126127 )
128+ m.keyMap.Edit = key.NewBinding(
129+ key.WithKeys("ctrl+e"),
130+ key.WithHelp("ctrl+e", "edit"),
131+ )
127132 m.keyMap.UpDown = key.NewBinding(
128133 key.WithKeys("up", "down"),
129134 key.WithHelp("↑/↓", "choose"),
@@ -181,7 +186,7 @@ func (m *Models) HandleMsg(msg tea.Msg) Action {
181186 }
182187 m.list.SelectNext()
183188 m.list.ScrollToSelected()
184− case key.Matches(msg, m.keyMap.Select):
189+ case key.Matches(msg, m.keyMap.Select, m.keyMap.Edit):
185190 selectedItem := m.list.SelectedItem()
186191 if selectedItem == nil {
187192 break
@@ -192,10 +197,13 @@ func (m *Models) HandleMsg(msg tea.Msg) Action {
192197 break
193198 }
194199
200+ isEdit := key.Matches(msg, m.keyMap.Edit)
201+
195202 return ActionSelectModel{
196− Provider: modelItem.prov,
197− Model: modelItem.SelectedModel(),
198− ModelType: modelItem.SelectedModelType(),
203+ Provider: modelItem.prov,
204+ Model: modelItem.SelectedModel(),
205+ ModelType: modelItem.SelectedModelType(),
206+ ReAuthenticate: isEdit,
199207 }
200208 case key.Matches(msg, m.keyMap.Tab):
201209 if m.isOnboarding {
@@ -309,27 +317,35 @@ func (m *Models) ShortHelp() []key.Binding {
309317 m.keyMap.Select,
310318 }
311319 }
312− return []key.Binding{
320+ h := []key.Binding{
313321 m.keyMap.UpDown,
314322 m.keyMap.Tab,
315323 m.keyMap.Select,
316− m.keyMap.Close,
317324 }
325+ if m.isSelectedConfigured() {
326+ h = append(h, m.keyMap.Edit)
327+ }
328+ h = append(h, m.keyMap.Close)
329+ return h
318330}
319331
320332// FullHelp returns the full help view.
321333func (m *Models) FullHelp() [][]key.Binding {
322− return [][]key.Binding{
323− {
324− m.keyMap.Select,
325− m.keyMap.Next,
326− m.keyMap.Previous,
327− m.keyMap.Tab,
328− },
329− {
330− m.keyMap.Close,
331− },
334+ return [][]key.Binding{m.ShortHelp()}
335+}
336+
337+func (m *Models) isSelectedConfigured() bool {
338+ selectedItem := m.list.SelectedItem()
339+ if selectedItem == nil {
340+ return false
341+ }
342+ modelItem, ok := selectedItem.(*ModelItem)
343+ if !ok {
344+ return false
332345 }
346+ providerID := string(modelItem.prov.ID)
347+ _, isConfigured := m.com.Config().Providers.Get(providerID)
348+ return isConfigured
333349}
334350
335351// setProviderItems sets the provider items in the list.
internal/ui/model/ui.go+2−2
@@ -1266,11 +1266,11 @@ func (m *UI) handleDialogMsg(msg tea.Msg) tea.Cmd {
12661266 )
12671267
12681268 // Attempt to import GitHub Copilot tokens from VSCode if available.
1269− if isCopilot && !isConfigured() {
1269+ if isCopilot && !isConfigured() && !msg.ReAuthenticate {
12701270 m.com.Config().ImportCopilot()
12711271 }
12721272
1273− if !isConfigured() {
1273+ if !isConfigured() || msg.ReAuthenticate {
12741274 m.dialog.CloseDialog(dialog.ModelsID)
12751275 if cmd := m.openAuthenticationDialog(msg.Provider, msg.Model, msg.ModelType); cmd != nil {
12761276 cmds = append(cmds, cmd)