INNER CODE UNIT · TypeScript
lastPage
hyperbrowserai/HyperAgent · src/agent/index.ts:316
const lastPage = pages[pages.length - 1];
// If the last page is different and not closed, switch to it
// We prefer the newest page as it's likely the result of the user's last action
if (lastPage && !lastPage.isClosed() && lastPage !== this._currentPage) {
if (this.debug) {
console.log(
`[HyperAgent] Polling detected new page, switching focus: ${lastPage.url()}`
);
}
this._currentPage = lastPage;
}
}
if (!this.currentPage || this.currentPage.isClosed()) {
this._currentPage = await this.context.newPage();
return this.setupHyperPage(this._currentPage);
}