fix: anchor sentinel observe session summaries (#924)

Co-authored-by: Codex <codex@noreply.local>
This commit is contained in:
Lyon
2026-06-26 04:07:26 +08:00
committed by GitHub
parent 9e17e906e4
commit 6771464b30
2 changed files with 54 additions and 13 deletions
@@ -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();