openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

fix(core): restore local_ai settings after failed runtime connection verification

Open coderabbitai[bot] opened this issue 1 month ago • 2 comments

Summary

Implement core-owned rollback of local_ai when local-runtime connection verification fails. Apply the same behavior to LM Studio, OMLX, and Ollama.

Problem

The desktop connection flow writes local runtime settings through openhumanUpdateLocalAiSettings before calling listProviderModels(slug). When verification fails, the flow restores the cloud provider list but does not restore the previous local_ai settings. The attempted provider, base_url, and api_key can therefore remain active after the dialog reports failure.

This behavior predates the optional LM Studio API-key change. It should be addressed consistently for all local runtimes rather than with an LM Studio-specific rollback.

Required changes

  • Implement a core-owned update-and-verification operation, or an equivalent core-owned transaction, that preserves the prior local runtime configuration until verification succeeds.
  • If verification fails, restore all local runtime settings changed by the attempt, including credentials and runtime enablement/opt-in fields where applicable.
  • Integrate the desktop connection flow with this operation so local configuration and provider-list rollback remain consistent.
  • Keep stored secrets inside the core. Do not make the desktop settings screen read the previous API key to perform rollback.
  • Preserve the existing contract: local_ai describes one active runtime, not separate saved configurations for each runtime.

Affected areas

  • Desktop orchestration: app/src/components/settings/panels/ai/useProviderConnect.ts
  • Core local-AI settings update operation behind openhumanUpdateLocalAiSettings
  • Local-runtime verification/model listing, including crates/openhuman-core/src/inference/provider/ops/models/catalog_listing.rs

Acceptance criteria

  • A failed connection attempt leaves the previous active local runtime configuration and credential unchanged.
  • Cover LM Studio, OMLX, and Ollama, including failed runtime switches and failed endpoint/key changes.
  • A successful attempt commits the new configuration.
  • Empty optional LM Studio keys still clear the key on successful verification.
  • Tests cover rollback and successful commits without exposing stored secrets to the desktop settings screen.
  • Handle overlapping attempts so rollback from an older attempt cannot overwrite a newer committed configuration.

Context

Requested by @obchain as a follow-up outside the scope of PR #8107.

  • PR: https://github.com/tinyhumansai/openhuman/pull/8107
  • Review discussion: https://github.com/tinyhumansai/openhuman/pull/8107#discussion_r4312748765

coderabbitai[bot] avatar Oct 21 '26 11:10 coderabbitai[bot]

Picking this one up, since it came out of my LM Studio PR. The plan is for the core to keep the old local AI settings until the connection check passes, so a failed attempt leaves things exactly as they were.

obchain avatar Oct 22 '26 11:10 obchain

Re-checked on current main: still the case. When the connection check for Ollama, LM Studio or OMLX fails, useProviderConnect.ts rolls back the cloud provider list but leaves the new local_ai settings saved. #8205 is the open fix; this will close when it merges.

M3gA-Mind avatar Nov 16 '26 16:11 M3gA-Mind