Repository navigation
fix(server): show the page a person opened from an agent browser tab #18234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1143,26 +1143,32 @@ const make = Effect.gen(function* () { | |
|
|
||
| const adoptPopup = async (opener: ServerTab, popup: Page) => { | ||
| const agentId = opener.control.agentId; | ||
| // Whoever holds the pointer clicked. Google results use target=_blank, so the | ||
| // page they asked for only exists as this popup. Hide it and the click looks dead. | ||
| const humanId = opener.control.controller; | ||
| // A popup past an agent's limit closes; its page sees window.open return a closed window. | ||
| if (opener.closing || (agentId !== null && atTabLimit(agentId))) { | ||
| // A person driving the tab is not spending that hidden-tab budget. | ||
| if (opener.closing || (agentId !== null && humanId === null && atTabLimit(agentId))) { | ||
| await popup.close().catch(constVoid); | ||
| return; | ||
| } | ||
| const url = popup.url(); | ||
| // Captured now: the person whose click opened the popup gets switched to it. | ||
| const controller = [...opener.viewers].find( | ||
| (viewer) => viewer.id === opener.control.controller, | ||
| ); | ||
| const controller = [...opener.viewers].find((viewer) => viewer.id === humanId); | ||
| await Effect.runPromise( | ||
| manager.open({ | ||
| threadId: opener.threadId, | ||
| ...(/^https?:/i.test(url) ? { url } : {}), | ||
| runtime: "server", | ||
| ...(opener.profileId === undefined ? {} : { profileId: opener.profileId }), | ||
| // Agent popups stay with the agent and only float when it asks, like its own opens. | ||
| ...(opener.control.agentId === null | ||
| // A person's click on that same tab has to come forward, or the link never shows. | ||
| ...(agentId === null | ||
| ? {} | ||
| : { automationOwner: opener.control.agentId, reveal: false }), | ||
| : { | ||
| automationOwner: agentId, | ||
| ...(humanId === null ? { reveal: false } : { reveal: true }), | ||
|
Comment on lines
+1169
to
+1170
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Exclude person-driven popups from the hidden-agent tab count. A person-driven popup keeps 🤖 Prompt for AI Agents |
||
| }), | ||
| beforePublish: (snapshot) => | ||
| adoptedPages.set(tabKey(snapshot.threadId, snapshot.tabId), { | ||
| page: popup, | ||
|
|
@@ -1172,8 +1178,7 @@ const make = Effect.gen(function* () { | |
| ).then( | ||
| (snapshot) => { | ||
| // The opener stays open behind it, so `window.opener` can still report back. | ||
| if (opener.control.agentId === null) | ||
| controller?.push({ _tag: "popup", tabId: snapshot.tabId }); | ||
| if (humanId !== null) controller?.push({ _tag: "popup", tabId: snapshot.tabId }); | ||
| }, | ||
| async () => { | ||
| await popup.close().catch(constVoid); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Keep the server-wide tab limit for person-driven popups.
When
humanIdis non-null, this condition skipsatTabLimit. That function also enforcesSERVER_TAB_LIMIT, so a person who controls an agent-owned opener can create popups beyond the server-wide limit. Check server capacity independently while exempting the popup only from the hidden-agent limit.🤖 Prompt for AI Agents