diff --git a/src/textual/devtools/client.py b/src/textual/devtools/client.py index 788e893af..a9a1a5971 100644 --- a/src/textual/devtools/client.py +++ b/src/textual/devtools/client.py @@ -14,7 +14,6 @@ from aiohttp import ClientResponseError, ClientConnectorError, ClientWebSocketRe from rich.console import Console from rich.segment import Segment - DEFAULT_PORT = 8081 WEBSOCKET_CONNECT_TIMEOUT = 3 LOG_QUEUE_MAXSIZE = 512 @@ -40,14 +39,10 @@ class DevtoolsConsole(Console): class DevtoolsConnectionError(Exception): """Raise when the devtools client is unable to connect to the server""" - pass - class ClientShutdown: """Sentinel type sent to client queue(s) to indicate shutdown""" - pass - class DevtoolsClient: """Client responsible for websocket communication with the devtools server. diff --git a/src/textual/devtools/renderables.py b/src/textual/devtools/renderables.py index dd0769757..77cc5df0b 100644 --- a/src/textual/devtools/renderables.py +++ b/src/textual/devtools/renderables.py @@ -5,6 +5,9 @@ from datetime import datetime, timezone from pathlib import Path from typing import Iterable +from rich.style import Style +from rich.text import Text + if sys.version_info >= (3, 8): from typing import Literal else: @@ -59,7 +62,9 @@ class DevtoolsLogMessage: file_and_line = escape(f"{Path(self.path).name}:{self.line_number}") table.add_row( f" [#888177]{local_time.time()} [dim]{timezone_name}[/]", - Align.right(f"[#888177][link={file_link}]{file_and_line} "), + Align.right( + Text(f"{file_and_line} ", style=Style(color="#888177", link=file_link)) + ), style="on #292724", ) yield table diff --git a/src/textual/devtools/service.py b/src/textual/devtools/service.py index 67eb5ec1b..21f136005 100644 --- a/src/textual/devtools/service.py +++ b/src/textual/devtools/service.py @@ -92,11 +92,13 @@ class DevtoolsService: """Handles a single client connection""" client = ClientHandler(request, service=self) self.clients.append(client) - websocket = await client.start() + websocket = await client.run() self.clients.remove(client) return websocket async def shutdown(self) -> None: + """Stop server async tasks and clean up all client handlers""" + # Stop polling/writing Console dimensions to clients self.shutdown_event.set() await self.size_poll_task @@ -180,7 +182,7 @@ class ClientHandler: self.service.console.print(info_renderable) self.incoming_queue.task_done() - async def start(self) -> WebSocketResponse: + async def run(self) -> WebSocketResponse: """Prepare the websocket and communication queues, and continuously read messages from the queues.