feat: 智能体详情新增「最近对话」列表,完善推荐问题与任务深链配置

- 新增 AgentRecentChats 组件,在智能体详情面板底部按 agent_id 展示最近对话
- 调整问答/智能体侧边栏与最近对话列表展示逻辑
- 补充 dashboard-input、task-deeplink 相关配置与线程工具方法
- 后端推荐问题接口标签处理及 position_sync 微调,新增相关测试

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
吉鑫升andClaude Opus 4.8 committed 2026-06-22 14:47:43 +08:00
1 parent 16ba5deb0e
commit 32476c7ad4
18 files changed
+457 -60

No files matched your search

@@ -77,3 +77,65 @@ async def test_list_without_tag_store_does_not_break() -> None:
assert [q.id for q in resp.questions] == ["q1", "q2"]
assert all(q.tags == [] for q in resp.questions)
class _FakeSync:
"""Stub position-sync whose ``resolve_visible`` returns a fixed value.
``None`` mimics 默认岗位 / 无标签绑定; a set mimics a position that binds
recommended_question 标签.
"""
def __init__(self, visible: set[str] | None) -> None:
self._visible = visible
async def resolve_visible(self, _user_id, _resource_type): # noqa: ANN001
return self._visible
@pytest.mark.asyncio
async def test_default_position_shows_only_untagged() -> None:
"""默认岗位(resolve_visible → None)只看到未打标的题目。"""
tag_store = MemoryTagStore()
tag = await tag_store.create_tag(
{"id": "t1", "name": "理赔", "tag_type": "recommended_question"}
)
await tag_store.set_target_tags("recommended_question", "q2", [tag["id"]])
req = _request(_FakeQuestionStore(_rows()), tag_store)
req.app.state.position_sync = _FakeSync(None)
resp = await rq_router.list_recommended_questions(req, all=False)
assert [q.id for q in resp.questions] == ["q1"]
@pytest.mark.asyncio
async def test_bound_position_shows_only_its_tagged_questions() -> None:
"""绑定了标签的岗位(resolve_visible → set)只看到对应打标的题目。"""
tag_store = MemoryTagStore()
tag = await tag_store.create_tag(
{"id": "t1", "name": "理赔", "tag_type": "recommended_question"}
)
await tag_store.set_target_tags("recommended_question", "q2", [tag["id"]])
req = _request(_FakeQuestionStore(_rows()), tag_store)
req.app.state.position_sync = _FakeSync({"q2"})
resp = await rq_router.list_recommended_questions(req, all=False)
assert [q.id for q in resp.questions] == ["q2"]
@pytest.mark.asyncio
async def test_admin_view_ignores_position_filter() -> None:
"""``all=True`` 管理视图照旧返回全部(含打标),不受岗位过滤影响。"""
tag_store = MemoryTagStore()
tag = await tag_store.create_tag(
{"id": "t1", "name": "理赔", "tag_type": "recommended_question"}
)
await tag_store.set_target_tags("recommended_question", "q2", [tag["id"]])
req = _request(_FakeQuestionStore(_rows()), tag_store)
req.app.state.position_sync = _FakeSync(None)
resp = await rq_router.list_recommended_questions(req, all=True)
assert [q.id for q in resp.questions] == ["q1", "q2"]