fix(tabs): avoid raising automation window
This commit is contained in:
@@ -36,22 +36,9 @@
|
||||
return null;
|
||||
}
|
||||
|
||||
if (typeof chrome?.tabs?.get === 'function' && typeof chrome?.windows?.update === 'function') {
|
||||
try {
|
||||
const tab = await chrome.tabs.get(tabId);
|
||||
const windowId = Number(tab?.windowId);
|
||||
if (Number.isInteger(windowId) && windowId >= 0) {
|
||||
await chrome.windows.update(windowId, { state: 'normal', focused: true }).catch(() => {});
|
||||
await chrome.windows.update(windowId, {
|
||||
focused: true,
|
||||
width: 1200,
|
||||
height: 900,
|
||||
}).catch(() => {});
|
||||
}
|
||||
} catch {
|
||||
// Best-effort only. Step 2 still has content-side entry retries.
|
||||
}
|
||||
}
|
||||
// Do not request window focus here. The automation tab is already
|
||||
// locked to the selected Chrome window; raising that window would
|
||||
// interrupt the user's active workspace.
|
||||
|
||||
if (typeof addLog === 'function') {
|
||||
await addLog(
|
||||
|
||||
@@ -185,31 +185,11 @@
|
||||
});
|
||||
}
|
||||
|
||||
async function normalizeSignupTabWindowForStep2(tabId) {
|
||||
if (
|
||||
!Number.isInteger(tabId)
|
||||
|| typeof chrome?.tabs?.get !== 'function'
|
||||
|| typeof chrome?.windows?.update !== 'function'
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const tab = await chrome.tabs.get(tabId);
|
||||
const windowId = Number(tab?.windowId);
|
||||
if (!Number.isInteger(windowId) || windowId < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
await chrome.windows.update(windowId, { state: 'normal', focused: true }).catch(() => {});
|
||||
await chrome.windows.update(windowId, {
|
||||
focused: true,
|
||||
width: 1200,
|
||||
height: 900,
|
||||
}).catch(() => {});
|
||||
} catch {
|
||||
// Best-effort only: content-side retries still handle layout recovery.
|
||||
}
|
||||
async function keepSignupTabWindowInBackgroundForStep2(tabId) {
|
||||
// Intentionally no-op: the task tab is locked to the selected Chrome
|
||||
// window by the tab-runtime layer. Step 2 must not focus/raise that
|
||||
// window while the user is working in another app or browser window.
|
||||
void tabId;
|
||||
}
|
||||
|
||||
async function ensureSignupPhoneEntryReady(tabId) {
|
||||
@@ -257,7 +237,7 @@
|
||||
signupTabId = (await ensureSignupEntryPageReady(2)).tabId;
|
||||
} else {
|
||||
await chrome.tabs.update(signupTabId, { active: true });
|
||||
await normalizeSignupTabWindowForStep2(signupTabId);
|
||||
await keepSignupTabWindowInBackgroundForStep2(signupTabId);
|
||||
await waitForStep2SignupTabToSettle(
|
||||
signupTabId,
|
||||
'步骤 2:已切换到注册页标签,正在等待页面加载完成并额外稳定 3 秒...'
|
||||
|
||||
Reference in New Issue
Block a user