搜索:Ctrl+K 支持会话聊天内容搜索,并支持命中定位与高亮 - #488
Conversation
- Persist an empty tombstone document for conversations whose transcript parses to zero turns (e.g. cancelled Claude sessions with no jsonl file) so the progress denominator counts them as handled and drift resync stops re-queueing them every ten minutes. - Fix search hit navigation to scan merged turn wrappers in reverse and scroll the highlighted mark itself to viewport center with a settle pass.
- Window the detail response only AFTER the full turn list has been handed to the indexer. Previously the tail-windowed turns were submitted, so opening a conversation could overwrite its indexed document with the last 120 turns and silently drop older history. - Stop submitting paged older-history slices to the indexer entirely. - Skip re-normalizing unchanged transcripts via the same source-metadata dirtiness probe drift_resync uses, keeping repeated opens cheap. - Drop match_kind/content_match_count/total_match_count, which no consumer reads, and the unused store setter.
|
先说结论:这个 PR 的工作量和完成度都很可观 —— 设计文档带实测数据、双运行模式共用核心切得干净、10 种语言文案一个不落(我逐个 locale 核对过 10/10), 不过我把后端和前端通读了一遍,并对几处存疑的地方做了实测复现,发现有 3 个问题会让功能在特定条件下直接不可用,还有若干条建议在合并前处理。下面按优先级列一下,附上复现证据,供你参考。 🔴 P0-1:FTS 模式下 1–2 字符查询直接报错(已复现)
ShortTermQuery::CjkUnigram { token } => format!("words : \"{token}\""),
ShortTermQuery::CjkBigram { phrase } => format!("bigrams : \"{phrase}\""),
ShortTermQuery::LatinPrefix{ token } => format!("words : \"{token}\"*"),SQLite FTS5 不支持 裸 sqlite3 3.51 同样复现,换 触发条件:设置页选「全文索引」,或 auto 模式下可索引文本 ≥ 40MB —— 影响:整个 修法:把 🔴 P0-2:限定文件夹 + FTS 模式 → 内容命中被静默丢光(已复现)
SELECT d.conversation_id, bm25(t) AS rank FROM t
JOIN message_search_document d ON d.id = t.rowid
WHERE t MATCH ? AND d.text LIKE ? ESCAPE '\' ORDER BY rank LIMIT ?LIMIT 是在全库文档上截断的,可见性过滤发生在之后的 Rust 侧。目标文件夹只有 3 个会话、全库有 5000 个匹配文档时,取到的是全局前 3 条,几乎必然不含目标文件夹。 复现(30 个噪声会话在别的文件夹,1 个匹配会话在目标文件夹,限定目标文件夹搜索): 设计文档 §9.2 的论证是「索引一行对应一个会话,因此任何单个词最多只能命中可见会话数;该默认值保证不会静默漏召回」—— 这个前提只有在 SQL 里带上可见性过滤时才成立,所以恰好落在了本 PR 主打的「限定项目范围」上。多词查询也受害(各词各自截断到 N 条再求交集,交集可能为空)。 修法: 🔴 P0-3:当前 contentless 布局下
|
背景
之前左侧的 Ctrl+K 搜索只匹配会话标题。本次改动把用户和助手的聊天文本纳入
搜索范围,在保持低存储占用和强性能的前提下,支持正文搜索、命中定位和结果
高亮。
主要功能
同一会话有多个命中时,提供“下一条匹配 1 / N”逐个跳转。
界面示意
搜索框(可限定文件夹范围):
搜索结果(正文命中带上下文摘要):
实现方案
参与索引,单个文本块最多保留 8192 字节。
逻辑;codeg-mcp 不变。
漂移核对、删除会话时同步清理;内容没有变化时跳过重新计算。
增加额外存储;全文模式使用 FTS5 trigram 索引加短词表,可索引文本超过
40MB 时自动切换,回落到一半以下时切回扫描模式。
精确定位到具体消息。
自动重建。
测试
增量索引、空会话墓碑、模式切换、结果排序与摘要生成。
的 check、clippy 和全量测试全部通过。
备注
变体仅在全文模式由 trigram 折叠。
取舍,用于控制索引体积和搜索性能。