refactor: 标题生成重构、UI样式优化、测试增强
- 将标题生成逻辑提取为独立函数,提前到Agent调用前非阻塞执行 - 修复模型/供应商不存在时的HTTP状态码 500→400 - ChatPanel: 分离模型选择useEffect、CSS类替代内联样式、按钮样式统一 - use-conversations: fetchConversations/fetchMessages改用handleResponse去重 - 聊天面板滚动优化(scroll-behavior: smooth, overflow-anchor: auto) - 测试: mock支持onFinish回调,新增首次消息标题生成测试 - 移除未使用的SendMessageRequest接口
This commit is contained in:
@@ -29,20 +29,12 @@ export async function fetchConversation(projectId: string, conversationId: strin
|
||||
|
||||
export async function fetchConversations(projectId: string): Promise<ConversationListResponse> {
|
||||
const response = await fetch(`/api/projects/${projectId}/conversations?pageSize=100`);
|
||||
if (!response.ok) {
|
||||
const body = (await response.json().catch(() => null)) as null | { error?: string };
|
||||
throw new Error(body?.error ?? `HTTP ${response.status}`);
|
||||
}
|
||||
return response.json() as Promise<ConversationListResponse>;
|
||||
return handleResponse(response, (data) => data as ConversationListResponse);
|
||||
}
|
||||
|
||||
export async function fetchMessages(projectId: string, conversationId: string): Promise<MessageListResponse> {
|
||||
const response = await fetch(`/api/projects/${projectId}/conversations/${conversationId}/messages?pageSize=200`);
|
||||
if (!response.ok) {
|
||||
const body = (await response.json().catch(() => null)) as null | { error?: string };
|
||||
throw new Error(body?.error ?? `HTTP ${response.status}`);
|
||||
}
|
||||
return response.json() as Promise<MessageListResponse>;
|
||||
return handleResponse(response, (data) => data as MessageListResponse);
|
||||
}
|
||||
|
||||
export async function updateConversation(
|
||||
|
||||
Reference in New Issue
Block a user