feat: add performance controls for large browser ops
- Add throttled large-operation handling for tab, group, and session commands. - Introduce performance profiles, audible-tab aware gentle mode, and job progress tracking. - Support background session restores with status/cancel commands and lazy placeholders. - Expose new perf and extension CLI groups plus matching Python SDK methods. - Preserve pinned tabs during session snapshots and debounce auto-save updates. - Bump browser-cli and extension versions to 0.10.0 and add pytest-cov to dev deps. - Add coverage for performance controls, background jobs, lazy restores, and tab metadata.
This commit is contained in:
+55
-2
@@ -758,8 +758,61 @@ class BrowserCLI:
|
||||
def session_save(self, name: str) -> None:
|
||||
self._cmd("session.save", {"name": name})
|
||||
|
||||
def session_load(self, name: str) -> None:
|
||||
self._cmd("session.load", {"name": name})
|
||||
def session_load(
|
||||
self,
|
||||
name: str,
|
||||
*,
|
||||
gentle_mode: str = "auto",
|
||||
discard_background_tabs: bool = False,
|
||||
lazy: bool = False,
|
||||
eager_tabs: int = 10,
|
||||
) -> None:
|
||||
self._cmd("session.load", {
|
||||
"name": name,
|
||||
"gentleMode": gentle_mode,
|
||||
"discardBackgroundTabs": discard_background_tabs,
|
||||
"lazy": lazy,
|
||||
"eagerTabs": eager_tabs,
|
||||
})
|
||||
|
||||
def session_load_background(
|
||||
self,
|
||||
name: str,
|
||||
*,
|
||||
gentle_mode: str = "auto",
|
||||
discard_background_tabs: bool = False,
|
||||
lazy: bool = False,
|
||||
eager_tabs: int = 10,
|
||||
) -> dict:
|
||||
return self._cmd("session.load", {
|
||||
"name": name,
|
||||
"gentleMode": gentle_mode,
|
||||
"discardBackgroundTabs": discard_background_tabs,
|
||||
"lazy": lazy,
|
||||
"eagerTabs": eager_tabs,
|
||||
"__background": True,
|
||||
}) or {}
|
||||
|
||||
def job_status(self, job_id: str) -> dict:
|
||||
return self._cmd("jobs.status", {"jobId": job_id}) or {}
|
||||
|
||||
def job_cancel(self, job_id: str) -> dict:
|
||||
return self._cmd("jobs.cancel", {"jobId": job_id}) or {}
|
||||
|
||||
def reload_extension(self) -> None:
|
||||
"""Reload the browser-cli extension service worker.
|
||||
|
||||
Schedules a ``chrome.runtime.reload()`` inside the extension and returns
|
||||
immediately. The extension restarts ~200 ms later and reconnects via the
|
||||
keepalive alarm within ~25 seconds.
|
||||
"""
|
||||
self._cmd("extension.reload", {})
|
||||
|
||||
def perf_status(self) -> dict:
|
||||
return self._cmd("perf.status", {}) or {}
|
||||
|
||||
def set_performance_profile(self, profile: str) -> dict:
|
||||
return self._cmd("perf.set_profile", {"profile": profile}) or {}
|
||||
|
||||
def session_diff(self, name_a: str, name_b: str) -> dict:
|
||||
return self._cmd("session.diff", {"nameA": name_a, "nameB": name_b}) or {}
|
||||
|
||||
Reference in New Issue
Block a user