Fix /continue getting stuck on API errors

21360a97fccde06feee00e67a502253ff9cb8b9f

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

1 files changed, +7 -3Showing whitespace changes
public/scripts/slash-commands.js+7 -3
@@ -2639,15 +2639,16 @@ async function openChat(id) {
2639async function continueChatCallback(args, prompt) {2639async function continueChatCallback(args, prompt) {
2640 const shouldAwait = isTrueBoolean(args?.await);2640 const shouldAwait = isTrueBoolean(args?.await);
26412641
2642 const outerPromise = new Promise((resolve) => {2642 const outerPromise = new Promise(async (resolve, reject) => {
2643 setTimeout(async () => {
2644 try {2643 try {
2645 await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);2644 await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
2646 } catch {2645 } catch {
2647 console.warn('Timeout waiting for generation unlock');2646 console.warn('Timeout waiting for generation unlock');
2648 toastr.warning('Cannot run /continue command while the reply is being generated.');2647 toastr.warning('Cannot run /continue command while the reply is being generated.');
2648 return reject();
2649 }2649 }
26502650
2651 try {
2651 // Prevent infinite recursion2652 // Prevent infinite recursion
2652 $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));2653 $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
26532654
@@ -2655,7 +2656,10 @@ async function continueChatCallback(args, prompt) {
2655 await Generate('continue', options);2656 await Generate('continue', options);
26562657
2657 resolve();2658 resolve();
2658 }, 1);2659 } catch (error) {
2660 console.error('Error running /continue command:', error);
2661 reject();
2662 }
2659 });2663 });
26602664
2661 if (shouldAwait) {2665 if (shouldAwait) {