mirror of https://github.com/openclaw/openclaw.git
fix(tui): guard sendMessage when disconnected; reset readyPromise on close
(cherry picked from commit df827c3eef)
This commit is contained in:
parent
a7518b7589
commit
b9e587fb63
|
|
@ -146,6 +146,10 @@ export class GatewayChatClient {
|
|||
});
|
||||
},
|
||||
onClose: (_code, reason) => {
|
||||
// Reset so waitForReady() blocks again until the next successful reconnect.
|
||||
this.readyPromise = new Promise((resolve) => {
|
||||
this.resolveReady = resolve;
|
||||
});
|
||||
this.onDisconnected?.(reason);
|
||||
},
|
||||
onGap: (info) => {
|
||||
|
|
|
|||
|
|
@ -456,6 +456,12 @@ export function createCommandHandlers(context: CommandHandlerContext) {
|
|||
};
|
||||
|
||||
const sendMessage = async (text: string) => {
|
||||
if (!state.isConnected) {
|
||||
chatLog.addSystem("not connected to gateway — message not sent");
|
||||
setActivityStatus("disconnected");
|
||||
tui.requestRender();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
chatLog.addUser(text);
|
||||
tui.requestRender();
|
||||
|
|
|
|||
Loading…
Reference in New Issue