fix: anchor sentinel observe session summaries (#924)
Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
@@ -16,16 +16,40 @@ async function cancelRunningTurn() {
|
||||
await page.keyboard.press("Backspace").catch(() => {});
|
||||
}
|
||||
}
|
||||
const cancelSelectors = [
|
||||
'button:has-text("取消")',
|
||||
'button:has-text("Cancel")',
|
||||
'[data-testid*="cancel" i]',
|
||||
'[aria-label*="cancel" i]',
|
||||
'[aria-label*="取消"]'
|
||||
].join(", ");
|
||||
const primaryButton = page.locator('#command-submit, [data-testid="command-submit"], [data-testid="composer-submit"], [data-testid="send-command"]').last();
|
||||
const button = await primaryButton.isVisible().catch(() => false)
|
||||
? primaryButton
|
||||
: page.locator([
|
||||
'button:has-text("取消")',
|
||||
'button:has-text("Cancel")',
|
||||
'[data-testid*="cancel" i]',
|
||||
'[aria-label*="cancel" i]',
|
||||
'[aria-label*="取消"]'
|
||||
].join(", ")).last();
|
||||
const explicitCancelButton = page.locator(cancelSelectors).last();
|
||||
let button = null;
|
||||
if (await primaryButton.isVisible().catch(() => false)) {
|
||||
const primaryLooksCancelable = await primaryButton.evaluate((element) => {
|
||||
const parts = [
|
||||
element.textContent || "",
|
||||
element.getAttribute("aria-label") || "",
|
||||
element.getAttribute("title") || "",
|
||||
element.getAttribute("data-testid") || "",
|
||||
element.getAttribute("data-state") || "",
|
||||
element.getAttribute("data-action") || "",
|
||||
element.className || ""
|
||||
];
|
||||
return /cancel|取消|停止|stop|abort/i.test(parts.join(" "));
|
||||
}).catch(() => false);
|
||||
if (primaryLooksCancelable) button = primaryButton;
|
||||
}
|
||||
if (button === null && await explicitCancelButton.isVisible().catch(() => false)) button = explicitCancelButton;
|
||||
if (button === null) {
|
||||
return {
|
||||
beforeUrl,
|
||||
afterUrl: currentPageUrl(),
|
||||
cancelSubmit: { status: null, statusText: null, skipped: true, reason: "cancel-button-not-visible", responseObserved: false },
|
||||
pageId
|
||||
};
|
||||
}
|
||||
await button.waitFor({ state: "visible", timeout: 15000 });
|
||||
const cancelResponsePromise = page.waitForResponse((response) => {
|
||||
const request = response.request();
|
||||
|
||||
Reference in New Issue
Block a user