mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 21:28:26 +00:00
TUI: guide pairing-required recovery in disconnect state
This commit is contained in:
@@ -195,6 +195,26 @@ export function resolveTuiSessionKey(params: {
|
||||
return `agent:${params.currentAgentId}:${trimmed}`;
|
||||
}
|
||||
|
||||
export function resolveGatewayDisconnectState(reason?: string): {
|
||||
connectionStatus: string;
|
||||
activityStatus: string;
|
||||
pairingHint?: string;
|
||||
} {
|
||||
const reasonLabel = reason?.trim() ? reason.trim() : "closed";
|
||||
if (/pairing required/i.test(reasonLabel)) {
|
||||
return {
|
||||
connectionStatus: `gateway disconnected: ${reasonLabel}`,
|
||||
activityStatus: "pairing required: run openclaw devices list",
|
||||
pairingHint:
|
||||
"Pairing required. Run `openclaw devices list`, approve your request ID, then reconnect.",
|
||||
};
|
||||
}
|
||||
return {
|
||||
connectionStatus: `gateway disconnected: ${reasonLabel}`,
|
||||
activityStatus: "idle",
|
||||
};
|
||||
}
|
||||
|
||||
export async function runTui(opts: TuiOptions) {
|
||||
const config = loadConfig();
|
||||
const initialSessionInput = (opts.session ?? "").trim();
|
||||
@@ -213,6 +233,7 @@ export async function runTui(opts: TuiOptions) {
|
||||
let wasDisconnected = false;
|
||||
let toolsExpanded = false;
|
||||
let showThinking = false;
|
||||
let pairingHintShown = false;
|
||||
const localRunIds = new Set<string>();
|
||||
|
||||
const deliverDefault = opts.deliver ?? false;
|
||||
@@ -772,6 +793,7 @@ export async function runTui(opts: TuiOptions) {
|
||||
|
||||
client.onConnected = () => {
|
||||
isConnected = true;
|
||||
pairingHintShown = false;
|
||||
const reconnected = wasDisconnected;
|
||||
wasDisconnected = false;
|
||||
setConnectionStatus("connected");
|
||||
@@ -794,9 +816,13 @@ export async function runTui(opts: TuiOptions) {
|
||||
isConnected = false;
|
||||
wasDisconnected = true;
|
||||
historyLoaded = false;
|
||||
const reasonLabel = reason?.trim() ? reason.trim() : "closed";
|
||||
setConnectionStatus(`gateway disconnected: ${reasonLabel}`, 5000);
|
||||
setActivityStatus("idle");
|
||||
const disconnectState = resolveGatewayDisconnectState(reason);
|
||||
setConnectionStatus(disconnectState.connectionStatus, 5000);
|
||||
setActivityStatus(disconnectState.activityStatus);
|
||||
if (disconnectState.pairingHint && !pairingHintShown) {
|
||||
pairingHintShown = true;
|
||||
chatLog.addSystem(disconnectState.pairingHint);
|
||||
}
|
||||
updateFooter();
|
||||
tui.requestRender();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user