@@ -23,9 +23,9 @@ def __init__(
2323 self ,
2424 command : str ,
2525 * ,
26- write_bytes : Callable [[bytes ], Awaitable ],
27- write_str : Callable [[str ], Awaitable ],
28- close : Callable [[], Awaitable ],
26+ write_bytes : Callable [[bytes ], Awaitable [ None ] ],
27+ write_str : Callable [[str ], Awaitable [ None ] ],
28+ close : Callable [[], Awaitable [ None ] ],
2929 debug : bool = False ,
3030 ) -> None :
3131 self .command = command
@@ -35,7 +35,7 @@ def __init__(
3535 self .debug = debug
3636
3737 self ._process : Process | None = None
38- self ._task : asyncio .Task | None = None
38+ self ._task : asyncio .Task [ None ] | None = None
3939 self ._stdin : asyncio .StreamWriter | None = None
4040 self ._exit_event = asyncio .Event ()
4141
@@ -268,7 +268,23 @@ async def on_meta(self, data: bytes) -> None:
268268 Args:
269269 data: Encoded meta data.
270270 """
271- meta_data = json .loads (data )
271+ meta_data : dict [str , object ] = json .loads (data )
272+ meta_type = meta_data ["type" ]
272273
273- if meta_data [ "type" ] == "exit" :
274+ if meta_type == "exit" :
274275 await self .remote_close ()
276+ elif meta_type == "open_url" :
277+ payload = json .dumps (
278+ [
279+ "open_url" ,
280+ {
281+ "url" : meta_data ["url" ],
282+ "new_tab" : meta_data ["new_tab" ],
283+ },
284+ ]
285+ )
286+ await self .remote_write_str (payload )
287+ else :
288+ log .warning (
289+ f"Unknown meta type: { meta_type !r} . You may need to update `textual-serve`."
290+ )
0 commit comments