fix(desktop): suppress generic provider warning in onboarding
Hide the red setup notice when the message is the generic missing-provider guidance, since onboarding already presents provider auth actions. Centralize provider-setup matching across desktop hooks and add coverage for the matcher.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { isProviderSetupErrorMessage } from './provider-setup-errors'
|
||||
|
||||
describe('isProviderSetupErrorMessage', () => {
|
||||
it('matches generic missing-provider copy', () => {
|
||||
expect(isProviderSetupErrorMessage('No inference provider configured. Run `hermes model` to choose one.')).toBe(true)
|
||||
expect(isProviderSetupErrorMessage('No inference provider is configured.')).toBe(true)
|
||||
expect(isProviderSetupErrorMessage('set an API key (OPENROUTER_API_KEY) in ~/.hermes/.env')).toBe(true)
|
||||
})
|
||||
|
||||
it('does not match non-provider runtime failures', () => {
|
||||
expect(
|
||||
isProviderSetupErrorMessage(
|
||||
'Selected runtime is not available. setup.status reports configured credentials.'
|
||||
)
|
||||
).toBe(false)
|
||||
})
|
||||
|
||||
it('returns false for empty input', () => {
|
||||
expect(isProviderSetupErrorMessage('')).toBe(false)
|
||||
expect(isProviderSetupErrorMessage(null)).toBe(false)
|
||||
expect(isProviderSetupErrorMessage(undefined)).toBe(false)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,12 @@
|
||||
const PROVIDER_SETUP_ERROR_RE =
|
||||
/No inference provider(?: is)? configured|no_provider_configured|OPENROUTER_API_KEY|OPENAI_API_KEY|ANTHROPIC_API_KEY|set an API key/i
|
||||
|
||||
export function isProviderSetupErrorMessage(message: null | string | undefined): boolean {
|
||||
const text = message?.trim()
|
||||
|
||||
if (!text) {
|
||||
return false
|
||||
}
|
||||
|
||||
return PROVIDER_SETUP_ERROR_RE.test(text)
|
||||
}
|
||||
Reference in New Issue
Block a user