cdp-tunnel 2.7.7 → 2.7.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -227,6 +227,25 @@ var SpecialHandler = (function() {
|
|
|
227
227
|
if (callback) callback(false);
|
|
228
228
|
return;
|
|
229
229
|
}
|
|
230
|
+
var cachedGroupId = State.getGroupIdForClient(clientId);
|
|
231
|
+
if (cachedGroupId) {
|
|
232
|
+
Logger.info('[TabGroup] Using cached groupId:', cachedGroupId, 'for client:', clientId);
|
|
233
|
+
chrome.tabs.group({ tabIds: tabId, groupId: cachedGroupId }, function(result) {
|
|
234
|
+
if (!chrome.runtime.lastError) {
|
|
235
|
+
updateTabGroupName(clientId);
|
|
236
|
+
Logger.info('[TabGroup] Tab', tabId, 'added to cached group:', cachedGroupId);
|
|
237
|
+
if (callback) callback(true);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
Logger.warn('[TabGroup] Cached groupId', cachedGroupId, 'failed:', chrome.runtime.lastError.message, '— falling back to query');
|
|
241
|
+
doGroupQuery(tabId, clientId, baseName, retries, callback);
|
|
242
|
+
});
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
doGroupQuery(tabId, clientId, baseName, retries, callback);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
function doGroupQuery(tabId, clientId, baseName, retries, callback) {
|
|
230
249
|
chrome.tabGroups.query({}, function(allGroups) {
|
|
231
250
|
if (chrome.runtime.lastError) {
|
|
232
251
|
Logger.error('[TabGroup] tabGroups.query failed:', chrome.runtime.lastError.message);
|
|
@@ -267,7 +286,7 @@ var SpecialHandler = (function() {
|
|
|
267
286
|
}
|
|
268
287
|
Logger.info('[TabGroup] chrome.tabs.group returned groupId:', groupId);
|
|
269
288
|
EventBuilder.send('CDPTunnel.debug', { source: 'doGroup', phase: 'groupCreated', tabId: tabId, groupId: groupId });
|
|
270
|
-
|
|
289
|
+
if (groupId) {
|
|
271
290
|
if (chrome.tabGroups) {
|
|
272
291
|
chrome.tabGroups.update(groupId, {
|
|
273
292
|
title: baseName,
|
|
@@ -488,24 +488,17 @@ var WebSocketManager = (function() {
|
|
|
488
488
|
Logger.info('[Monitor] Tab', tabId, 'escaped! Forcing regroup for client:', clientId);
|
|
489
489
|
if (groupId) {
|
|
490
490
|
chrome.tabs.group({ tabIds: tabId, groupId: groupId }, function() {
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
Logger.error('[Monitor] Failed to create group for tab', tabId, ':', chrome.runtime.lastError?.message);
|
|
498
|
-
return;
|
|
491
|
+
if (chrome.runtime.lastError) {
|
|
492
|
+
Logger.error('[Monitor] Failed to re-add tab', tabId, 'to group', groupId, ':', chrome.runtime.lastError?.message);
|
|
493
|
+
State.removeGroupForClient(clientId);
|
|
494
|
+
SpecialHandler.addTabToAutomationGroup(tabId, clientId);
|
|
495
|
+
} else {
|
|
496
|
+
Logger.info('[Monitor] Re-added tab', tabId, 'to existing group:', groupId);
|
|
499
497
|
}
|
|
500
|
-
chrome.tabGroups.update(newGroupId, {
|
|
501
|
-
title: baseName,
|
|
502
|
-
color: CDPUtils.getGroupColorForClient(clientId),
|
|
503
|
-
collapsed: true
|
|
504
|
-
}, function() {
|
|
505
|
-
State.setGroupIdForClient(clientId, newGroupId);
|
|
506
|
-
Logger.info('[Monitor] Created new group', newGroupId, 'for escaped tab', tabId);
|
|
507
|
-
});
|
|
508
498
|
});
|
|
499
|
+
} else {
|
|
500
|
+
Logger.info('[Monitor] No cached groupId for client', clientId, '— delegating to addTabToAutomationGroup for tab', tabId);
|
|
501
|
+
SpecialHandler.addTabToAutomationGroup(tabId, clientId);
|
|
509
502
|
}
|
|
510
503
|
});
|
|
511
504
|
});
|
package/package.json
CHANGED