Add /tempchat command

17c60ca91689a7b89baea38c53870073080bc0ae

Cohee <18619528+Cohee1207@users.noreply.github.com>

1 files changed, +22 -1Ignore whitespace
public/script.js+22 -1
@@ -9180,6 +9180,27 @@ jQuery(async function () {
91809180 helpString: 'Closes the current chat.',
91819181 }));
91829182 SlashCommandParser.addCommandObject(SlashCommand.fromProps({
9183+ name: 'tempchat',
9184+ callback: async () => {
9185+ return new Promise((resolve, reject) => {
9186+ const eventCallback = async (chatId) => {
9187+ if (chatId) {
9188+ return reject('Not in a temporary chat');
9189+ }
9190+ await newAssistantChat();
9191+ return resolve('');
9192+ };
9193+ eventSource.once(event_types.CHAT_CHANGED, eventCallback);
9194+ doCloseChat();
9195+ setTimeout(() => {
9196+ reject('Failed to open temporary chat');
9197+ eventSource.removeListener(event_types.CHAT_CHANGED, eventCallback);
9198+ }, debounce_timeout.relaxed);
9199+ });
9200+ },
9201+ helpString: 'Opens a temporary chat with Assistant.',
9202+ }));
9203+ SlashCommandParser.addCommandObject(SlashCommand.fromProps({
91839204 name: 'panels',
91849205 callback: doTogglePanels,
91859206 aliases: ['togglepanels'],
@@ -9888,8 +9909,8 @@ jQuery(async function () {
98889909 select_rm_characters();
98899910 sendSystemMessage(system_message_types.WELCOME);
98909911 sendSystemMessage(system_message_types.WELCOME_PROMPT);
9891- eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId());
98929912 await getClientVersion();
9913+ await eventSource.emit(event_types.CHAT_CHANGED, getCurrentChatId());
98939914 } else {
98949915 toastr.info('Please stop the message generation first.');
98959916 }