feat(tabs): batch-close tabs by id list
Testing / remote-protocol-compat (0.9.5) (push) Successful in 44s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 45s
Testing / test (push) Successful in 52s
Build & Publish Package / publish (push) Successful in 32s
Package Extension / package-extension (push) Successful in 35s
Testing / remote-protocol-compat (0.9.5) (push) Successful in 44s
Testing / remote-protocol-compat (0.9.3) (push) Successful in 45s
Testing / test (push) Successful in 52s
Build & Publish Package / publish (push) Successful in 32s
Package Extension / package-extension (push) Successful in 35s
Closing many tabs previously meant one IPC round-trip per tab (tab.close() in a loop). Add a single batched path so callers can close N tabs in one command, reusing the existing large-operation throttle so the browser UI stays responsive. - extension: tabs.close accepts tabIds: number[]; new branch feeds the array through processInBatches/chrome.tabs.remove - sdk: tabs_close(tab_ids=...) takes tab IDs or Tab objects; the payload always carries "tabIds" (null when unused) - tests: cover id-list and Tab-object batch close in test_api.py - bump 0.10.3 -> 0.10.4 (pyproject.toml, manifest.json)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 3,
|
||||
"name": "browser-cli",
|
||||
"version": "0.10.3",
|
||||
"version": "0.10.4",
|
||||
"description": "Control your browser from the terminal or Python SDK",
|
||||
"permissions": [
|
||||
"tabs",
|
||||
|
||||
@@ -19,7 +19,7 @@ export class TabsMutationCommands extends CommandGroup {
|
||||
"tabs.screenshot": (a: TabsScreenshotArgs) => this.tabsScreenshot(a),
|
||||
};
|
||||
|
||||
private async tabsClose({ tabId, inactive, duplicates, gentleMode, __job }: TabsCloseArgs = {}) {
|
||||
private async tabsClose({ tabId, tabIds, inactive, duplicates, gentleMode, __job }: TabsCloseArgs = {}) {
|
||||
return runLargeOperation("tabs.close", async () => {
|
||||
let toClose: number[] = [];
|
||||
if (duplicates) {
|
||||
@@ -33,6 +33,8 @@ export class TabsMutationCommands extends CommandGroup {
|
||||
} else if (inactive) {
|
||||
const all = await chrome.tabs.query({});
|
||||
toClose = all.filter(t => !t.active).map(t => t.id);
|
||||
} else if (tabIds?.length) {
|
||||
toClose = tabIds.filter(id => id != null);
|
||||
} else if (tabId) {
|
||||
toClose = [tabId];
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ export interface NavOpenWaitArgs {
|
||||
}
|
||||
|
||||
// ── Tabs ──────────────────────────────────────────────────────────────────────
|
||||
export interface TabsCloseArgs { tabId?: number; inactive?: boolean; duplicates?: boolean; gentleMode?: string; __job?: Job; }
|
||||
export interface TabsCloseArgs { tabId?: number; tabIds?: number[]; inactive?: boolean; duplicates?: boolean; gentleMode?: string; __job?: Job; }
|
||||
export interface TabsMoveArgs { tabId?: number; groupId?: number; windowId?: number; index?: number; forward?: boolean; backward?: boolean; }
|
||||
export interface TabIdArgs { tabId?: number; }
|
||||
export interface TabsActiveInWindowArgs { windowId?: number; }
|
||||
|
||||
Reference in New Issue
Block a user