mirror of
https://github.com/moltbot/moltbot.git
synced 2026-03-09 15:35:17 +00:00
fix(tui): guard sendMessage when disconnected; reset readyPromise on close
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user