feat: 扫描 Gemini history/ 目录并支持按模型名搜索会话

- gemini.rs: list_chat_files() 同时扫描 tmp/(进行中)和 history/
  (已归档)目录,修复已完成的 Gemini 会话不可见的问题
- conversations.rs: 搜索过滤新增 model 字段匹配,
  支持按模型名搜索会话(如 'gemini-2.5-pro'、'claude-sonnet')
This commit is contained in:
helwd
2026-03-12 23:13:34 +08:00
parent b31849549c
commit 596ac1eb58
2 changed files with 18 additions and 9 deletions

View File

@@ -84,6 +84,10 @@ fn list_conversations_sync(
.as_ref() .as_ref()
.map(|b| b.to_lowercase().contains(&query_lower)) .map(|b| b.to_lowercase().contains(&query_lower))
.unwrap_or(false) .unwrap_or(false)
|| s.model
.as_ref()
.map(|m| m.to_lowercase().contains(&query_lower))
.unwrap_or(false)
}); });
} }

View File

@@ -49,18 +49,23 @@ impl GeminiParser {
} }
fn list_chat_files(&self) -> Vec<PathBuf> { fn list_chat_files(&self) -> Vec<PathBuf> {
let tmp_dir = self.tmp_dir(); let mut files: Vec<PathBuf> = Vec::new();
if !tmp_dir.exists() {
return Vec::new(); // Scan both tmp/ (active sessions) and history/ (archived sessions)
for dir in [self.tmp_dir(), self.history_dir()] {
if !dir.exists() {
continue;
}
let found = WalkDir::new(&dir)
.into_iter()
.filter_map(|e| e.ok())
.map(|e| e.path().to_path_buf())
.filter(|p| p.is_file() && Self::is_chat_file(p));
files.extend(found);
} }
let mut files: Vec<PathBuf> = WalkDir::new(&tmp_dir)
.into_iter()
.filter_map(|e| e.ok())
.map(|e| e.path().to_path_buf())
.filter(|p| p.is_file() && Self::is_chat_file(p))
.collect();
files.sort(); files.sort();
files.dedup();
files files
} }