The best way to control Claude Code, Codex and more from any computer or phone
fix(desktop): agents see visible:true while the desktop shows their tab (#23589)
Co-authored-by: PR Batch Tester <agent@local.test> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
shivam committed
Nov 10, 2026 at 07:42 UTC
5ae957848a3bac1324213f68dc3e091b23f8a69b
2 files changed
+44
-4
apps/server/src/preview/ServerBrowser.test.ts
+41
@@ -1961,6 +1961,47 @@ it.effect("a stalled desktop viewer still gets its size, control and reconnect",
1961
).pipe(Effect.provide(layer)),
1962
);
1963
1964
+it.live("the tab the desktop shows is visible and picked for agents without a tab", () =>
1965
+ Effect.scoped(
1966
+ Effect.gen(function* () {
1967
+ const broker = yield* Broker.PreviewAutomationBroker;
1968
+ const manager = yield* Manager.PreviewManager;
1969
+ yield* ServerBrowser.ServerBrowser;
1970
+ yield* Effect.yieldNow;
1971
+ const openDesktopTab = Effect.fn("openDesktopTab")(function* (url: string) {
1972
+ desktopRendersNext = true;
1973
+ const opened = yield* manager.open({
1974
+ threadId: scope.thread.threadId,
1975
+ url,
1976
+ runtime: "server",
1977
+ });
1978
+ const tabId = PreviewTabId.make(opened.tabId);
1979
+ yield* broker.invoke({ scope, tabId, operation: "status", input: {} });
1980
+ return tabId;
1981
+ });
1982
+ const recentTab = yield* openDesktopTab("http://localhost:5173/recent");
1983
+ const shownTab = yield* openDesktopTab("http://localhost:5173/shown");
1984
+ // Opened first and used last, so recency or insertion order alone picks it.
1985
+ yield* broker.invoke({ scope, tabId: recentTab, operation: "status", input: {} });
1986
+
1987
+ shownDesktopTabs.add(shownTab);
1988
+ const status = yield* broker.invoke<PreviewAutomationStatus>({
1989
+ scope: asSession("agent-b"),
1990
+ operation: "status",
1991
+ input: {},
1992
+ });
1993
+ expect(status).toMatchObject({
1994
+ tabId: shownTab,
1995
+ visible: true,
1996
+ tabs: [
1997
+ expect.objectContaining({ tabId: recentTab, visible: false }),
1998
+ expect.objectContaining({ tabId: shownTab, visible: true }),
1999
+ ],
2000
+ });
2001
+ }),
2002
+ ).pipe(Effect.provide(layer)),
2003
+);
2004
+
2005
it.live("agents read a human's tab with no arguments and act on it only while nobody drives", () =>
2006
Effect.scoped(
2007
Effect.gen(function* () {
apps/server/src/preview/ServerBrowser.ts
+3
-4
@@ -1511,8 +1511,7 @@ const make = Effect.gen(function* () {
1511
.sort((left, right) => right.createdAt - left.createdAt)[0] ??
1512
threadTabs.sort(
1513
(left, right) =>
1514
- Number(right.viewers.size > 0) - Number(left.viewers.size > 0) ||
1515
- right.usedAt - left.usedAt,
1514
+ Number(isVisible(right)) - Number(isVisible(left)) || right.usedAt - left.usedAt,
1515
)[0]
1516
);
1517
};
@@ -1621,7 +1620,7 @@ const make = Effect.gen(function* () {
1620
const viewport = tab.desktop ? await layoutSize(tab) : tab.page.viewportSize();
1621
const status = {
1622
available: true,
1624
- visible: tab.viewers.size > 0,
1623
+ visible: isVisible(tab),
1624
tabId: tab.tabId,
1625
url: url === "about:blank" ? null : url,
1626
title: null,
@@ -1648,7 +1647,7 @@ const make = Effect.gen(function* () {
1647
...(candidate.openerTabId === undefined ? {} : { openerTabId: candidate.openerTabId }),
1648
owner: tabOwner(candidate),
1649
ownedByCaller: candidate.control.agentId === agentSessionId,
1651
- visible: candidate.viewers.size > 0,
1650
+ visible: isVisible(candidate),
1651
...(candidate.profileId === undefined ? {} : { profileId: candidate.profileId }),
1652
})),
1653
...profileStatus(),