From 9cd43b2ce8d150588645d650cfce56f479b63e2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 15 Sep 2026 18:04:01 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E9=BD=90DirectProject=E5=8E=86?= =?UTF-8?q?=E5=8F=B2=E5=AE=8C=E6=88=90=E9=A1=B9=E9=94=9A=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Thread Manager订阅在内存锚点为空时读取持久化最后item ID\n保持重启恢复与历史懒加载锚点一致 --- .../src-tauri/src/agent/direct_project_history.rs | 12 ++++++++++++ apps/ai-game-creator-shell/src-tauri/src/commands.rs | 8 ++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs index 2f3a6f62c..24b3aed74 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/agent/direct_project_history.rs @@ -530,6 +530,18 @@ pub(crate) fn read_direct_project_history_items_slice_at( Ok((items[start..end].to_vec(), start > 0)) } +pub(crate) fn read_direct_project_last_item_id_at(root: &Path) -> Result, String> { + Ok(read_direct_project_history_items_at(root)? + .into_iter() + .rev() + .find_map(|item| { + item.get("id") + .and_then(Value::as_str) + .filter(|id| !id.is_empty()) + .map(str::to_string) + })) +} + pub(crate) fn read_direct_project_chat_history_at( root: &Path, ) -> Result { diff --git a/apps/ai-game-creator-shell/src-tauri/src/commands.rs b/apps/ai-game-creator-shell/src-tauri/src/commands.rs index 0ca57dc67..b70b8c6d7 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/commands.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/commands.rs @@ -1,5 +1,5 @@ use super::*; -use crate::agent::read_direct_project_chat_history_at; +use crate::agent::{read_direct_project_chat_history_at, read_direct_project_last_item_id_at}; use crate::ui_editor::resource::font::FontAsset; use sha2::{Digest, Sha256}; use std::collections::{BTreeMap, HashSet}; @@ -5282,7 +5282,11 @@ pub(crate) fn subscribe_direct_project_thread( let root = Path::new(project_path.trim()); enforce_project_permission_policy(root, "conversation.read")?; let thread_id = root.to_string_lossy().into_owned(); - Ok(subscribe_direct_thread(&thread_id)) + let mut bootstrap = subscribe_direct_thread(&thread_id); + if bootstrap.last_completed_item_id.is_none() { + bootstrap.last_completed_item_id = read_direct_project_last_item_id_at(root)?; + } + Ok(bootstrap) } #[tauri::command]