openclaw - ✅(Solved) Fix feat(tui): improve UX when gateway is disconnected or restarting [1 pull requests, 1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#43778Fetched 2026-04-08 00:18:08
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Participants
Timeline (top)
cross-referenced ×1referenced ×1

Triggered by a workflow where openclaw gateway restart was run to apply a config change (removing a duplicate plugin). The TUI showed the disconnected error with no recovery path visible.

Error Message

Triggered by a workflow where openclaw gateway restart was run to apply a config change (removing a duplicate plugin). The TUI showed the disconnected error with no recovery path visible.

Root Cause

Triggered by a workflow where openclaw gateway restart was run to apply a config change (removing a duplicate plugin). The TUI showed the disconnected error with no recovery path visible.

Fix Action

Fixed

PR fix notes

PR #43793: feat(tui): show reconnect hint and auto-probe gateway when disconnected

Description (problem / solution / changelog)

Problem

Fixes #43778.

When the gateway restarts (e.g. after openclaw gateway restart), the TUI shows not connected to gateway — message not sent with no guidance on what to do. Users had no way to know they could manually reconnect or how to restart the TUI.

Changes

1. GatewayClient — trackable reconnect timer + reconnect() method

  • Store the pending reconnect setTimeout handle so it can be cancelled before a forced reconnect (prevents double-connect race)
  • New public reconnect() method: resets exponential backoff to 1 s and immediately retries. If a WebSocket is open/mid-handshake it closes it cleanly; if already disconnected it calls start() directly
  • stop() now clears the tracked timer

2. GatewayChatClient — expose reconnect()

Delegates to GatewayClient.reconnect().

3. CustomEditoronCtrlR hook

Adds ctrl+r key binding alongside the existing ctrl+l / ctrl+g / ctrl+p family.

4. tui.ts — UX improvements on disconnect

  • ctrl+r wired: editor.onCtrlR calls client.reconnect() when disconnected
  • Status hint updated: activityStatus now reads reconnecting… ctrl+r to retry now instead of the silent idle
  • One-shot system message: first disconnect in a session surfaces:
    Gateway disconnected. Auto-reconnecting… press ctrl+r to retry immediately.
    If the problem persists, restart the TUI with: openclaw tui
    (resets on reconnect so it fires again if the gateway goes away a second time)

Behaviour summary

ScenarioBeforeAfter
Gateway restartsSilent not connectedSystem message + ctrl+r to retry now in status
User wants to retry immediatelyNo shortcutctrl+r forces immediate reconnect
Gateway takes >30 s to come backBackoff maxes at 30 s silentlyctrl+r resets backoff at any time
Gateway stays downNo guidanceChat log shows openclaw tui restart command

Testing

  • All existing tests pass (57 tests across tui, gateway-chat, tui-event-handlers)
  • Updated tui.test.ts to reflect new activityStatus text

Changed files

  • apps/macos/Sources/OpenClaw/AppState.swift (modified, +25/-22)
  • apps/macos/Sources/OpenClaw/GeneralSettings.swift (modified, +20/-112)
  • apps/macos/Sources/OpenClaw/MenuBar.swift (modified, +2/-0)
  • apps/macos/Sources/OpenClaw/NodeMode/MacNodeBrowserProxy.swift (modified, +3/-1)
  • apps/macos/Sources/OpenClaw/Onboarding.swift (modified, +4/-0)
  • apps/macos/Sources/OpenClaw/OnboardingView+Pages.swift (modified, +271/-19)
  • apps/macos/Sources/OpenClaw/RemoteGatewayProbe.swift (added, +242/-0)
  • apps/macos/Sources/OpenClaw/TalkModeGatewayConfig.swift (modified, +4/-4)
  • apps/shared/OpenClawKit/Sources/OpenClawKit/GatewayChannel.swift (modified, +5/-5)
  • extensions/diffs/src/store.test.ts (modified, +10/-2)
  • extensions/diffs/src/store.ts (modified, +5/-1)
  • src/gateway/client.test.ts (modified, +55/-0)
  • src/gateway/client.ts (modified, +52/-2)
  • src/tui/components/custom-editor.ts (modified, +5/-0)
  • src/tui/gateway-chat.ts (modified, +5/-0)
  • src/tui/tui.test.ts (modified, +19/-2)
  • src/tui/tui.ts (modified, +50/-1)

Code Example

[R] Reconnect  |  Gateway disconnected

---

Not connected. Press [R] to reconnect, or restart with: openclaw tui
RAW_BUFFERClick to expand / collapse

Problem

When the gateway restarts (e.g. after openclaw gateway restart), the TUI shows not connected to gateway — message not sent with no guidance on what to do next. Users are left wondering whether to wait, retry, or restart.

Proposed Improvements

1. In-TUI reconnect hint

When the TUI detects a disconnected state, display a visible hint in the status bar or as an overlay:

[R] Reconnect  |  Gateway disconnected

Many users don't know the R keybinding exists until they stumble on it.

2. Restart instructions

Alongside the reconnect hint, show how to restart the TUI itself:

Not connected. Press [R] to reconnect, or restart with: openclaw tui

3. Gateway health indicator + auto-probe

  • Show a live gateway status indicator in the TUI (e.g. 🟢 / 🔴 in the status bar)
  • When disconnected, periodically probe ws://127.0.0.1:<port> and auto-reconnect (or at minimum surface the result: "Gateway is back up — press R to reconnect")
  • Optionally: auto-reconnect silently when the gateway comes back

Context

Triggered by a workflow where openclaw gateway restart was run to apply a config change (removing a duplicate plugin). The TUI showed the disconnected error with no recovery path visible.

extent analysis

Problem Summary

The TUI shows “not connected to gateway — message not sent” after a gateway restart, but it gives no guidance or automatic recovery. Users must guess to press R (re‑connect) or restart the TUI.

Root Cause

  • The WebSocket client in the TUI only reports a disconnection and never tries to recover.
  • No UI hint is rendered for the existing R key‑binding.
  • There is no background health‑probe that can auto‑re‑connect when the gateway comes back up.

Fix Plan

Below is a minimal, production‑ready set of changes (Go + tview) that:

  1. Shows a reconnect hint in the status bar.
  2. Adds a visible key‑binding (R) that triggers a manual reconnect.
  3. Runs a periodic health‑probe (default every 2 s) that:
    • Pings the gateway WebSocket endpoint (ws://127.0.0.1:<port>/ws).
    • Updates the status indicator (🟢/🔴).
    • Auto‑reconnects when the gateway is reachable (optional flag).

1. Add UI state & constants

// ui/state.go
package ui

type ConnState int

const (
    StateConnected ConnState = iota
    StateDisconnected
    StateConnecting
)

type UI struct {
    app          *tview.Application
    statusBar    *tview.TextView
    wsClient     *gateway.Client // wrapper around gorilla/websocket
    connState    ConnState
    probeTicker  *time.Ticker
    autoReconnect bool // configurable via flag or env
}

2. Render status bar with hint

func (ui *UI) renderStatus() {
    var connIcon, hint string
    switch ui.connState {
    case StateConnected:
        connIcon = "🟢"
        hint = ""
    case StateConnecting:
        connIcon = "🟡"
        hint = "Connecting…"
    case StateDisconnected:
        connIcon = "🔴"
        hint = "[R] Reconnect  |  Gateway disconnected"
    }

    // Example: “Gateway: 🔴  [R] Reconnect  |  openclaw tui”
    fmt.Fprintf(ui.statusBar, "Gateway: %s

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix feat(tui): improve UX when gateway is disconnected or restarting [1 pull requests, 1 participants]