feat(local-ai): add editable Ollama server URL with connection test
Summary
ollama_base_url()previously read only env vars and ignoredconfig.local_ai.base_url; addsollama_base_url_from_config(config)with correct priority chain (config → env → default) and updates bootstrap/health-check/infer/vision-embed callsites- Registers new RPC
openhuman.local_ai_test_connectionthat probes/api/tagswith a 3-second timeout and returns{reachable, error, models_count} - Adds an editable "Ollama Server URL" section to
LocalModelDebugPanel/ModelStatusSection: text input, inline validation, Test Connection button, Save/Reset, seeded from persisted config on mount - Adds
validate_ollama_urlin both Rust and TypeScript (scheme + host + creds + path normalization) - Adds i18n keys (
localModel.ollamaServer.*) across all 12 locale chunks
Problem
- Windows users running Ollama on an existing server/port had no UI way to point OpenHuman at it — the only option was hand-editing
config.toml ollama_base_url()ignoredconfig.local_ai.base_urlentirely, so the config field was effectively a no-op- The bootstrap flow attempted binary discovery/install even when an external server was reachable; once
ollama_healthy()uses the config-aware URL this path is skipped naturally
Solution
ollama_base_url_from_config(config)replaces the env-var-only lookup in all bootstrap-critical callsites;ollama_base_url()zero-arg wrapper preserved for non-critical legacy callsitesensure_ollama_serveris now purely a connectivity check — if the configured endpoint responds, bootstrap proceeds without any binary discovery or install attempt- Frontend seeds URL state from
openhumanGetConfig()on mount so the saved value is visible immediately, not only after running diagnostics - Two-step UX: Test Connection (non-destructive probe) then explicit Save
Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) per Testing Strategy — 4 Rust unit tests for
test_ollama_connection, 8 Vitest tests forModelStatusSectionURL UX, 12 tests forollamaUrlValidation, 8 Rust tests forvalidate_ollama_url+ollama_base_url_from_config - [x] Diff coverage ≥ 80% — all new logic paths covered; 2627/2630 Vitest tests pass; Rust tests pass
- [x] N/A: Coverage matrix updated — no new feature rows; this wires an existing config field to UI
- [x] N/A: All affected feature IDs listed — behaviour-only config wiring, no new feature IDs
- [x] No new external network dependencies introduced —
test_ollama_connectionuses the existingreqwestclient already in scope; mock Axum server used in Rust tests - [x] N/A: Manual smoke checklist updated — Local Model debug panel; no release-cut surface change
- [x] Linked issue closed via
Closes #2159in Related section
Impact
- Desktop only (Local Model settings panel in Tauri shell)
- No performance or security implications; the connection test is a read-only GET with a 3-second timeout
ollama_base_url()zero-arg form unchanged — non-critical callsites (embeddings, memory, triage) are unaffected
Related
Closes #2159
AI Authored PR Metadata (required for Codex/Linear PRs)
Keep this section for AI-authored PRs. For human-only PRs, mark each field
N/A.
Linear Issue
- Key: N/A
- URL: N/A
Commit & Branch
- Branch: feat/ollama-external-server-url
- Commit SHA: 2011507fc27799a3b92ad4fd921a85a419a206fd
Validation Run
- [x]
pnpm --filter openhuman-app format:check - [x]
pnpm typecheck - [x] Focused tests:
pnpm debug unit— 2627 passed, 0 failed;cargo test -p openhuman test_ollama_connection— 4 passed - [x] Rust fmt/check (if changed):
cargo check --manifest-path Cargo.tomlclean - [x] Tauri fmt/check (if changed):
cargo check --manifest-path app/src-tauri/Cargo.tomlclean
Validation Blocked
- command: N/A
- error: N/A
- impact: N/A
Behavior Changes
- Intended behavior change: Users can now configure, test, and save an external Ollama server URL from the Local Model debug panel; the saved URL is used by all local-AI inference paths
- User-visible effect: New "Ollama Server URL" section in Settings → Developer → Local Model with editable input, Test Connection button, and Save/Reset
Parity Contract
- Legacy behavior preserved:
ollama_base_url()zero-arg unchanged; env varOPENHUMAN_OLLAMA_BASE_URLstill overrides default when config field is unset - Guard/fallback/dispatch parity checks: Bootstrap health check now uses config-aware URL; fallback to env var → default preserved when
config.local_ai.base_urlisNone
Duplicate / Superseded PR Handling
- Duplicate PR(s): N/A
- Canonical PR: this one
- Resolution (closed/superseded/updated): N/A
Summary by CodeRabbit
- New Features
- Configurable Ollama server URL in settings with Test / Save / Reset controls; input seeded from app config and shows reachability, model count, and validation feedback.
- Added a connectivity test API and URL validation/normalization for user-supplied Ollama endpoints.
- Bug Fixes / Behavior
- Filesystem tools now use canonical, containment-aware path validation with clearer failure messages.
- Documentation
- Expanded developer guidance: fixes & gotchas, workflow checklist, testing caveats (coverage race), repo/CI tips.
- Tests
- Added/extended tests for URL validation, connection testing, settings UI, and security/path handling.
- Localization
- Added translations for the Ollama server UI across multiple languages.
[!NOTE]
Reviews paused
It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the
reviews.auto_review.auto_pause_after_reviewed_commitssetting.Use the following commands to manage reviews:
@coderabbitai resumeto resume automatic reviews.@coderabbitai reviewto trigger a single review.Use the checkboxes below for quick actions:
- [ ] ▶️ Resume reviews
- [ ] 🔍 Trigger review
📝 Walkthrough
Walkthrough
Adds editable Ollama Server URL end-to-end: client validation, UI Test/Save/Reset, RPC + backend connectivity probe and normalization, i18n and tests. Simultaneously replaces string-only path checks with canonicalization-based async validators and updates filesystem tools and tests to use them.
Changes
External Ollama Server Configuration
| Layer / File(s) | Summary |
|---|---|
Docs / memory .claude/memory.md |
Adds Ollama URL gotchas, tooling caveats, project/git tips, workflow checklist, and security-policy notes. |
Client URL validation app/src/utils/ollamaUrlValidation.ts, app/src/utils/ollamaUrlValidation.test.ts |
Frontend validateOllamaUrl() enforces http/https, forbids credentials/query/fragments, trims/strips path, and returns normalized scheme://host[:port]; tested for acceptance/rejection and normalization. |
Renderer↔Core RPC wrapper app/src/utils/tauriCommands/localAi.ts, app/src/utils/tauriCommands/localAi.test.ts |
Adds OllamaConnectionTestResult and openhumanLocalAiTestConnection(url) with tests verifying RPC call shape and error propagation. |
RPC schema & handler src/openhuman/inference/local/schemas.rs, src/openhuman/inference/local/schemas_tests.rs |
Adds local_ai_test_connection controller schema/params and handler that invokes backend connectivity test and returns JSON; registry test updated. |
Ollama admin/service src/openhuman/inference/local/service/ollama_admin.rs, src/openhuman/inference/local/service/ollama_admin_tests.rs, src/openhuman/inference/local/service/mod.rs |
Refactors admin helpers to accept explicit base URLs; adds ollama_healthy_at, list_models_at, has_model_at, and test_ollama_connection() which validates/normalizes a URL and probes /api/tags; tests updated to use mock endpoints. |
Inference/embed integration src/openhuman/inference/local/service/public_infer.rs, src/openhuman/inference/local/service/vision_embed.rs |
Chat/inference/embed derive base URL from Config and use URL-aware error formatting (redacted) and logging. |
Rust Ollama utils src/openhuman/inference/local/ollama.rs |
Adds ollama_base_url_from_config, validate_ollama_url, and redact_ollama_base_url with unit tests for normalization, validation, and redaction. |
Frontend UI and state app/src/components/settings/panels/LocalModelDebugPanel.tsx, app/src/components/settings/panels/local-model/ModelStatusSection.tsx |
Adds editable Ollama Server URL input, seeds from Rust config on mount, Test/Save/Reset handlers calling RPC and settings RPC, and wires new props to ModelStatusSection. |
Frontend tests & i18n app/src/components/settings/panels/__tests__/LocalModelDebugPanel.test.tsx, app/src/components/settings/panels/local-model/ModelStatusSection.test.tsx, app/src/lib/i18n/* |
Adds tests for initialization/seeding, Test/Save/Reset behavior and RPC calls; adds localModel.ollamaServer.* translation keys across language chunks. |
Security Policy Path Validation Refactor
| Layer / File(s) | Summary |
|---|---|
Core security policy API src/openhuman/security/policy.rs |
Replaces is_path_allowed() with is_path_string_allowed() (string-only checks), adds expand_tilde(), and new async validate_path() / validate_parent_path() that canonicalize targets/ancestors, verify workspace containment, and enforce forbidden-directory blocking. |
Security policy tests src/openhuman/security/policy_tests.rs |
Updates assertions to use is_path_string_allowed() and adds async #[tokio::test] coverage for canonicalized validate_path() / validate_parent_path() behavior including symlink escape and forbidden-path checks. |
Filesystem tools integration src/openhuman/tools/impl/browser/image_info.rs, src/openhuman/tools/impl/filesystem/{apply_patch,csv_export,edit_file,file_read,file_write,grep,list_files}.rs |
Tools now call validate_path() / validate_parent_path() and use the resolved canonical paths for filesystem operations; validation failures return ToolResult::error. |
Scheduler gate update src/openhuman/cron/scheduler.rs |
Switched forbidden_path_argument() to call is_path_string_allowed() for CLI-argument path detection. |
Sequence Diagram(s)
sequenceDiagram
participant User
participant ModelStatusSection
participant LocalModelDebugPanel
participant RPC as openhumanLocalAiTestConnection
participant Core as Rust Backend
User->>ModelStatusSection: Type Ollama URL
ModelStatusSection->>ModelStatusSection: validateOllamaUrl()
ModelStatusSection->>User: Show validation error or enable Test/Save
User->>ModelStatusSection: Click "Test Connection"
ModelStatusSection->>LocalModelDebugPanel: onTestConnection()
LocalModelDebugPanel->>RPC: openhumanLocalAiTestConnection(url)
RPC->>Core: call openhuman.local_ai_test_connection
Core->>Core: test_ollama_connection() validates & probes /api/tags
Core-->>RPC: JSON {reachable, models_count, error}
RPC-->>LocalModelDebugPanel: OllamaConnectionTestResult
LocalModelDebugPanel->>ModelStatusSection: connectionTestResult prop
ModelStatusSection->>User: Display "Reachable (N models)" or error
User->>ModelStatusSection: Click "Save"
ModelStatusSection->>LocalModelDebugPanel: onSaveOllamaBaseUrl()
LocalModelDebugPanel->>RPC: openhumanUpdateLocalAiSettings({base_url})
RPC->>Core: update config.local_ai.base_url
Core->>Core: persist to config.toml
Core-->>RPC: success
RPC-->>LocalModelDebugPanel: update savedOllamaBaseUrl state
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related issues
- tinyhumansai/openhuman#2159: Implements the editable Ollama server URL, validation, connection testing, and persistence requested by that issue.
- tinyhumansai/openhuman#1927: The canonicalization-based path validators address the symlink-bypass/symlink-escape concerns reported there.
Possibly related PRs
- tinyhumansai/openhuman#1975: Related Ollama-area UI changes; may overlap with base-URL handling.
- tinyhumansai/openhuman#2165: Related frontend/state changes around
local_ai.base_urlpersistence and normalization. - tinyhumansai/openhuman#1975: (duplicate noted in similarity; included due to close overlap)
Suggested reviewers
- graycyrus
- senamakel
Poem
🐰 I found a URL in the glen,
I tested and trimmed it, then and then —
Paths now canonical, safe to behold,
Configs saved, tests brave and bold,
Hooray — the Ollama's greeting is told!
🚥 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 title 'feat(local-ai): add editable Ollama server URL with connection test' clearly summarizes the main change: adding editable Ollama URL functionality with connection testing capability. |
| Linked Issues check | ✅ Passed | The PR fully addresses all acceptance criteria from #2159: editable URL field with validation, connection test, external server support, bootstrap skip, config persistence, read-only display update, regression tests, and meets diff-coverage requirements. |
| Out of Scope Changes check | ✅ Passed | All changes are scoped to adding Ollama server URL configuration and connection testing. Security policy refactoring supports the required path validation for file tools. |
| 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.