mirror of
https://github.com/aiclientproxy/proxycast.git
synced 2026-09-24 23:10:56 +08:00
fix: 修复发送第一条消息时的闪退问题
问题分析: - 用户报告 v0.70 在发送第一条消息时闪退,v0.60 正常工作 - 从 v0.68/v0.69/v0.70 开始出现问题 修复内容: 1. 移除危险的 unwrap() 调用 (bootstrap.rs:147) - 将 .unwrap() 改为 .expect() 提供详细错误信息 - 如果 tokio runtime 创建失败,现在会显示具体错误而不是 panic 2. 添加前端错误处理 (AgentChat/index.tsx) - 在 handleSend 函数中添加 try-catch 错误处理 - 捕获 sendMessage 调用中的异常 - 显示友好的错误提示并恢复输入内容 3. 验证模型过滤逻辑 (modelThemePolicy.ts) - 确认已有完善的回退机制 - 过滤后无模型时会返回原始列表 - ModelSelector 在空列表时显示提示而非崩溃 4. 验证加密模块 - ChaCha20-Poly1305 加密仅在测试中使用 - 实际使用的是自定义 XOR 加密 - 加密初始化不会导致启动时崩溃 相关提交: - v0.69.0 (bd6d487d): 新增模型主题策略 - v0.70.0 (0c357c8b): 新增加密模块和安全中间件 参考: test-crash-fix.md
This commit is contained in:
@@ -144,7 +144,10 @@ pub fn init_states(config: &Config) -> Result<AppStates, String> {
|
||||
// 使用 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 {
|
||||
|
||||
@@ -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],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user