fix(chat): 优化消息加载逻辑,移除不必要的延迟参数( Error: 关于v0.5版本数据库引发的问题

Fixes #513)
This commit is contained in:
Wenjie Zhang 2026-02-25 12:17:02 +08:00
parent 5fa89ddc85
commit 74cb569569
2 changed files with 9 additions and 6 deletions

View File

@ -433,8 +433,7 @@ async def stream_agent_chat(
if agent_state:
yield make_chunk(status="agent_state", agent_state=agent_state, meta=meta)
yield make_chunk(status="finished", meta=meta)
# 先存储数据库,再返回 finished避免前端查询时数据未落库
await save_messages_from_langgraph_state(
agent_instance=agent,
thread_id=thread_id,
@ -442,6 +441,8 @@ async def stream_agent_chat(
config_dict=langgraph_config,
)
yield make_chunk(status="finished", meta=meta)
except (asyncio.CancelledError, ConnectionError) as e:
logger.warning(f"Client disconnected, cancelling stream: {e}")
@ -589,8 +590,8 @@ async def stream_agent_resume(
yield chunk
meta["time_cost"] = asyncio.get_event_loop().time() - start_time
yield make_resume_chunk(status="finished", meta=meta)
# 先存储数据库,再返回 finished避免前端查询时数据未落库
conv_repo = ConversationRepository(db)
await save_messages_from_langgraph_state(
agent_instance=agent,
@ -599,6 +600,8 @@ async def stream_agent_resume(
config_dict=langgraph_config,
)
yield make_resume_chunk(status="finished", meta=meta)
except (asyncio.CancelledError, ConnectionError) as e:
logger.warning(f"Client disconnected during resume: {e}")

View File

@ -962,7 +962,7 @@ const handleSendMessage = async ({ image } = {}) => {
} finally {
threadState.streamAbortController = null
//
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 500 }).finally(
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId }).finally(
() => {
//
resetOnGoingConv(threadId)
@ -982,7 +982,7 @@ const handleSendOrStop = async (payload) => {
//
try {
await fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 500 })
await fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId })
message.info('已中断对话生成')
} catch (error) {
console.error('刷新消息历史失败:', error)
@ -1043,7 +1043,7 @@ const handleApprovalWithStream = async (approved) => {
}
//
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId, delay: 500 }).finally(
fetchThreadMessages({ agentId: currentAgentId.value, threadId: threadId }).finally(
() => {
//
resetOnGoingConv(threadId)