Skip to content

fix(local-ai): fix false-negative Ollama diagnostics (binary + model detection)#1327

Merged
senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/1293-local-ai-diagnostics
May 7, 2026
Merged

fix(local-ai): fix false-negative Ollama diagnostics (binary + model detection)#1327
senamakel merged 2 commits into
tinyhumansai:mainfrom
M3gA-Mind:fix/1293-local-ai-diagnostics

Conversation

@M3gA-Mind
Copy link
Copy Markdown
Contributor

@M3gA-Mind M3gA-Mind commented May 7, 2026

Summary

  • Fix binary detection missing macOS drag-install path (/Applications/Ollama.app/Contents/Resources/ollama)
  • Unify diagnostics' resolve_binary_path with bootstrap's broader detection (adds OLLAMA_BIN env + all workspace candidates)
  • Honor OLLAMA_HOST env var as URL fallback in ollama_base_url() so health checks hit the correct endpoint
  • Enrich diagnostics JSON with ollama_base_url + repair_actions for actionable one-click fixes in the UI
  • UI: show checked endpoint, fix "Not found" when server is running via external process, render per-issue repair buttons

Problem

  • Ollama installed via the macOS .app bundle was never found by find_system_ollama_binary() — it only checked /usr/local/bin and /opt/homebrew/bin, not the standard /Applications/Ollama.app/Contents/Resources/ollama path.
  • Diagnostics used a simpler, narrower binary-detection path than bootstrap, so bootstrap could launch Ollama successfully while diagnostics still reported "binary not found".
  • If OLLAMA_HOST was set (Ollama's own env var), health checks hit the wrong port and reported the server as down, cascading into all models showing as missing.

Solution

  • Added macOS app bundle paths to find_system_ollama_binary() in install.rs.
  • Rewrote resolve_binary_path() to mirror bootstrap's priority order: configured path → OLLAMA_BIN → workspace candidates → PATH scan → platform paths.
  • Added OLLAMA_HOST fallback in ollama_base_url() with scheme normalization.
  • Extended diagnostics() to always emit ollama_base_url and a repair_actions array (install_ollama / start_server / pull_model per missing model).
  • Updated LocalAiDiagnostics TS interface and ModelStatusSection.tsx to surface these fields.

Submission Checklist

  • Tests added or updated (happy path + at least one failure / edge case) per docs/TESTING-STRATEGY.md
  • Diff coverage ≥ 80% — 20+ Rust unit tests + 13 Vitest tests cover all changed paths; cargo test and pnpm test:unit pass locally.
  • N/A: Coverage matrix updated — no new feature rows; this is a bug fix to existing local-AI diagnostics behaviour.
  • N/A: All affected feature IDs listed — behaviour-only fix, no matrix row changes.
  • No new external network dependencies introduced (all tests mock the Ollama HTTP endpoint).
  • N/A: Manual smoke checklist updated — no release-cut surface changes.
  • Linked issue closed via Closes #1293 in Related section.

Impact

  • Desktop only (macOS primary repro; Linux/Windows binary-detection paths unchanged).
  • No performance, security, or migration implications — purely additive diagnostics data.

Related

Closes #1293

  • Follow-up: consider wiring "Pull model" repair action to an actual ollama pull invocation via bootstrap pipeline.

AI Authored PR Metadata (required for Codex/Linear PRs)

Linear Issue

  • Key: N/A
  • URL: N/A

Commit & Branch

  • Branch: fix/1293-local-ai-diagnostics
  • Commit SHA: PLACEHOLDER

Validation Run

  • pnpm --filter openhuman-app format:check
  • pnpm typecheck
  • Focused tests: pnpm debug unit local-model (13 passed), cargo test --lib local_ai (181 passed)
  • Rust fmt/check (if changed): clean
  • N/A: Tauri fmt/check (if changed): no Tauri shell changes

Validation Blocked

  • command: N/A
  • error: N/A
  • impact: N/A

Behavior Changes

  • Intended behavior change: Diagnostics now accurately reflects Ollama installation state on macOS and surfaces actionable repair options.
  • User-visible effect: "Ollama not running / binary not found" false negatives eliminated when Ollama is installed and reachable.

Parity Contract

  • Legacy behavior preserved: All existing bootstrap, install, and server-start paths unchanged; diagnostics is read-only.
  • Guard/fallback/dispatch parity checks: OPENHUMAN_OLLAMA_BASE_URL still takes priority over OLLAMA_HOST and the default.

Duplicate / Superseded PR Handling

  • Duplicate PR(s): None
  • Canonical PR: This PR
  • Resolution: N/A

Summary by CodeRabbit

  • New Features

    • Added suggested fixes in the diagnostics panel that recommend actions like installing Ollama, starting the server, or pulling required models.
    • Enhanced Ollama server URL configuration to support environment variable overrides with improved scheme handling.
    • Improved detection of local Ollama installations across multiple system locations.
  • Tests

    • Added comprehensive test coverage for diagnostics, repair actions, and Ollama binary detection.

M3gA-Mind added 2 commits May 7, 2026 15:38
…odels

- Add /Applications/Ollama.app/Contents/Resources/ollama and
  ~/Applications/... to find_system_ollama_binary() so macOS drag-install
  is detected correctly
- Unify resolve_binary_path() with bootstrap's broader detection: now
  checks OLLAMA_BIN env and all workspace binary candidates, not just a
  single path
- Honor OLLAMA_HOST env var as fallback in ollama_base_url() (priority:
  OPENHUMAN_OLLAMA_BASE_URL > OLLAMA_HOST > default localhost:11434)
- Include ollama_base_url and repair_actions in diagnostics JSON so the
  UI can show which endpoint is checked and surface one-click fixes
- Update LocalAiDiagnostics TS interface with new fields
- Show "Running via external process" instead of "Not found" when binary
  path is unknown but server is reachable
- Render fine-grained repair action buttons (install / start / pull model)
  in ModelStatusSection diagnostics panel
- Add 20+ Rust unit tests and 13 Vitest tests covering all changed paths

Closes tinyhumansai#1293
@M3gA-Mind M3gA-Mind requested a review from a team May 7, 2026 10:35
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 7, 2026

Review Change Stack
No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 27f76b04-8020-4a58-a204-e954ca07d061

📥 Commits

Reviewing files that changed from the base of the PR and between 894485a and b43d6b6.

📒 Files selected for processing (7)
  • app/src/components/settings/panels/local-model/ModelStatusSection.test.tsx
  • app/src/components/settings/panels/local-model/ModelStatusSection.tsx
  • app/src/utils/tauriCommands/localAi.ts
  • src/openhuman/local_ai/install.rs
  • src/openhuman/local_ai/ollama_api.rs
  • src/openhuman/local_ai/service/ollama_admin.rs
  • src/openhuman/local_ai/service/ollama_admin_tests.rs

📝 Walkthrough

Walkthrough

This PR adds intelligent repair actions to local AI diagnostics. The backend now detects Ollama configuration via environment variables (OLLAMA_HOST, OPENHUMAN_OLLAMA_BASE_URL), resolves the binary path through multiple strategies, and generates actionable remediation suggestions (install, start, pull models). The frontend renders these as interactive buttons, enabling users to fix setup issues without manual terminal work.

Changes

Ollama Diagnostics with Repair Actions

Layer / File(s) Summary
Data and Type Contracts
app/src/utils/tauriCommands/localAi.ts
Adds RepairAction union type (install_ollama, start_server, pull_model); extends LocalAiDiagnostics with ollama_base_url and repair_actions[]; adds local_ai_enabled to ApplyPresetResult.
Ollama Base URL Resolution
src/openhuman/local_ai/ollama_api.rs
Multi-source URL resolution: OPENHUMAN_OLLAMA_BASE_URL first, then OLLAMA_HOST (with scheme normalization), then default; includes trimming and trailing slash removal. Test helper expanded for arbitrary env var guards.
Binary Path Resolution
src/openhuman/local_ai/service/ollama_admin.rs
Multi-step binary resolution: configured path, OLLAMA_BIN env var, workspace binary, PATH search, platform-specific well-known locations.
macOS System Binary Discovery
src/openhuman/local_ai/install.rs
Refactors macOS Ollama.app detection to build bundle-relative paths checking both /Applications and ~/Applications via HOME env var. New test validates bundle discovery.
Diagnostics Backend with Repair Actions
src/openhuman/local_ai/service/ollama_admin.rs
Computes ollama_base_url, resolves binary path, builds repair_actions array mapping issues to remediation steps (install/start/pull), includes in returned JSON diagnostics report.
Diagnostics Tests (Rust)
src/openhuman/local_ai/service/ollama_admin_tests.rs
Validates ollama_base_url presence, repair_actions array when unreachable; verifies base URL and pull_model for missing models; tests embedding detection and empty repairs when installed; validates binary resolution via OLLAMA_BIN; asserts start_server action when binary present but down; ensures repair_actions always a JSON array.
Frontend UI Components
app/src/components/settings/panels/local-model/ModelStatusSection.tsx
Imports RepairAction, adds onRepairAction callback prop, implements repairActionLabel helper; renders ollama_base_url in Server card with truncation/tooltip; updates Binary card for null path with conditional messaging; adds Suggested Fixes button group when repair_actions non-empty.
Frontend Tests (React)
app/src/components/settings/panels/local-model/ModelStatusSection.test.tsx
Comprehensive Vitest/Testing Library suite: test helpers (defaultProps, makeDiagnostics); verifies base URL, server status, binary path messaging, repair button rendering/callbacks, pass/fail UI, null diagnostics fallback.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

Suggested reviewers

  • graycyrus
  • senamakel

Poem

🐰 A hop through diagnostics bright,
Repair actions guide the path aright,
No more terminal toil or bother—
Just buttons blue to help each other,
Ollama hops, the models fly!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title clearly and specifically summarizes the main fix: resolving false-negative diagnostics for binary and model detection in Local AI Ollama.
Linked Issues check ✅ Passed The PR comprehensively addresses all coding objectives from issue #1293: accurate binary/model detection [1293], repair actions UI [1293], test coverage [1293], and diagnostics alignment [1293].
Out of Scope Changes check ✅ Passed All changes are scoped to Local AI diagnostics, Ollama binary/URL detection, repair actions infrastructure, and corresponding tests. No extraneous changes detected.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@senamakel senamakel merged commit 3189501 into tinyhumansai:main May 7, 2026
21 checks passed
AusAgentSmith pushed a commit to AusAgentSmith/openhuman that referenced this pull request May 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Local AI diagnostics report Ollama as not running and required models as missing

2 participants