diff --git a/src-tauri/src/app/bootstrap.rs b/src-tauri/src/app/bootstrap.rs index 49c1e8f49..3f3b26a45 100644 --- a/src-tauri/src/app/bootstrap.rs +++ b/src-tauri/src/app/bootstrap.rs @@ -144,7 +144,10 @@ pub fn init_states(config: &Config) -> Result { // 使用 tokio runtime 来设置全局 store let rt = tokio::runtime::Handle::try_current().unwrap_or_else(|_| { // 如果没有 runtime,创建一个临时的 - tokio::runtime::Runtime::new().unwrap().handle().clone() + tokio::runtime::Runtime::new() + .expect("Failed to create tokio runtime: 系统资源不足或配置错误") + .handle() + .clone() }); rt.block_on(async { if let Err(e) = aster::session::set_global_session_store(session_store).await { diff --git a/src/components/agent/chat/index.tsx b/src/components/agent/chat/index.tsx index bbea594e7..a18f0f265 100644 --- a/src/components/agent/chat/index.tsx +++ b/src/components/agent/chat/index.tsx @@ -975,14 +975,22 @@ export function AgentChatPage({ setInput(""); setMentionedCharacters([]); // 清空引用的角色 - await sendMessage( - text, - images || [], - webSearch, - thinking, - false, - sendExecutionStrategy, - ); + + try { + await sendMessage( + text, + images || [], + webSearch, + thinking, + false, + sendExecutionStrategy, + ); + } catch (error) { + console.error("[AgentChat] 发送消息失败:", error); + toast.error(`发送失败: ${error instanceof Error ? error.message : String(error)}`); + // 恢复输入内容,让用户可以重试 + setInput(sourceText); + } }, [input, mentionedCharacters, projectId, sendMessage], );