Repository navigation
Conversation
…ses (yetanotherbrowser#819) The bench takes the first window's browser at launch and keeps it, and every agent call ran in it (Bench.swift:565). Closing the first window keeps it out of sight with its tabs (BrowserWindows.swift:448), so tabs, find and the tab marked in front came from that hidden window. With today's tabs in every window those are stale copies of the ones on screen. Calls now go to the window in front once the bench's window is closed, and find still reaches a running task's tabs in the closed one.
[Medium impact] The latest changes appear safe to merge. SummaryAgent calls now use a normal window after the first window closes, while calls naming an existing tab use that tab's window.
Reviews (3) · Last reviewed commit: "Agents keep working in a normal window w..." · Reviewed by Greptile |
A tab id not found in the window in front was looked up in every window by find, but the verb then acted on the window in front. The bench now runs a call in the window that holds the tab it names (Bench.holder), so select, close, move and the rest act on that tab's own window, and find is back to looking in one window.
Comments Outside DiffThese findings could not be posted inline.
|
With the first window closed and a private window in front, the bench handed calls to the private window, so a page an agent opened there was a private tab its next call refused. BrowserWindows.live now takes the window in front only when it is a normal one, else the last normal window on screen, else the first window as before.
What changes
With Settings › Tabs › "Today's tabs in every window" on, open a second window, close the first, and ask the side chat about the page in front of you. The chat's
tabscall now lists the second window's tabs, and the tab marked "(in front)" is the one you are looking at. Before this change, the list came from the closed window: old URLs, blank titles, and that window's last front tab marked "in front".Fixes #819
Why it happened
The bench takes the first window's browser at launch and keeps it (
Sources/Fast/Bench.swift:225-228), and every agent call ran in that browser unless a test picked another window (Sources/Fast/Bench.swift:565). Closing the first window doesn't let it go. It stays out of sight with its tabs (Sources/Fast/BrowserWindows.swift:448-453). Soagent-tabs(Sources/Fast/AgentBenchPage.swift:915),find(_:in:)(Sources/Fast/Bench.swift:9692) and the row'sactiveall read the hidden window. With today's tabs in every window, that window holds its own, mostly asleep copy of every tab, which is where the stale rows came from.The fix:
BrowserWindows.live(_:)(Sources/Fast/BrowserWindows.swift:365) returns the bench's window unless it was closed and not shown again. In that case it returns the window in front if that is a normal window, else the last normal window on screen. A private window is never chosen, because a tab opened there is private and the next call would refuse it. If no normal window is up, it still returns the bench's window. It reads the close timesBrowserWindowsalready keeps for ⇧⌘T, which are cleared when the window comes back.Bench.holder(of:in:)(Sources/Fast/Bench.swift:9705) keeps a task that was already working when the first window closed. Its tabs stay in that window. When a call names a tab byidthat isn't in the window in front, the call runs in the window that holds the tab. Select, close, move, pin and every other verb then act on the tab's own window, never the one in front.find(_:in:)is unchanged and still looks in one window, so the callers that checkfind(...) === tabto see whether a tab is still open keep their meaning.Sources/Fast/Bench.swift:565). The test-only window override still comes first.Proof
mainand pass here:swift test --filter AgentLiveWindowTestsAgentLiveWindowTestsopens a first window with a tab on a.example, a second in front on b.example, then closes the first.aClosedFirstWindowHandsTheToolsToTheOneInFrontrunsagent-tabsagainst the browser the bench now picks. Without thelive(_:)change it fails with:aTabInTheClosedFirstWindowIsWorkedInItsOwnWindownames the closed window's tab by its short id, takes the window the bench routes the call to, finds the tab there and selects it as theselectverb does. It expects the routed window to be the first one and the second window's front tab to be unchanged. Withoutholder(of:in:)it fails with:aPrivateWindowInFrontLeavesTheToolsInANormalOneputs a private window in front of the second one before the first closes. Without the normal-window check inlive(_:)it fails with:Checked on
Checklist
swift test --filter 'AgentLiveWindowTests|ClosedWindowTests|TabMoveEveryWindowTests|PrivateEmptyWindowCloseTests|AgentDockStopTests|RemoteTaskReadTests|ChatAskPlaceTests', 58 tests in 7 suites./design-check --headis cleanNativeActions.swift(none added)Not in this PR
Agents.shared.browser, which stays the first window (ChatColumn.swift:54-55), so a chip from the second window is still dropped. This may be Agent: with a Figma members page attached as a chip, 'give them Full Access' made the agent look at a... #850.Agents.shared.browsertoo (AssistantApprovals.swift,ApprovalDetails.swift:374). An approval for a tab an agent opens in the second window, after the first is closed, may not find it.idonly. A verb that takes a list of ids (ids) or a second tab under another key (tab,other,target) looks those up in the window the call runs in, as onmain. A tab in another window under those keys is not found, rather than acted on in the wrong window.Not verified
swift testrun. Only the suites listed above were run.