@@ -340,18 +340,9 @@ chrome.runtime.onConnect.addListener(async (port) => {
340
340
} ) ;
341
341
}
342
342
343
- // every time devtool is closed, remove the port from portsArr
344
- // port.onDisconnect.addListener((e) => {
345
- // for (let i = 0; i < portsArr.length; i += 1) {
346
- // if (portsArr[i] === e) {
347
- // portsArr.splice(i, 1);
348
- // chrome.runtime.sendMessage({ action: 'portDisconnect', port: e.name });
349
- // break;
350
- // }
351
- // }
352
- // }); //ellie commented out
343
+ // Handles port disconnection by removing the disconnected port and attempting reconnection after 1s delay
344
+ // This prevents permanent connection loss during idle periods or temporary disconnects -ellie
353
345
port . onDisconnect . addListener ( ( e ) => {
354
- //ellie added reconnection attempt
355
346
for ( let i = 0 ; i < portsArr . length ; i += 1 ) {
356
347
if ( portsArr [ i ] === e ) {
357
348
portsArr . splice ( i , 1 ) ;
@@ -448,18 +439,15 @@ chrome.runtime.onConnect.addListener(async (port) => {
448
439
toggleAxRecord = ! toggleAxRecord ;
449
440
450
441
await replaceEmptySnap ( tabsObj , tabId , toggleAxRecord ) ;
451
-
452
442
// sends new tabs obj to devtools
453
443
if ( portsArr . length > 0 ) {
454
- console . log ( 'Sending snapshots to frontend:' , tabsObj [ tabId ] . snapshots ) ; //ellie
455
444
portsArr . forEach ( ( bg ) =>
456
445
bg . postMessage ( {
457
446
action : 'sendSnapshots' ,
458
447
payload : tabsObj ,
459
448
tabId,
460
449
} ) ,
461
450
) ;
462
- console . log ( 'Current tabsObj:' , tabsObj ) ; //ellie
463
451
}
464
452
return true ; // return true so that port remains open
465
453
@@ -621,16 +609,7 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
621
609
break ;
622
610
}
623
611
624
- // DUPLICATE SNAPSHOT CHECK
625
- // This may be where the bug is coming from that when Reactime fails to collect
626
- // state. If they happen to take the same actual duration, it won't record the snapshot.
627
- // const previousSnap = //ellie commented out
628
- // tabsObj[tabId]?.currLocation?.stateSnapshot?.children[0]?.componentData?.actualDuration;
629
- // const incomingSnap = request.payload.children[0].componentData.actualDuration;
630
- // if (previousSnap === incomingSnap) {
631
- // break;
632
- // }
633
- // ellie added new duplicate snapshot check
612
+ // DUPLICATE SNAPSHOT CHECK -ellie
634
613
const isDuplicateSnapshot = ( previous , incoming ) => {
635
614
if ( ! previous || ! incoming ) return false ;
636
615
const prevData = previous ?. componentData ;
@@ -658,7 +637,6 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
658
637
// don't add anything to snapshot storage if tab is reloaded for the initial snapshot
659
638
reloaded [ tabId ] = false ;
660
639
} else {
661
- console . log ( 'Adding new snapshot to snapshots array.' ) ; //ellie
662
640
tabsObj [ tabId ] . snapshots . push ( request . payload ) ;
663
641
// INVOKING buildHierarchy FIGURE OUT WHAT TO PASS IN
664
642
if ( ! tabsObj [ tabId ] [ index ] ) {
@@ -671,12 +649,10 @@ chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => {
671
649
addedAxSnap = 'emptyAxSnap' ;
672
650
tabsObj [ tabId ] . axSnapshots . push ( addedAxSnap ) ;
673
651
}
674
- console . log ( 'Updating hierarchy with new snapshot.' ) ; //ellie
675
652
sendToHierarchy (
676
653
tabsObj [ tabId ] ,
677
654
new HistoryNode ( tabsObj [ tabId ] , request . payload , addedAxSnap ) ,
678
655
) ;
679
- console . log ( 'Updated hierarchy:' , tabsObj [ tabId ] . hierarchy ) ; //ellie
680
656
}
681
657
}
682
658
@@ -751,15 +727,10 @@ chrome.tabs.onActivated.addListener((info) => {
751
727
if ( ! tab . pendingUrl ?. match ( '^chrome-extension' ) ) {
752
728
activeTab = tab ;
753
729
754
- /**this setInterval is here to make sure that the app does not stop working even
755
- * if chrome pauses to save energy. There is probably a better solution, but v25 did
756
- * not have time to complete.
730
+ /**this setKeepAlive is here to make sure that the app does not stop working even
731
+ * if chrome pauses to save energy.
757
732
*/
758
- // setInterval(() => {
759
- // console.log(activeTab);
760
- // }, 10000); //ellie commented out
761
733
chrome . runtime . onStartup . addListener ( ( ) => {
762
- //ellie replaced with this
763
734
chrome . runtime . setKeepAlive ( true ) ;
764
735
} ) ;
765
736
if ( portsArr . length > 0 ) {
0 commit comments