Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/toad/comms_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/toad/session_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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:
Expand Down
Loading