| 2623 | await reloadCurrentChat(); | 2636 | await reloadCurrentChat(); |
| 2624 | } | 2637 | } |
| 2625 | | 2638 | |
| 2626 | function continueChatCallback(_, prompt) { | 2639 | async function continueChatCallback(args, prompt) { |
| 2627 | setTimeout(async () => { | 2640 | const shouldAwait = isTrueBoolean(args?.await); |
| 2628 | try { | | |
| 2629 | await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100); | | |
| 2630 | } catch { | | |
| 2631 | console.warn('Timeout waiting for generation unlock'); | | |
| 2632 | toastr.warning('Cannot run /continue command while the reply is being generated.'); | | |
| 2633 | } | | |
| 2634 | | 2641 | |
| 2635 | // Prevent infinite recursion | 2642 | const outerPromise = new Promise((resolve) => { |
| 2636 | $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true })); | 2643 | setTimeout(async () => { |
| 2637 | $('#option_continue').trigger('click', { fromSlashCommand: true, additionalPrompt: prompt }); | 2644 | try { |
| 2638 | }, 1); | 2645 | await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100); |
| | 2646 | } catch { |
| | 2647 | console.warn('Timeout waiting for generation unlock'); |
| | 2648 | toastr.warning('Cannot run /continue command while the reply is being generated.'); |
| | 2649 | } |
| | 2650 | |
| | 2651 | // Prevent infinite recursion |
| | 2652 | $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true })); |
| | 2653 | |
| | 2654 | const options = prompt?.trim() ? { quiet_prompt: prompt.trim(), quietToLoud: true } : {}; |
| | 2655 | await Generate('continue', options); |
| | 2656 | |
| | 2657 | resolve(); |
| | 2658 | }, 1); |
| | 2659 | }); |
| | 2660 | |
| | 2661 | if (shouldAwait) { |
| | 2662 | await outerPromise; |
| | 2663 | } |
| 2639 | | 2664 | |
| 2640 | return ''; | 2665 | return ''; |
| 2641 | } | 2666 | } |