Skip to content

fix(ollama): add ollama health check#88

Merged
remarkablemark merged 4 commits into
masterfrom
fix/ollama
May 19, 2026
Merged

fix(ollama): add ollama health check#88
remarkablemark merged 4 commits into
masterfrom
fix/ollama

Conversation

@remarkablemark
Copy link
Copy Markdown
Member

@remarkablemark remarkablemark commented May 19, 2026

What is the motivation for this pull request?

This PR bundles three related improvements to app readiness and UX consistency:

  1. Ollama health check – distinguish "server unavailable" from generic model-load failures so users see actionable copy (ollama serve).
  2. ExitHint component – centralise the "Esc/Ctrl+C to exit" hint with consistent theming across ModelManager, SearchSettings, and SelectPrompt.
  3. ModelManager error-state keyboard handling – the load-error screen was unresponsive to Esc/Ctrl+C; now navigates back to the menu.

What is the current behavior?

  • A network failure reaching the Ollama server surfaces the same error screen as a model-load failure, with no guidance on how to fix it.
  • Each screen that needs an exit hint duplicates its own inline <Text> with inconsistent dim/color usage.
  • Pressing Esc or Ctrl+C on the ModelManager load-error screen does nothing.

What is the new behavior?

  • A new checkHealth(): Promise<boolean> utility probes the configured Ollama host; if unreachable, ReadinessCheck renders a ServerUnavailable state with copy directing the user to run ollama serve.
  • A shared <ExitHint /> component (with its own theme handling) replaces all inline exit hints.
  • Esc and Ctrl+C on the ModelManager load-error screen return the user to the menu.

plan.md

Checklist:

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
@remarkablemark remarkablemark changed the title fix(ollama): add ollama health check, ExitHint component, and ModelManager error handling fix(ollama): add ollama health check May 19, 2026
@remarkablemark remarkablemark added the bug Something isn't working label May 19, 2026
@remarkablemark remarkablemark self-assigned this May 19, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/components/App/App.tsx 100.00% <100.00%> (ø)
src/components/App/ReadinessCheck.tsx 100.00% <100.00%> (ø)
src/components/ExitHint/ExitHint.tsx 100.00% <100.00%> (ø)
...omponents/ModelManager/ModelCustomDownloadView.tsx 100.00% <ø> (ø)
src/components/ModelManager/ModelManager.tsx 100.00% <100.00%> (ø)
src/components/SearchSettings.tsx 100.00% <ø> (ø)
src/components/SelectPrompt/SelectPromptHint.tsx 100.00% <100.00%> (ø)
src/utils/ollama.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Comment thread src/utils/ollama.ts Dismissed
@remarkablemark remarkablemark enabled auto-merge May 19, 2026 03:07
@remarkablemark remarkablemark merged commit 7b73189 into master May 19, 2026
16 checks passed
@remarkablemark remarkablemark deleted the fix/ollama branch May 19, 2026 03:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants