Skip to content

The agent that grows with you

fix(desktop): no CLI instructions in any readiness reason when nothing is set up (review)

alt-glitch736354aa74fa
diff --git a/apps/desktop/src/lib/runtime-readiness.test.ts b/apps/desktop/src/lib/runtime-readiness.test.ts
index cb3df198edf..c3daaf71481 100644
--- a/apps/desktop/src/lib/runtime-readiness.test.ts
+++ b/apps/desktop/src/lib/runtime-readiness.test.ts
@@ -50,6 +50,34 @@ describe('interpretRuntimeReadiness', () => {
})
})
+ const NOT_CONNECTED = 'Hermes is not connected to any AI provider yet. Run `hermes model` to pick one.'
+
+ it.each([
+ ['runtime_check', { runtime: { error: NOT_CONNECTED, ok: false }, runtimeError: null }],
+ ['setup_status', { runtime: null, runtimeError: NOT_CONNECTED }]
+ ] as const)('gives the default reason, not the CLI sentence, when nothing is set up (%s)', (source, runtime) => {
+ const result = interpretRuntimeReadiness(
+ { setup: { provider_configured: false }, setupError: null, ...runtime },
+ { defaultReason: 'Pick a provider.' }
+ )
+
+ expect(result).toMatchObject({ ready: false, reason: 'Pick a provider.', source })
+ })
+
+ it('keeps the cause for an explicitly requested provider even when nothing is set up', () => {
+ const result = interpretRuntimeReadiness(
+ {
+ setup: { provider_configured: false },
+ setupError: null,
+ runtime: { error: 'No usable credentials found for nous.', ok: false },
+ runtimeError: null
+ },
+ { requestedProvider: 'nous' }
+ )
+
+ expect(result.reason).toBe('No usable credentials found for nous.')
+ })
+
it('uses explicit fallback when both checks are missing', () => {
const result = interpretRuntimeReadiness({
setup: null,
diff --git a/apps/desktop/src/lib/runtime-readiness.ts b/apps/desktop/src/lib/runtime-readiness.ts
index 8a2342845f2..c032e6abf9f 100644
--- a/apps/desktop/src/lib/runtime-readiness.ts
+++ b/apps/desktop/src/lib/runtime-readiness.ts
@@ -52,9 +52,6 @@ export interface RuntimeReadinessResult {
ready: boolean
reason: null | string
source: 'fallback' | 'runtime_check' | 'setup_status'
- /** The check failed and setup.status says no provider is set up at all: `reason` is then the
- * check's own sentence for "nothing is set up", not a cause. */
- unconfigured?: true
}
export type RuntimeReadinessDisplay = 'checking' | 'needs_setup' | 'ready' | 'unavailable'
@@ -129,6 +126,10 @@ export function interpretRuntimeReadiness(
const runtimeOk = typeof signals.runtime?.ok === 'boolean' ? Boolean(signals.runtime.ok) : undefined
const runtimeFailure = normalizeMessage(signals.runtime?.error) ?? normalizeMessage(signals.runtimeError)
const setupFailure = normalizeMessage(signals.setupError)
+ // With nothing set up, the check's own sentence only restates that in CLI terms (`hermes model`,
+ // the home path), so every surface gets the caller's default instead. A requested provider keeps
+ // its cause: that check was about that provider.
+ const nothingSetUp = setupConfigured === false && !options.requestedProvider?.trim()
// Route facts the check reported, carried through untouched so consumers
// (free-tier chrome) don't have to re-issue setup.runtime_check. Left
@@ -152,7 +153,7 @@ export function interpretRuntimeReadiness(
}
}
- let reason = runtimeFailure ?? defaultReason
+ let reason = (nothingSetUp ? null : runtimeFailure) ?? defaultReason
if (checksDisagree && setupConfigured) {
reason = `${reason} setup.status reports configured credentials, but runtime resolution still failed.`
@@ -163,8 +164,7 @@ export function interpretRuntimeReadiness(
checksDisagree,
ready: false,
reason,
- source: 'runtime_check',
- ...(setupConfigured === false ? { unconfigured: true as const } : {})
+ source: 'runtime_check'
}
}
@@ -173,7 +173,7 @@ export function interpretRuntimeReadiness(
...route,
checksDisagree: false,
ready: setupConfigured,
- reason: setupConfigured ? null : (runtimeFailure ?? setupFailure ?? defaultReason),
+ reason: setupConfigured ? null : ((nothingSetUp ? null : (runtimeFailure ?? setupFailure)) ?? defaultReason),
source: 'setup_status'
}
}
diff --git a/apps/desktop/src/store/onboarding.test.ts b/apps/desktop/src/store/onboarding.test.ts
index 3731916cf34..773d815c118 100644
--- a/apps/desktop/src/store/onboarding.test.ts
+++ b/apps/desktop/src/store/onboarding.test.ts
@@ -24,6 +24,9 @@ import {
// Onboarding's due check answered "not due": first-run surfaces are free to show.
markOnboardingDecided()
+const NOT_CONNECTED =
+ 'Hermes is not connected to any AI provider yet. Run `hermes model` to pick one, or `hermes auth add <provider>`.'
+
function baseState(overrides: Partial<DesktopOnboardingState> = {}): DesktopOnboardingState {
return {
configured: false,
@@ -226,6 +229,33 @@ describe('refreshOnboarding', () => {
expect($desktopOnboarding.get()).toMatchObject({ configured: false, reason: DEFAULT_ONBOARDING_REASON })
})
+ it.each([
+ ['answers', async () => ({ ok: false, error: NOT_CONNECTED }) as never],
+ [
+ 'fails',
+ async () => {
+ throw new Error(NOT_CONNECTED)
+ }
+ ]
+ ])('drops an earlier raw sentence once nothing is set up and the runtime check %s', async (_, runtimeCheck) => {
+ $desktopOnboarding.set(baseState({ reason: NOT_CONNECTED }))
+
+ const unconfigured: OnboardingContext['requestGateway'] = async method => {
+ if (method === 'setup.status') {
+ return { provider_configured: false } as never
+ }
+
+ if (method === 'setup.runtime_check') {
+ return runtimeCheck()
+ }
+
+ throw new Error(`unexpected gateway method: ${method}`)
+ }
+
+ expect(await refreshOnboarding(onboardingContext(unconfigured))).toBe(false)
+ expect($desktopOnboarding.get().reason).not.toContain('hermes model')
+ })
+
it('keeps cached providers when onboarding was not re-requested', async () => {
const api = vi.fn(async ({ path }: { path: string }) => {
if (path === '/api/providers/oauth') {
@@ -1081,7 +1111,7 @@ describe('saveOnboardingLocalEndpoint', () => {
}
if (method === 'setup.status') {
- return { provider_configured: false } as never
+ return { provider_configured: true } as never
}
if (method === 'setup.runtime_check') {
diff --git a/apps/desktop/src/store/onboarding.ts b/apps/desktop/src/store/onboarding.ts
index 407db9fff63..acf828dff80 100644
--- a/apps/desktop/src/store/onboarding.ts
+++ b/apps/desktop/src/store/onboarding.ts
@@ -818,7 +818,7 @@ export async function refreshOnboarding(ctx: OnboardingContext, stillWanted?: ()
return false
}
- const reason = (runtime.unconfigured ? null : runtime.reason) || state.reason || DEFAULT_ONBOARDING_REASON
+ const reason = runtime.reason || state.reason || DEFAULT_ONBOARDING_REASON
if (shouldPreserveConfiguredOnBootRace(runtime, state)) {
// The backend answered inside its boot window with a not-ready that is