From a825ba764dae36286dc1b68f5b1326099c7f8ec9 Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Fri, 23 Oct 2026 17:31:25 -0400 Subject: [PATCH] Centralize live route confirmation on CoordinationAccess --- src/toad/comms_root.py | 10 +++++++--- src/toad/session_entry.py | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/toad/comms_root.py b/src/toad/comms_root.py index 6c5c712be..90c8ec22e 100644 --- a/src/toad/comms_root.py +++ b/src/toad/comms_root.py @@ -361,10 +361,13 @@ def open_current(self) -> Observing | FailedObservation: except (OSError, ValueError, RuntimeError) as error: return self.observation.failed(error, selected) - def require(self, selected: RouteSelection) -> Observing: - """The service for ``selected``; a new selection opens it and starts its observation.""" + def confirm(self, selected: RouteSelection) -> None: if RouteSelection.capture() != selected: raise RouteChangedError("Comms route changed before the operation") + + def require(self, selected: RouteSelection) -> Observing: + """The service for ``selected``; a new selection opens it and starts its observation.""" + self.confirm(selected) with self.opening: return self.observation.require(self, selected) @@ -373,8 +376,9 @@ def attach() -> Observing: previous = self.observation with selected.route.hold_client_route(): service = Comms(selected.route) - if service.root.resolve() != selected.root or RouteSelection.capture() != selected: + if service.root.resolve() != selected.root: raise RouteChangedError("Comms route changed while opening the service") + self.confirm(selected) observed = Observing( selected, service, SidebarModel(self.app.call_next), ObservationProcess(service.route), self.app.running_loop, access=self) diff --git a/src/toad/session_entry.py b/src/toad/session_entry.py index 0123cc40e..c3bc0f9be 100644 --- a/src/toad/session_entry.py +++ b/src/toad/session_entry.py @@ -14,7 +14,6 @@ from agent_comms.declared_family import DeclaredFamily from agent_comms.display_references import CurrentDisplayReferences, ReferenceContext from agent_comms.mro_dispatch import handles -from agent_comms.route_selection import RouteSelection from agent_comms.thread_identity import ThreadIncarnation from agent_comms.ui_model.sidebar import ThreadRowModel @@ -155,7 +154,8 @@ def thread_row(self, sessions, row): return source.session_disposition.present(row, row.disconnected) async def reconnect(self, sessions, selected, snapshot, targets): - if sessions.get(self.mode) is not self or RouteSelection.capture() != selected: + sessions.app.coordination_access.confirm(selected) + if sessions.get(self.mode) is not self: return source = self.source(sessions) if source is None: