The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 23:30 UTC
fix(web): local server cards in the browser empty state take pointer clicks (#34050)
Julius Marminge committed
Nov 11, 2026 at 00:14 UTC
f697d4db3e32c30a1ff16f9970ee4d69e9f608d5
2 files changed
+60
-15
apps/web/src/components/preview/PreviewView.browser.test.tsx
+55
-10
@@ -30,6 +30,7 @@ const mocks = vi.hoisted(() => ({
30
addImage: vi.fn(),
31
pictureInPicture: false,
32
showEmptyState: false,
33
+ idleServerTab: false,
34
loading: false,
35
nativeServerTab: false,
36
serverEpoch: null as string | null,
@@ -112,17 +113,29 @@ vi.mock(import("~/previewStateStore"), async (original) => ({
113
recentlySeenUrls: [],
114
sessions: mocks.showEmptyState
115
? {}
115
- : {
116
- "tab-1": {
117
- threadId: "thread-1",
118
- tabId: "tab-1",
119
- runtime: mocks.nativeServerTab ? "server" : "desktop",
120
- navStatus: { _tag: "Success", url: "http://example.com/", title: "Example" },
121
- canGoBack: false,
122
- canGoForward: false,
123
- updatedAt: "2026-07-13T00:00:00.000Z",
116
+ : mocks.idleServerTab
117
+ ? {
118
+ "tab-1": {
119
+ threadId: "thread-1",
120
+ tabId: "tab-1",
121
+ runtime: "server",
122
+ navStatus: { _tag: "Idle" },
123
+ canGoBack: false,
124
+ canGoForward: false,
125
+ updatedAt: "2026-07-13T00:00:00.000Z",
126
+ },
127
+ }
128
+ : {
129
+ "tab-1": {
130
+ threadId: "thread-1",
131
+ tabId: "tab-1",
132
+ runtime: mocks.nativeServerTab ? "server" : "desktop",
133
+ navStatus: { _tag: "Success", url: "http://example.com/", title: "Example" },
134
+ canGoBack: false,
135
+ canGoForward: false,
136
+ updatedAt: "2026-07-13T00:00:00.000Z",
137
+ },
138
},
125
- },
139
})) as never,
140
}));
141
vi.mock(import("~/state/environments"), async (original) => ({
@@ -151,6 +164,13 @@ vi.mock(import("~/browser/previewRuntime"), async (original) => ({
164
}));
165
166
vi.mock(import("~/browser/browserViewportActions"), { spy: true });
167
+// The real surface opens a preview stream to the server; only its box matters here.
168
+vi.mock(import("~/browser/ServerBrowserSurface"), async (original) => ({
169
+ ...(await original()),
170
+ ServerBrowserSurface: ((props: { className?: string }) => (
171
+ <div data-testid="server-browser-surface" className={props.className} />
172
+ )) as never,
173
+}));
174
175
import { useComposerDraftStore } from "~/composerDraftStore";
176
import { useBrowserPointerStore } from "~/browser/browserPointerStore";
@@ -201,6 +221,7 @@ function setup() {
221
mocks.pickElement.mockReset();
222
mocks.pictureInPicture = false;
223
mocks.showEmptyState = false;
224
+ mocks.idleServerTab = false;
225
mocks.loading = false;
226
mocks.nativeServerTab = false;
227
mocks.serverEpoch = null;
@@ -287,6 +308,30 @@ describe("PreviewView", () => {
308
expect(mocks.addImage).not.toHaveBeenCalled();
309
});
310
311
+ it("lets the pointer reach a local server card above an idle server-rendered tab", async () => {
312
+ setup();
313
+ mocks.idleServerTab = true;
314
+ mocks.servers = [
315
+ {
316
+ host: "localhost",
317
+ port: 8081,
318
+ url: "http://localhost:8081/",
319
+ requestedUrl: "http://localhost:8081/",
320
+ processName: "python3",
321
+ pid: 4242,
322
+ terminal: null,
323
+ source: "scanner",
324
+ },
325
+ ];
326
+ await using _screen = await render(<ToastProvider timeout={0}>{view()}</ToastProvider>);
327
+ const card = page.getByRole("button", { name: /localhost:8081/ });
328
+ await expect.element(card).toBeVisible();
329
+
330
+ const rect = card.element().getBoundingClientRect();
331
+ const hit = document.elementFromPoint(rect.x + rect.width / 2, rect.y + rect.height / 2);
332
+ expect(card.element().contains(hit)).toBe(true);
333
+ });
334
+
335
it("focuses and selects the address from forwarded desktop actions only while visible", async () => {
336
setup();
337
using stack = new DisposableStack();
apps/web/src/components/preview/PreviewView.tsx
+5
-5
@@ -991,7 +991,10 @@ export function PreviewView({
991
</div>
992
) : null}
993
<div
994
- className="absolute inset-x-0 bottom-0"
994
+ className={cn(
995
+ "absolute inset-x-0 bottom-0",
996
+ (showEmptyState || isUnreachable) && "invisible",
997
+ )}
998
style={{ top: viewport._tag !== "fill" ? BROWSER_DEVICE_TOOLBAR_HEIGHT : 0 }}
999
>
1000
<ServerBrowserSurface
@@ -1012,10 +1015,7 @@ export function PreviewView({
1015
}
1016
onPopup={(popupTabId) => showPreviewPopup(threadRef, popupTabId, "panel")}
1017
// Stays connected under the empty state so a URL picked there reaches the page.
1015
- className={cn(
1016
- "absolute inset-0 h-full w-full",
1017
- (showEmptyState || isUnreachable) && "invisible",
1018
- )}
1018
+ className="absolute inset-0 h-full w-full"
1019
/>
1020
</div>
1021
</>