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
fix(voice): address review — stale test result, key trim, dry-run contract\n\nThree review findings on the "Test Key" dry run, all verified locally.\n\n**Stale test result (Codex).** The API-key field is disabled only while\n*saving*, so it stays editable during a test. Test key A, edit to key B\nbefore the response lands, and A's verdict renders beside B — the same\n"the UI is telling you something untrue about this key" failure this PR\nexists to fix. Added a monotonic `testRequestIdRef`, bumped on every test\nstart and every `onChange`; a response whose id is stale is dropped, in\nthe `catch` as well as the `try`. Same guard `CustomRoutingDialog`\nalready uses, so the two dialogs now behave alike.\n\n`setIsTestingKey(false)` stays unconditional in `finally`: the Test\nbutton is disabled while `isTestingKey`, so only one test is ever in\nflight, and gating it would strand the button on "Testing…" when the\nuser edits mid-test.\n\n**Trim the candidate key (CodeRabbit).** The guard tested `apiKey.trim()`\nwhile the payload sent `apiKey`. Note the reviewer's stated rationale was\nwrong — the core already trims before use, so validation succeeded either\nway. The real defect is the inconsistency, which puts an untrimmed\ncredential on the wire for any future consumer that does not trim.\n\n**Reserved slugs broke the dry-run contract (CodeRabbit).** This PR\nrewrote the schema to promise "no inference call", then left reserved\nslugs falling through to `transcribe`/`synthesize`. A doc that lies is\nworse than the vaguer one it replaced, so this needed a structural guard,\nnot a caveat. Reserved slugs now return before either live branch.\n\nDeviating from the suggested fix: it returned `ok: false`. `ok` drives a\nred/green alert, and `cloud`/`openhuman`/`piper` are working providers\nthat simply have no user-held key — reporting a healthy managed provider\nas a failed check is the same misleading-status bug this PR fixes. Return\n`ok: true` with "No API key to validate". No existing caller changes\nbehaviour: the only `validate_only: true` caller is the modal, which\nsends only deepgram/elevenlabs/openai.\n\nVerification (local, through the fleet CI semaphore):\n\n* `cargo test -p openhuman --lib --features voice test_provider` — 9\n passed. `voice` is NOT in the contributor `default` set, so without\n `--features voice` this silently matches zero voice tests.\n* Revert-proof, Rust: restored the derived `Debug` on\n `VoiceTestProviderParams`. Exactly one test failed —\n `voice_test_provider_params_debug_redacts_the_candidate_key` — naming\n its own assertion at `schemas_tests.rs:518`, with the panic output\n showing `api_key: Some("sk-super-secret-value")`. Restored, 9 pass.\n* `vitest run VoicePanel.test.tsx` — 43 passed.\n* Revert-proof, frontend: removing the stale-response guard fails the new\n race test at `VoicePanel.test.tsx:891` on the stale-verdict assertion.\n Restored, 43 pass.\n* `pnpm typecheck` (`tsc --noEmit`) clean; rustfmt and prettier clean.\n\nNot covered by a test: the reserved-slug guard itself.\n`handle_voice_test_provider` calls `load_config_with_timeout()` and this\nmodule has no config-free unit-test seam — every existing test here is at\nthe schema/params layer. Verified by reading, not executed.\n
M3gA-Mind8cf122062cc6
diff --git a/app/src/components/settings/panels/VoicePanelKeyModal.tsx b/app/src/components/settings/panels/VoicePanelKeyModal.tsxindex 1a091b12d2..2ddb41c0cb 100644--- a/app/src/components/settings/panels/VoicePanelKeyModal.tsx+++ b/app/src/components/settings/panels/VoicePanelKeyModal.tsx@@ -1,4 +1,4 @@-import { useState } from 'react';+import { useRef, useState } from 'react';import type { VoiceInstallStatus } from '../../../services/api/voiceInstallApi';import { testVoiceProvider } from '../../../services/api/voiceSettingsApi';@@ -106,6 +106,14 @@ const VoicePanelKeyModal = ({}: VoicePanelKeyModalProps) => {const [isTestingKey, setIsTestingKey] = useState(false);const [keyTestResult, setKeyTestResult] = useState<{ ok: boolean; detail: string } | null>(null);+ // Monotonic id for the in-flight key test. The API-key field stays editable+ // during a test (it is only disabled while *saving*), so without this a+ // result for key A can land next to key B and read as a validation of B —+ // the same "the UI is telling you something untrue about this key" failure+ // this modal is being fixed for. Bumped on every edit and every new test;+ // a response whose id is stale is dropped. Same guard as the LLM routing+ // dialog's `testRequestIdRef`.+ const testRequestIdRef = useRef(0);const isPiper = pendingKeySlug === 'piper';const close = () => {@@ -174,6 +182,8 @@ const VoicePanelKeyModal = ({disabled={!pendingKeyValue.trim() || isTestingKey || isSavingPendingKey}onClick={async () => {if (!pendingKeySlug || !pendingKeyValue.trim()) return;+ const requestId = testRequestIdRef.current + 1;+ testRequestIdRef.current = requestId;setIsTestingKey(true);setKeyTestResult(null);try {@@ -194,13 +204,18 @@ const VoicePanelKeyModal = ({true,pendingKeyValue);+ if (testRequestIdRef.current !== requestId) return;setKeyTestResult(result);} catch (err) {+ if (testRequestIdRef.current !== requestId) return;setKeyTestResult({ok: false,detail: err instanceof Error ? err.message : 'Test failed',});} finally {+ // Unconditional: the Test button is disabled while+ // `isTestingKey`, so there is only ever one test in+ // flight and this cannot strand the button on "Testing…".setIsTestingKey(false);}}}>@@ -272,6 +287,9 @@ const VoicePanelKeyModal = ({onChange={e => {setPendingKeyValue(e.target.value);setKeyTestResult(null);+ // Any edit invalidates a test still in flight for the old+ // key, so its result cannot arrive and describe this one.+ testRequestIdRef.current += 1;}}disabled={isSavingPendingKey}placeholder={t('voice.providers.chip.apiKeyPlaceholder')}diff --git a/app/src/components/settings/panels/__tests__/VoicePanel.test.tsx b/app/src/components/settings/panels/__tests__/VoicePanel.test.tsxindex 76385728e0..a9f44800e1 100644--- a/app/src/components/settings/panels/__tests__/VoicePanel.test.tsx+++ b/app/src/components/settings/panels/__tests__/VoicePanel.test.tsx@@ -859,6 +859,38 @@ describe('VoicePanel', () => {expect(screen.getByTestId('voice-provider-key-modal')).toBeInTheDocument();});+ it('discards an in-flight Test Key result when the key is edited', async () => {+ // The key field stays editable during a test (it is disabled only while+ // *saving*). Without the request-id guard, key A's verdict lands next to+ // key B and reads as a validation of B.+ let resolveTest: (r: { ok: boolean; detail: string }) => void = () => {};+ vi.mocked(testVoiceProvider).mockReturnValueOnce(+ // Annotated: `VoiceTestResult` is not exported, and a bare `new Promise`+ // would infer `Promise<unknown>` and fail typecheck on the mock.+ new Promise<{ ok: boolean; detail: string }>(resolve => {+ resolveTest = resolve;+ })+ );++ renderWithProviders(<VoicePanel />, { initialEntries: ['/settings/voice'] });++ await screen.findByTestId('voice-providers-section');+ fireEvent.click(screen.getByTestId('voice-provider-chip-elevenlabs'));+ await screen.findByTestId('voice-provider-key-modal');++ const keyInput = screen.getByPlaceholderText(/sk/i);+ fireEvent.change(keyInput, { target: { value: 'sk-key-AAAA-1234567890' } });+ fireEvent.click(screen.getByRole('button', { name: /^Test Key$/i }));++ // User edits to a different key before the verdict for the first arrives.+ fireEvent.change(keyInput, { target: { value: 'sk-key-BBBB-0987654321' } });++ resolveTest({ ok: true, detail: 'STALE VERDICT FOR KEY A' });++ await waitFor(() => expect(screen.getByRole('button', { name: /^Test Key$/i })).toBeEnabled());+ expect(screen.queryByText(/STALE VERDICT FOR KEY A/i)).not.toBeInTheDocument();+ });+it('the ElevenLabs modal Cancel button closes without saving', async () => {renderWithProviders(<VoicePanel />, { initialEntries: ['/settings/voice'] });diff --git a/app/src/services/api/voiceSettingsApi.ts b/app/src/services/api/voiceSettingsApi.tsindex c6ae74af32..ccac05e21f 100644--- a/app/src/services/api/voiceSettingsApi.ts+++ b/app/src/services/api/voiceSettingsApi.ts@@ -245,7 +245,10 @@ export async function testVoiceProvider(// candidate as "fall back to the stored credential", and sending one// for a provider with no stored key would report a confusing// "no API key configured" instead of the real validation result.- ...(apiKey?.trim() ? { api_key: apiKey } : {}),+ // Trimmed on the way out so the guard and the payload agree — a key+ // pasted with a trailing newline should be tested as the key the user+ // will actually save, not as a different string.+ ...(apiKey?.trim() ? { api_key: apiKey.trim() } : {}),},timeoutMs: VOICE_TEST_TIMEOUT_MS,});diff --git a/src/openhuman/voice/schemas/handlers/provider_server.rs b/src/openhuman/voice/schemas/handlers/provider_server.rsindex b9d039e6a9..56253cc45e 100644--- a/src/openhuman/voice/schemas/handlers/provider_server.rs+++ b/src/openhuman/voice/schemas/handlers/provider_server.rs@@ -327,10 +327,20 @@ pub(crate) fn handle_voice_test_provider(params: Map<String, Value>) -> Controll// always answered with a live transcription (#5896).//// Reserved slugs (`cloud`/`openhuman`/`backend`/`piper`/`whisper`/- // `local`/empty) have no user-held API key to check, so they fall- // through to the live test, where the factory reports misconfiguration- // by name.- if p.validate_only && !crate::openhuman::config::schema::is_voice_slug_reserved(trimmed) {+ // `local`/empty) are managed or local engines with no user-held API+ // key, so there is nothing to validate. They must still return here+ // rather than fall through: `validate_only` promises no inference+ // call, and falling through would quietly bill the caller for a real+ // transcription/synthesis. `ok: true` because nothing is wrong — a+ // managed provider with no key to check is not a failed check.+ if p.validate_only {+ if crate::openhuman::config::schema::is_voice_slug_reserved(trimmed) {+ return Ok(serde_json::json!({+ "ok": true,+ "detail": "No API key to validate — this provider is managed by OpenHuman.",+ "latency_ms": start.elapsed().as_millis(),+ }));+ }return match validate_provider_key(trimmed, &config, p.api_key.as_deref()).await {Ok(detail) => {let elapsed = start.elapsed().as_millis();