openhuman icon indicating copy to clipboard operation
openhuman copied to clipboard

A chat turn that fails before streaming never surfaces an error — the UI hangs to a generic connection timeout

Open nocstah opened this issue 3 months ago • 2 comments

Summary

When a chat turn fails before the provider produces any stream (e.g. the provider probe fails), no error event reaches the frontend — the user stares at an idle chat until the client's own ~2-minute timeout shows "No response from the agent after 2 minutes. Try again or check your connection."

Problem

What happened vs expected: web_chat logged run_chat_task failed … [claude-code] \claude` CLI not installedandreport_errorfired at11:42:46— the backend knew the turn was dead within milliseconds. The UI was never told: nochat_error-style socket event was emitted for the turn (an external_transfer_pendingegress event did go out, but nothing terminal). Expected: an immediate, actionable error bubble ("Claude Code CLI not found — …") the momentrun_chat_task` fails.

The "check your connection" copy is also misleading — the failure was local and permanent, not connectivity.

Steps to reproduce:

  1. Configure the claude-code provider and make the CLI unresolvable (e.g. launch from Finder with the CLI only in ~/.local/bin — see the companion issue — or temporarily rename the binary).
  2. Send a message.
  3. Backend log shows run_chat_task failed instantly; the chat UI shows a spinner/typing state for ~2 minutes, then a generic connection error.

Version/platform: v0.63.14, macOS (Darwin 25.3.0), desktop bundle.

Solution (optional)

Emit a terminal per-turn error event on the socket surface from the run_chat_task failure path (src/openhuman/web_chat/ops.rs — the same place that logs the WRN), carrying the provider's error string; frontend renders it as the turn's result. The 2-minute client timeout then remains a true last resort for transport loss only.

Acceptance criteria

  • [ ] Repro gone — a provider failure surfaces in the chat within ~1s with the provider's actual error message.
  • [ ] Regression safety — a test covers "run_chat_task error ⇒ terminal error event emitted for that turn".
  • [ ] Diff coverage ≥ 80% — the fix PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/ci-lite.yml).

Related

Companion issue: Finder-launch CLI resolution (the failure that exposed this); its fix removes this particular trigger but not the gap.

nocstah avatar Aug 24 '26 10:08 nocstah

Triage: valid — Current review confirms this is a concrete, in-scope engineering issue or request: “A chat turn that fails before streaming never surfaces an error — the UI hangs to a generic connection timeout”. No complete resolution is evident in current main.

senamakel avatar Oct 09 '26 17:10 senamakel

I looked into this against current main. The backend side of the requested fix is already in place. The remaining gap is on the UI side, and I haven't been able to pin it down yet.

What exists today

  • When run_chat_task returns an error, crates/openhuman-core/src/web_chat/ops/start_chat.rs builds a classified chat_error event for that thread and request (line 605) and publishes it after the turn slot is released (line 659). This code predates v0.63.14. It is older than the version in this report, so the problem wasn't simply a missing emit.
  • app/src/providers/ChatRuntimeProvider.tsx (onError, around line 1778) turns chat_error into an assistant error message.

What is still unresolved

  • app/test/playwright/specs/chat-pre-stream-failure.spec.ts:183 reproduces a pre-stream failure (a 400 on /chat/completions) and is currently skipped under #6388 because the turn still falls through to the watchdog.
  • That spec checks for the composer send banner ([data-chat-send-error-code], line 117). Provider errors from chat_error render as an assistant error bubble, not as that banner. So the skip may hide either of two cases: (a) the error is shown, and the spec is looking at the wrong element, or (b) the chat_error never reaches this client. Case (b) matches what you observed, and possible causes are client-id routing or the event arriving before the frontend registers the turn.

What a real fix needs

  1. Run the skipped scenario and record whether a chat_error reaches the socket for that request id, and whether an assistant error bubble appears.
  2. If it arrives and renders, assert on the bubble in the spec, remove the skip, and close this together with #6388.
  3. If it doesn't arrive, trace why between publish_web_channel_event and the socket for that client. Then add a regression test for "an error that run_chat_task returns before streaming produces a visible error for that turn within a few seconds".

Separately, the watchdog wording ("check your connection") is still misleading for local, permanent failures.

Leaving this open. #6388 tracks the same gap from the test side.

senamakel avatar Oct 09 '26 19:10 senamakel