feat(ui,api,telegram): shared conversation panel for obsidian and /admin/panel, bind materializes a window, inbox survives link previews

This commit is contained in:
hh
2026-08-29 18:30:33 +02:00
parent a989d2909d
commit 9efff6e814
58 changed files with 2858 additions and 499 deletions
+42
View File
@@ -448,3 +448,45 @@ async def test_close_distills_a_deep_chat(world: World) -> None:
f"/conversations/{branch.external_id}/close", headers=HEADERS
)
assert plain.status_code == 200 and plain.json()["status"] == "closed"
async def test_bind_without_a_window_materializes_one(world: World) -> None:
api = Api(world)
chat = await world.conversations.create(kind="deep", agent="d", origin="test")
world.markdown.materialized.clear()
res = await api.http.post(
f"/conversations/{chat.external_id}/bind",
json={"frontend": "markdown"},
headers=HEADERS,
)
assert res.status_code == 200, res.text
assert world.markdown.materialized == [chat.external_id]
assert res.json()["bindings"] == [
{
"frontend": "markdown",
"external_id": f"markdown:{chat.external_id}",
"visible": True,
}
]
hidden = await api.http.post(
f"/conversations/{chat.external_id}/bind",
json={
"frontend": "markdown",
"external_id": f"markdown:{chat.external_id}",
"visible": False,
},
headers=HEADERS,
)
assert hidden.json()["bindings"][0]["visible"] is False
no_window = await api.http.post(
f"/conversations/{chat.external_id}/bind",
json={"frontend": "api"},
headers=HEADERS,
)
assert no_window.status_code == 400
unknown = await api.http.post(
f"/conversations/{chat.external_id}/bind",
json={"frontend": "nope"},
headers=HEADERS,
)
assert unknown.status_code == 400
+21
View File
@@ -593,3 +593,24 @@ def test_render_helpers() -> None:
assert status_label("Read", {"file_path": "/x"}) == "читаю vault"
assert status_label("mcp__firefly__list_accounts", None) == "firefly: list_accounts"
assert status_label("Foo", {"command": "ls -la"}) == "Foo ls -la"
async def test_message_with_a_link_preview_is_stored_and_answered(stack: Stack) -> None:
stack.bot.push(
{
"message": {
"message_id": 77,
"date": 1700000000,
"chat": {"id": USER, "type": "private"},
"from": {"id": USER, "is_bot": False, "first_name": "h"},
"text": "see https://x.y",
"link_preview_options": {"url": "https://x.y"},
}
}
)
await stack.until(lambda: stack.sent_with("see https://x.y"), what="reply")
async with stack.world.db.session() as session:
rows = list((await session.exec(select(TelegramUpdate))).all())
preview = rows[0].payload["message"]["link_preview_options"]
assert preview["url"] == "https://x.y"
assert preview.get("is_disabled") is None