From b7043a428f74d290c4d24d11e03d46e1c41ece76 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Wed, 15 May 2024 22:39:32 +0200 Subject: [PATCH] Add /renamechat slash command --- public/script.js | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/public/script.js b/public/script.js index 8dd9b427e..47cb8de06 100644 --- a/public/script.js +++ b/public/script.js @@ -8290,6 +8290,23 @@ async function doDeleteChat() { $('#dialogue_popup_ok').trigger('click', { fromSlashCommand: true }); } +async function doRenameChat(_, chatName) { + if (!chatName) { + toastr.warning('Name must be provided as an argument to rename this chat.'); + return; + } + + const currentChatName = getCurrentChatId(); + if (!currentChatName) { + toastr.warning('No chat selected that can be renamed.'); + return; + } + + await renameChat(currentChatName, chatName); + + toastr.success(`Successfully renamed chat to: ${chatName}`); +} + /** * Renames the currently selected chat. * @param {string} oldFileName Old name of the chat (no JSONL extension) @@ -8581,6 +8598,16 @@ jQuery(async function () { callback: doDeleteChat, helpString: 'Deletes the current chat.', })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ + name: 'renamechat', + callback: doRenameChat, + unnamedArgumentList: [ + new SlashCommandArgument( + 'new chat name', [ARGUMENT_TYPE.STRING], true, + ), + ], + helpString: 'Renames the current chat.', + })); SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'getchatname', callback: doGetChatName, returns: 'chat file name', @@ -8590,6 +8617,11 @@ jQuery(async function () { callback: doCloseChat, helpString: 'Closes the current chat.', })); + SlashCommandParser.addCommandObject(SlashCommand.fromProps({ + name: 'closechat', + callback: doCloseChat, + helpString: 'Closes the current chat.', + })); SlashCommandParser.addCommandObject(SlashCommand.fromProps({ name: 'panels', callback: doTogglePanels, aliases: ['togglepanels'],