Fix /continue getting stuck on API errors

21360a97fccde06feee00e67a502253ff9cb8b9f

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

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