@@ -48,9 +48,10 @@ func resolveKeyAsync(secret string) tea.Cmd {
4848
4949func credentialResolveFromRuntime (res runtime.CredentialResolveResult ) hawkconfig.CredentialResolveResult {
5050 out := hawkconfig.CredentialResolveResult {
51- FormatOK : res .FormatOK ,
52- FormatError : res .FormatError ,
53- Providers : make ([]hawkconfig.CredentialProviderOption , len (res .Providers )),
51+ FormatOK : res .FormatOK ,
52+ FormatError : res .FormatError ,
53+ ProbeDisambiguationUsed : res .ProbeDisambiguationUsed ,
54+ Providers : make ([]hawkconfig.CredentialProviderOption , len (res .Providers )),
5455 }
5556 for i , p := range res .Providers {
5657 out .Providers [i ] = hawkconfig.CredentialProviderOption {
@@ -191,10 +192,44 @@ func (m chatModel) configProvidersView() string {
191192 if end < total {
192193 b .WriteString (mutedStyle .Render (fmt .Sprintf (" ··· %d more below ···" , total - end )) + "\n " )
193194 }
194- b .WriteString ("\n " + mutedStyle .Render (fmt . Sprintf ( "%d gateways · ★ = suggested · ↑/↓ · enter · esc" , total )))
195+ b .WriteString ("\n " + mutedStyle .Render (configProviderPickerHelp ( total , m . configProviderOptions )))
195196 return b .String ()
196197}
197198
199+ func configProviderPickerHelp (total int , opts []hawkconfig.CredentialProviderOption ) string {
200+ if credentialOptionsHaveInference (opts ) {
201+ return fmt .Sprintf ("%d gateways · ★ = suggested · ↑/↓ · enter · esc" , total )
202+ }
203+ return fmt .Sprintf ("%d gateways · choose gateway manually · ↑/↓ · enter · esc" , total )
204+ }
205+
206+ func credentialOptionsHaveInference (opts []hawkconfig.CredentialProviderOption ) bool {
207+ for _ , opt := range opts {
208+ if opt .Inferred {
209+ return true
210+ }
211+ }
212+ return false
213+ }
214+
215+ func providerPickerNotice (secret string , opts []hawkconfig.CredentialProviderOption , probeUsed bool ) string {
216+ if credentialOptionsHaveInference (opts ) {
217+ if probeUsed {
218+ return "Select gateway (★ = matched pattern or verified with provider API)"
219+ }
220+ return "Select gateway (★ = suggested from key shape)"
221+ }
222+ if isGenericOpenAICompatibleKey (secret ) {
223+ return "Generic OpenAI-compatible key — choose the gateway it belongs to"
224+ }
225+ return "Select gateway"
226+ }
227+
228+ func isGenericOpenAICompatibleKey (secret string ) bool {
229+ secret = strings .TrimSpace (secret )
230+ return strings .HasPrefix (secret , "sk-" )
231+ }
232+
198233func (m chatModel ) configProviderLabels () []string {
199234 out := make ([]string , len (m .configProviderOptions ))
200235 for i , p := range m .configProviderOptions {
@@ -225,10 +260,10 @@ func (m chatModel) handleConfigKeyResolvedMsg(msg configKeyResolvedMsg) (chatMod
225260 m .configProviderOptions = msg .result .Providers
226261 m .configEntry = configEntryNone
227262 m .configMenu = configMenuProviders
228- m .configTab = configTabKeys
263+ m .configTab = configTabGateways
229264 m .configSel = 0
230265 m .configScroll = 0
231- m .configNotice = "Select gateway (★ = suggested from key shape)"
266+ m .configNotice = providerPickerNotice ( secret , msg . result . Providers , msg . result . ProbeDisambiguationUsed )
232267 m .restoreChatInput ()
233268 return m , nil
234269}
@@ -292,13 +327,14 @@ func (m chatModel) handleConfigApplyCredentialsMsg(msg configApplyCredentialsMsg
292327 notice = "Key saved — " + notice + " · retry in Gateways or Models tab"
293328 }
294329 m .configNotice = notice
295- if strings .TrimSpace (m .configPendingKey ) != "" && len (m .configProviderOptions ) > 0 {
296- m .configMenu = configMenuProviders
297- m .configTab = configTabKeys
298- m .configSel = 0
299- } else {
300- m .configMenu = configMenuNone
301- m .configTab = configTabKeys
330+ m .configPendingKey = ""
331+ m .configProviderOptions = nil
332+ m .configMenu = configMenuNone
333+ m .configTab = configTabGateways
334+ if pid := strings .TrimSpace (msg .providerID ); pid != "" {
335+ if idx := m .configGatewayRowIndex (pid ); idx >= 0 {
336+ m .configSel = idx
337+ }
302338 }
303339 return m , nil
304340 }
@@ -318,10 +354,10 @@ func (m chatModel) handleConfigApplyCredentialsMsg(msg configApplyCredentialsMsg
318354 next .invalidateConnStatus ()
319355 if post := strings .TrimSpace (m .configPostSaveKeysProvider ); post != "" {
320356 next .configPostSaveKeysProvider = ""
321- next .configTab = configTabKeys
357+ next .configTab = configTabGateways
322358 next .configMenu = configMenuNone
323359 next .configEntry = configEntryNone
324- if idx := next .configKeysCredentialIndex (post ); idx >= 0 {
360+ if idx := next .configGatewayRowIndex (post ); idx >= 0 {
325361 next .configSel = idx
326362 }
327363 next .configNotice = "Key updated for " + hawkconfig .GatewayDisplayName (post )
@@ -336,7 +372,7 @@ func (m chatModel) handleConfigApplyCredentialsMsg(msg configApplyCredentialsMsg
336372 if msg .providerID == configProviderOllama {
337373 return next .returnToOllamaURLAfterError (fmt .Errorf ("no models installed — run: ollama pull llama3.2" ))
338374 }
339- next .configTab = configTabKeys
375+ next .configTab = configTabGateways
340376 next .configNotice = "No models in catalog for " + msg .providerID + " — try another gateway"
341377 return next , cmd
342378 }
0 commit comments