fix: wait for sentinel submit readiness
This commit is contained in:
@@ -1166,11 +1166,17 @@ async function sendPrompt(text, options = {}) {
|
||||
].join(", ")).last();
|
||||
await submit.waitFor({ state: "visible", timeout: 15000 });
|
||||
if (options.expectedAction) {
|
||||
await page.waitForFunction(({ selector, expected }) => {
|
||||
const element = document.querySelector(selector);
|
||||
return element?.getAttribute("data-action") === expected || element?.getAttribute("disabled") !== null;
|
||||
}, { selector: primarySubmitSelector, expected: options.expectedAction }, { timeout: 1000 }).catch(() => null);
|
||||
const composer = await composerButtonState(submit);
|
||||
const actionWaitMs = Number.isFinite(Number(options.expectedActionWaitMs))
|
||||
? Math.max(1000, Math.trunc(Number(options.expectedActionWaitMs)))
|
||||
: options.expectedAction === "turn" ? 180000 : 1000;
|
||||
const actionDeadline = Date.now() + actionWaitMs;
|
||||
let composer = null;
|
||||
while (Date.now() <= actionDeadline) {
|
||||
composer = await composerButtonState(submit);
|
||||
if (composer.action === options.expectedAction && composer.disabled !== true) break;
|
||||
await page.waitForTimeout(250);
|
||||
}
|
||||
composer = composer || await composerButtonState(submit);
|
||||
if (composer.action !== options.expectedAction || composer.disabled === true) {
|
||||
await clearComposerEditor(editor).catch(() => {});
|
||||
const sideEffect = await waitForPromptSideEffect(beforeEvidence, 200).catch(() => promptSideEffectSnapshot());
|
||||
@@ -1190,6 +1196,7 @@ async function sendPrompt(text, options = {}) {
|
||||
responseObserved: false,
|
||||
sideEffectObserved: sideEffectHasAuthoritativePromptSubmission(sideEffect),
|
||||
sideEffect,
|
||||
actionWaitMs,
|
||||
expectedAction: options.expectedAction,
|
||||
actualAction: composer.action,
|
||||
valuesRedacted: true
|
||||
|
||||
Reference in New Issue
Block a user