Fix startup crash and autosave input interruption

This commit is contained in:
daniellee2015
2026-05-20 04:00:33 +08:00
parent a4810c421f
commit 098b9c3516
4 changed files with 208 additions and 39 deletions
+5 -1
View File
@@ -290,7 +290,7 @@
}
async function closeConflictingTabsForSource(source, currentUrl, options = {}) {
const { excludeTabIds = [] } = options;
const { excludeTabIds = [], preserveActiveTab = true } = options;
const excluded = new Set(excludeTabIds.filter((id) => Number.isInteger(id)));
const state = await getState();
const lastUrl = getSourceMapValue(state.sourceLastUrls, source);
@@ -299,8 +299,12 @@
if (!referenceUrls.length) return;
const tabs = await queryTabsInAutomationWindow({});
const activeTabId = preserveActiveTab
? tabs.find((tab) => Boolean(tab?.active) && Number.isInteger(tab?.id))?.id || null
: null;
const matchedIds = tabs
.filter((tab) => Number.isInteger(tab.id) && !excluded.has(tab.id))
.filter((tab) => !(preserveActiveTab && activeTabId !== null && tab.id === activeTabId))
.filter((tab) => referenceUrls.some((refUrl) => matchesSourceUrlFamily(source, tab.url, refUrl)))
.map((tab) => tab.id);