The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(ai): simplify Ollama state model to reflect user-run endpoint
Steven Enamakeld1cba854d98d
diff --git a/app/src/components/settings/panels/ai/aiPanelTypes.ts b/app/src/components/settings/panels/ai/aiPanelTypes.tsindex 13ecbc0c85..675e6d662d 100644--- a/app/src/components/settings/panels/ai/aiPanelTypes.ts+++ b/app/src/components/settings/panels/ai/aiPanelTypes.ts@@ -28,14 +28,12 @@ export type CloudProvider = {maskedKey: string;};-export type OllamaState =- | 'disabled'- | 'missing'- | 'stopped'- | 'starting'- | 'running'- | 'degraded'- | 'error';+/**+ * State of the user-run local endpoint. `unreachable` and `stopped` are both+ * offline; `degraded` is reachable but unhealthy. The app never installs or+ * starts the runtime, so there are no install / start / download states.+ */+export type OllamaState = 'disabled' | 'stopped' | 'running' | 'degraded' | 'unreachable';export type OllamaModel = { id: string; sizeBytes: number; family: string };diff --git a/app/src/components/settings/panels/ai/deriveOllamaState.test.ts b/app/src/components/settings/panels/ai/deriveOllamaState.test.tsindex 7ce2367155..386f5982d3 100644--- a/app/src/components/settings/panels/ai/deriveOllamaState.test.ts+++ b/app/src/components/settings/panels/ai/deriveOllamaState.test.ts@@ -33,7 +33,6 @@ function makeSnapshot(ok: false,} as never): null,- presets: null,installedModels: [],};}@@ -61,19 +60,33 @@ describe('deriveOllamaState', () => {expect(deriveOllamaState(makeSnapshot({ ollama_running: true }))).toBe('running');});- it('returns missing when state is missing and ollama is not running', () => {- expect(deriveOllamaState(makeSnapshot({ state: 'missing', ollama_running: false }))).toBe(- 'missing'+ it('returns unreachable when the core cannot reach the user-run endpoint', () => {+ expect(deriveOllamaState(makeSnapshot({ state: 'unreachable', ollama_running: false }))).toBe(+ 'unreachable');});- it('returns starting when state is starting or downloading', () => {- expect(deriveOllamaState(makeSnapshot({ state: 'starting' }))).toBe('starting');- expect(deriveOllamaState(makeSnapshot({ state: 'downloading' }))).toBe('starting');+ it('a live diagnostics probe wins over a stale unreachable status', () => {+ expect(deriveOllamaState(makeSnapshot({ state: 'unreachable', ollama_running: true }))).toBe(+ 'running'+ );+ });++ it('returns degraded when the core reports degraded without a diagnostics verdict', () => {+ expect(deriveOllamaState(makeSnapshot({ state: 'degraded' }))).toBe('degraded');+ });++ it('maps retired managed-runtime states to stopped', () => {+ // The app no longer installs or downloads anything; an older core that+ // still reports these must not surface a phantom progress state.+ for (const state of ['downloading', 'installing', 'starting', 'missing']) {+ expect(deriveOllamaState(makeSnapshot({ state }))).toBe('stopped');+ }});- it('returns error when state is error', () => {- expect(deriveOllamaState(makeSnapshot({ state: 'error' }))).toBe('error');+ it('returns stopped for an idle or ready status without a running probe', () => {+ expect(deriveOllamaState(makeSnapshot({ state: 'idle' }))).toBe('stopped');+ expect(deriveOllamaState(makeSnapshot({ state: 'ready' }))).toBe('stopped');});it('returns stopped as catch-all', () => {diff --git a/app/src/components/settings/panels/ai/useAISettingsState.ts b/app/src/components/settings/panels/ai/useAISettingsState.tsindex d9e21c8530..71d3400eef 100644--- a/app/src/components/settings/panels/ai/useAISettingsState.ts+++ b/app/src/components/settings/panels/ai/useAISettingsState.ts@@ -207,14 +207,19 @@ export function useAISettings() {* UI expects. Extracted as a pure function so it can be unit-tested without* rendering the hook.*+ * The local endpoint is user-run (Ollama / LM Studio / OpenAI-compatible); the+ * app never installs, starts or downloads anything, so there is no+ * starting / downloading / installing state to surface.+ ** Priority order:- * 1. `disabled` — config master switch is off.- * 2. `degraded` — server alive but slow (ollama_status === 'degraded').- * 3. `running` — normal healthy state (ollama_running true, not degraded).- * 4. `missing` — daemon installed but not found on disk.- * 5. `starting` / `downloading` — daemon is coming up.- * 6. `error` — daemon in error state.- * 7. `stopped` — catch-all / no snapshot.+ * 1. `disabled` — config master switch is off.+ * 2. `degraded` — server alive but slow (ollama_status === 'degraded').+ * 3. `running` — normal healthy state (ollama_running true, not degraded).+ * 4. `unreachable` — the core could not reach the configured endpoint+ * (status.state === 'unreachable'); treated as offline.+ * 5. `degraded` — the core reports the runtime degraded without a+ * diagnostics verdict.+ * 6. `stopped` — catch-all / no snapshot.*/export function deriveOllamaState(snapshot: LocalProviderSnapshot | null): OllamaState {if (!snapshot) return 'stopped';@@ -222,9 +227,8 @@ export function deriveOllamaState(snapshot: LocalProviderSnapshot | null): Ollamif (stateStr === 'disabled') return 'disabled';if (snapshot.diagnostics?.ollama_status === 'degraded') return 'degraded';if (snapshot.diagnostics?.ollama_running) return 'running';- if (stateStr === 'missing') return 'missing';- if (stateStr === 'starting' || stateStr === 'downloading') return 'starting';- if (stateStr === 'error') return 'error';+ if (stateStr === 'unreachable') return 'unreachable';+ if (stateStr === 'degraded') return 'degraded';return 'stopped';}