From 752a546f91bf1a3d0d957306233efc36dd779abd Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Fri, 23 Oct 2026 18:12:36 -0400 Subject: [PATCH 1/2] Read tab sender from its identity and create the scripted session --- tests/support/ui.py | 2 +- tests/textual/test_welcome_view.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/support/ui.py b/tests/support/ui.py index 89e1bd865..c977e9034 100644 --- a/tests/support/ui.py +++ b/tests/support/ui.py @@ -397,7 +397,7 @@ async def open_preview(self, path) -> str: return identity def sender_of(self, identity: str) -> str: - return self.app.workspace_sessions.require(identity).me + return self.app.workspace_sessions.require(identity).thread_identity.thread_name() async def thread_renamed(self, owner: str, previous: str, current: str) -> None: self.app.session_navigation.sync_identity(owner, previous, current) diff --git a/tests/textual/test_welcome_view.py b/tests/textual/test_welcome_view.py index 6fba9e346..8b5e6e1b4 100644 --- a/tests/textual/test_welcome_view.py +++ b/tests/textual/test_welcome_view.py @@ -71,7 +71,7 @@ async def test_opening_a_thread_run_elsewhere_opens_its_history_read_as_the_user async def test_closing_the_last_tab_shows_the_view_again_and_starts_no_agent(workspace): async with workspace.app(session=False, binding=AgentAttached(peer("echo"))) as ui: await ui.until_shows(HINT) - await ui.press("n") + await ui.new_session() await ui.until(lambda: len(ui.tabs()) == 1, why="the new session's tab") await ui.until_agent_ready() assert not ui.shows(HINT) From 84b5a12e5c618e1405275d763198677f09151ecd Mon Sep 17 00:00:00 2001 From: Tristan Simas Date: Fri, 23 Oct 2026 18:40:34 -0400 Subject: [PATCH 2/2] Prove senders from published messages instead of tab identities --- tests/app/test_channel_tab_sharing.py | 13 ++++++++++++- tests/support/ui.py | 7 ------- tests/textual/test_welcome_view.py | 15 ++++++++++++++- 3 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tests/app/test_channel_tab_sharing.py b/tests/app/test_channel_tab_sharing.py index 58becd301..efa56e0a2 100644 --- a/tests/app/test_channel_tab_sharing.py +++ b/tests/app/test_channel_tab_sharing.py @@ -6,6 +6,8 @@ product decision (tests/open_defects.toml, shared-channel-tab). """ +from agent_comms.channel_targets import CommandTarget + async def two_sessions_on_one_channel(workspace, ui): for name in (workspace.project.name, "owner-a", "owner-b"): @@ -35,7 +37,16 @@ async def test_going_back_from_a_shared_channel_tab_returns_to_the_session_it_wa async def test_a_shared_channel_tab_sends_as_the_session_it_was_opened_from(workspace): async with workspace.app(size=(120, 44)) as ui: first, second, channel = await two_sessions_on_one_channel(workspace, ui) - assert ui.sender_of(channel) == "owner-b" + await ui.write_draft("hello shared channel") + await ui.press("enter") + + def sent_messages(): + return tuple(message for message in workspace.comms.views.history_page( + CommandTarget.named("#all"), + ).messages if message.body == "hello shared channel") + + await ui.until(sent_messages, why="the message on the wire") + assert sent_messages()[0].sender == "owner-b" async def test_closing_one_session_keeps_the_channel_tab_another_session_opened(workspace): diff --git a/tests/support/ui.py b/tests/support/ui.py index c977e9034..c2944f758 100644 --- a/tests/support/ui.py +++ b/tests/support/ui.py @@ -152,10 +152,6 @@ def can_go_forward(self) -> bool: async def open_preview(self, path) -> str: """Open a file preview tab for `path` and return its tab identity.""" - @abstractmethod - def sender_of(self, identity: str) -> str: - """The thread name a channel or direct-message tab sends as.""" - @abstractmethod async def thread_renamed(self, owner: str, previous: str, current: str) -> None: """Tell the interface that the thread behind session tab `owner` was renamed on the wire.""" @@ -396,9 +392,6 @@ async def open_preview(self, path) -> str: await self.step() return identity - def sender_of(self, identity: str) -> str: - return self.app.workspace_sessions.require(identity).thread_identity.thread_name() - async def thread_renamed(self, owner: str, previous: str, current: str) -> None: self.app.session_navigation.sync_identity(owner, previous, current) await self.step() diff --git a/tests/textual/test_welcome_view.py b/tests/textual/test_welcome_view.py index 8b5e6e1b4..c90f2f1e6 100644 --- a/tests/textual/test_welcome_view.py +++ b/tests/textual/test_welcome_view.py @@ -2,6 +2,8 @@ from toad.session_scope import AgentAttached from support.agents import peer +from agent_comms.channel_targets import CommandTarget +from agent_comms.read_basis import NamedViewer from agent_comms.threads import Thread HINT = "n new session" @@ -64,7 +66,18 @@ async def test_opening_a_thread_run_elsewhere_opens_its_history_read_as_the_user await focus_row(ui, "ThreadStatusRow") await ui.press("enter") await ui.until(lambda: len(ui.tabs()) == 1, why="the thread's tab") - assert ui.sender_of(ui.selected_tab) == workspace.viewer + app, _ = ui.textual + assert app.selected_session.thread_identity.thread_name() == "scribe" + await ui.write_draft("hello scribe") + await ui.press("enter") + + def sent_messages(): + return tuple(message for message in workspace.comms.views.history_page( + CommandTarget.named("scribe"), viewer=NamedViewer(workspace.viewer), + ).messages if message.body == "hello scribe" and message.target == "scribe") + + await ui.until(sent_messages, why="the message on the wire") + assert sent_messages()[0].sender == workspace.viewer assert not ui.shows(HINT)