fix(ollama): add ollama health check#88
Merged
Merged
Conversation
Add an explicit `checkHealth()` utility in `src/utils/ollama.ts` and use it in `src/components/App/App.tsx` to distinguish "Ollama server is unavailable" from generic model-loading failures. Keep `src/components/App/ReadinessCheck.tsx` presentation-only. Key Changes: - Add `checkHealth(): Promise<boolean>` to `src/utils/ollama.ts`. Probe the configured Ollama `host` with a lightweight HTTP request and return `true` for a successful reachable response, `false` for network or unreachable failures. - Update `ReadinessState` in `ReadinessCheck.tsx` to add `ServerUnavailable`. - Update `App.tsx` readiness flow: If no configured model, keep `MissingModelConfig`. If on non-chat screens, keep current behavior and do not re-run readiness work. On chat screen with a configured model, set `Checking`, call `checkHealth()`, and: if `false`, set `ServerUnavailable` and skip `listModels()` if `true`, call `listModels()` if models exist, set `Ready` if no models exist, set `NoInstalledModels` if `listModels()` throws after a healthy probe, set `ModelLoadError` and preserve the thrown message - Update `ReadinessCheck.tsx` UI copy: `Checking`: clarify it is checking Ollama/model setup `ServerUnavailable`: show that the Ollama server is not running or unreachable and instruct the user to run `ollama serve` Keep existing model-config and no-installed-models flows unchanged Keep `ModelLoadError` for unexpected post-healthcheck failures - Export shape remains local to `ollama.ts`; no new module is needed. Public Interfaces: - `src/utils/ollama.ts` Add `checkHealth(): Promise<boolean>` - `src/components/App/ReadinessCheck.tsx` Add `ReadinessState.ServerUnavailable` Test Plan: - Add `ollama.ts` tests for `checkHealth()`: reachable host returns `true` connection failure returns `false` non-network unexpected fetch/setup error behavior matches chosen implementation contract - Update `App.test.tsx`: healthy server + installed models -> chat renders unhealthy server -> readiness screen renders server-unavailable copy and does not depend on `listModels()` success healthy server + zero models -> `NoInstalledModels` healthy server + `listModels()` throws -> `ModelLoadError` - Update `ReadinessCheck.test.tsx`: render coverage for `ServerUnavailable` preserve current expectations for other states Assumptions: - `checkHealth()` will use the same configured `host` already loaded for the Ollama client, not a hardcoded `http://localhost:11434`. - A successful HTTP response from the Ollama base URL is sufficient to treat the server as reachable. - `checkHealth()` is a read-only probe and does not need to expose status codes to callers in v1; `App` only needs a boolean reachability result.
The load-error screen was rendering in a non-menu view, but the `useInput` handler only handled `Esc`/`Ctrl+C` for custom download and active download states, so the error screen prompt was dead. I added a load-error branch that sends `Esc` and `Ctrl+C` back to the menu, and updated the hint text to match.
…ude Ctrl+C - Created `ExitHint` component with internal theme handling - Updated `SelectPromptHint` to show "Esc/Ctrl+C" (using / separator) - Replaced inline exit hints with <ExitHint /> in 3 files
Codecov Report✅ All modified and coverable lines are covered by tests.
🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the motivation for this pull request?
This PR bundles three related improvements to app readiness and UX consistency:
ollama serve).ModelManager,SearchSettings, andSelectPrompt.What is the current behavior?
<Text>with inconsistent dim/color usage.What is the new behavior?
checkHealth(): Promise<boolean>utility probes the configured Ollama host; if unreachable,ReadinessCheckrenders aServerUnavailablestate with copy directing the user to runollama serve.<ExitHint />component (with its own theme handling) replaces all inline exit hints.plan.md
Checklist: