Skip to content
Closed
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
5 changes: 3 additions & 2 deletions src/toad/acp/agent_session.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
import os
from dataclasses import dataclass, replace
from collections.abc import Callable
from agent_comms.route_selection import RouteChanged, RouteSelection
from agent_comms.errors import RouteChangedError
from agent_comms.route_selection import RouteSelection
from agent_comms.thread_presentation import SessionDisconnected
import toad
from toad import constants
Expand Down Expand Up @@ -340,7 +341,7 @@ async def reconnect(self, plan: SessionLoadPlan | None = None) -> None:
try:
await asyncio.to_thread(
RouteSelection.capture, self.agent.controller.transcripts.access.launch_root.path)
except RouteChanged as error:
except RouteChangedError as error:
self.startup_failed(f"Reconnect blocked before restart: {error}")
return
await self.agent.stop()
Expand Down
4 changes: 2 additions & 2 deletions src/toad/acp/comms_updates.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ def input_started(self, update: InputStartedUpdate) -> None:
@handles(CoordinationChangedUpdate)
def coordination_changed(self, update: CoordinationChangedUpdate) -> None:
from pathlib import Path
from agent_comms.route_selection import RouteChanged
from agent_comms.errors import RouteChangedError

agent = self.agent
root = agent.controller.transcripts.access.launch_root.path
if Path(update.wire_root).resolve() != root.resolve():
raise RouteChanged("ACP owner reported a different coordination root")
raise RouteChangedError("ACP owner reported a different coordination root")
agent.coordination = update
agent.project_root_path = Path(update.worktree)
agent.context_measurement = ContextMeasurement.saved(update.context_usage)
Expand Down
11 changes: 6 additions & 5 deletions src/toad/comms_root.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
from agent_comms.mro_dispatch import MroDispatch, handles
from agent_comms.presentation import MessageNotification, NoRevision, ReadState
from agent_comms.revision_views import ExternalTranscriptsView, StatusView
from agent_comms.route_selection import RouteChanged, RouteSelection, run_selected_write
from agent_comms.errors import RouteChangedError
from agent_comms.route_selection import RouteSelection, run_selected_write
from agent_comms.ui_model.observation import (
ObserveNotifications, NotificationsObserved, NotificationsUnreadable, ReadNotifications,
ObservationProcess, ObserveSidebar, ObserveThreads, ObserveViews, RevisionObserved,
Expand Down Expand Up @@ -107,7 +108,7 @@ def attach(self, access, previous):
waiters, access.sidebar_waiters = access.sidebar_waiters, []
for _, waiter in waiters:
if not waiter.done():
waiter.set_exception(RouteChanged("Comms service changed before the sidebar was read"))
waiter.set_exception(RouteChangedError("Comms service changed before the sidebar was read"))
access.revision = NoRevision()
access.sidebar_interest = access.sidebar_current = None
access.thread_status.clear()
Expand Down Expand Up @@ -253,7 +254,7 @@ def references_for(self, root):
async def current_references(self, access, root):
try:
await access.current_sidebar()
except RouteChanged:
except RouteChangedError:
return await access.observation.current_references(access, root)
return access.reference_context(root)

Expand Down Expand Up @@ -331,7 +332,7 @@ def open_current(self) -> Observing | FailedObservation:
def require(self, selected: RouteSelection) -> Observing:
"""The service for ``selected``; a new selection opens it and starts its observation."""
if RouteSelection.capture() != selected:
raise RouteChanged("Comms route changed before the operation")
raise RouteChangedError("Comms route changed before the operation")
with self.opening:
return self.observation.require(self, selected)

Expand All @@ -343,7 +344,7 @@ def open_selected(self, selected: RouteSelection) -> Observing:
acquisition.enter_context(selected.route.hold_client_route())
service = wire(selected.route)
if service.root.resolve() != selected.root or RouteSelection.capture() != selected:
raise RouteChanged("Comms route changed while opening the service")
raise RouteChangedError("Comms route changed while opening the service")
observed = Observing(
selected, service, SidebarModel(self.app.call_next), ObservationProcess(service.route),
self.app.running_loop, access=self)
Expand Down
10 changes: 5 additions & 5 deletions src/toad/session_navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

from agent_comms.presentation import NoRevision, ReadState
from agent_comms.revision_views import RegistrationsView
from agent_comms.errors import UnknownChannelError, UnregisteredThreadError
from agent_comms.route_selection import RouteChanged, root_is_current
from agent_comms.errors import RouteChangedError, UnknownChannelError, UnregisteredThreadError
from agent_comms.route_selection import root_is_current
from agent_comms.thread_identity import ThreadIncarnation
from toad.navigation_preparation import CommsNavigationRequest
from toad.session_entry import (HistorySessionEntry, NativeSessionEntry,
Expand Down Expand Up @@ -197,7 +197,7 @@ async def history(self, *, owner_mode: str, project_path: Path, me: str,
return app.selected_mode
prepared = await app.navigation_reader.read(CommsNavigationRequest(
comms, owner_mode, me, conversation, source.coordination_root))
except (UnknownChannelError, UnregisteredThreadError, RouteChanged) as error:
except (UnknownChannelError, UnregisteredThreadError, RouteChangedError) as error:
app.show_error(error, "Comms target unavailable")
return app.selected_mode
if prepared is None:
Expand Down Expand Up @@ -311,7 +311,7 @@ async def _retire_requested_views(self) -> None:
await self.retire_missing()

async def retire_missing(self) -> None:
from agent_comms.route_selection import RouteChanged, RouteSelection
from agent_comms.route_selection import RouteSelection

# Borrow each open entry, including hidden views. Core decides
# which of their sources no longer exist; Toad only closes the views.
Expand Down Expand Up @@ -339,7 +339,7 @@ def read():
retired = service.views.retired_views(threads, channels)
if RouteSelection.capture(root) != selected:
continue # Replaced while reading; the next observation reads it.
except RouteChanged:
except RouteChangedError:
continue # The next observation reads the replacement route.
answers[root] = service, retired
return answers
Expand Down
5 changes: 3 additions & 2 deletions src/toad/target_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

from agent_comms.comms import Comms
from agent_comms.channel_targets import ChannelSelection, CommandTarget, NoChannel
from agent_comms.route_selection import RouteChanged, root_is_current
from agent_comms.errors import RouteChangedError
from agent_comms.route_selection import root_is_current
from toad.slash_command import CommandPresentation, LocalCommand, SlashCommand
from agent_comms.cli_commands import CliCommand, TargetAction
from toad.thread_actions import ThreadAction
Expand Down Expand Up @@ -42,7 +43,7 @@ def title(self):

def current(self):
if not root_is_current(self.comms.root):
raise RouteChanged('Comms route changed; reopen this view')
raise RouteChangedError('Comms route changed; reopen this view')
return self

def available_actions(self):
Expand Down
5 changes: 3 additions & 2 deletions src/toad/thread_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
from agent_comms.cli_commands import TargetAction, TargetEdit, TargetBatchResult, TargetFailed
from agent_comms.cli_result import CliResult
from agent_comms.native_pi import NativePiUnavailable
from agent_comms.route_selection import RouteChanged, RouteSelection
from agent_comms.errors import RouteChangedError
from agent_comms.route_selection import RouteSelection

if TYPE_CHECKING:
from toad.app import ToadApp
Expand Down Expand Up @@ -138,7 +139,7 @@ async def prepare():
fields = await ctx.app.preparation.run_thread(
lambda: asyncio.run(definition.prepare_fields()))
ctx.current()
except (NativePiUnavailable, RouteChanged) as error:
except (NativePiUnavailable, RouteChangedError) as error:
ctx.app.show_error(error, definition.label)
return
if ctx.app.screen is screen:
Expand Down
Loading