fix tab page history so we can restore if page tab is closed - #65
Conversation
|
|
||
| // History Stack: [Root, Tab1, Tab2, ...] | ||
| const pageStack: Page[] = [page]; | ||
| const getActivePage = () => pageStack[pageStack.length - 1]; |
There was a problem hiding this comment.
Bug: Empty page stack returns undefined
When all pages in the pageStack are closed (including the root page), getActivePage() returns undefined because it accesses pageStack[pageStack.length - 1] on an empty array. This undefined value is then passed to executeTask, executeSingleAction, and executeTaskAsync, causing runtime errors since these methods expect a valid Page object. The page stack needs to handle the empty state or prevent the root page from being removed.
| const activePage = await this.getCurrentPage(); | ||
| return this.executeSingleAction(instruction, activePage, params); | ||
| // Listen for close on the root page | ||
| page.on("close", () => handleClose(page)); |
There was a problem hiding this comment.
Bug: Memory leak from accumulating close event listeners
When setupHyperPage is called multiple times on the same page (e.g., through repeated getPages() calls), new close event listeners are added to pages without removing the old ones. The _scopeListenerCleanup function only removes the context's page listener but doesn't clean up the close listeners attached to individual pages at lines 1151 and 1167. This causes close listeners to accumulate, creating a memory leak where each page holds references to multiple obsolete closures.
Note
Stops global auto-switching on new tabs, adds per-task and per-page scoped tab tracking with auto-follow and retries, and bumps version to 1.0.4.
this._currentPageon contextpageevents to preserve scoped interactions.executeTask/executeTaskAsyncby trackingactiveTaskPageand updating when a child tab opens; ensure listener cleanup.executeSingleActionto acceptPage | (() => Page), lock toinitialPage, and abort with 409 on context switches; useinitialPagefor CDP/runtime and debug.getActivePage.ai/aiAsyncto scopedgetActivePageand keep background tasks auto-following.aiActionretries when page context switches (tab changes) and brief stabilization waits.pagelistener with cleanup to track tab flow.package.jsonto1.0.4.Written by Cursor Bugbot for commit 5099e1a. This will update automatically on new commits. Configure here.