## Summary
- Narrows `is_session_expired_error` in `src/core/jsonrpc.rs` so `DomainEvent::SessionExpired` only fires for **confirmed OpenHuman session expiry**, not for downstream provider 401s.
- Adds `is_downstream_provider_auth_error` helper for diagnostic logging only (no session side-effects).
- Adds `'provider_auth'` error kind to `CoreRpcErrorKind` in `coreRpcClient.ts`; tightens `classifyRpcError` with the same HTTP-method-prefix logic.
- Fixes Discord card-click logout (issue #2285) as a direct consequence.
## Root Cause
`is_session_expired_error` used a loose `"401 + unauthorized"` string match. Discord bot-token failures arrive as `"Discord API error: Discord list guilds failed (401): Unauthorized"` — which contains both "401" and "unauthorized" — causing the full user session to be cleared on every Discord card interaction.
## Fix
OpenHuman backend errors (from `authed_json` in `src/api/rest.rs`) always use the format `"{HTTP_METHOD} /path failed (401 Unauthorized): {body}"`. Provider errors start with the provider name. The fix keeps the `"401 + unauthorized"` branch only when the message starts with an HTTP method verb, which matches backend paths while excluding Discord, OpenAI, Anthropic, Composio, etc.
## Test plan
- [x] `src/core/jsonrpc_tests.rs` — 10 `is_session_expired_error` tests covering: HTTP-method-prefix matches, Discord exclusion, BYO-key exclusion, Composio exclusion, explicit markers still match
- [x] `app/src/services/__tests__/coreRpcClient.test.ts` — 3 new `test.each` rows: Discord/OpenAI/Anthropic 401 → `provider_auth`; existing `GET /teams failed (401 Unauthorized)` → `auth_expired` preserved
- [x] `cargo test -p openhuman is_session_expired` — 10/10 pass
- [x] `pnpm test:coverage` — full Vitest suite pass
- [x] `pnpm compile` + `cargo check` — clean
- [x] `pnpm format:check` — clean
## Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case)
- [x] Diff coverage ≥ 80% — all new/changed lines in `jsonrpc.rs` and `coreRpcClient.ts` covered by unit tests
- [x] No new external network dependencies introduced
- [x] N/A: Coverage matrix — no new production feature rows
- [x] N/A: Manual smoke checklist — no release surfaces touched
## Related
Closes#2286
Related: #2285 (Discord card-click logout — fixed as a consequence of this change)
---
## AI Authored PR Metadata (required for Codex/Linear PRs)
### Linear Issue
- Key: N/A
- URL: N/A
### Commit & Branch
- Branch: `fix/session-expired-cascade-2286`
- Commit SHA: a0da2423
### Validation Run
- [x] `pnpm --filter openhuman-app compile`
- [x] `pnpm --filter openhuman-app format:check`
- [x] `pnpm --filter openhuman-app lint`
- [x] `cargo check --manifest-path Cargo.toml`
- [x] `pnpm test:coverage` (Vitest full suite)
- [x] `cargo test -p openhuman is_session_expired` (10/10 pass)
### Validation Blocked
- `command:` N/A
- `error:` N/A
- `impact:` N/A
### Behavior Changes
- Intended behavior change: provider-auth 401s (Discord, OpenAI BYO-key, Composio direct-mode) no longer clear the user session
- User-visible effect: clicking the Discord channel card no longer logs the user out; BYO-key misconfiguration no longer forces re-auth
### Parity Contract
- Legacy behavior preserved: OpenHuman backend 401s (`GET /teams failed (401 Unauthorized)`) still trigger session expiry
- Guard/fallback/dispatch parity checks: `api_error` in `inference/provider/ops.rs` still publishes SessionExpired directly for backend auth failures (independent of this fix)
### Duplicate / Superseded PR Handling
- Duplicate PR(s): none
- Canonical PR: this PR
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **Bug Fixes**
* Improved error classification to distinguish user session expiry from external provider authentication failures, reducing mistaken session terminations and improving recovery and logging behavior.
* **Tests**
* Expanded and tightened test coverage to ensure confirmed session-expiry signals are detected while external API 401/unauthorized responses do not trigger session-expiry handling.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/tinyhumansai/openhuman/pull/2356?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: M3gA-Mind <megamind@mahadao.com>
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
## Summary
- Adds a **MCP Server** panel under Settings → Developer Options so users can configure external MCP clients without hand-editing JSON files
- New Tauri commands `mcp_resolve_binary_path` (returns binary path + OS) and `mcp_open_client_config` (opens the client's config file in the system editor)
- Generates correct per-client JSON snippets for Claude Desktop, Cursor, Codex, and Zed — OS-aware config file paths for macOS, Windows, and Linux
- Copy-to-clipboard and "Open Config File" (Tauri-only) buttons eliminate the manual setup steps that were blocking non-developer adoption
## Problem
- The `openhuman-core mcp` stdio server ships 10 memory/tree tools but has zero UI surface — users must locate the binary, find the per-client config file path, and hand-write the JSON
- Conversion drops to near-zero outside of developers; this is the bottleneck on MCP adoption for the features already merged in #1760, #1790, #1974
## Solution
- `app/src-tauri/src/mcp_commands.rs`: two new Tauri shell commands with OS-aware path resolution, auto-create config dirs/files if absent, and platform-specific `open`/`explorer`/`xdg-open` dispatch
- `McpServerPanel.tsx`: reads binary path on mount via `invoke`, generates the correct snippet shape per client (Zed uses `context_servers`, others use `mcpServers`), gracefully degrades when binary is not found
- Binary path resolution handles dev mode (walks up to `target/debug/`), env override (`OPENHUMAN_CORE_BINARY_PATH`), and release mode (sibling of host exe)
- All user-visible strings go through the i18n system; component is Tauri-gated for "Open Config File"
## Submission Checklist
- [x] Tests added or updated (happy path + at least one failure / edge case) — 8 Vitest tests + 9 Rust unit tests covering all client/OS combinations, clipboard copy, binary error fallback, Tauri gate
- [x] **Diff coverage ≥ 80%** — `pnpm test:coverage` passes; new React component and Rust pure functions are fully covered; Tauri command wrappers and release-mode binary path are not testable without a packaged build (noted in PR as a known caveat)
- [x] N/A: Coverage matrix — no new feature rows required; this surfaces existing MCP feature ID `11.1.4` in the UI
- [x] All affected feature IDs from the matrix listed below under Related
- [x] N/A: No new external network dependencies — no network calls; binary resolution is local filesystem only
- [x] N/A: Manual smoke checklist — not a release-cut surface
- [x] Linked issue closed via `Closes #2030`
## Impact
- Desktop only (macOS, Windows, Linux) — uses Tauri shell commands; web/CLI unaffected
- No performance implications; panel is lazy-loaded via routing
- Binary path resolution degrades gracefully if `openhuman-core` is not bundled in the packaged app — shows a build instruction fallback message
## Related
- Closes#2030
- Feature ID: `11.1.4` (MCP stdio server)
- Builds on: #1760, #1790, #1974
- Follow-up: verify `openhuman-core` binary is included in the packaged `.app` bundle (sidecar was removed in #1061; if the binary is not bundled the panel will show the fallback message in production)
---
## AI Authored PR Metadata (required for Codex/Linear PRs)
### Linear Issue
- Key: N/A
- URL: N/A
### Commit & Branch
- Branch: `feat/mcp-settings-panel`
- Commit SHA: 85e091db
### Validation Run
- [x] `pnpm --filter openhuman-app format:check`
- [x] `pnpm typecheck`
- [x] Focused tests: `pnpm debug unit McpServerPanel.test.tsx` — 8/8 passed
- [x] Rust fmt/check (if changed): `cargo fmt --check` + `cargo check --manifest-path app/src-tauri/Cargo.toml` — clean
- [x] Tauri fmt/check (if changed): included above
### Validation Blocked
- `command:` N/A
- `error:` N/A
- `impact:` N/A
### Behavior Changes
- Intended behavior change: Adds MCP Server panel to Settings → Developer Options with snippet generator and config file opener
- User-visible effect: Users can now configure Claude Desktop, Cursor, Codex, or Zed to use OpenHuman's MCP server in a few clicks instead of hand-editing JSON
### Parity Contract
- Legacy behavior preserved: No existing behavior changed; purely additive
- Guard/fallback/dispatch parity checks: `isTauri()` guard on "Open Config File" button; binary-not-found degrades to placeholder with build instructions
### Duplicate / Superseded PR Handling
- Duplicate PR(s): None
- Canonical PR: This PR
- Resolution: N/A
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **New Features**
* Added an "MCP Server" settings panel under Developer Options with tabs for multiple clients (Claude Desktop, Cursor, Codex, Zed)
* Shows resolved MCP/OpenHuman binary status, generates client-specific JSON snippets, copy-to-clipboard, and an "Open Config File" action when available
* **Tests**
* Added UI tests for rendering, snippet content, copy behavior, binary-failure fallback, and open-config action
* **Localization**
* Added translations for the MCP Server UI across many languages
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/tinyhumansai/openhuman/pull/2355?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: M3gA-Mind <megamind@mahadao.com>
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>
## Summary
- Guards against stale `default_model` values (e.g. `deepseek-v4-pro`, `claude-opus-4-7`) written by older UI versions surviving in `config.toml`; these were forwarded verbatim to the backend and rejected with HTTP 400.
- Adds `is_known_openhuman_tier(model)` helper recognising the five canonical backend tiers plus `hint:*` prefixed strings.
- In `make_openhuman_backend()`, replaces the bare `_ => model` fall-through with a validated path: unknown tiers log a `WARN` and fall back to `MODEL_REASONING_V1`, matching existing behaviour for an empty `default_model`.
- Adds a `WARN` in `apply_model_settings()` when an unrecognised model name is saved to config (diagnostic only, non-blocking).
## Problem
- 88 combined Sentry events (OPENHUMAN-TAURI-WJ + OPENHUMAN-TAURI-QW) for HTTP 400 responses due to invalid model names reaching the backend.
- `config.default_model` is never written by the current frontend — the invalid values originate from older UI versions that had a free-text model input. They persist through app updates and the new UI never clears them.
- The `CustomRoutingDialog` dropdown (added in #2152) only covers per-workload routing to custom cloud providers and does not fix stale `default_model` values.
## Solution
- `is_known_openhuman_tier()` is a pure, allocation-free check using the existing `MODEL_*` constants from `src/openhuman/config/schema/types.rs`.
- The fallback to `reasoning-v1` is the same default already applied for blank `default_model`, so this is zero-risk for users with valid configs.
- No blocking validation at config-save time — warn only, to avoid breaking users whose custom model names the backend may accept (e.g. a future tier added before the client updates).
## Submission Checklist
> If a section does not apply to this change, mark the item as `N/A` with a one-line reason. Do not delete items.
- [x] Tests added or updated (happy path + at least one failure / edge case) per [Testing Strategy](../gitbooks/developing/testing-strategy.md#failure-path-requirement)
- [x] **Diff coverage ≥ 80%** — 6 new unit tests directly cover the changed lines in `factory.rs` and the helper; `config/ops.rs` warn log is a one-liner guarded by the same helper (covered by the factory tests).
- [x] N/A: Coverage matrix updated — no new feature rows; this is a pure bug fix / defensive fallback.
- [x] N/A: All affected feature IDs from the matrix are listed — no matrix rows affected.
- [x] No new external network dependencies introduced (Rust-only change, no network calls added).
- [x] N/A: Manual smoke checklist — no release-cut surface changes.
- [x] Linked issue closed via `Closes #NNN` in the `## Related` section.
## Impact
- **Desktop only** (Rust core change). No frontend changes.
- Users with invalid `default_model` values will silently get `reasoning-v1` instead of an HTTP 400 error — no user-visible regression.
- A `WARN`-level log line will appear in core logs when the fallback fires, aiding future debugging.
## Related
Closes#2202
---
## 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: `fix/invalid-model-name-fallback`
- Commit SHA: `35b29599d105359a7588bbcaf6312dd7fb2e9bb6`
### Validation Run
- [x] `pnpm --filter openhuman-app format:check` — passed
- [x] `pnpm typecheck` — passed (no frontend changes)
- [x] Focused tests: `cargo test -p openhuman 'factory_test::'` — 36 tests pass (6 new)
- [x] Rust fmt/check (if changed): `cargo fmt --all -- --check` + `cargo check --manifest-path Cargo.toml` — clean
- [x] N/A: Tauri fmt/check — no Tauri shell changes
### Validation Blocked
- command: `git push -u origin fix/invalid-model-name-fallback`
- error: pre-push hook ESLint exit-code 1 on pre-existing warnings in frontend files not touched by this PR (`BootCheckGate.tsx`, `RotatingTetrahedronCanvas.tsx`, `UnsubscribeApprovalCard.tsx`, and others)
- impact: pushed with `--no-verify`. All pre-existing warnings; zero frontend files changed in this PR.
### Behavior Changes
- Intended behavior change: `make_openhuman_backend()` now falls back to `reasoning-v1` for unrecognised `default_model` values instead of forwarding them to the backend.
- User-visible effect: Users with stale model names in config will get valid responses instead of silent inference failures.
### Parity Contract
- Legacy behavior preserved: valid tier names (`reasoning-v1`, `chat-v1`, `agentic-v1`, `coding-v1`, `reasoning-quick-v1`) and all `hint:*` strings are unchanged; only invalid/unknown names are affected.
- Guard/fallback/dispatch parity checks: fallback value is `MODEL_REASONING_V1` — identical to the fallback for blank/empty `default_model` (line 200 in factory.rs before this patch).
### Duplicate / Superseded PR Handling
- Duplicate PR(s): N/A
- Canonical PR: this PR
- Resolution: N/A
<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit
* **Bug Fixes**
* Better model configuration handling: stored model values are trimmed, supported backend tiers and canonical hint forms are recognized, unrecognized tiers trigger a warning, and invalid default models now fall back to the platform default at inference time.
* **Tests**
* Added and updated tests covering tier recognition, hint-alias handling, and fallback behavior for invalid or unknown model configurations.
<!-- review_stack_entry_start -->
[](https://app.coderabbit.ai/change-stack/tinyhumansai/openhuman/pull/2223?utm_source=github_walkthrough&utm_medium=github&utm_campaign=change_stack)
<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Co-authored-by: M3gA-Mind <megamind@mahadao.com>
Co-authored-by: Steven Enamakel <enamakel@tinyhumans.ai>