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
13 changes: 12 additions & 1 deletion tests/app/test_channel_tab_sharing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 0 additions & 7 deletions tests/support/ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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).me

async def thread_renamed(self, owner: str, previous: str, current: str) -> None:
self.app.session_navigation.sync_identity(owner, previous, current)
await self.step()
Expand Down
17 changes: 15 additions & 2 deletions tests/textual/test_welcome_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -64,14 +66,25 @@ 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)


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)
Expand Down
Loading