Fix /continue getting stuck on API errors

This commit is contained in:
Cohee
2024-07-08 20:12:52 +03:00
parent f8a55d51d2
commit 21360a97fc

View File

@ -2639,15 +2639,16 @@ async function openChat(id) {
async function continueChatCallback(args, prompt) { async function continueChatCallback(args, prompt) {
const shouldAwait = isTrueBoolean(args?.await); const shouldAwait = isTrueBoolean(args?.await);
const outerPromise = new Promise((resolve) => { const outerPromise = new Promise(async (resolve, reject) => {
setTimeout(async () => {
try { try {
await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100); await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
} catch { } catch {
console.warn('Timeout waiting for generation unlock'); console.warn('Timeout waiting for generation unlock');
toastr.warning('Cannot run /continue command while the reply is being generated.'); toastr.warning('Cannot run /continue command while the reply is being generated.');
return reject();
} }
try {
// Prevent infinite recursion // Prevent infinite recursion
$('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true })); $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
@ -2655,7 +2656,10 @@ async function continueChatCallback(args, prompt) {
await Generate('continue', options); await Generate('continue', options);
resolve(); resolve();
}, 1); } catch (error) {
console.error('Error running /continue command:', error);
reject();
}
}); });
if (shouldAwait) { if (shouldAwait) {