feat(jobs): t3code events go back to the dispatching conversation, quiet branches close at night

This commit is contained in:
hh committed 2026-10-23 22:25:12 +02:00
1 parent 2bf2326178
commit 6db6c7b6ec
3 files changed
+43 -3

No files matched your search

+3 -1
View File
@@ -1,4 +1,4 @@
"""Ночью после ротации: глубокие чаты, тихие два дня, закрываются, не больше трёх.""" """Ночью после ротации: тихие глубокие чаты - с выжимкой, тихие ветки - молча."""
from __future__ import annotations from __future__ import annotations
@@ -21,3 +21,5 @@ async def close_idle(run: JobRun) -> None:
result.digest.path if result.digest else None, result.digest.path if result.digest else None,
result.error, result.error,
) )
for branch in await run.close_quiet(kind="branch", days=3):
_log.info("closed quiet branch %s «%s»", branch.external_id, branch.title)
+7 -2
View File
@@ -1,4 +1,4 @@
"""`POST /hooks/t3code`: тред завершился, упал или спрашивает - срочно в мастер.""" """`POST /hooks/t3code`: событие треда - срочно в разговор, который его запустил."""
from __future__ import annotations from __future__ import annotations
@@ -15,7 +15,12 @@ QUESTION_HINT = (
async def t3code_event(run: JobRun) -> None: async def t3code_event(run: JobRun) -> None:
await run.inject_master(describe(run.payload), urgency="urgent", origin="t3code") await run.inject_into(
run.payload.get("origin"),
describe(run.payload),
urgency="urgent",
origin="t3code",
)
def describe(p: dict[str, Any]) -> str: def describe(p: dict[str, Any]) -> str:
+33
View File
@@ -0,0 +1,33 @@
from typing import Any
from beaver_agent.jobs.t3code import t3code_event
class FakeRun:
def __init__(self, payload: dict[str, Any]) -> None:
self.payload = payload
self.injects: list[tuple[str | None, str, str, str]] = []
async def inject_into(
self, public_id: str | None, text: str, *, urgency: str, origin: str
) -> bool:
self.injects.append((public_id, text, urgency, origin))
return True
async def test_the_event_goes_to_the_conversation_that_dispatched() -> None:
run = FakeRun(
{
"event": "completed",
"thread_id": "t1",
"title": "lint",
"machine": "mac",
"project": "beaver",
"origin": "conv-7",
"text": "done",
}
)
await t3code_event(run) # ty: ignore[invalid-argument-type]
[(target, text, urgency, origin)] = run.injects
assert (target, urgency, origin) == ("conv-7", "urgent", "t3code")
assert "завершён" in text and "done" in text