feat: 切换管理端聊天记录至智能体会话
- 管理端固定筛选 Agent 会话并拒绝旧 Bot 历史访问 - 筛选候选及页面语义切换为智能体并补充前后端回归测试
This commit is contained in:
@@ -60,7 +60,7 @@ function resolveSenderName(item: any) {
|
||||
if (item?.role === 'tool') {
|
||||
return '工具调用';
|
||||
}
|
||||
return item?.role === 'assistant' ? '聊天助手' : '聊天用户';
|
||||
return item?.role === 'assistant' ? '智能体' : '聊天用户';
|
||||
}
|
||||
|
||||
async function handleLoadMore() {
|
||||
@@ -152,7 +152,7 @@ async function handleCopyMessage(item: ChatTimeTimelineItem) {
|
||||
{{ session?.title || '未命名会话' }}
|
||||
</h2>
|
||||
<span class="chat-history-detail__assistant-tag">
|
||||
{{ session?.assistantName || '聊天助手' }}
|
||||
{{ session?.assistantName || '智能体' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="chat-history-detail__meta-row">
|
||||
|
||||
28
easyflow-ui-admin/app/src/views/ai/chatHistory/index.test.ts
Normal file
28
easyflow-ui-admin/app/src/views/ai/chatHistory/index.test.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import detailDrawerSource from '#/components/chat-history/ChatHistoryDetailDrawer.vue?raw';
|
||||
|
||||
import pageSource from './index.vue?raw';
|
||||
|
||||
describe('管理端智能体聊天历史契约', () => {
|
||||
it('使用智能体候选接口并保留 assistantId 查询参数', () => {
|
||||
expect(pageSource).toContain("'/api/v1/agent/list'");
|
||||
expect(pageSource).not.toContain('/api/v1/bot/list');
|
||||
expect(pageSource).toContain('label: item.name');
|
||||
expect(pageSource).toContain('assistantId: query.value.assistantId');
|
||||
expect(pageSource).not.toContain('publishedOnly');
|
||||
});
|
||||
|
||||
it('统一页面和详情抽屉的智能体文案', () => {
|
||||
expect(pageSource).toContain('placeholder="筛选智能体"');
|
||||
expect(pageSource).toContain('label="智能体"');
|
||||
expect(pageSource).toContain('暂无智能体聊天记录');
|
||||
expect(pageSource).not.toContain('聊天助手');
|
||||
expect(detailDrawerSource).not.toContain('聊天助手');
|
||||
});
|
||||
|
||||
it('为智能体筛选提供独立加载反馈', () => {
|
||||
expect(pageSource).toContain(':loading="agentLoading"');
|
||||
expect(pageSource).toContain('智能体列表加载失败');
|
||||
});
|
||||
});
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
ElDatePicker,
|
||||
ElEmpty,
|
||||
ElInput,
|
||||
ElMessage,
|
||||
ElPagination,
|
||||
ElSelect,
|
||||
ElTable,
|
||||
@@ -27,7 +28,8 @@ import { api } from '#/api/request';
|
||||
import ChatHistoryDetailDrawer from '#/components/chat-history/ChatHistoryDetailDrawer.vue';
|
||||
import ListPageShell from '#/components/page/ListPageShell.vue';
|
||||
|
||||
const assistantList = ref<any[]>([]);
|
||||
const agentOptions = ref<any[]>([]);
|
||||
const agentLoading = ref(false);
|
||||
const sessions = ref<any[]>([]);
|
||||
const loading = ref(false);
|
||||
const query = ref({
|
||||
@@ -88,19 +90,25 @@ const selectedSessionId = computed(() =>
|
||||
);
|
||||
|
||||
onMounted(async () => {
|
||||
await Promise.all([fetchAssistants(), fetchSessions()]);
|
||||
await Promise.all([fetchAgents(), fetchSessions()]);
|
||||
});
|
||||
|
||||
async function fetchAssistants() {
|
||||
const [, res] = await tryit(api.get)('/api/v1/bot/list', {
|
||||
params: { status: 1 },
|
||||
});
|
||||
if (res?.errorCode === 0) {
|
||||
assistantList.value = (res.data || []).map((item: any) => ({
|
||||
label: item.title,
|
||||
async function fetchAgents() {
|
||||
agentLoading.value = true;
|
||||
const [error, res] = await tryit(api.get)('/api/v1/agent/list');
|
||||
agentLoading.value = false;
|
||||
if (error || res?.errorCode !== 0) {
|
||||
agentOptions.value = [];
|
||||
ElMessage.error(res?.message || '智能体列表加载失败');
|
||||
return;
|
||||
}
|
||||
const agents = Array.isArray(res.data) ? res.data : [];
|
||||
agentOptions.value = agents
|
||||
.filter((item: any) => item?.id !== undefined && item?.id !== null)
|
||||
.map((item: any) => ({
|
||||
label: item.name || `智能体 #${item.id}`,
|
||||
value: item.id,
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
async function fetchSessions() {
|
||||
@@ -372,8 +380,10 @@ function closeDetail() {
|
||||
<ElSelect
|
||||
v-model="query.assistantId"
|
||||
clearable
|
||||
placeholder="筛选聊天助手"
|
||||
:options="assistantList"
|
||||
filterable
|
||||
placeholder="筛选智能体"
|
||||
:loading="agentLoading"
|
||||
:options="agentOptions"
|
||||
class="chat-history-page__filter-control is-select"
|
||||
@change="handleSearch"
|
||||
/>
|
||||
@@ -436,10 +446,10 @@ function closeDetail() {
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
|
||||
<ElTableColumn label="聊天助手" min-width="160">
|
||||
<ElTableColumn label="智能体" min-width="160">
|
||||
<template #default="{ row }">
|
||||
<span class="chat-history-page__assistant-chip">
|
||||
{{ row.assistantName || '聊天助手' }}
|
||||
{{ row.assistantName || '智能体' }}
|
||||
</span>
|
||||
</template>
|
||||
</ElTableColumn>
|
||||
@@ -484,7 +494,7 @@ function closeDetail() {
|
||||
</div>
|
||||
|
||||
<div v-else class="chat-history-page__empty">
|
||||
<ElEmpty description="暂无聊天历史" />
|
||||
<ElEmpty description="暂无智能体聊天记录" />
|
||||
</div>
|
||||
|
||||
<div v-if="pageState.total > 0" class="chat-history-page__pagination">
|
||||
|
||||
Reference in New Issue
Block a user