Add inline chat search and Spotlight global search#1419
Conversation
Agent-Logs-Url: https://github.com/ThinkInAIXYZ/deepchat/sessions/03e6c597-17cc-43b2-b07e-9690c5828beb Co-authored-by: zhangmo8 <43628500+zhangmo8@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ThinkInAIXYZ/deepchat/sessions/03e6c597-17cc-43b2-b07e-9690c5828beb Co-authored-by: zhangmo8 <43628500+zhangmo8@users.noreply.github.com>
|
我补充一个 plan,可以参考做做,既然这次要做搜索,我们可以考虑做的完整一点 DeepChat 内置 Spotlight 全局搜索方案Summary
UX & Interaction
Implementation Changes
Public APIs / Types
Test Plan
Assumptions
|
zhangmo8
left a comment
There was a problem hiding this comment.
除了当前的task内搜索,还想实现一个全局索引快速跳转
Summary
目标是做一个单实例、App 级、Raycast 风格的命令面板:Cmd/Ctrl+P 全局唤起,希望可以设置该快捷键,基于之前快捷键设置的实现进行扩展
主要功能统一搜索会话标题、历史消息、Agent、设置页面和少量非破坏性动作。
视觉语言沿用现有侧边栏/欢迎页的半透明卡片风格:rounded-2xl + border + bg-card/40 + backdrop-blur,不引入新视觉系统。
首版设置搜索只覆盖“设置页面”,不下钻具体开关;动作只做非破坏性动作,避免误触。
先在 docs/specs/app-spotlight-search/ 补 spec.md、plan.md、tasks.md,再进入代码实现。
主窗口
┌──────────── 左侧 rail ────────────┬──────────────────────────────┐
│ ○ All Agents │ │
│ ◉ DeepChat │ │
│ ◎ Claude Code │ │
│ │ │
│ 🔍 Spotlight │ Chat / New Thread / ... │
│ ⇆ Collapse │ │
│ … Settings │ │
└───────────────────────────────────┴──────────────────────────────┘
Spotlight overlay
╭──────────────────────────────────────────────────────────────────╮
│ 🔎 Search chats, messages, agents, settings, actions… ⌘F │
│──────────────────────────────────────────────────────────────────│
│ › 💬 Release checklist Session │
│ Claude Code · 2h ago · /deepchat │
│ ≡ "pnpm run build still fails on arm64..." Message │
│ in Release checklist · assistant · 2h ago │
│ 🤖 Claude Code Agent │
│ ⚙ Shortcuts Setting │
│ ⌁ New Chat Action │
│──────────────────────────────────────────────────────────────────│
│ ↑↓ move Enter open Esc close Click works Hover follows │
╰──────────────────────────────────────────────────────────────────╯
UX & Interaction
Cmd/Ctrl+F 由主进程全局快捷键接管,并新增为可配置快捷键项 QuickSearch;鼠标入口放在左侧 rail,常驻可见。
面板为 App 顶层 modal overlay,打开时自动聚焦输入框;Esc 关闭,↑/↓ 移动,Home/End 跳首尾,Enter 执行当前项,鼠标 hover 同步高亮,click 执行。
空查询展示 Recent Sessions + Agents + Actions;有查询时展示一条统一结果列表,用 kind pill 标记 Session / Message / Agent / Setting / Action,不做多段重复分组,保证键盘移动稳定。
session 命中切到该会话;message 命中切到该会话,待消息加载完成后滚动到目标消息并高亮 2 秒。
agent 命中复用现有侧栏切换逻辑;setting 命中打开/聚焦设置窗口并导航到对应页面;action 只执行非破坏性动作,首版包含 New Chat、Open Settings 和到 Providers / Agents / MCP / Shortcuts 的快捷入口。
搜索范围默认忽略当前 sidebar 的 agent 过滤,始终在“全量历史 + 全量导航项”里搜索。
Implementation Changes
主进程新增可复用历史搜索服务,抽离当前 conversation search 的“消息正文提取 + snippet 生成”逻辑,给 MCP 和 UI 共用,避免两套规则漂移。
历史搜索默认走 SQLite FTS5:新增 deepchat_search_documents 普通表存 entity_kind / entity_id / session_id / title / body / role / updated_at,再建 deepchat_search_documents_fts 虚表做全文索引。
首次启动或 schema 变更时,从现有 new_sessions + deepchat_messages 全量回填;此后在“会话创建/重命名/删除、消息写入/编辑/删除、历史导入”路径增量同步。
FTS 查询失败或当前 query 无法被 tokenizer 正常处理时,自动降级到同一份 deepchat_search_documents 上的 LIKE 查询,保证“任意字符都能出结果”。
历史索引只收录用户可见文本:用户消息取 text,助手消息取可见内容块和错误文本,不索引工具调用原始 JSON、图片元数据和未持久化的流式内容。
渲染层新增 spotlight store 管理 open/query/results/activeIndex/loading/pendingMessageJump/requestSeq,输入 80ms debounce,请求按序号丢弃过期响应,结果最多渲染 12 条。
设置页搜索不散落硬编码:把设置导航元数据抽成一份共享 registry,设置窗口路由和 Spotlight 同时消费;Spotlight 只读页面级条目。
结果排序统一在 renderer 合并完成:标题前缀命中 > 名称前缀命中 > 正文命中,session 略高于 message,再叠加轻量 recency boost。
消息跳转通过 pendingMessageJump 串起来:执行 message 结果后先记目标,Chat 页在 session 激活并加载消息完成后再消费,成功滚动后清空。
Public APIs / Types
新增 INewAgentPresenter.searchHistory(query, options?),只返回聊天数据的 union results:session hit | message hit。
新增共享类型:HistorySearchHit、HistorySearchSessionHit、HistorySearchMessageHit、HistorySearchOptions;renderer 本地再补 SpotlightItem 的 agent | setting | action。
新增快捷键配置项 QuickSearch 和事件 SHORTCUT_EVENTS.TOGGLE_SPOTLIGHT,默认值为 CommandOrControl+F。
新增共享设置导航 registry,字段固定为 routeName / titleKey / icon / keywords[]。
Test Plan
Main tests 覆盖:session title hit 与 message hit 的排序、会话重命名/消息编辑删除后的索引同步、legacy import 后的回填、FTS 失败时自动降级到 LIKE。
Renderer tests 覆盖:Cmd/Ctrl+F 打开关闭、输入框自动聚焦、Esc/↑/↓/Enter 全链路、统一结果列表混排与去重、message 结果切会话后滚动高亮、agent/setting/action 执行行为、hover 与 click 不破坏键盘 active item。
验收场景:空查询有 recent/agents/actions;sidebar 收起时仍可用;设置窗口获得焦点时按 Cmd/Ctrl+F,会聚焦主聊天窗口并打开同一个 Spotlight。
Assumptions
v1 只做一个 Spotlight 实例,挂在主聊天窗口,不在设置窗口内再做第二套 UI。
v1 不做 prefix scopes(如 >、@、#)、不做具体设置开关级搜索,也不提供 destructive actions。
v1 搜索“历史消息”仅覆盖已持久化内容,不覆盖正在 streaming 但尚未落库的临时内容。
动效保持轻量,并统一尊重 prefers-reduced-motion。
Agent-Logs-Url: https://github.com/ThinkInAIXYZ/deepchat/sessions/c50314d6-15fd-4335-b969-aab75fd62c4b Co-authored-by: zhangmo8 <43628500+zhangmo8@users.noreply.github.com>
... 已在 5e3ea2d 补上
已在 5e3ea2d 先按 SDD 补齐 |
zhangmo8
left a comment
There was a problem hiding this comment.
帮我按照文档完成spotlight search spec 的功能
Agent-Logs-Url: https://github.com/ThinkInAIXYZ/deepchat/sessions/d4d03af1-949d-45cf-aad8-257e96a2cf3f Co-authored-by: zhangmo8 <43628500+zhangmo8@users.noreply.github.com>
Agent-Logs-Url: https://github.com/ThinkInAIXYZ/deepchat/sessions/d4d03af1-949d-45cf-aad8-257e96a2cf3f Co-authored-by: zhangmo8 <43628500+zhangmo8@users.noreply.github.com>
已按 Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
close #1417
This PR expands the original lightweight search work into two complementary search flows: inline search inside the active conversation, plus an app-level Spotlight overlay for fast global navigation across sessions, messages, agents, settings, and safe actions.
Current chat inline search
ChatPageCtrl/Cmd+Fcurrent / total)Enter/Shift+Enterfor next/previous matchEscDOM-scoped message highlighting
chatSearchutility to:Sidebar history search
WindowSideBarWindowSideBarSessionItemSpotlight global search
QuickSearchshortcut, defaulting toCmd/Ctrl+PEsc,↑/↓,Home/End,Enter, hover, and click interactionsHistory search integration
INewAgentPresenter.searchHistory(query, options?)Settings and shortcut integration
SHORTCUT_EVENTS.TOGGLE_SPOTLIGHTQuickSearchto shortcut settings and exposes it in the settings UICross-surface result execution
sessionhits activate the matched sessionmessagehits activate the matched session, then scroll to and temporarily highlight the target message after loadagenthits reuse existing agent switching flowsettinghits open/focus the settings window and navigate to the matched pageactionhits support non-destructive shortcuts such asNew Chat,Open Settings, and direct entries forProviders,Agents,MCP,Remote, andShortcutsLocalization and test coverage
Example
**
Original prompt
背景需求
参考 issue:#1417
用户希望:
设计目标
• 当前聊天搜索应优先支持:
• Ctrl+F 打开搜索框
• 实时高亮匹配结果
• Enter / Shift+Enter 跳转上下一个结果
• Esc 关闭搜索
• 显示命中数量,例如 3 / 12