Skip to content

The agent that grows with you

fix(desktop): the local-model notice clears when the server comes back

Tekniumefb8ded70d48
diff --git a/apps/desktop/src/app/shell/hooks/use-status-snapshot.test.ts b/apps/desktop/src/app/shell/hooks/use-status-snapshot.test.ts
index c528de918b3..a431968d362 100644
--- a/apps/desktop/src/app/shell/hooks/use-status-snapshot.test.ts
+++ b/apps/desktop/src/app/shell/hooks/use-status-snapshot.test.ts
@@ -8,8 +8,9 @@ import { getStatus } from '@/hermes'
import { I18nProvider, type Locale, TRANSLATIONS, type Translations } from '@/i18n'
import { $freeTierStatus } from '@/store/free-tier'
import { $setupReadyTick, notifySetupReady } from '@/store/live-sync'
-import { clearNotifications } from '@/store/notifications'
-import { $desktopOnboarding } from '@/store/onboarding'
+import { $notifications, clearNotifications } from '@/store/notifications'
+import { $desktopOnboarding, refreshOnboarding } from '@/store/onboarding'
+import { markOnboardingDecided } from '@/store/onboarding-presence'
import { deferred } from '../../../test/deferred'
@@ -406,6 +407,43 @@ describe('useStatusSnapshot', () => {
expect(result.current.inferenceStatus).toMatchObject({ ready: true, source: 'runtime_check' })
})
+ it('clears the "Local model unavailable" notice once the local server recovers', async () => {
+ // The Webapp opened while the local server was still starting: onboarding stayed exempt
+ // (configured) and raised the notice. Recovery must take it down, not leave "ready" beside it.
+ let serving = false
+
+ const requestGatewayMock = vi.fn(async (method: string) => {
+ if (method === 'setup.runtime_check') {
+ return (
+ serving
+ ? { ok: true }
+ : { error: 'The local model server is not running.', error_code: 'local_runtime_unavailable', ok: false }
+ ) as never
+ }
+
+ return { provider_configured: true } as never
+ })
+
+ const requestGateway = requestGatewayMock as unknown as GatewayRequester
+ markOnboardingDecided()
+ await refreshOnboarding({ requestGateway })
+ const notice = () => $notifications.get().find(item => item.id === 'local-runtime-unavailable')
+ expect(notice()).toBeTruthy()
+
+ const { result } = renderHook(() => useStatusSnapshot('open', requestGateway))
+ await flushAsync()
+ expect(result.current.inferenceStatus).toMatchObject({ errorCode: 'local_runtime_unavailable', ready: false })
+
+ // A starting server announces nothing to this window: the ambient tick keeps checking.
+ serving = true
+ await act(async () => {
+ await vi.advanceTimersByTimeAsync(60_000)
+ })
+
+ expect(result.current.inferenceStatus).toMatchObject({ ready: true })
+ expect(notice()).toBeUndefined()
+ })
+
it('re-reads readiness and the free-tier verdict once per setup.ready, off the status tick', async () => {
const requestGatewayMock = vi.fn(
async (method: string) =>
diff --git a/apps/desktop/src/app/shell/hooks/use-status-snapshot.ts b/apps/desktop/src/app/shell/hooks/use-status-snapshot.ts
index 6aba6ec4d4a..3933c7613b5 100644
--- a/apps/desktop/src/app/shell/hooks/use-status-snapshot.ts
+++ b/apps/desktop/src/app/shell/hooks/use-status-snapshot.ts
@@ -7,7 +7,7 @@ import { isSignedOutStatus } from '@/lib/signed-out-status'
import { $freeTierStatus, refreshFreeTierStatus, setFreeTierRoute } from '@/store/free-tier'
import { $setupReadyTick } from '@/store/live-sync'
import { dismissNotification, notify } from '@/store/notifications'
-import { $desktopOnboarding } from '@/store/onboarding'
+import { $desktopOnboarding, isLocalRuntimeUnavailable, settleLocalRuntimeNotice } from '@/store/onboarding'
import type { StatusResponse } from '@/types/hermes'
// Statusbar health is ambient chrome, not live data — nothing the user acts on
@@ -43,7 +43,8 @@ export function useStatusSnapshot(
let readinessAnswered = false
const publishInferenceStatus = (next: RuntimeReadinessResult | null): void => {
- readinessAnswered = next !== null
+ // A down local model server is not settled: it may be starting, so the tick keeps checking.
+ readinessAnswered = next !== null && !isLocalRuntimeUnavailable(next)
setInferenceStatus(next)
}
@@ -119,6 +120,7 @@ export function useStatusSnapshot(
// became unconfigured. Keep the last authoritative result instead
// of flashing "Inference not ready" during a gateway flap.
publishInferenceStatus(inference)
+ settleLocalRuntimeNotice(inference)
setFreeTierRoute(inference.freeTier)
}
}
diff --git a/apps/desktop/src/store/onboarding.ts b/apps/desktop/src/store/onboarding.ts
index d1cf214d236..98d59faaa21 100644
--- a/apps/desktop/src/store/onboarding.ts
+++ b/apps/desktop/src/store/onboarding.ts
@@ -313,10 +313,26 @@ function shouldPreserveConfiguredOnBootRace(runtime: RuntimeReadinessResult, sta
const LOCAL_RUNTIME_UNAVAILABLE = 'local_runtime_unavailable'
const LOCAL_MODELS_ROUTE = '/settings?tab=providers&pview=local'
+const LOCAL_RUNTIME_NOTICE_ID = 'local-runtime-unavailable'
+
function isLocalRuntimeDown(runtime: RuntimeReadinessResult, state: DesktopOnboardingState): boolean {
return runtime.source === 'runtime_check' && runtime.errorCode === LOCAL_RUNTIME_UNAVAILABLE && !state.requested
}
+/** True while the verdict is "the local model server is down": a server that is starting or being
+ * switched back on announces nothing to this window, so the readiness tracker keeps re-checking. */
+export function isLocalRuntimeUnavailable(runtime: RuntimeReadinessResult | null): boolean {
+ return runtime?.ready === false && runtime.errorCode === LOCAL_RUNTIME_UNAVAILABLE
+}
+
+/** Readiness answered ready: the server came up, so the notice raised while it was down goes. The
+ * onboarding exemption means no onboarding round runs on recovery to clear it there. */
+export function settleLocalRuntimeNotice(runtime: RuntimeReadinessResult) {
+ if (runtime.ready) {
+ dismissNotification(LOCAL_RUNTIME_NOTICE_ID)
+ }
+}
+
// The Webapp has no Local models pane (the flag is Electron-only), so there the way forward it can
// offer is another model, and the sentence must not send the user to a pane they cannot open.
const WEBAPP_LOCAL_RUNTIME_DOWN =
@@ -331,7 +347,7 @@ function keepConfiguredWithLocalRuntimeDown(reason: string) {
action: pane
? { label: 'Open Local models', onClick: () => requestRoute(LOCAL_MODELS_ROUTE) }
: { label: 'Choose another model', onClick: () => setModelPickerOpen(true) },
- id: 'local-runtime-unavailable',
+ id: LOCAL_RUNTIME_NOTICE_ID,
kind: 'warning',
message: pane ? reason : WEBAPP_LOCAL_RUNTIME_DOWN,
title: 'Local model unavailable'
@@ -783,7 +799,7 @@ export function closeManualOnboarding() {
export function completeDesktopOnboarding(connected = false) {
clearPoll()
dismissNotification('runtime-not-ready')
- dismissNotification('local-runtime-unavailable')
+ dismissNotification(LOCAL_RUNTIME_NOTICE_ID)
writeCachedConfigured(true)
if (connected) {