MCPcopy Index your code
hub / github.com/agent0ai/agent-zero / refreshBrowserSessions

Function refreshBrowserSessions

plugins/_browser/webui/browser-store.js:280–310  ·  view source on GitHub ↗
(contextId = "")

Source from the content-addressed store, hash-verified

278 },
279
280 async refreshBrowserSessions(contextId = "") {
281 const requestedContextId = this.normalizeContextId(contextId || this.resolveContextId());
282 if (this._sessionRefreshPromise) {
283 const inFlightContextId = this._sessionRefreshContextId;
284 await this._sessionRefreshPromise;
285 if (requestedContextId && requestedContextId !== inFlightContextId) {
286 return await this.refreshBrowserSessions(requestedContextId);
287 }
288 return;
289 }
290 this._sessionRefreshContextId = requestedContextId;
291 this._sessionRefreshPromise = (async () => {
292 const response = await websocket.request(
293 "browser_viewer_sessions",
294 { context_id: requestedContextId },
295 { timeoutMs: 10000 },
296 );
297 const data = firstOk(response);
298 this.applyBrowserListing(data.browsers || [], data.context_id || "", {
299 replaceAll: Boolean(data.all_browsers),
300 });
301 })();
302 try {
303 await this._sessionRefreshPromise;
304 } catch (error) {
305 console.warn("Browser session refresh failed", error);
306 } finally {
307 this._sessionRefreshPromise = null;
308 this._sessionRefreshContextId = "";
309 }
310 },
311
312 async syncViewerToSelectedContext(contextId = "") {
313 const selectedContextId = this.normalizeContextId(contextId || this.resolveContextId());

Callers

nothing calls this directly

Calls 2

requestMethod · 0.80
firstOkFunction · 0.70

Tested by

no test coverage detected