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
test(inference): address review — assertable templates, a real precondition, offline Ollama\n\nReview fixes for #5879. NOT EXECUTED LOCALLY: the no-local-builds rule landed\nmid-way, so everything below is reasoned from source and CI is the check. I have\nsaid so on each thread rather than implying these were run.\n\n**EmbeddingsSetupModal — two tests that could not fail (YellowSnnowmann).**\nThe i18n mock returned the key for every lookup, so `t('…testSuccess')` yielded\nthe literal key with no `{dims}` placeholder and the component's\n`.replace('{dims}', …)` was a no-op. `actual_dimensions: 1536`, the `?? '?'`\nfallback, and dropping the substitution entirely all rendered identically — the\ntest name promised a check it never made, and the same held for `{error}`. The\nmock now returns the real `en.ts` templates for exactly those two keys, and the\ntests assert the substituted output (`Connected: 1536 dimensions`,\n`Failed: bad key`). Added the `?` fallback case, which is now expressible.\n\n**EmbeddingsSetupModal — a name that contradicted its assertion\n(YellowSnnowmann).** "locks both buttons while testing" asserted Save is\n*enabled*. The assertion is the correct one — Save stays live so a user who has\nalready pasted a working key is not blocked behind a slow probe — so the name is\nwhat was wrong. Renamed, with the reason in a comment.\n\n**AgentInsightsPreview — a precondition that was doing no work (CodeRabbit).**\nThe "leaves errors alone" half only exercises anything if the fixture contains\nan error entry. Removing that fixture, or flipping it to success, would have\nleft the test green while it silently stopped checking preservation. Now asserts\nan error entry exists before the mapping check, and that one survives.\n\n**Rust controller suite — it was not actually offline (chatgpt-codex).** Correct\nand specific: `assets_status` and `downloads_progress` reach\n`LocalAiService::assets_status`, which probes `GET {base}/api/tags` with a\ntwo-second timeout, defaulting to localhost:11434 and honouring the ambient\n`OLLAMA_HOST`. So the suite made real socket calls and behaved differently on a\nmachine running Ollama — contradicting its own header. Both tests now pin\n`OPENHUMAN_OLLAMA_BASE_URL` to a closed loopback port (discard port 9, so\nconnect is refused instantly rather than timing out) and clear `OLLAMA_HOST`.\nThe header no longer overclaims.\n\n**One ask answered rather than implemented (CodeRabbit, credential redaction).**\n`presentProviderSetupError` performs no redaction, so a custom provider echoing\nan arbitrary-shaped key reaches the DOM. The concern is real, but redacting is a\nproduct change that would also hide diagnostics, and this is a test-only PR.\nAdded a characterisation test pinning the current behaviour with a pointer to\nthe bug list, so the gap is visible and regression-locked; the fix belongs in\nits own PR.\n
M3gA-Minda1f87e74dbf9
diff --git a/app/src/components/settings/panels/__tests__/EmbeddingsSetupModal.test.tsx b/app/src/components/settings/panels/__tests__/EmbeddingsSetupModal.test.tsxindex fc69eba4c1..52553fc120 100644--- a/app/src/components/settings/panels/__tests__/EmbeddingsSetupModal.test.tsx+++ b/app/src/components/settings/panels/__tests__/EmbeddingsSetupModal.test.tsx@@ -15,7 +15,24 @@ import type {} from '../../../../services/api/embeddingsApi';import EmbeddingsSetupModal, { type EmbeddingsSetupModalProps } from '../EmbeddingsSetupModal';-vi.mock('../../../../lib/i18n/I18nContext', () => ({ useT: () => ({ t: (key: string) => key }) }));+/**+ * The mock returns the key for most lookups, which keeps assertions readable.+ * Two keys are the exception: `testSuccess` and `testFailed` are TEMPLATES that+ * the component fills with `.replace('{dims}', …)` / `.replace('{error}', …)`+ * (`EmbeddingsSetupModal.tsx:191-195`). Returning the bare key there makes+ * `.replace()` a no-op, so the substituted value never reaches the DOM and a+ * component that stopped surfacing it would keep the test green. Returning the+ * real templates (from `en.ts`) is what makes the substitution assertable.+ */+vi.mock('../../../../lib/i18n/I18nContext', () => ({+ useT: () => ({+ t: (key: string) => {+ if (key === 'settings.embeddings.testSuccess') return 'Connected: {dims} dimensions';+ if (key === 'settings.embeddings.testFailed') return 'Failed: {error}';+ return key;+ },+ }),+}));const provider = (over: Partial<EmbeddingProviderEntry> = {}): EmbeddingProviderEntry => ({slug: 'openai',@@ -155,12 +172,17 @@ describe('EmbeddingsSetupModal — feedback', () => {it('reports a successful test with the dimensions the provider returned', () => {renderModal({ setupTestResult: result({ actual_dimensions: 1536 }) });- expect(screen.getByText('settings.embeddings.testSuccess')).toBeInTheDocument();+ expect(screen.getByText('Connected: 1536 dimensions')).toBeInTheDocument();+ });++ it('falls back to ? when the provider reports no dimension count', () => {+ renderModal({ setupTestResult: result({ actual_dimensions: undefined }) });+ expect(screen.getByText('Connected: ? dimensions')).toBeInTheDocument();});- it('reports a failed test', () => {+ it('reports a failed test with the provider error', () => {renderModal({ setupTestResult: result({ success: false, error: 'bad key' }) });- expect(screen.getByText('settings.embeddings.testFailed')).toBeInTheDocument();+ expect(screen.getByText('Failed: bad key')).toBeInTheDocument();});it('surfaces a save error verbatim', () => {@@ -168,7 +190,9 @@ describe('EmbeddingsSetupModal — feedback', () => {expect(screen.getByText('could not write config')).toBeInTheDocument();});- it('shows progress labels and locks both buttons while testing', () => {+ // Testing locks the Test button only — Save stays live on purpose, so a user+ // who has already pasted a working key is not blocked behind a slow probe.+ it('locks Test but leaves Save available while a test is running', () => {renderModal({ setupKey: 'sk-live', setupTesting: true });expect(screen.getByRole('button', { name: 'settings.embeddings.testing' })).toBeDisabled();diff --git a/app/src/components/settings/panels/__tests__/ProviderSetupErrorNotice.test.tsx b/app/src/components/settings/panels/__tests__/ProviderSetupErrorNotice.test.tsxindex 03be772a71..a8704610d2 100644--- a/app/src/components/settings/panels/__tests__/ProviderSetupErrorNotice.test.tsx+++ b/app/src/components/settings/panels/__tests__/ProviderSetupErrorNotice.test.tsx@@ -110,6 +110,27 @@ describe('presentProviderSetupError', () => {expect(summary).toBe('Provider setup failed.');});+ // CHARACTERISES A GAP, not desired behaviour. `presentProviderSetupError`+ // performs no redaction: `findProviderJsonMessage` lifts the provider's+ // `message` verbatim and `details` is the raw error. The backend redacts a+ // fixed set of known token prefixes, so a CUSTOM provider echoing an+ // arbitrary-shaped credential reaches the DOM intact.+ //+ // Pinned so the gap is visible and regression-locked rather than implied.+ // Redacting at this boundary is a product change — it would also hide+ // diagnostics a user may need — so it belongs in its own PR, not in a+ // test-only one. Recorded in ~/tinyhuman/bugs/W1-ui-bugs.md. When redaction+ // lands, invert these assertions.+ it('echoes an arbitrary provider credential verbatim (known gap)', () => {+ const secret = 'zz-corp-9f8e7d6c5b4a3210';+ const { summary, details } = present(+ `Could not reach CustomLLM: {"error":{"message":"Invalid token: ${secret}"}}`+ );++ expect(summary).toContain(secret);+ expect(details).toContain(secret);+ });+it('preserves the raw error as details, untouched', () => {const raw = 'Could not reach OpenAI: provider returned 401 {"message":"nope"}';expect(present(raw).details).toBe(raw);diff --git a/app/src/pages/dev/__tests__/AgentInsightsPreview.test.tsx b/app/src/pages/dev/__tests__/AgentInsightsPreview.test.tsxindex 40eb87362e..31e063ef0c 100644--- a/app/src/pages/dev/__tests__/AgentInsightsPreview.test.tsx+++ b/app/src/pages/dev/__tests__/AgentInsightsPreview.test.tsx@@ -78,14 +78,23 @@ describe('AgentInsightsPreview', () => {expect(running.some(e => e.status === 'running')).toBe(true);expect(running.some(e => e.status === 'success')).toBe(true);expect(running.some(e => e.subagent)).toBe(true);+ expect(running.some(e => e.status === 'error')).toBe(true);});it('settles every non-error entry to success and leaves errors alone', () => {const { running, settled } = renderPreview();+ // Precondition, not decoration: the "leaves errors alone" half of this test+ // only exercises anything if the fixture actually contains an error entry.+ // Without this, removing the error fixture (or flipping it to 'success')+ // would leave the test green while it silently stopped checking+ // preservation at all.+ expect(running.some(e => e.status === 'error')).toBe(true);+settled.forEach((entry, i) => {expect(entry.status).toBe(running[i].status === 'error' ? 'error' : 'success');});+ expect(settled.some(e => e.status === 'error')).toBe(true);expect(settled.some(e => e.status === 'running')).toBe(false);});diff --git a/tests/raw_coverage/inference_local_controllers_rpc_raw_coverage_e2e.rs b/tests/raw_coverage/inference_local_controllers_rpc_raw_coverage_e2e.rsindex ebe4b83c58..a17f7ed301 100644--- a/tests/raw_coverage/inference_local_controllers_rpc_raw_coverage_e2e.rs+++ b/tests/raw_coverage/inference_local_controllers_rpc_raw_coverage_e2e.rs@@ -27,8 +27,20 @@//!//! # Offline discipline//!-//! Temp workspaces, a temp PATH, and a stub `piper` shell script only. Nothing-//! here starts a server, opens a socket, or downloads an asset: the download and+//! Temp workspaces, a temp PATH, and a stub `piper` shell script only.+//!+//! Two of these controllers (`assets_status`, `downloads_progress`) reach+//! `LocalAiService::assets_status`, which probes `GET {ollama_base_url}/api/tags`+//! with a two-second timeout. That base URL defaults to `localhost:11434` and is+//! also taken from the ambient `OLLAMA_HOST`, so without pinning it this suite+//! would make real socket calls — behaving differently on a machine that+//! happens to be running Ollama, and costing up to two seconds per call. Every+//! test therefore pins `OPENHUMAN_OLLAMA_BASE_URL` (the app-specific override,+//! `ollama.rs:76`) to a closed loopback port and clears `OLLAMA_HOST`, so the+//! probe is refused immediately and deterministically.+//!+//! Beyond that, nothing here starts a server, opens a listening socket, or+//! downloads an asset: the download and//! STT paths are driven to their *rejection* branches on purpose, because the//! bundled whisper.cpp engine was deleted and `transcribe` is now a hosted proxy//! call with no local binary to stub — see the note at@@ -92,6 +104,19 @@ impl Drop for EnvVarGuard {}}+/// Point the Ollama health probe at a closed loopback port and clear the+/// ambient override, so `assets_status` fails its probe instantly instead of+/// dialling a real service (or waiting out a two-second timeout).+///+/// Port 9 is the discard port: nothing listens, so connect() is refused rather+/// than hanging. Returned as guards — hold them for the life of the test.+fn pin_offline_ollama() -> (EnvVarGuard, EnvVarGuard) {+ (+ EnvVarGuard::set("OPENHUMAN_OLLAMA_BASE_URL", "http://127.0.0.1:9"),+ EnvVarGuard::unset("OLLAMA_HOST"),+ )+}+fn controller<'a>(controllers: &'a [RegisteredController],function: &str,@@ -433,6 +458,9 @@ async fn inference_transcribe_controllers_cover_params_trimming_and_local_reject#[tokio::test]async fn inference_download_asset_controller_covers_disabled_unknown_and_case_folding() {let _lock = env_lock();+ // `download_asset` ends in `assets_status`, which probes Ollama — pin it+ // even though every branch asserted here errors before reaching that call.+ let _ollama = pin_offline_ollama();let tmp = tempdir().expect("tempdir");let mut config = temp_config(&tmp);config.local_ai.runtime_enabled = false;@@ -570,6 +598,7 @@ async fn inference_agent_chat_simple_controller_covers_params_and_prompt_guard()#[tokio::test]async fn inference_status_controllers_tolerate_extra_params_and_reject_bad_urls() {let _lock = env_lock();+ let _ollama = pin_offline_ollama();let tmp = tempdir().expect("tempdir");let mut config = temp_config(&tmp);config.local_ai.runtime_enabled = false;