diff --git a/public/script.js b/public/script.js index 3dd51692f..24dd839f6 100644 --- a/public/script.js +++ b/public/script.js @@ -9179,6 +9179,27 @@ jQuery(async function () { callback: doCloseChat, helpString: 'Closes the current chat.', })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ + name: 'tempchat', + callback: async () => { + return new Promise((resolve, reject) => { + const eventCallback = async (chatId) => { + if (chatId) { + return reject('Not in a temporary chat'); + } + await newAssistantChat(); + return resolve(''); + }; + eventSource.once(event_types.CHAT_CHANGED, eventCallback); + doCloseChat(); + setTimeout(() => { + reject('Failed to open temporary chat'); + eventSource.removeListener(event_types.CHAT_CHANGED, eventCallback); + }, debounce_timeout.relaxed); + }); + }, + helpString: 'Opens a temporary chat with Assistant.', + })); SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'panels', callback: doTogglePanels, @@ -9888,8 +9909,8 @@ jQuery(async function () { select_rm_characters(); sendSystemMessage(system_message_types.WELCOME); sendSystemMessage(system_message_types.WELCOME_PROMPT); - eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId()); await getClientVersion(); + await eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId()); } else { toastr.info('Please stop the message generation first.'); }