Merge pull request #10 from hsqbyte/feat/gemini-history-and-search-model

feat: 扫描 Gemini history/ 目录并支持按模型名搜索会话
This commit is contained in:
XinTaoFei
2026-03-13 00:05:55 +08:00
committed by GitHub
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
} }