Added /continue "await" arg

aad65c9273176a2bf3960bf655a23db1adf4ae7e

Wolfsblvt <wolfsblvt@gmail.com>

1 files changed, +27 -2Showing whitespace changes
public/scripts/slash-commands.js+27 -2
@@ -329,6 +329,16 @@ export function initDefaultSlashCommands() {
329329 name: 'continue',
330330 callback: continueChatCallback,
331331 aliases: ['cont'],
332+ namedArgumentList: [
333+ new SlashCommandNamedArgument(
334+ 'await',
335+ 'Whether to await for the continued generation before continuing',
336+ [ARGUMENT_TYPE.BOOLEAN],
337+ false,
338+ false,
339+ 'false',
340+ ),
341+ ],
332342 unnamedArgumentList: [
333343 new SlashCommandArgument(
334344 'prompt', [ARGUMENT_TYPE.STRING], false,
@@ -339,6 +349,9 @@ export function initDefaultSlashCommands() {
339349 Continues the last message in the chat, with an optional additional prompt.
340350 </div>
341351 <div>
352+ If <code>await=true</code> named argument is passed, the command will await for the continued generation before continuing.
353+ </div>
354+ <div>
342355 <strong>Example:</strong>
343356 <ul>
344357 <li>
@@ -2623,7 +2636,10 @@ async function openChat(id) {
26232636 await reloadCurrentChat();
26242637}
26252638
26262639async function continueChatCallback(_args, prompt) {
2640+ const shouldAwait = isTrueBoolean(args?.await);
2641+
2642+ const outerPromise = new Promise((resolve) => {
26272643 setTimeout(async () => {
26282644 try {
26292645 await waitUntilCondition(() => !is_send_press && !is_group_generating, 10000, 100);
@@ -2634,8 +2650,17 @@ function continueChatCallback(_, prompt) {
26342650
26352651 // Prevent infinite recursion
26362652 $('#send_textarea').val('')[0].dispatchEvent(new Event('input', { bubbles: true }));
2637- $('#option_continue').trigger('click', { fromSlashCommand: true, additionalPrompt: prompt });
2653+
2654+ const options = prompt?.trim() ? { quiet_prompt: prompt.trim(), quietToLoud: true } : {};
2655+ await Generate('continue', options);
2656+
2657+ resolve();
26382658 }, 1);
2659+ });
2660+
2661+ if (shouldAwait) {
2662+ await outerPromise;
2663+ }
26392664
26402665 return '';
26412666}