@@ -30,6 +30,7 @@ const mocks = vi.hoisted(() => ({
3030 addImage : vi . fn ( ) ,
3131 pictureInPicture : false ,
3232 showEmptyState : false ,
33+ idleServerTab : false ,
3334 loading : false ,
3435 nativeServerTab : false ,
3536 serverEpoch : null as string | null ,
@@ -112,17 +113,29 @@ vi.mock(import("~/previewStateStore"), async (original) => ({
112113 recentlySeenUrls : [ ] ,
113114 sessions : mocks . showEmptyState
114115 ? { }
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+ } ,
124138 } ,
125- } ,
126139 } ) ) as never ,
127140} ) ) ;
128141vi . mock ( import ( "~/state/environments" ) , async ( original ) => ( {
@@ -151,6 +164,13 @@ vi.mock(import("~/browser/previewRuntime"), async (original) => ({
151164} ) ) ;
152165
153166vi . 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+ } ) ) ;
154174
155175import { useComposerDraftStore } from "~/composerDraftStore" ;
156176import { useBrowserPointerStore } from "~/browser/browserPointerStore" ;
@@ -201,6 +221,7 @@ function setup() {
201221 mocks . pickElement . mockReset ( ) ;
202222 mocks . pictureInPicture = false ;
203223 mocks . showEmptyState = false ;
224+ mocks . idleServerTab = false ;
204225 mocks . loading = false ;
205226 mocks . nativeServerTab = false ;
206227 mocks . serverEpoch = null ;
@@ -287,6 +308,30 @@ describe("PreviewView", () => {
287308 expect ( mocks . addImage ) . not . toHaveBeenCalled ( ) ;
288309 } ) ;
289310
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 : / l o c a l h o s t : 8 0 8 1 / } ) ;
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+
290335 it ( "focuses and selects the address from forwarded desktop actions only while visible" , async ( ) => {
291336 setup ( ) ;
292337 using stack = new DisposableStack ( ) ;
0 commit comments