fix(telegram): brief-seeded branches reply and stream in their topic
This commit is contained in:
@@ -648,9 +648,7 @@ class TelegramFrontend(Frontend):
|
|||||||
return
|
return
|
||||||
match kind:
|
match kind:
|
||||||
case "turn.start":
|
case "turn.start":
|
||||||
if event.get("origin") == "user" and not str(
|
if event.get("origin") == "user":
|
||||||
event.get("item_origin") or ""
|
|
||||||
).startswith("сид"):
|
|
||||||
await self._open_draft(key, event, target)
|
await self._open_draft(key, event, target)
|
||||||
case "stream":
|
case "stream":
|
||||||
self._feed_draft(key, event)
|
self._feed_draft(key, event)
|
||||||
@@ -672,8 +670,6 @@ class TelegramFrontend(Frontend):
|
|||||||
key=f"{event.get('turn_id')}:error",
|
key=f"{event.get('turn_id')}:error",
|
||||||
)
|
)
|
||||||
case "reply":
|
case "reply":
|
||||||
if str(event.get("item_origin") or "").startswith("сид"):
|
|
||||||
return
|
|
||||||
await self._on_reply(conv, event)
|
await self._on_reply(conv, event)
|
||||||
case "say":
|
case "say":
|
||||||
await self._deliver(
|
await self._deliver(
|
||||||
|
|||||||
@@ -474,6 +474,27 @@ async def test_commands_status_merge_and_new(stack: Stack) -> None:
|
|||||||
assert stack.bot.topics[-1] == "edit:902:✅ отчёт"
|
assert stack.bot.topics[-1] == "edit:902:✅ отчёт"
|
||||||
|
|
||||||
|
|
||||||
|
async def test_brief_branch_from_the_tool_replies_in_its_topic(stack: Stack) -> None:
|
||||||
|
stack.bot.message("hi")
|
||||||
|
await stack.until(lambda: stack.sent_with("hi"), what="reply")
|
||||||
|
master = await stack.world.conversations.find_bound(
|
||||||
|
frontend="telegram", external_id=GENERAL
|
||||||
|
)
|
||||||
|
child = await stack.world.conversations.spawn(
|
||||||
|
kind="branch",
|
||||||
|
seed="brief",
|
||||||
|
text="найди X",
|
||||||
|
title="X",
|
||||||
|
parent=master,
|
||||||
|
origin="mcp",
|
||||||
|
)
|
||||||
|
reply = await stack.until(lambda: stack.sent_with("найди X"), what="brief reply")
|
||||||
|
assert reply["thread"] == 902
|
||||||
|
assert not any(m["text"].startswith("📝") for m in stack.bot.sent)
|
||||||
|
assert any(d["message_thread_id"] == 902 for d in stack.bot.drafts)
|
||||||
|
assert (await stack.world.conversations.get(child.external_id)).flags == {}
|
||||||
|
|
||||||
|
|
||||||
async def test_master_topic_survives_rotation(stack: Stack) -> None:
|
async def test_master_topic_survives_rotation(stack: Stack) -> None:
|
||||||
stack.bot.message("hi")
|
stack.bot.message("hi")
|
||||||
await stack.until(lambda: stack.sent_with("hi"), what="reply")
|
await stack.until(lambda: stack.sent_with("hi"), what="reply")
|
||||||
|
|||||||
Reference in New Issue
Block a user