#843 Wait for group to stop generating before checking objectives

This commit is contained in:
Cohee
2023-08-01 15:53:10 +03:00
parent 7596d78322
commit e5f3a70860
2 changed files with 26 additions and 11 deletions

View File

@ -334,7 +334,7 @@ async function summarizeChat(context) {
async function summarizeChatMain(context, force) {
try {
// Wait for the send button to be released
waitUntilCondition(() => is_send_press === false, 10000, 100);
waitUntilCondition(() => is_send_press === false, 30000, 100);
} catch {
console.debug('Timeout waiting for is_send_press');
return;

View File

@ -1,4 +1,4 @@
import { chat_metadata, callPopup, saveSettingsDebounced, getCurrentChatId } from "../../../script.js";
import { chat_metadata, callPopup, saveSettingsDebounced, is_send_press } from "../../../script.js";
import { getContext, extension_settings, saveMetadataDebounced } from "../../extensions.js";
import {
substituteParams,
@ -7,6 +7,8 @@ import {
generateQuietPrompt,
} from "../../../script.js";
import { registerSlashCommand } from "../../slash-commands.js";
import { waitUntilCondition } from "../../utils.js";
import { is_group_generating, selected_group } from "../../group-chats.js";
const MODULE_NAME = "Objective"
@ -109,6 +111,19 @@ async function checkTaskCompleted() {
if (jQuery.isEmptyObject(currentTask)) {
return
}
try {
// Wait for group to finish generating
if (selected_group) {
await waitUntilCondition(() => is_group_generating === false, 1000, 10);
}
// Another extension might be doing something with the chat, so wait for it to finish
await waitUntilCondition(() => is_send_press === false, 30000, 10);
} catch {
console.debug("Failed to wait for group to finish generating")
return;
}
checkCounter = $('#objective-check-frequency').val()
toastr.info("Checking for task completion.")