fix(onboarding): prevent TUI hatch hang by adding timeouts, abort logic, and improved watchdog (#76132)#76192
Conversation
…uts and watchdog abort - Add 5-minute default timeout for embedded TUI runs (down from 48 hours) - Improve streaming watchdog to actively abort hanging runs with actionable error messages - Add 5-minute timeout wrapper around OpenAI OAuth authentication - Add diagnostic logging for TUI runs and OAuth flow to aid troubleshooting Fixes openclaw#76132
…stuck-76132 # Conflicts: # CHANGELOG.md
…ic, and improved watchdog (openclaw#76132)
|
Codex review: needs changes before merge. Summary Reproducibility: yes. for the PR blocker: with default config, the PR's omitted timeout path resolves the 48-hour agent default and Next step before merge Security Review findings
Review detailsBest possible solution: Keep the PR open and bound only the onboarding/local embedded hatch fallback, while preserving explicit Do we have a high-confidence way to reproduce the issue? Yes for the PR blocker: with default config, the PR's omitted timeout path resolves the 48-hour agent default and Is this the best way to solve the issue? No. The direction is reasonable, but the current implementation misses the pre-event hang case; pass an onboarding-specific timeout or use a fallback that does not preserve the global 48-hour default for hatch runs. Full review comments:
Overall correctness: patch is incorrect Acceptance criteria:
What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against f6aedd33e556. |
- Fix watchdog abort ordering: abort run before clearing activeChatRunId so abortActive() actually terminates the stuck run - Preserve configured timeouts: resolve from agents.defaults.timeoutSeconds with 5-minute minimum instead of hardcoded override - Clear OAuth timeout: properly cleanup setTimeout handle in withTimeout finally block to prevent process lingering All tests passing (50/50 TUI, 14/14 OAuth, 5/5 CLI smoke)
|
Thanks @michaelatamuk for the contribution and for chasing the hatch hang. We landed the narrower fix in #76241, which bounds the setup Terminal hatch bootstrap run by default; closing this PR in favor of that merged path. |
|
Closing in favor of the merged targeted fix in #76241. Thanks again @michaelatamuk. |
Summary
Problem:
On Ubuntu 26 with OpenAI Cloud, the onboarding flow (“Hatch in Terminal”) freezes during the initial agent hatch. The TUI becomes unresponsive, the watchdog fires after 30 seconds, and no assistant output is ever produced. Users cannot complete onboarding.
Why it matters:
This regression blocks first‑run onboarding for affected environments. The embedded TUI run can hang indefinitely due to silent provider stalls, OAuth delays, or missing final events — and the default 48‑hour timeout prevents recovery.
What changed:
This PR introduces a comprehensive fix across the TUI, embedded backend, and provider OAuth layer:
What did NOT change:
Change Type
Scope
Linked Issue/PR
Root Cause
1. Embedded TUI runs inherited the global 48‑hour agent timeout
The onboarding hatch uses a local embedded run.
This run inherited the default 48‑hour timeout, meaning:
…the TUI would wait 48 hours before aborting.
2. The streaming watchdog only reset UI state
The watchdog fired after 30 seconds of no stream updates, but:
This left the TUI frozen.
3. OAuth authentication could hang indefinitely
The OpenAI OAuth flow had no timeout wrapper.
If the callback server stalled or the provider delayed, onboarding froze.
Regression Test Plan
Coverage level that should have caught this:
Target test or file:
tui/tests/onboarding-hatch-timeout.spec.ts(recommended)Scenario the test should lock in:
Why this is the smallest reliable guardrail:
Only an integration test can detect TUI freezes and silent provider stalls.
User-visible / Behavior Changes
openclaw models statusopenclaw logs --followopenclaw doctorDiagram
Security Impact
Repro + Verification
Environment
Steps
Expected
Actual (before fix)
Evidence
Human Verification
Compatibility / Migration
Risks and Mitigations
Risk: Timeout too short for slow providers
Mitigation: Timeout is configurable; 5 minutes is safe default
Risk: Aborting runs may hide deeper provider issues
Mitigation: Diagnostic logging now surfaces root causes
Code Changes Included in This PR
1.
src/tui/embedded-backend.tsDEFAULT_TUI_TIMEOUT_MS = 3000002.
src/tui/tui-event-handlers.tsabortActive()3.
src/tui/tui.ts4.
src/plugins/provider-openai-codex-oauth.tswithTimeout()helper5.
CHANGELOG.md