@renyuluo/dsh-deepsearch 0.1.16 → 0.1.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +11 -0
- package/README.en.md +43 -15
- package/README.md +43 -15
- package/client.js +286 -26
- package/host.js +2 -2
- package/package.json +4 -4
- package/runtime-0.1.17.js +1 -0
- package/search-core.js +3 -3
- package/runtime-0.1.16.js +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.1.17
|
|
4
|
+
|
|
5
|
+
- Add local search history: one-second idle recording outside IME composition, 30 deduplicated keywords, replay, individual deletion and clear; no result or chat content is stored.
|
|
6
|
+
- Add a persistent Default history preference with immediate tab ordering, preserved current content and the preferred start view on reopen.
|
|
7
|
+
- Open project results in the native new-conversation page without aborting host navigation; make one bounded sidebar expand/reveal attempt after navigation succeeds.
|
|
8
|
+
- Add opt-in macOS Desktop native ⌘K takeover through the official shortcut service, with recovery journaling, guarded rollback, original-binding restoration and unchanged ⌘⇧K fallback. Turn takeover off before uninstalling.
|
|
9
|
+
- Include archived conversations by default in the UI while retaining the backend API’s opt-in archive behavior; require confirmation before restoring archived results.
|
|
10
|
+
- Show recent conversations’ workspace and last update in local time, including live host summary fallback for older catalogs.
|
|
11
|
+
- Compact Settings: inline reset icon, concise shortcut help with full accessibility details, aligned Settings/Esc controls, and updated bilingual documentation and badges.
|
|
12
|
+
- Preserve existing appearance, manual-unread and local preference keys.
|
|
13
|
+
|
|
3
14
|
## 0.1.16
|
|
4
15
|
|
|
5
16
|
- Add public documentation images for the opt-in manual-unread settings, session context menu and left-side indicator, using fictional demo data.
|
package/README.en.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# DeepSearch · Full-text Conversation Search
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch)
|
|
4
|
+
[](https://github.com/luorenyu/dsh-deepsearch/releases/latest)
|
|
5
|
+
[](https://github.com/luorenyu/dsh-deepsearch/actions/workflows/test.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/luorenyu/dsh-deepsearch)
|
|
8
|
+
|
|
3
9
|
[简体中文](README.md) | **English**
|
|
4
10
|
|
|
5
11
|
A local full-text search plugin for **DeepSeek Harness**. Find a conversation from a fragment you remember, without having to remember its title.
|
|
@@ -10,6 +16,8 @@ A local full-text search plugin for **DeepSeek Harness**. Find a conversation fr
|
|
|
10
16
|
- **Native conversation navigation**: open the original DSH conversation, load the exact message, and attempt to scroll to and highlight it—without replacing the conversation view.
|
|
11
17
|
- **Scope and appearance controls**: project/workspace filters, optional archived conversations, frosted glass, host theme, and custom color, opacity, and blur.
|
|
12
18
|
- **Optional manual unread**: enable session context-menu marking in settings, with the native leading unread dot, automatic clearing on re-entry, and local-only persistence.
|
|
19
|
+
- **Local search history**: record keywords after one idle second, keep up to 30, replay or delete them, and choose the default start tab without storing chat content.
|
|
20
|
+
- **Projects and shortcuts**: start native conversations from project results with a bounded sidebar reveal; optionally use macOS `⌘K` and restore the original binding when disabled.
|
|
13
21
|
- **No chat uploads**: reuse the host's authentication and history services with no additional production listener. Messages are never edited; archive state changes only after explicit restoration confirmation.
|
|
14
22
|
|
|
15
23
|
## Feature Preview
|
|
@@ -18,31 +26,39 @@ Except for the explicitly labeled sidebar illustration, these images use the **a
|
|
|
18
26
|
|
|
19
27
|
### Full-text search, highlighted snippets, and message timestamps
|
|
20
28
|
|
|
21
|
-

|
|
22
30
|
|
|
23
31
|
### Project and workspace filters
|
|
24
32
|
|
|
25
|
-

|
|
26
34
|
|
|
27
35
|
### Archived conversations
|
|
28
36
|
|
|
29
|
-

|
|
30
38
|
|
|
31
39
|
### Three panel appearance modes
|
|
32
40
|
|
|
33
|
-

|
|
34
42
|
|
|
35
|
-

|
|
36
44
|
|
|
37
|
-

|
|
38
46
|
|
|
39
47
|
### Optional extension: manual unread
|
|
40
48
|
|
|
41
49
|
Enable it in Settings, then mark a sidebar conversation unread/read from its context menu. Re-entering the conversation clears the mark. Preferences and marks remain local to this client. The settings image uses the actual plugin component. The context-menu image places a faithful fictional sidebar illustration inside the matching feature-card frame; it is not a native screenshot or runtime-verification evidence.
|
|
42
50
|
|
|
43
|
-

|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
### Search history and compact settings
|
|
44
56
|
|
|
45
|
-
|
|
57
|
+
Keywords stay local, with a preferred start tab, replay and deletion. The CmdK demonstration uses an in-memory mock shortcut service, not real host configuration writes.
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+

|
|
46
62
|
|
|
47
63
|
## Installation
|
|
48
64
|
|
|
@@ -50,7 +66,7 @@ The verified host is **DSH Desktop 0.2.2-rc.3**. Other versions and platforms ha
|
|
|
50
66
|
|
|
51
67
|
### Install from npm (recommended)
|
|
52
68
|
|
|
53
|
-
The public package is [@renyuluo/dsh-deepsearch](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch). **0.1.
|
|
69
|
+
The public package is [@renyuluo/dsh-deepsearch](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch). The feature release documented here is **0.1.17**. Use the commands below; npm and GitHub Releases are the source of truth for publication status.
|
|
54
70
|
|
|
55
71
|
```sh
|
|
56
72
|
dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
@@ -61,13 +77,13 @@ The public package name is **`@renyuluo/dsh-deepsearch`**. The product name and
|
|
|
61
77
|
### Install from GitHub
|
|
62
78
|
|
|
63
79
|
```sh
|
|
64
|
-
dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.
|
|
80
|
+
dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.17'
|
|
65
81
|
```
|
|
66
82
|
|
|
67
83
|
Alternatively, download the package from [Releases](https://github.com/luorenyu/dsh-deepsearch/releases), then install it:
|
|
68
84
|
|
|
69
85
|
```sh
|
|
70
|
-
dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.
|
|
86
|
+
dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.17.tgz
|
|
71
87
|
```
|
|
72
88
|
|
|
73
89
|
> **Important: do not install the unscoped npm package with `add dsh-deepsearch`.** That package belongs to another author and is unrelated to this repository. Use `@renyuluo/dsh-deepsearch` or this repository's GitHub/Release URL instead.
|
|
@@ -81,7 +97,7 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
81
97
|
|
|
82
98
|
This migration applies only to this project's old installation; it is not a recommendation to remove another author's similarly named plugin. The appearance storage key is unchanged, so existing preferences are preserved on the same host page origin.
|
|
83
99
|
|
|
84
|
-
|
|
100
|
+
Component screenshots have been refreshed for 0.1.17; the approved fictional sidebar illustration is preserved. All demos use an isolated mock host and invented data, never private conversations. Native navigation and persisted shortcut integration require actual-host verification.
|
|
85
101
|
|
|
86
102
|
### Discover it in the DSH plugin marketplace
|
|
87
103
|
|
|
@@ -95,17 +111,29 @@ Once accepted, search the relevant marketplace for **DeepSearch** or **会话全
|
|
|
95
111
|
| --- | --- |
|
|
96
112
|
| Open or close search | macOS `⌘⇧K`; Windows/Linux `Ctrl⇧K` (not tested on physical devices) |
|
|
97
113
|
| Select a result | `↑` / `↓` |
|
|
98
|
-
| Open a result | `Enter
|
|
114
|
+
| Open a result | `Enter`; clicking a project result or pressing Enter starts a native conversation in that workspace |
|
|
99
115
|
| Close the panel | `Esc` or click outside |
|
|
100
116
|
| Set the search scope | All / Conversations / Projects, workspace dropdown, include archived |
|
|
101
117
|
| Adjust the panel and extensions | “设置” (Settings) in the upper-right corner |
|
|
102
118
|
|
|
103
|
-
|
|
119
|
+
By default, DeepSearch leaves DSH's native `⌘K` alone; takeover is optional in Settings. It does not claim `⌘F`, commonly used by other search plugins.
|
|
120
|
+
|
|
121
|
+
Include archived is checked by default and can be unchecked. With an empty query, recent conversations show the project and session's last update in local time (`YYYY/MM/DD HH:mm`); missing metadata displays 未分配项目 / 时间未知. The reset-arrow icon after the blur slider restores default appearance and exposes a hover tooltip.
|
|
122
|
+
|
|
123
|
+
With an empty query, switch between Recent conversations and Search history. The Default history checkbox, before Include archived, remembers a local preference: checked puts Search history first; unchecked puts Recent conversations first. Changing it reorders tabs without switching the current content; reopening selects the first tab. Keywords are saved after one second of idle input, never during IME composition; at most 30 exact-deduplicated keywords are kept, newest first. Clicking a history entry or selecting it with Enter searches again without directly opening a conversation. Individual deletion and Clear history affect only local keywords, not results or chat messages.
|
|
104
124
|
|
|
105
125
|
Enter a Chinese fragment or an English keyword. Search continues automatically, with results appearing as each batch is scanned—no manual paging is required. “No results” is shown only after a complete scan finds no matches. Read failures, timeouts, incomplete scans, and the 200-result limit are reported separately. Changing the query or closing the panel cancels the previous task.
|
|
106
126
|
|
|
107
127
|
Opening a message result takes you to the native conversation. The plugin verifies the exact message using `sessionId + seq`, then attempts to locate and highlight the corresponding native row. The status area lets you return to search or clear the highlight. Switching conversations or feature pages releases navigation resources. Title results only open the conversation; they do not claim successful message positioning.
|
|
108
128
|
|
|
129
|
+
Project results open the native new-conversation page first, then make one bounded attempt to expand the target workspace and folded ancestors and reveal the workspace and conversation in the sidebar. Manual scrolling, further input, or another result stops the attempt. A collapsed sidebar, flat/filtered view, or changed host DOM may skip sidebar reveal without preventing navigation. The workspace dropdown still only filters search scope.
|
|
130
|
+
|
|
131
|
+
### Optional native ⌘K takeover
|
|
132
|
+
|
|
133
|
+
Enable “使用 ⌘K 打开 DeepSearch” in Settings to replace native session search with DeepSearch through the official DSH shortcut service on macOS Desktop. ⌘⇧K remains available. Off by default; disabling restores the original override, including custom bindings. This writes DSH shortcut preferences and saves a local recovery journal, surviving reload.
|
|
134
|
+
|
|
135
|
+
**Turn takeover off before uninstalling.** Direct removal cannot automatically restore host preferences; use DSH shortcut settings to restore Session Search and clear the DeepSearch binding. Failed writes attempt a safe rollback; externally changed bindings are not overwritten and recovery data is kept. Currently macOS Desktop only, not an arbitrary shortcut recorder.
|
|
136
|
+
|
|
109
137
|
### Opening archived results
|
|
110
138
|
|
|
111
139
|
With “含归档” (Include archived) enabled, archived title and message hits display an **“已归档”** badge. Selecting one keeps the results visible and asks for confirmation. Only **“恢复并打开” (Restore and open)** calls the host unarchive command, then opens the native conversation and attempts message positioning. Cancel does not change archive state.
|
|
@@ -129,7 +157,7 @@ Preferences and markers stay in this client’s local storage, do not sync acros
|
|
|
129
157
|
## Privacy and Limitations
|
|
130
158
|
|
|
131
159
|
- Reads history through the host's public services, not by parsing private chat files directly. It does not upload chats or write to original messages. The search API uses the host's owner-authenticated `connection.fetch` routes.
|
|
132
|
-
- By default, searches regular conversation titles, user messages, and completed final assistant replies. Tool output, reasoning, subagents, and unfinished replies are excluded.
|
|
160
|
+
- By default, searches regular conversation titles, user messages, and completed final assistant replies. Tool output, reasoning, subagents, and unfinished replies are excluded. The UI includes archived conversations by default and lets you opt out; the underlying API still requires an explicit archive flag.
|
|
133
161
|
- Uses bounded memory, short-lived cursors, and batch scanning—**not a persistent incremental index**. Initial searches through very long histories may be slower. At most 200 results are displayed. Cursors expire after two minutes of inactivity, requiring a new search.
|
|
134
162
|
- Each conversation's history snapshot at its first read defines the scope of that scan. Messages appended during scanning appear only after a new search. History revisions or truncation explicitly require restarting the search.
|
|
135
163
|
- Projects come from workspaces registered with the host. DeepSearch **does not search file contents on disk** or provide command search.
|
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# DeepSearch · 会话全文搜索
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch)
|
|
4
|
+
[](https://github.com/luorenyu/dsh-deepsearch/releases/latest)
|
|
5
|
+
[](https://github.com/luorenyu/dsh-deepsearch/actions/workflows/test.yml)
|
|
6
|
+
[](LICENSE)
|
|
7
|
+
[](https://github.com/luorenyu/dsh-deepsearch)
|
|
8
|
+
|
|
3
9
|
**简体中文** | [English](README.en.md)
|
|
4
10
|
|
|
5
11
|
为 **DeepSeek Harness** 制作的本地全文搜索插件。记得一小段内容,就能找回对应会话,而不必记住标题。
|
|
@@ -10,6 +16,8 @@
|
|
|
10
16
|
- **原生会话定位**:打开 DSH 原生会话,加载精确消息并尝试滚动、高亮,不替换详情页。
|
|
11
17
|
- **范围与外观**:项目 / 工作区过滤、可选归档;毛玻璃、跟随主题、自定义颜色、不透明度与模糊。
|
|
12
18
|
- **可选手动未读**:设置开关控制侧栏右键标记,复用原生左侧未读点;再次打开自动已读,标记仅保存在本机。
|
|
19
|
+
- **本机搜索历史**:停顿 1 秒记录关键词,最多 30 条;重搜、删除和默认起始 Tab 偏好,不存聊天正文。
|
|
20
|
+
- **项目直达与快捷键**:项目结果开启原生新会话并尝试展开侧栏;macOS 可选接管 `⌘K`,关闭恢复原绑定。
|
|
13
21
|
- **不上传聊天**:复用宿主认证与历史服务,不开额外生产监听端口,不修改消息;仅在你确认“恢复并打开”时取消归档。
|
|
14
22
|
|
|
15
23
|
## 功能预览
|
|
@@ -18,31 +26,39 @@
|
|
|
18
26
|
|
|
19
27
|
### 全文搜索、命中摘要与准确时间
|
|
20
28
|
|
|
21
|
-

|
|
22
30
|
|
|
23
31
|
### 项目与工作区范围
|
|
24
32
|
|
|
25
|
-

|
|
26
34
|
|
|
27
35
|
### 归档会话
|
|
28
36
|
|
|
29
|
-

|
|
30
38
|
|
|
31
39
|
### 三种面板外观
|
|
32
40
|
|
|
33
|
-

|
|
34
42
|
|
|
35
|
-

|
|
36
44
|
|
|
37
|
-

|
|
38
46
|
|
|
39
47
|
### 扩展小功能:手动未读
|
|
40
48
|
|
|
41
49
|
在设置中开启后,通过侧栏右键菜单标记未读 / 已读;再次进入会话自动清除。标记和开关仅保存在本机。设置图来自真实插件组件;右键菜单图使用高还原侧边栏重绘,嵌入统一功能卡片。重绘图不是原生截图或运行验证证据。
|
|
42
50
|
|
|
43
|
-

|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
### 搜索历史与紧凑设置
|
|
44
56
|
|
|
45
|
-
|
|
57
|
+
关键词在本机保存;可选择默认历史、重搜或删除。设置中的 ⌘K 演示使用内存模拟快捷键服务,不代表修改真实宿主配置。
|
|
58
|
+
|
|
59
|
+

|
|
60
|
+
|
|
61
|
+

|
|
46
62
|
|
|
47
63
|
## 安装
|
|
48
64
|
|
|
@@ -50,7 +66,7 @@
|
|
|
50
66
|
|
|
51
67
|
### 从 npm 安装(推荐)
|
|
52
68
|
|
|
53
|
-
公开包名为 [@renyuluo/dsh-deepsearch](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch)
|
|
69
|
+
公开包名为 [@renyuluo/dsh-deepsearch](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch)。本次功能版本为 **0.1.17**。请使用下方命令安装;发布状态以 npm 版本页与 GitHub Release 为准。
|
|
54
70
|
|
|
55
71
|
```sh
|
|
56
72
|
dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
@@ -61,13 +77,13 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
61
77
|
### 从 GitHub 安装
|
|
62
78
|
|
|
63
79
|
```sh
|
|
64
|
-
dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.
|
|
80
|
+
dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.17'
|
|
65
81
|
```
|
|
66
82
|
|
|
67
83
|
也可以从 [Releases](https://github.com/luorenyu/dsh-deepsearch/releases) 下载安装包后安装:
|
|
68
84
|
|
|
69
85
|
```sh
|
|
70
|
-
dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.
|
|
86
|
+
dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.17.tgz
|
|
71
87
|
```
|
|
72
88
|
|
|
73
89
|
> **重要:不要运行 `add dsh-deepsearch` 来安装 npm 同名包。** 无作用域的 npm 同名包属于其他作者,与本仓库无关。请使用 `@renyuluo/dsh-deepsearch`,或本仓库 GitHub / Release 地址。
|
|
@@ -81,7 +97,7 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
81
97
|
|
|
82
98
|
这是替换本项目旧安装条目,不是建议卸载其他作者的同名插件。外观存储键保持不变;同一宿主页面来源下已有偏好会继续使用。
|
|
83
99
|
|
|
84
|
-
|
|
100
|
+
组件截图已按 0.1.17 更新;菜单场景仍保留已批准的虚构侧边栏重绘。所有演示使用隔离宿主和虚构数据,不展示私人会话;原生导航、快捷键持久化等须以真实宿主验证为准。
|
|
85
101
|
|
|
86
102
|
### 在 DSH 插件市场中发现
|
|
87
103
|
|
|
@@ -95,17 +111,29 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
95
111
|
| --- | --- |
|
|
96
112
|
| 打开或关闭搜索 | macOS `⌘⇧K`;Windows / Linux `Ctrl⇧K`(未实机验证) |
|
|
97
113
|
| 选择结果 | `↑` / `↓` |
|
|
98
|
-
| 打开结果 | `Enter
|
|
114
|
+
| 打开结果 | `Enter`;项目结果点击或回车将在该项目下开启原生新会话 |
|
|
99
115
|
| 关闭浮层 | `Esc` 或点击外部 |
|
|
100
116
|
| 搜索范围 | 全部 / 对话 / 项目,工作区下拉,含归档 |
|
|
101
117
|
| 调整面板与扩展功能 | 右上角「设置」 |
|
|
102
118
|
|
|
103
|
-
|
|
119
|
+
默认不占用 DSH 原生 `⌘K`,可在设置中选择接管;不占用其他搜索插件常用的 `⌘F`。
|
|
120
|
+
|
|
121
|
+
「含归档」默认勾选,可手动取消。未输入关键词时,最近对话显示所属项目与会话最后更新时间(本机时区,`年/月/日 时:分`);缺失的项目或时间分别显示「未分配项目」「时间未知」。外观恢复默认使用模糊滑条后的回转箭头图标,悬停可见说明。
|
|
122
|
+
|
|
123
|
+
未输入关键词时,可切换「最近对话 / 搜索历史」。「默认历史」位于「含归档」左侧,勾选后「搜索历史」排在第一位,取消后「最近对话」排在第一位;切换偏好不跳走当前内容,每次重新打开选中第一项(仅本机保存)。关键词停顿 1 秒后记录,中文输入法组词期间不记录;最多 30 条、同词去重、最近使用优先。点击或回车选择历史会重新搜索,不会直接打开会话;支持单条删除与清空,不保存结果或聊天正文。
|
|
104
124
|
|
|
105
125
|
输入中文片段或英文关键词后,搜索自动继续,不需要逐页点击。结果随扫描逐步出现;只有扫描完成且没有命中才显示没有找到。读取失败、超时、未完成与 200 条结果上限会单独提示。切换关键词或关闭面板会取消旧任务。
|
|
106
126
|
|
|
107
127
|
点击正文结果后,插件打开原生会话,使用 `sessionId + seq` 检查精确消息是否存在,随后尝试定位原生行并高亮。提示区可以返回搜索或清除高亮;切换会话或其他功能页时释放定位资源。标题结果仅打开会话,不冒充消息定位成功。
|
|
108
128
|
|
|
129
|
+
项目结果会先进入该项目的原生新会话页,再尝试一次性展开左侧目标项目及折叠的父级,并将项目和新会话滚动到可见区域。手动滚动、继续操作或打开其他结果会终止定位;侧栏收起、平铺/筛选视图或宿主结构变化时可跳过,不影响新会话打开。工作区下拉仍只筛选搜索范围。
|
|
130
|
+
|
|
131
|
+
### 可选接管原生 ⌘K
|
|
132
|
+
|
|
133
|
+
在「设置」开启「使用 ⌘K 打开 DeepSearch」后,macOS 桌面端通过 DSH 官方快捷键接口将原生会话搜索让位给 DeepSearch;⌘⇧K 保留。默认关闭,关闭时恢复开启前的原绑定,而不是强制重置你的自定义快捷键。该选项会写入 DSH 快捷键配置,并在本机保存恢复备份;刷新后保留。
|
|
134
|
+
|
|
135
|
+
**卸载插件前请先关闭接管。** 直接卸载不会自动恢复宿主配置;可在 DSH 快捷键设置中恢复「会话搜索」,并清除 DeepSearch 的绑定。若写入失败或期间被其他设置修改,插件会尝试安全回滚,保留备份并提示恢复,不覆盖新配置。当前只支持 macOS 桌面端,不是任意快捷键录入器。
|
|
136
|
+
|
|
109
137
|
### 打开归档结果
|
|
110
138
|
|
|
111
139
|
勾选“含归档”后,归档会话的标题与正文结果显示 **「已归档」** 标签。点击时保留搜索结果并请求确认;只有选择 **「恢复并打开」** 才调用宿主取消归档,然后进入原生会话并尝试定位。选择「取消」不会改变归档状态。
|
|
@@ -129,7 +157,7 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
129
157
|
## 隐私与限制
|
|
130
158
|
|
|
131
159
|
- 通过宿主公开历史服务读取,不直接解析私有聊天文件,不上传聊天、不写入原始消息。搜索 API 使用宿主 `connection.fetch` owner 认证路由。
|
|
132
|
-
-
|
|
160
|
+
- 默认搜索普通会话标题、用户输入及已完成助手最终回复;排除工具输出、推理、子智能体与未完成回复。界面默认勾选「含归档」,可手动关闭;底层 API 仍需显式请求归档。
|
|
133
161
|
- 搜索采用有界内存、短期游标和逐批扫描,**不是持久增量索引**。超长历史首次查询可能较慢;最多显示 200 条命中,游标闲置两分钟过期后需重搜。
|
|
134
162
|
- 每个会话首次读取的历史切面构成本次范围;扫描期间新追加内容需要重新搜索才会出现。版本变更或历史截断会明确要求重新搜索。
|
|
135
163
|
- 项目来自宿主已登记工作区,**不搜索磁盘文件内容**,也不提供命令搜索。
|
package/client.js
CHANGED
|
@@ -4,6 +4,71 @@ window.__ModuleLoader__.load({
|
|
|
4
4
|
const React = require('react'), h = React.createElement;
|
|
5
5
|
const {StateDot} = require('@deepseek-ai/dsh-client-ui-primitives');
|
|
6
6
|
const MAX_RESULTS = 200;
|
|
7
|
+
// Bounded compatibility adapter: native navigation first, exact sidebar rows second.
|
|
8
|
+
function revealProject(ctx, workspaceId, start) {
|
|
9
|
+
const sources = [ctx.sessions?.list, ctx.workspaces?.list, ctx.layout?.panelInfo];
|
|
10
|
+
if (!document.querySelectorAll || sources.some(source => !source?.subscribe)) {start(); return () => {};}
|
|
11
|
+
let stopped = false, timer, deadline, observer, selectedId;
|
|
12
|
+
const disposers = [], clicked = new WeakSet();
|
|
13
|
+
const mainIds = () => Object.values(sources[0].getSnapshot().byId || {}).filter(row => (row.retainedBy?.mainView || 0) > 0).map(row => row.id);
|
|
14
|
+
const initial = new Set(mainIds());
|
|
15
|
+
const stop = () => {
|
|
16
|
+
if (stopped) return; stopped = true; clearTimeout(timer); clearTimeout(deadline); observer?.disconnect();
|
|
17
|
+
for (const dispose of disposers.splice(0)) dispose();
|
|
18
|
+
for (const name of ['wheel', 'touchstart', 'pointerdown', 'keydown']) document.removeEventListener(name, interrupt, true);
|
|
19
|
+
};
|
|
20
|
+
const interrupt = event => {if (event.isTrusted) stop();};
|
|
21
|
+
const schedule = () => {if (!stopped) {clearTimeout(timer); timer = setTimeout(check, 0);}};
|
|
22
|
+
const findRow = key => Array.from(document.querySelectorAll('[data-row-key][role="treeitem"]')).find(row => row.getAttribute('data-row-key') === key && row.getClientRects().length);
|
|
23
|
+
function check() {
|
|
24
|
+
if (stopped) return;
|
|
25
|
+
try {
|
|
26
|
+
const snapshot = sources[1].getSnapshot(), items = snapshot.items || [], target = items.find(row => row.workspaceId === workspaceId);
|
|
27
|
+
const ids = mainIds(), rows = sources[0].getSnapshot().byId || {};
|
|
28
|
+
if (selectedId && (ids.length !== 1 || ids[0] !== selectedId)) {stop(); return;}
|
|
29
|
+
if (!target || snapshot.phase !== 'ready') return;
|
|
30
|
+
const id = ids.length === 1 && target.sessionIds?.includes(ids[0]) && rows[ids[0]]?.blank === true ? ids[0] : undefined;
|
|
31
|
+
if (!id) {if (ids.some(value => !initial.has(value) && !target.sessionIds?.includes(value))) stop(); return;}
|
|
32
|
+
if (sources[2].getSnapshot().activePanelId !== null) return;
|
|
33
|
+
selectedId = id;
|
|
34
|
+
let row = findRow('workspace:' + workspaceId);
|
|
35
|
+
if (!row) {
|
|
36
|
+
// A missing child can be behind collapsed path ancestors; flat mode skips this branch.
|
|
37
|
+
const normalize = path => (/^[A-Za-z]:[/\\]/.test(path) || path.startsWith('\\\\') ? path.replace(/\\/g, '/') : path).replace(/\/+$/, '');
|
|
38
|
+
const path = typeof target.path === 'string' ? normalize(target.path) : '';
|
|
39
|
+
const parents = path ? items.filter(item => item.workspaceId !== workspaceId && typeof item.path === 'string' && path.startsWith(normalize(item.path) + '/')).sort((a, b) => normalize(a.path).length - normalize(b.path).length) : [];
|
|
40
|
+
row = parents.map(parent => findRow('workspace:' + parent.workspaceId)).find(parent => parent?.getAttribute('aria-expanded') === 'false');
|
|
41
|
+
if (!row) return;
|
|
42
|
+
}
|
|
43
|
+
if (row.getAttribute('aria-expanded') === 'false') {
|
|
44
|
+
if (!clicked.has(row)) {clicked.add(row); row.click(); schedule();}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const sessionRow = findRow('session:' + id);
|
|
48
|
+
if (!sessionRow) return;
|
|
49
|
+
// Adjust only sidebar ancestors, inner first; never scroll the conversation/document.
|
|
50
|
+
const scrollers = [];
|
|
51
|
+
for (let node = row.parentElement; node && node !== document.body; node = node.parentElement) {
|
|
52
|
+
if (node.scrollHeight > node.clientHeight && (/^(auto|scroll)$/.test(window.getComputedStyle(node).overflowY) || node.hasAttribute?.('data-sidebar-list-area') || node.hasAttribute?.('data-sidebar-scrollport'))) scrollers.push(node);
|
|
53
|
+
}
|
|
54
|
+
stop();
|
|
55
|
+
for (const scroller of scrollers) {
|
|
56
|
+
const bounds = scroller.getBoundingClientRect(), header = row.getBoundingClientRect(), session = sessionRow.getBoundingClientRect();
|
|
57
|
+
const bottom = session.bottom - header.top <= scroller.clientHeight ? session.bottom : header.bottom;
|
|
58
|
+
const delta = header.top < bounds.top ? header.top - bounds.top : bottom > bounds.bottom ? bottom - bounds.bottom : 0;
|
|
59
|
+
if (delta) scroller.scrollTop += delta;
|
|
60
|
+
}
|
|
61
|
+
} catch {stop();} // A changed host DOM must not break navigation.
|
|
62
|
+
}
|
|
63
|
+
try {
|
|
64
|
+
for (const source of sources) disposers.push(source.subscribe(schedule));
|
|
65
|
+
if (typeof MutationObserver !== 'undefined') {observer = new MutationObserver(schedule); observer.observe(document.body, {childList: true, subtree: true, attributes: true, attributeFilter: ['aria-expanded', 'aria-selected']});}
|
|
66
|
+
deadline = setTimeout(stop, 8000);
|
|
67
|
+
for (const name of ['wheel', 'touchstart', 'pointerdown', 'keydown']) document.addEventListener(name, interrupt, true);
|
|
68
|
+
} catch {stop();}
|
|
69
|
+
try {start(); schedule();} catch (error) {stop(); throw error;}
|
|
70
|
+
return stop;
|
|
71
|
+
}
|
|
7
72
|
function selectedKeys(chat, seq) {
|
|
8
73
|
if (!Number.isSafeInteger(seq) || !chat?.order || !chat.nodes?.get) return [];
|
|
9
74
|
return chat.order.filter(key => {
|
|
@@ -54,6 +119,116 @@ window.__ModuleLoader__.load({
|
|
|
54
119
|
return (event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey &&
|
|
55
120
|
event.key.toLowerCase() === 'k' && !event.isComposing && !event.repeat;
|
|
56
121
|
}
|
|
122
|
+
const SHORTCUT_KEY = 'dsh-deepsearch.shortcut-takeover.v1';
|
|
123
|
+
function createShortcutTakeover(service, storage, toggle) {
|
|
124
|
+
const id = 'deepsearch.toggle', nativeId = 'session.search', key = {code: 'KeyK', modifiers: ['meta']};
|
|
125
|
+
const profile = 'desktop:macos', listeners = new Set(), disposers = [];
|
|
126
|
+
let busy = false, error = '', journal = null, disposed = false, state;
|
|
127
|
+
let supported = service?.runtime === 'desktop' && service?.platform === 'macos' && typeof service.edit === 'function', invalidBackup = false;
|
|
128
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
129
|
+
const override = command => {
|
|
130
|
+
const values = service.config.getSnapshot().document.profiles[profile] || {};
|
|
131
|
+
return Object.hasOwn(values, command) ? {present: true, value: values[command]} : {present: false};
|
|
132
|
+
};
|
|
133
|
+
const cleared = {present: true, value: null}, assigned = {present: true, value: key};
|
|
134
|
+
const ownsKey = binding => binding?.code === 'KeyK' && !binding.secondCode && binding.modifiers?.length === 1 && binding.modifiers[0] === 'meta';
|
|
135
|
+
const publish = () => {
|
|
136
|
+
const rows = service?.catalog?.getSnapshot() || [], own = rows.find(row => row.id === id), native = rows.find(row => row.id === nativeId);
|
|
137
|
+
state = {supported, busy, error, recovery: !!journal, enabled: !!(ownsKey(own?.binding) && native?.binding === null && !own?.conflicts?.length && !own?.issue)};
|
|
138
|
+
for (const listener of listeners) listener();
|
|
139
|
+
};
|
|
140
|
+
const readJournal = () => {
|
|
141
|
+
journal = null; invalidBackup = false;
|
|
142
|
+
try {const raw = storage?.getItem(SHORTCUT_KEY); if (raw) {
|
|
143
|
+
const value = JSON.parse(raw);
|
|
144
|
+
const valid = entry => {
|
|
145
|
+
if (!entry || typeof entry.present !== 'boolean') return false;
|
|
146
|
+
if (!entry.present || entry.value === null) return true;
|
|
147
|
+
const binding = entry.value;
|
|
148
|
+
if (!binding || Object.keys(binding).some(key => !['code','secondCode','modifiers'].includes(key)) || typeof binding.code !== 'string' ||
|
|
149
|
+
(Object.hasOwn(binding, 'secondCode') && typeof binding.secondCode !== 'string') || !Array.isArray(binding.modifiers) ||
|
|
150
|
+
!binding.modifiers.every(value => ['primary','control','alt','shift','meta'].includes(value))) return false;
|
|
151
|
+
// The public host normalizer rejects unsupported/duplicate physical codes before any write.
|
|
152
|
+
try {service.describeBinding(binding); return true;} catch {return false;}
|
|
153
|
+
};
|
|
154
|
+
if (value?.profile === profile && valid(value.native) && valid(value.own)) journal = value;
|
|
155
|
+
else {invalidBackup = true; error = '快捷键备份无法识别,请先在 DSH 快捷键设置中检查原生会话搜索。';}
|
|
156
|
+
}} catch {invalidBackup = true; error = '无法读取快捷键备份;未修改 DSH 配置。';}
|
|
157
|
+
};
|
|
158
|
+
readJournal();
|
|
159
|
+
try {
|
|
160
|
+
if (supported) {
|
|
161
|
+
disposers.push(service.register({id, label: () => 'DeepSearch 全文搜索', aliases: ['DeepSearch'], defaults: {}, regions: ['page', 'editable'], modals: ['sidebar'],
|
|
162
|
+
resolve: () => ({status: 'handled', run: () => {if (!disposed) toggle();}})}));
|
|
163
|
+
disposers.push(service.config.subscribe(publish), service.catalog.subscribe(publish));
|
|
164
|
+
if (typeof window !== 'undefined' && window.addEventListener) {
|
|
165
|
+
const onStorage = event => {if (!busy && (event.key === SHORTCUT_KEY || event.key === null)) {readJournal(); publish();}};
|
|
166
|
+
window.addEventListener('storage', onStorage);
|
|
167
|
+
disposers.push(() => window.removeEventListener('storage', onStorage));
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
} catch {supported = false; for (const off of disposers.splice(0)) off(); error = '无法注册 DeepSearch 快捷键命令。';}
|
|
171
|
+
publish();
|
|
172
|
+
const edit = async (command, value) => {
|
|
173
|
+
if (disposed) throw new Error('插件已卸载,请在 DSH 快捷键设置中恢复原绑定。');
|
|
174
|
+
const snapshot = service.config.getSnapshot();
|
|
175
|
+
if (snapshot.status !== 'ready') throw new Error('DSH 快捷键配置尚未就绪,请稍后重试。');
|
|
176
|
+
const result = await service.edit(value.present ? {type: 'set', id: command, binding: value.value} : {type: 'reset', id: command}, snapshot.revision);
|
|
177
|
+
if (result.status !== 'saved') throw new Error('DSH 快捷键保存失败(' + result.status + '),请检查配置后重试。');
|
|
178
|
+
};
|
|
179
|
+
const restore = async () => {
|
|
180
|
+
if (!journal) throw new Error('缺少原快捷键备份,请到 DSH 快捷键设置中手动恢复会话搜索。');
|
|
181
|
+
const previous = journal;
|
|
182
|
+
if (![previous.native, cleared].some(value => same(value, override(nativeId))) || ![previous.own, assigned].some(value => same(value, override(id))))
|
|
183
|
+
throw new Error('相关快捷键已被其他设置修改;为避免覆盖,请在 DSH 快捷键设置中手动恢复。');
|
|
184
|
+
if (!same(override(id), previous.own)) await edit(id, previous.own);
|
|
185
|
+
if (!same(override(nativeId), previous.native)) {
|
|
186
|
+
if (!same(override(nativeId), cleared)) throw new Error('原生搜索绑定已变化,已停止恢复,未覆盖新配置。');
|
|
187
|
+
await edit(nativeId, previous.native);
|
|
188
|
+
}
|
|
189
|
+
if (!same(override(nativeId), previous.native) || !same(override(id), previous.own)) throw new Error('恢复期间快捷键配置已变化,请检查 DSH 设置,备份已保留。');
|
|
190
|
+
if (!same(JSON.parse(storage.getItem(SHORTCUT_KEY)), previous)) throw new Error('快捷键恢复备份已被其他窗口修改,已保留新的备份。');
|
|
191
|
+
storage.removeItem(SHORTCUT_KEY); journal = null;
|
|
192
|
+
};
|
|
193
|
+
return {
|
|
194
|
+
getSnapshot: () => state,
|
|
195
|
+
subscribe(listener) {listeners.add(listener); return () => listeners.delete(listener);},
|
|
196
|
+
async setEnabled(value) {
|
|
197
|
+
if (!supported || disposed || busy) return;
|
|
198
|
+
busy = true; error = ''; publish();
|
|
199
|
+
const perform = async () => {try {
|
|
200
|
+
// Another window may have taken over since this controller was mounted.
|
|
201
|
+
readJournal();
|
|
202
|
+
if (!value) await restore();
|
|
203
|
+
else {
|
|
204
|
+
if (invalidBackup) throw new Error('快捷键备份不可用,未修改 DSH 配置;请检查本机存储及 DSH 快捷键设置。');
|
|
205
|
+
if (journal) throw new Error('存在待恢复的快捷键备份,请先点击恢复原绑定。');
|
|
206
|
+
const snapshot = service.config.getSnapshot();
|
|
207
|
+
if (snapshot.status !== 'ready') throw new Error('DSH 快捷键配置尚未就绪。');
|
|
208
|
+
const conflicts = service.describeBinding(key);
|
|
209
|
+
if (conflicts.issue || conflicts.conflicts.some(command => command !== nativeId && command !== id)) throw new Error('⌘K 已被其他命令占用,请先在 DSH 快捷键设置中处理冲突。');
|
|
210
|
+
const previous = {profile, native: override(nativeId), own: override(id)};
|
|
211
|
+
// Persist recovery data before the first host write; never silently lose the old binding.
|
|
212
|
+
storage.setItem(SHORTCUT_KEY, JSON.stringify(previous)); journal = previous;
|
|
213
|
+
try {
|
|
214
|
+
await edit(nativeId, cleared);
|
|
215
|
+
if (!same(override(nativeId), cleared) || !same(override(id), previous.own)) throw new Error('快捷键配置已变化,停止接管。');
|
|
216
|
+
await edit(id, assigned);
|
|
217
|
+
} catch (failure) {
|
|
218
|
+
try {await restore();} catch (recovery) {throw new Error(failure.message + ' ' + recovery.message);}
|
|
219
|
+
throw failure;
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
} catch (failure) {error = failure.message || '快捷键设置失败,未完成接管。';}
|
|
223
|
+
finally {busy = false; publish();}};
|
|
224
|
+
// Serialize renderer windows sharing this origin, including recovery journal ownership.
|
|
225
|
+
if (typeof navigator !== 'undefined' && navigator.locks?.request) {
|
|
226
|
+
try {await navigator.locks.request(SHORTCUT_KEY, perform);} catch {busy = false; error = '无法锁定快捷键配置,请重试。'; publish();}
|
|
227
|
+
} else await perform();
|
|
228
|
+
},
|
|
229
|
+
dispose() {disposed = true; for (const off of disposers.splice(0)) off(); listeners.clear();},
|
|
230
|
+
};
|
|
231
|
+
}
|
|
57
232
|
function joinItems(previous, next) {
|
|
58
233
|
const seen = new Set(previous.map(item => item.id));
|
|
59
234
|
return previous.concat(next.filter(item => !seen.has(item.id) && seen.add(item.id))).slice(0, MAX_RESULTS);
|
|
@@ -144,6 +319,41 @@ window.__ModuleLoader__.load({
|
|
|
144
319
|
}
|
|
145
320
|
return style;
|
|
146
321
|
}
|
|
322
|
+
const HISTORY_KEY = 'dsh-deepsearch.search-history.v1';
|
|
323
|
+
function createSearchHistory(storage) {
|
|
324
|
+
const normalize = value => {
|
|
325
|
+
const seen = new Set(), entries = [];
|
|
326
|
+
for (const item of (Array.isArray(value?.entries) ? value.entries.slice(0, 1000) : [])) {
|
|
327
|
+
const query = typeof item?.query === 'string' ? item.query.trim() : '';
|
|
328
|
+
if (!query || query.length > 256 || seen.has(query) || typeof item.time !== 'number' || !Number.isFinite(item.time) || item.time <= 0 || !Number.isFinite(new Date(item.time).getTime())) continue;
|
|
329
|
+
seen.add(query); entries.push({query, time: item.time});
|
|
330
|
+
}
|
|
331
|
+
entries.sort((a, b) => b.time - a.time);
|
|
332
|
+
return {defaultHistory: value?.defaultHistory === true, entries: entries.slice(0, 30), error: ''};
|
|
333
|
+
};
|
|
334
|
+
const read = () => {const raw = storage?.getItem(HISTORY_KEY); if (raw?.length > 200000) throw new Error(); return normalize(JSON.parse(raw || 'null'));};
|
|
335
|
+
let state; try {state = read();} catch {state = {...normalize(null), error: '无法读取搜索历史;本次记录仅在内存中可用。'};}
|
|
336
|
+
const listeners = new Set(), notify = () => {for (const listener of listeners) listener();};
|
|
337
|
+
const commit = value => {
|
|
338
|
+
state = normalize(value);
|
|
339
|
+
try {if (!storage) throw new Error(); storage.setItem(HISTORY_KEY, JSON.stringify({defaultHistory: state.defaultHistory, entries: state.entries}));}
|
|
340
|
+
catch {state = {...state, error: '搜索历史本次已更新,但无法保存到本机;刷新或重启后可能丢失。'};}
|
|
341
|
+
notify();
|
|
342
|
+
};
|
|
343
|
+
return {
|
|
344
|
+
getSnapshot: () => state,
|
|
345
|
+
subscribe(listener) {listeners.add(listener); return () => listeners.delete(listener);},
|
|
346
|
+
add(value) {
|
|
347
|
+
const query = typeof value === 'string' ? value.trim() : '';
|
|
348
|
+
if (!query || query.length > 256) return;
|
|
349
|
+
commit({...state, entries: [{query, time: Date.now()}, ...state.entries.filter(item => item.query !== query)]});
|
|
350
|
+
},
|
|
351
|
+
remove: query => commit({...state, entries: state.entries.filter(item => item.query !== query)}),
|
|
352
|
+
clear: () => commit({...state, entries: []}),
|
|
353
|
+
setDefault: value => commit({...state, defaultHistory: value === true}),
|
|
354
|
+
reload() {try {state = read();} catch {state = {...state, error: '无法读取更新的搜索历史,已保留当前记录。'};} notify();},
|
|
355
|
+
};
|
|
356
|
+
}
|
|
147
357
|
// Independent, local-only reminders: never mutate the host's completionUnread status.
|
|
148
358
|
const UNREAD_KEY = 'dsh-deepsearch.manual-unread.v1';
|
|
149
359
|
function unreadPrefs(value) {
|
|
@@ -211,14 +421,21 @@ window.__ModuleLoader__.load({
|
|
|
211
421
|
if (!preview.range) return preview.text;
|
|
212
422
|
return h(React.Fragment, null, preview.text.slice(0, preview.range[0]), h('mark', null, preview.text.slice(...preview.range)), preview.text.slice(preview.range[1]));
|
|
213
423
|
}
|
|
214
|
-
const css = "\n.deepsearch-panel{--ds-bg:var(--we-panel-color,var(--dsw-alias-bg-base,#fff));--ds-line:var(--dsw-alias-border-l1,#e5e7eb);--ds-text:var(--dsw-alias-label-primary,#18212f);--ds-muted:var(--dsw-alias-label-secondary,#657080);--ds-hover:var(--dsw-alias-bg-layer-2,#f3f5f7);position:fixed;pointer-events:auto;z-index:10000;top:clamp(26px,12vh,128px);left:50%;transform:translateX(-50%);width:min(700px,calc(100vw - 32px));max-height:calc(100vh - clamp(26px,12vh,128px) - 24px);display:flex;flex-direction:column;color:var(--ds-text);background:var(--ds-bg);background:var(--ds-effective-surface,var(--ds-surface,var(--ds-bg)));backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none));-webkit-backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none));border:1px solid var(--ds-line);border-radius:16px;box-shadow:0 16px 60px #0002,0 2px 8px #0001;font-family:inherit;overflow:hidden;text-align:left;isolation:isolate}\n.deepsearch-panel *{box-sizing:border-box}.deepsearch-panel button,.deepsearch-panel input,.deepsearch-panel select,.deepsearch-jump button{font:inherit;color:inherit}.deepsearch-panel button{cursor:pointer}.deepsearch-panel button:disabled{cursor:default;opacity:.6}.deepsearch-panel button:focus-visible,.deepsearch-panel select:focus-visible,.deepsearch-jump button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#3478f6);outline-offset:-2px}.deepsearch-search{display:flex;align-items:center;gap:14px;padding:19px 20px 17px;color:var(--ds-muted)}.deepsearch-search>input{min-width:0;flex:1;border:0;outline:none;background:transparent;font-size:18px;line-height:28px;color:var(--ds-text)}.deepsearch-search>input::placeholder{color:var(--ds-muted);opacity:.8}.deepsearch-escape{border:1px solid var(--ds-line);border-radius:5px;padding:2px 6px;background:none;font-size:11px!important;color:var(--ds-muted)!important}.deepsearch-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 16px 11px;border-bottom:1px solid var(--ds-line)}.deepsearch-tabs{display:flex;gap:4px}.deepsearch-tabs button{border:0;border-radius:6px;background:none;font-size:12px;padding:6px 12px;color:var(--ds-muted)}.deepsearch-tabs button[aria-selected=true]{background:var(--ds-hover);color:var(--ds-text);font-weight:600}.deepsearch-toolbar select{max-width:190px;min-width:0;border:0;outline:none;background:var(--ds-bg);font-size:11px;color:var(--ds-muted);padding:5px}.deepsearch-caption{display:flex;justify-content:space-between;gap:12px;padding:13px 20px 7px;font-size:11px;color:var(--ds-muted)}.deepsearch-caption label{display:flex;align-items:center;gap:4px;cursor:pointer}.deepsearch-caption input{margin:0;width:12px;height:12px;accent-color:var(--dsw-alias-brand-primary,#3478f6)}.deepsearch-results{overflow-y:auto;overscroll-behavior:contain;max-height:min(440px,50vh);padding:0 8px 8px;scroll-padding:8px;min-height:80px}.deepsearch-result{display:flex;width:100%;gap:12px;align-items:flex-start;border:0;border-radius:8px;background:transparent;padding:12px;text-align:left}.deepsearch-result[aria-selected=true]{background:var(--ds-hover)}.deepsearch-result-icon{color:var(--ds-muted);padding-top:2px;flex:none}.deepsearch-result-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:5px}.deepsearch-result-title{font-size:13px;line-height:20px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.deepsearch-snippet{font-size:12px;line-height:1.7;color:var(--ds-muted);white-space:pre-wrap;overflow-wrap:anywhere;display:block}.deepsearch-snippet mark{background:#ffe293;color:#382a09;border-radius:2px;padding:0 1px}.deepsearch-meta{font-size:10px;line-height:17px;color:var(--ds-muted);opacity:.85}.deepsearch-return{font-size:14px;align-self:center;color:var(--ds-muted);opacity:0}.deepsearch-result[aria-selected=true] .deepsearch-return{opacity:1}.deepsearch-footer{display:flex;justify-content:space-between;align-items:center;gap:8px;border-top:1px solid var(--ds-line);padding:12px 20px;color:var(--ds-muted);font-size:10px}.deepsearch-footer strong{font-weight:600;color:var(--ds-text)}.deepsearch-empty{display:flex;align-items:center;flex-direction:column;gap:12px;padding:37px 18px 32px;color:var(--ds-muted)}.deepsearch-empty>svg{width:27px;height:27px;opacity:.5}.deepsearch-empty strong{font-size:13px;font-weight:500;color:var(--ds-text)}.deepsearch-empty p{font-size:11px;margin:0;text-align:center}.deepsearch-error,.deepsearch-warning{padding:8px 20px;font-size:11px;color:var(--ds-text);background:var(--ds-hover)}.deepsearch-error button{margin-left:8px;border:0;background:none;text-decoration:underline}.deepsearch-more{background:transparent;border:0;border-top:1px solid var(--ds-line);padding:10px;font-size:11px;color:var(--ds-muted)}.deepsearch-jump{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;position:relative}.deepsearch-jump-bar{display:flex;align-items:center;gap:12px;padding:9px 18px;flex-shrink:0;border-bottom:1px solid var(--dsw-alias-border-l1,#ddd);font-size:11px;color:var(--dsw-alias-label-secondary,#667);background:var(--dsw-alias-bg-base,#fff)}.deepsearch-jump-bar>span{flex:1}.deepsearch-jump button,.deepsearch-jump-loading button{border:1px solid var(--dsw-alias-border-l1,#ddd);border-radius:5px;background:var(--dsw-alias-bg-base,#fff);font:inherit;color:inherit;padding:3px 7px;cursor:pointer}.deepsearch-jump-loading{padding:24px;font:inherit;color:var(--dsw-alias-label-primary,#18212f)}.deepsearch-jump *::highlight(deepsearch-hit){background:#ffe293;color:#382a09}\n@media(max-width:520px){.deepsearch-panel{top:18px;width:calc(100vw - 20px);border-radius:12px}.deepsearch-search{padding:14px;gap:10px}.deepsearch-search>input{font-size:16px}.deepsearch-toolbar{padding:0 10px 10px}.deepsearch-toolbar select{max-width:130px}.deepsearch-caption{padding-left:14px;padding-right:14px}.deepsearch-footer{padding:11px 14px}.deepsearch-key-hint{display:none}.deepsearch-jump-bar{flex-wrap:wrap}}\n";
|
|
424
|
+
const css = "\n.deepsearch-panel{--ds-bg:var(--we-panel-color,var(--dsw-alias-bg-base,#fff));--ds-line:var(--dsw-alias-border-l1,#e5e7eb);--ds-text:var(--dsw-alias-label-primary,#18212f);--ds-muted:var(--dsw-alias-label-secondary,#657080);--ds-hover:var(--dsw-alias-bg-layer-2,#f3f5f7);position:fixed;pointer-events:auto;z-index:10000;top:clamp(26px,12vh,128px);left:50%;transform:translateX(-50%);width:min(700px,calc(100vw - 32px));max-height:calc(100vh - clamp(26px,12vh,128px) - 24px);display:flex;flex-direction:column;color:var(--ds-text);background:var(--ds-bg);background:var(--ds-effective-surface,var(--ds-surface,var(--ds-bg)));backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none));-webkit-backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none));border:1px solid var(--ds-line);border-radius:16px;box-shadow:0 16px 60px #0002,0 2px 8px #0001;font-family:inherit;overflow:hidden;text-align:left;isolation:isolate}\n.deepsearch-panel *{box-sizing:border-box}.deepsearch-panel button,.deepsearch-panel input,.deepsearch-panel select,.deepsearch-jump button{font:inherit;color:inherit}.deepsearch-panel button{cursor:pointer}.deepsearch-panel button:disabled{cursor:default;opacity:.6}.deepsearch-panel button:focus-visible,.deepsearch-panel select:focus-visible,.deepsearch-jump button:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#3478f6);outline-offset:-2px}.deepsearch-search{display:flex;align-items:center;gap:14px;padding:19px 20px 17px;color:var(--ds-muted)}.deepsearch-search>input{min-width:0;flex:1;border:0;outline:none;background:transparent;font-size:18px;line-height:28px;color:var(--ds-text)}.deepsearch-search>input::placeholder{color:var(--ds-muted);opacity:.8}.deepsearch-escape{box-sizing:border-box;display:inline-flex;align-items:center;justify-content:center;flex-shrink:0;height:22px;line-height:16px!important;border:1px solid var(--ds-line);border-radius:5px;padding:2px 6px;background:none;font-size:11px!important;color:var(--ds-muted)!important}.deepsearch-toolbar{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:0 16px 11px;border-bottom:1px solid var(--ds-line)}.deepsearch-tabs{display:flex;gap:4px}.deepsearch-tabs button{border:0;border-radius:6px;background:none;font-size:12px;padding:6px 12px;color:var(--ds-muted)}.deepsearch-tabs button[aria-selected=true]{background:var(--ds-hover);color:var(--ds-text);font-weight:600}.deepsearch-toolbar select{max-width:190px;min-width:0;border:0;outline:none;background:var(--ds-bg);font-size:11px;color:var(--ds-muted);padding:5px}.deepsearch-caption{display:flex;justify-content:space-between;gap:12px;padding:13px 20px 7px;font-size:11px;color:var(--ds-muted)}.deepsearch-caption label{display:flex;align-items:center;gap:4px;cursor:pointer}.deepsearch-caption input{margin:0;width:12px;height:12px;accent-color:var(--dsw-alias-brand-primary,#3478f6)}.deepsearch-results{overflow-y:auto;overscroll-behavior:contain;max-height:min(440px,50vh);padding:0 8px 8px;scroll-padding:8px;min-height:80px}.deepsearch-result{display:flex;width:100%;gap:12px;align-items:flex-start;border:0;border-radius:8px;background:transparent;padding:12px;text-align:left}.deepsearch-result[aria-selected=true]{background:var(--ds-hover)}.deepsearch-result-icon{color:var(--ds-muted);padding-top:2px;flex:none}.deepsearch-result-text{flex:1;min-width:0;display:flex;flex-direction:column;gap:5px}.deepsearch-result-title{font-size:13px;line-height:20px;font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.deepsearch-snippet{font-size:12px;line-height:1.7;color:var(--ds-muted);white-space:pre-wrap;overflow-wrap:anywhere;display:block}.deepsearch-snippet mark{background:#ffe293;color:#382a09;border-radius:2px;padding:0 1px}.deepsearch-meta{font-size:10px;line-height:17px;color:var(--ds-muted);opacity:.85}.deepsearch-return{font-size:14px;align-self:center;color:var(--ds-muted);opacity:0}.deepsearch-result[aria-selected=true] .deepsearch-return{opacity:1}.deepsearch-footer{display:flex;justify-content:space-between;align-items:center;gap:8px;border-top:1px solid var(--ds-line);padding:12px 20px;color:var(--ds-muted);font-size:10px}.deepsearch-footer strong{font-weight:600;color:var(--ds-text)}.deepsearch-empty{display:flex;align-items:center;flex-direction:column;gap:12px;padding:37px 18px 32px;color:var(--ds-muted)}.deepsearch-empty>svg{width:27px;height:27px;opacity:.5}.deepsearch-empty strong{font-size:13px;font-weight:500;color:var(--ds-text)}.deepsearch-empty p{font-size:11px;margin:0;text-align:center}.deepsearch-error,.deepsearch-warning{padding:8px 20px;font-size:11px;color:var(--ds-text);background:var(--ds-hover)}.deepsearch-error button{margin-left:8px;border:0;background:none;text-decoration:underline}.deepsearch-more{background:transparent;border:0;border-top:1px solid var(--ds-line);padding:10px;font-size:11px;color:var(--ds-muted)}.deepsearch-jump{display:flex;flex-direction:column;flex:1;min-height:0;height:100%;position:relative}.deepsearch-jump-bar{display:flex;align-items:center;gap:12px;padding:9px 18px;flex-shrink:0;border-bottom:1px solid var(--dsw-alias-border-l1,#ddd);font-size:11px;color:var(--dsw-alias-label-secondary,#667);background:var(--dsw-alias-bg-base,#fff)}.deepsearch-jump-bar>span{flex:1}.deepsearch-jump button,.deepsearch-jump-loading button{border:1px solid var(--dsw-alias-border-l1,#ddd);border-radius:5px;background:var(--dsw-alias-bg-base,#fff);font:inherit;color:inherit;padding:3px 7px;cursor:pointer}.deepsearch-jump-loading{padding:24px;font:inherit;color:var(--dsw-alias-label-primary,#18212f)}.deepsearch-jump *::highlight(deepsearch-hit){background:#ffe293;color:#382a09}\n@media(max-width:520px){.deepsearch-panel{top:18px;width:calc(100vw - 20px);border-radius:12px}.deepsearch-search{padding:14px;gap:10px}.deepsearch-search>input{font-size:16px}.deepsearch-toolbar{padding:0 10px 10px}.deepsearch-toolbar select{max-width:130px}.deepsearch-caption{padding-left:14px;padding-right:14px}.deepsearch-footer{padding:11px 14px}.deepsearch-key-hint{display:none}.deepsearch-jump-bar{flex-wrap:wrap}}\n";
|
|
215
425
|
const archiveCss = '.deepsearch-archived{display:inline-block;margin-left:8px;padding:1px 5px;border:1px solid var(--ds-line);border-radius:4px;font-size:11px;font-weight:400;color:var(--ds-muted);vertical-align:middle}.deepsearch-confirm{padding:14px 20px;border-top:1px solid var(--ds-line);font-size:13px}.deepsearch-confirm p{margin:6px 0 10px;color:var(--ds-muted)}.deepsearch-confirm button{padding:6px 10px;margin-right:8px;border:1px solid var(--ds-line);border-radius:6px;background:var(--ds-hover)}';
|
|
216
|
-
const appearanceCss = '.deepsearch-appearance{display:flex;flex-wrap:wrap;gap:12px;padding:12px 20px 16px;border-top:1px solid var(--ds-line);font-size:12px}.deepsearch-appearance label{display:flex;align-items:center;gap:8px}.deepsearch-appearance select,.deepsearch-appearance button{background:var(--ds-hover);border:1px solid var(--ds-line);border-radius:6px;padding:5px}.deepsearch-appearance input[type=range]{width:100px;accent-color:var(--dsw-alias-brand-primary,#3478f6)}.deepsearch-appearance input[type=color]{width:30px;height:24px;padding:0;border:0;background:none}.deepsearch-appearance p{width:100%;margin:0;color:var(--ds-muted)}/* Wallpaper Engine intentionally solidifies ordinary ARIA dialogs. Only this owned panel opts back into its selected material; never forge its runtime markers or change global settings. */body[data-we-glass-page][data-we-floater-solid] .deepsearch-panel[role=dialog][data-appearance]{background-color:var(--ds-effective-surface,var(--ds-surface,var(--ds-bg)))!important;backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none))!important;-webkit-backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none))!important}@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.deepsearch-panel{--ds-effective-surface:var(--ds-bg);--ds-effective-filter:none}}@media(prefers-reduced-transparency:reduce){.deepsearch-panel{--ds-effective-surface:var(--ds-bg);--ds-effective-filter:none}}';
|
|
426
|
+
const appearanceCss = '.deepsearch-appearance{display:flex;flex-wrap:wrap;gap:12px;padding:12px 20px 16px;border-top:1px solid var(--ds-line);font-size:12px}.deepsearch-appearance-controls{display:flex;align-items:center;gap:12px;width:100%;min-width:0;overflow-x:auto}.deepsearch-appearance-controls>*{flex-shrink:0}.deepsearch-appearance label{display:flex;align-items:center;gap:8px;white-space:nowrap}.deepsearch-appearance .deepsearch-reset{display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;padding:4px}.deepsearch-shortcut-help{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.deepsearch-extension>div{min-width:0}.deepsearch-sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}.deepsearch-appearance select,.deepsearch-appearance button{background:var(--ds-hover);border:1px solid var(--ds-line);border-radius:6px;padding:5px}.deepsearch-appearance input[type=range]{width:100px;accent-color:var(--dsw-alias-brand-primary,#3478f6)}.deepsearch-appearance input[type=color]{width:30px;height:24px;padding:0;border:0;background:none}.deepsearch-appearance p{width:100%;margin:0;color:var(--ds-muted)}/* Wallpaper Engine intentionally solidifies ordinary ARIA dialogs. Only this owned panel opts back into its selected material; never forge its runtime markers or change global settings. */body[data-we-glass-page][data-we-floater-solid] .deepsearch-panel[role=dialog][data-appearance]{background-color:var(--ds-effective-surface,var(--ds-surface,var(--ds-bg)))!important;backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none))!important;-webkit-backdrop-filter:var(--ds-effective-filter,var(--ds-filter,none))!important}@supports not ((backdrop-filter:blur(1px)) or (-webkit-backdrop-filter:blur(1px))){.deepsearch-panel{--ds-effective-surface:var(--ds-bg);--ds-effective-filter:none}}@media(prefers-reduced-transparency:reduce){.deepsearch-panel{--ds-effective-surface:var(--ds-bg);--ds-effective-filter:none}}';
|
|
427
|
+
const historyCss = '.deepsearch-caption{flex-wrap:wrap;gap:10px}.deepsearch-caption-options{display:flex;align-items:center;gap:14px;margin-left:auto}.deepsearch-empty-tabs{display:flex;gap:12px}.deepsearch-empty-tabs button{font:inherit;padding:0 0 4px;color:var(--ds-muted);border:0;border-bottom:2px solid transparent;border-radius:0;background:none}.deepsearch-empty-tabs button[aria-selected=true]{color:var(--ds-text);border-bottom-color:currentColor}.deepsearch-history-tools{display:flex;justify-content:flex-end;padding:0 20px 6px}.deepsearch-history-tools button,.deepsearch-history-delete{background:none;border:0;color:var(--ds-muted);font:inherit;cursor:pointer}.deepsearch-history-row{padding:0;gap:0}.deepsearch-history-main{min-width:0;flex:1}.deepsearch-history-replay{width:100%;display:flex;align-items:center;gap:14px;min-width:0;flex:1;text-align:left;padding:14px 16px;background:none;border:0;color:inherit;font:inherit;cursor:pointer}.deepsearch-history-delete{flex-shrink:0;padding:12px;font-size:20px}.deepsearch-history-delete:hover{color:var(--ds-text)}.deepsearch-history-replay:focus-visible,.deepsearch-history-delete:focus-visible{outline:2px solid var(--ds-text);outline-offset:-3px;border-radius:6px}';
|
|
217
428
|
const extensionCss = '.deepsearch-extension{width:100%;display:flex;align-items:center;justify-content:space-between;gap:20px;padding-top:14px;border-top:1px solid var(--ds-line)}.deepsearch-extension strong{font-weight:600;font-size:13px}.deepsearch-extension p{margin:5px 0 0;line-height:1.6}.deepsearch-panel .deepsearch-switch{flex-shrink:0;width:38px;height:22px;padding:2px;border:1px solid var(--ds-line);border-radius:20px;background:var(--ds-hover)}.deepsearch-panel .deepsearch-switch[aria-checked=true]{background:#3478f6;border-color:transparent}.deepsearch-switch span{display:block;width:16px;height:16px;border-radius:50%;background:var(--ds-muted)}.deepsearch-switch[aria-checked=true] span{transform:translateX(16px);background:#fff}';
|
|
218
429
|
return {
|
|
219
|
-
inject: ['slots', 'layout', 'uiWorkspace', 'uiSession', 'sessions', 'workspaces', 'contextMenus'],
|
|
430
|
+
inject: ['slots', 'layout', 'uiWorkspace', 'uiSession', 'sessions', 'workspaces', 'contextMenus', 'shortcuts'],
|
|
220
431
|
apply(ctx) {
|
|
221
432
|
let storage; try {storage = window.localStorage;} catch {}
|
|
433
|
+
const historyStore = createSearchHistory(storage);
|
|
434
|
+
ctx.effect(() => {
|
|
435
|
+
const reload = event => {if (event.key === HISTORY_KEY || event.key === null) historyStore.reload();};
|
|
436
|
+
window.addEventListener('storage', reload);
|
|
437
|
+
return () => window.removeEventListener('storage', reload);
|
|
438
|
+
});
|
|
222
439
|
const unreadStore = createUnreadStore(storage);
|
|
223
440
|
ctx.effect(() => installUnread(ctx, unreadStore));
|
|
224
441
|
function ManualUnreadDot({sessionId, useManualUnread}) {
|
|
@@ -231,17 +448,20 @@ window.__ModuleLoader__.load({
|
|
|
231
448
|
name: 'sidebar.session.row.leading', id: 'deepsearch-manual-unread', order: 50,
|
|
232
449
|
inject: () => ({hooks: {manualUnread: unreadStore}}),
|
|
233
450
|
}, ManualUnreadDot));
|
|
234
|
-
|
|
451
|
+
const shortcutStore = createShortcutTakeover(ctx.shortcuts, storage, () => setOpen(!opened));
|
|
452
|
+
ctx.effect(() => () => shortcutStore.dispose());
|
|
453
|
+
let opened = false, intent = null, releaseShell, cancelProjectReveal, previousFocus, preferredSessionId, selectionEpoch = 0, disposed = false;
|
|
235
454
|
const listeners = new Set(), recoveries = new Map();
|
|
236
455
|
const notify = () => { for (const listener of listeners) listener(); };
|
|
237
456
|
const subscribe = listener => { listeners.add(listener); return () => listeners.delete(listener); };
|
|
238
457
|
const setOpen = value => {
|
|
239
|
-
if (value && !opened) {previousFocus = document.activeElement; preferredSessionId = currentSessionId(ctx.uiSession.adapter.current.getSnapshot(), ctx.sessions.list.getSnapshot());}
|
|
458
|
+
if (value && !opened) {cancelProjectReveal?.(); previousFocus = document.activeElement; preferredSessionId = currentSessionId(ctx.uiSession.adapter.current.getSnapshot(), ctx.sessions.list.getSnapshot());}
|
|
240
459
|
if (!value) selectionEpoch++;
|
|
241
460
|
opened = value; notify();
|
|
242
461
|
if (!value && previousFocus?.isConnected) previousFocus.focus?.({preventScroll: true});
|
|
243
462
|
};
|
|
244
463
|
function clearIntent() {
|
|
464
|
+
cancelProjectReveal?.(); cancelProjectReveal = undefined;
|
|
245
465
|
const current = intent; intent = null;
|
|
246
466
|
const release = releaseShell; releaseShell = undefined;
|
|
247
467
|
current?.cancelDOM?.(); release?.(); window.CSS?.highlights?.delete('deepsearch-hit'); notify();
|
|
@@ -383,9 +603,13 @@ window.__ModuleLoader__.load({
|
|
|
383
603
|
}
|
|
384
604
|
function Overlay() {
|
|
385
605
|
const visible = React.useSyncExternalStore(subscribe, () => opened);
|
|
606
|
+
const history = React.useSyncExternalStore(historyStore.subscribe, historyStore.getSnapshot);
|
|
607
|
+
const [emptyView, setEmptyView] = React.useState(() => history.defaultHistory ? 'history' : 'recent');
|
|
386
608
|
const unread = React.useSyncExternalStore(unreadStore.subscribe, unreadStore.getSnapshot);
|
|
609
|
+
const shortcut = React.useSyncExternalStore(shortcutStore.subscribe, shortcutStore.getSnapshot);
|
|
610
|
+
const liveSessions = React.useSyncExternalStore(ctx.sessions.list.subscribe, ctx.sessions.list.getSnapshot);
|
|
387
611
|
const [query, setQuery] = React.useState(''), [tab, setTab] = React.useState('all');
|
|
388
|
-
const [workspace, setWorkspace] = React.useState(''), [archived, setArchived] = React.useState(
|
|
612
|
+
const [workspace, setWorkspace] = React.useState(''), [archived, setArchived] = React.useState(true);
|
|
389
613
|
const [catalog, setCatalog] = React.useState({sessions: [], workspaces: []}), [catalogError, setCatalogError] = React.useState('');
|
|
390
614
|
const [result, setResult] = React.useState({items: [], cursor: null, scanned: 0, totalSessions: 0, warnings: []});
|
|
391
615
|
const [busy, setBusy] = React.useState(false), [error, setError] = React.useState(''), [index, setIndex] = React.useState(0), [retry, setRetry] = React.useState(0);
|
|
@@ -401,7 +625,16 @@ window.__ModuleLoader__.load({
|
|
|
401
625
|
let saved = false; try {saved = saveAppearance(window.localStorage, next);} catch {}
|
|
402
626
|
setAppearanceError(saved ? '' : '本次外观已应用,但浏览器禁止保存;重新打开后可能恢复默认。');
|
|
403
627
|
};
|
|
404
|
-
React.useEffect(() => {
|
|
628
|
+
React.useEffect(() => {
|
|
629
|
+
if (!visible) {setComposing(false); return;}
|
|
630
|
+
setEmptyView(history.defaultHistory ? 'history' : 'recent');
|
|
631
|
+
setQuery(''); setTab('all');
|
|
632
|
+
}, [visible]);
|
|
633
|
+
React.useEffect(() => {
|
|
634
|
+
if (!visible || composing || !query.trim() || query.trim().length > 256) return;
|
|
635
|
+
const timer = setTimeout(() => historyStore.add(query), 1000);
|
|
636
|
+
return () => clearTimeout(timer);
|
|
637
|
+
}, [query, visible, composing]);
|
|
405
638
|
const request = {query: query.trim(), ...(workspace ? {workspaceId: workspace} : {}), ...(preferredSessionId ? {preferredSessionId} : {}), includeArchived: archived};
|
|
406
639
|
requestRef.current = request;
|
|
407
640
|
const key = JSON.stringify(request);
|
|
@@ -413,7 +646,7 @@ window.__ModuleLoader__.load({
|
|
|
413
646
|
input.current?.focus();
|
|
414
647
|
const controller = new AbortController();
|
|
415
648
|
setCatalogError('');
|
|
416
|
-
api('catalog', null, controller.signal).then(setCatalog).catch(failure => {if (!controller.signal.aborted) setCatalogError(failure.message);});
|
|
649
|
+
api('catalog?includeArchived=true', null, controller.signal).then(setCatalog).catch(failure => {if (!controller.signal.aborted) setCatalogError(failure.message);});
|
|
417
650
|
const outside = event => {if (panel.current && !panel.current.contains(event.target)) {event.preventDefault(); event.stopPropagation(); setOpen(false);}};
|
|
418
651
|
document.addEventListener('pointerdown', outside, true);
|
|
419
652
|
return () => {controller.abort(); document.removeEventListener('pointerdown', outside, true);};
|
|
@@ -438,16 +671,27 @@ window.__ModuleLoader__.load({
|
|
|
438
671
|
}, [key, visible, tab, composing, retry]);
|
|
439
672
|
const projects = (catalog.workspaces || []).filter(project => (!workspace || project.id === workspace) &&
|
|
440
673
|
(!request.query || (project.title || '').toLocaleLowerCase().includes(request.query.toLocaleLowerCase()))).map(project => ({...project, kind: 'project'}));
|
|
441
|
-
const recent = (catalog.sessions || []).filter(session => !workspace || session.workspaceId === workspace).slice(0, 7).map(session => ({...session, kind: 'title', sessionId: session.id}));
|
|
674
|
+
const recent = (catalog.sessions || []).filter(session => (!workspace || session.workspaceId === workspace) && (archived || !session.archived)).slice(0, 7).map(session => ({...session, kind: 'title', recent: true, updatedAt: liveSessions.byId?.[session.id]?.updatedAt ?? session.updatedAt, sessionId: session.id, workspaceTitle: (catalog.workspaces || []).find(project => project.id === session.workspaceId)?.title || '未分配项目'}));
|
|
442
675
|
const visibleHits = result.renderOwner === renderKey ? result.items : [];
|
|
443
|
-
const
|
|
676
|
+
const showingHistory = !request.query && tab !== 'projects' && emptyView === 'history';
|
|
677
|
+
const items = showingHistory ? history.entries.map(entry => ({...entry, id: entry.query, kind: 'history', title: entry.query})) : tab === 'projects' ? projects : request.query ? (tab === 'all' ? projects.slice(0, 3).concat(visibleHits) : visibleHits) : recent;
|
|
444
678
|
React.useEffect(() => {setIndex(old => Math.min(old, Math.max(0, items.length - 1)));}, [items.length]);
|
|
445
679
|
function choose(item) {
|
|
446
680
|
if (!item || !opened || disposed || activeRender.current !== renderKey) return;
|
|
447
681
|
if (selection.current?.pending) return;
|
|
448
682
|
cancelSelection();
|
|
449
|
-
if (item.kind === 'project') {setWorkspace(item.id); setTab('conversations'); setQuery(''); input.current?.focus(); return;}
|
|
450
683
|
try {
|
|
684
|
+
if (item.kind === 'history') {
|
|
685
|
+
setQuery(item.query); setTab('all'); setIndex(0); input.current?.focus(); return;
|
|
686
|
+
}
|
|
687
|
+
if (item.kind === 'project') {
|
|
688
|
+
if (typeof ctx.uiWorkspace.startSession !== 'function') throw new Error('当前宿主不支持在项目中新建会话,请升级后重试');
|
|
689
|
+
clearIntent();
|
|
690
|
+
// Native New Session preserves an existing blank's draft; never pass the search as a prompt.
|
|
691
|
+
// startSession owns asynchronous reveal; selectPanel here aborts its pending navigation.
|
|
692
|
+
cancelProjectReveal = revealProject(ctx, item.id, () => ctx.uiWorkspace.startSession(item.id));
|
|
693
|
+
setOpen(false); return;
|
|
694
|
+
}
|
|
451
695
|
const isArchived = archiveState(item.sessionId);
|
|
452
696
|
if (!isArchived && recoveries.has(item.sessionId)) throw new Error('恢复请求仍在进行,请等待完成后重试');
|
|
453
697
|
if (isArchived) {
|
|
@@ -518,37 +762,53 @@ window.__ModuleLoader__.load({
|
|
|
518
762
|
}
|
|
519
763
|
}
|
|
520
764
|
return h('section', {className: 'deepsearch-panel', style: appearanceStyle(appearance), 'data-appearance': appearance.mode, role: 'dialog', 'aria-label': 'DeepSearch 全文搜索', 'aria-modal': false, ref: panel, onKeyDown: onKey},
|
|
521
|
-
h('style', null, css + appearanceCss + archiveCss + extensionCss),
|
|
765
|
+
h('style', null, css + appearanceCss + archiveCss + extensionCss + historyCss),
|
|
522
766
|
h('header', {className: 'deepsearch-search'}, h(Icon),
|
|
523
|
-
h('input', {ref: input, value: query, maxLength: 256, placeholder: '搜索对话里的任何一句话…', 'aria-label': '搜索会话正文', role: 'combobox', 'aria-expanded': true, 'aria-controls': 'deepsearch-results', 'aria-activedescendant': items[index] ? 'deepsearch-result-' + index : undefined, autoComplete: 'off', spellCheck: false, onChange: event => {cancelSelection(); setQuery(event.target.value);}, onCompositionStart: () => {cancelSelection(); setComposing(true);}, onCompositionEnd: () => setComposing(false)}),
|
|
767
|
+
h('input', {ref: input, value: query, maxLength: 256, placeholder: '搜索对话里的任何一句话…', 'aria-label': '搜索会话正文', role: 'combobox', 'aria-haspopup': showingHistory ? 'grid' : 'listbox', 'aria-expanded': true, 'aria-controls': 'deepsearch-results', 'aria-activedescendant': items[index] ? 'deepsearch-result-' + index : undefined, autoComplete: 'off', spellCheck: false, onChange: event => {cancelSelection(); setQuery(event.target.value);}, onCompositionStart: () => {cancelSelection(); setComposing(true);}, onCompositionEnd: () => setComposing(false)}),
|
|
524
768
|
h('button', {className: 'deepsearch-escape', 'aria-expanded': settings, 'aria-controls': 'deepsearch-appearance', onClick: () => setSettings(value => !value)}, '设置'),
|
|
525
769
|
h('button', {className: 'deepsearch-escape', onClick: () => setOpen(false), 'aria-label': '关闭 DeepSearch'}, 'esc')),
|
|
526
770
|
settings && h('div', {className: 'deepsearch-appearance', id: 'deepsearch-appearance', role: 'group', 'aria-label': 'DeepSearch 设置'},
|
|
527
|
-
h('label', null, '背景模式', h('select', {value: appearance.mode, onChange: e => updateAppearance({...appearance, mode:e.target.value})},
|
|
771
|
+
h('div', {className: 'deepsearch-appearance-controls'}, h('label', null, '背景模式', h('select', {value: appearance.mode, onChange: e => updateAppearance({...appearance, mode:e.target.value})},
|
|
528
772
|
...[['glass','毛玻璃'],['theme','跟随 DSH'],['custom','自定义']].map(([value,label]) => h('option',{key:value,value},label)))),
|
|
529
773
|
appearance.mode === 'custom' && h('label', null, '底色', h('input', {type:'color', value:appearance.color, onChange:e=>updateAppearance({...appearance,color:e.target.value})})),
|
|
530
774
|
appearance.mode === 'custom' && h('label', null, '不透明度 ' + appearance.opacity + '%', h('input', {type:'range', min:55, max:100, value:appearance.opacity, onChange:e=>updateAppearance({...appearance,opacity:Number(e.target.value)})})),
|
|
531
775
|
appearance.mode !== 'theme' && h('label', null, '模糊 ' + appearance.blur + 'px', h('input', {type:'range', min:0, max:32, value:appearance.blur, onChange:e=>updateAppearance({...appearance,blur:Number(e.target.value)})})),
|
|
532
|
-
h('button', {onClick:()=>updateAppearance(null)}, '
|
|
776
|
+
h('button', {type: 'button', className: 'deepsearch-reset', title: '恢复默认', 'aria-label': '恢复默认', onClick:()=>updateAppearance(null)}, h('svg', {width:16, height:16, viewBox:'0 0 24 24', fill:'none', stroke:'currentColor', strokeWidth:1.7, 'aria-hidden':true}, h('path', {d:'M3 10a9 9 0 1 1 2.7 8.4M3 4v6h6'})))),
|
|
533
777
|
appearanceError && h('p', {role:'status'}, appearanceError),
|
|
534
778
|
h('div', {className: 'deepsearch-extension'},
|
|
535
779
|
h('div', null, h('strong', {id: 'deepsearch-unread-label'}, '会话未读标记'), h('p', {id: 'deepsearch-unread-help'}, '扩展小功能 · 右键标记未读,再次打开自动已读。仅存本机;关闭保留标记。')),
|
|
536
780
|
h('button', {type: 'button', role: 'switch', className: 'deepsearch-switch', 'aria-checked': unread.enabled, 'aria-labelledby': 'deepsearch-unread-label', 'aria-describedby': 'deepsearch-unread-help', onClick: () => unreadStore.setEnabled(!unread.enabled)}, h('span', {'aria-hidden': true}))),
|
|
537
|
-
unreadStore.getError() && h('p', {role: 'status'}, unreadStore.getError())
|
|
781
|
+
unreadStore.getError() && h('p', {role: 'status'}, unreadStore.getError()),
|
|
782
|
+
h('div', {className: 'deepsearch-extension'},
|
|
783
|
+
h('div', null, h('strong', {id: 'deepsearch-shortcut-label'}, '使用 ⌘K 打开 DeepSearch'), h('p', {id: 'deepsearch-shortcut-help', className:'deepsearch-shortcut-help', title:'仅 macOS 桌面端;写入 DSH 官方快捷键配置,关闭恢复开启前的绑定。卸载插件前请先关闭接管。'}, '替代原生搜索,关闭恢复原绑定;⌘⇧K 仍可用。'), h('span', {id:'deepsearch-shortcut-details', className:'deepsearch-sr-only'}, '仅 macOS 桌面端;写入 DSH 官方快捷键配置。卸载插件前请先关闭接管。')),
|
|
784
|
+
h('button', {type: 'button', role: 'switch', className: 'deepsearch-switch', disabled: !shortcut.supported || shortcut.busy, 'aria-checked': shortcut.enabled, 'aria-labelledby': 'deepsearch-shortcut-label', 'aria-describedby': 'deepsearch-shortcut-help deepsearch-shortcut-details', onClick: () => shortcutStore.setEnabled(!shortcut.enabled)}, h('span', {'aria-hidden': true}))),
|
|
785
|
+
shortcut.busy && h('p', {role: 'status'}, '正在保存快捷键配置…'),
|
|
786
|
+
!shortcut.supported && h('p', {role: 'status'}, '当前宿主不支持 macOS 桌面快捷键配置,仍可使用 ⌘⇧K / Ctrl⇧K。'),
|
|
787
|
+
shortcut.error && h('p', {role: 'alert'}, shortcut.error),
|
|
788
|
+
shortcut.recovery && !shortcut.enabled && h('button', {disabled: shortcut.busy, onClick: () => shortcutStore.setEnabled(false)}, '恢复原快捷键绑定')),
|
|
538
789
|
h('div', {className: 'deepsearch-toolbar'}, h('div', {className: 'deepsearch-tabs', role: 'tablist', 'aria-label': '结果类型'},
|
|
539
790
|
...[['all', '全部'], ['conversations', '对话'], ['projects', '项目']].map(([value, label]) => h('button', {key: value, role: 'tab', 'aria-selected': tab === value, onClick: () => {cancelSelection(); setTab(value);}}, label))),
|
|
540
791
|
h('select', {'aria-label': '工作区范围', value: workspace, onChange: event => {cancelSelection(); setWorkspace(event.target.value);}}, h('option', {value: ''}, '所有工作区'), ...(catalog.workspaces || []).map(project => h('option', {key: project.id, value: project.id}, project.title)))),
|
|
541
|
-
h('div', {className: 'deepsearch-caption'},
|
|
542
|
-
tab !== 'projects'
|
|
543
|
-
|
|
544
|
-
|
|
792
|
+
h('div', {className: 'deepsearch-caption'},
|
|
793
|
+
!request.query && tab !== 'projects' ? h('div', {className:'deepsearch-tabs deepsearch-empty-tabs', role:'tablist', 'aria-label':'起始列表'},
|
|
794
|
+
...(history.defaultHistory ? [['history','搜索历史'],['recent','最近对话']] : [['recent','最近对话'],['history','搜索历史']]).map(([value,label]) => h('button', {key:value, type:'button', role:'tab', 'aria-selected':emptyView === value, onClick:() => {cancelSelection(); setEmptyView(value); setIndex(0);}}, label))) : h('span', null, tab === 'projects' ? '匹配项目' : '标题 · 你的输入 · 助手回复'),
|
|
795
|
+
h('div', {className:'deepsearch-caption-options'},
|
|
796
|
+
h('label', null, h('input', {type:'checkbox', checked:history.defaultHistory, onChange:event => historyStore.setDefault(event.target.checked)}), '默认历史'),
|
|
797
|
+
tab !== 'projects' && h('label', null, h('input', {type: 'checkbox', checked: archived, onChange: event => {cancelSelection(); setArchived(event.target.checked);}}), '含归档'))),
|
|
798
|
+
showingHistory && history.entries.length > 0 && h('div', {className:'deepsearch-history-tools'}, h('button', {type:'button', onClick:() => {historyStore.clear(); setIndex(0); input.current?.focus();}}, '清空搜索历史')),
|
|
799
|
+
history.error && h('div', {className:'deepsearch-warning', role:'status'}, history.error),
|
|
800
|
+
h('div', {className: 'deepsearch-results', ref: list, role: showingHistory ? 'grid' : 'listbox', id: 'deepsearch-results', 'aria-label': '搜索结果', 'aria-busy': busy},
|
|
801
|
+
...items.map((item, i) => item.kind === 'history' ? h('div', {key:item.id, id:'deepsearch-result-' + i, className:'deepsearch-result deepsearch-history-row', role:'row', 'aria-selected':index === i, onMouseEnter:() => setIndex(i)},
|
|
802
|
+
h('div', {role:'gridcell', className:'deepsearch-history-main'}, h('button', {type:'button', className:'deepsearch-history-replay', onClick:() => choose(item), 'aria-label':'重新搜索:' + item.query}, h('span', {className:'deepsearch-result-icon'}, h(Icon)),
|
|
803
|
+
h('span', {className:'deepsearch-result-text'}, h('span', {className:'deepsearch-result-title'}, item.query), h('span', {className:'deepsearch-meta'}, formatMessageTime(item.time))), h('span', {className:'deepsearch-return', 'aria-hidden':true}, '↵'))),
|
|
804
|
+
h('div', {role:'gridcell'}, h('button', {type:'button', className:'deepsearch-history-delete', title:'删除此条搜索历史', 'aria-label':'删除搜索历史:' + item.query, onClick:() => {historyStore.remove(item.query); input.current?.focus();}}, '×'))) : h('button', {key: item.id, id: 'deepsearch-result-' + i, className: 'deepsearch-result', tabIndex: -1, role: 'option', 'aria-selected': index === i, onMouseEnter: () => setIndex(i), onClick: () => choose(item)},
|
|
545
805
|
h('span', {className: 'deepsearch-result-icon'}, h(Icon, {folder: item.kind === 'project'})),
|
|
546
806
|
h('span', {className: 'deepsearch-result-text'}, h('span', {className: 'deepsearch-result-title'}, item.title || '未命名会话', item.archived === true && h('span', {className: 'deepsearch-archived'}, '已归档')),
|
|
547
807
|
item.snippet && h('span', {className: 'deepsearch-snippet'}, h(Mark, {text: item.snippet, range: item.range})),
|
|
548
|
-
h('span', {className: 'deepsearch-meta'}, item.kind === 'project' ? '工作区 ·
|
|
549
|
-
[item.role === 'user' ? '你' : item.role === 'assistant' ? '助手' : '会话标题', item.workspaceTitle, formatMessageTime(item.time)].filter(Boolean).join(' · '))), h('span', {className: 'deepsearch-return', 'aria-hidden': true}, '↵'))),
|
|
550
|
-
!items.length && h('div', {className: 'deepsearch-empty', role: 'status'}, h(Icon), h('strong', null, status.empty),
|
|
551
|
-
h('p', null, busy ? '逐批读取本地历史,不上传你的对话。' : request.query ? '支持连续中文片段,不需要输入整句话。' : '中文片段、英文关键词,都可以。'))),
|
|
808
|
+
h('span', {className: 'deepsearch-meta'}, item.kind === 'project' ? '工作区 · 点击或回车新建会话' :
|
|
809
|
+
item.recent ? [item.workspaceTitle, (typeof item.updatedAt === 'number' && item.updatedAt > 0 ? formatMessageTime(item.updatedAt) : null) || '时间未知'].join(' · ') : [item.role === 'user' ? '你' : item.role === 'assistant' ? '助手' : '会话标题', item.workspaceTitle, formatMessageTime(item.time)].filter(Boolean).join(' · '))), h('span', {className: 'deepsearch-return', 'aria-hidden': true}, '↵'))),
|
|
810
|
+
!items.length && h('div', {className: 'deepsearch-empty', role: 'status'}, h(Icon), h('strong', null, showingHistory ? '暂无搜索历史' : status.empty),
|
|
811
|
+
h('p', null, showingHistory ? '搜索关键词停顿 1 秒后自动记录,仅保存在本机。' : busy ? '逐批读取本地历史,不上传你的对话。' : request.query ? '支持连续中文片段,不需要输入整句话。' : '中文片段、英文关键词,都可以。'))),
|
|
552
812
|
confirmation && h('div', {className: 'deepsearch-confirm', role: 'group', 'aria-label': '恢复归档会话', 'aria-busy': !!confirmation.pending},
|
|
553
813
|
h('strong', null, '此会话已归档'),
|
|
554
814
|
h('p', null, '恢复“' + (confirmation.item.title || '未命名会话') + '”后将在原生会话中打开;取消会保留当前结果。'),
|
|
@@ -558,8 +818,8 @@ window.__ModuleLoader__.load({
|
|
|
558
818
|
(error || catalogError) && h('div', {className: 'deepsearch-error', role: 'alert'}, error || '目录读取失败:' + catalogError, h('button', {onClick: () => error && displayResult.cursor ? more() : setRetry(value => value + 1)}, '重试')),
|
|
559
819
|
displayResult.warnings?.length > 0 && h('div', {className: 'deepsearch-warning', role: 'status'}, '部分历史读取失败(' + displayResult.warnings.length + ');当前结果可能不完整。'),
|
|
560
820
|
tab !== 'projects' && displayResult.cursor && h('button', {className: 'deepsearch-more', onClick: more, disabled: busy || result.items.length >= MAX_RESULTS}, result.items.length >= MAX_RESULTS ? '已显示 200 条,请缩小搜索范围' : busy ? '正在继续扫描…' : '继续搜索剩余历史'),
|
|
561
|
-
h('footer', {className: 'deepsearch-footer'}, h('span', null, h('strong', null, 'DeepSearch'), ' 0.1.
|
|
562
|
-
h('span', {role: 'status'}, status.footer),
|
|
821
|
+
h('footer', {className: 'deepsearch-footer'}, h('span', null, h('strong', null, 'DeepSearch'), ' 0.1.17 / 本地全文'),
|
|
822
|
+
h('span', {role: 'status'}, shortcut.enabled && status.footer === '⌘⇧K / Ctrl⇧K' ? '⌘K · ⌘⇧K / Ctrl⇧K' : status.footer),
|
|
563
823
|
h('span', {className: 'deepsearch-key-hint'}, '↑↓ 选择 ↵ 打开')));
|
|
564
824
|
}
|
|
565
825
|
ctx.effect(() => {
|
package/host.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {createSearchService, SearchError} from './search-core.js?deepsearch=0.1.
|
|
1
|
+
import {createSearchService, SearchError} from './search-core.js?deepsearch=0.1.17';
|
|
2
2
|
|
|
3
3
|
export const inject = ['sessionQuery', 'sessionController', 'workspaceController', 'connection'];
|
|
4
4
|
export const MAX_BODY_BYTES = 16 * 1024;
|
|
@@ -56,7 +56,7 @@ export function apply(ctx) {
|
|
|
56
56
|
ctx.connection.fetch.register({path: '/api/deepsearch/search', methods: ['POST'], requestBody: 'buffered',
|
|
57
57
|
fetch: handler('POST', async request => service.search(await readJson(request), request.signal))});
|
|
58
58
|
ctx.connection.fetch.register({path: '/api/deepsearch/catalog', methods: ['GET'], requestBody: 'buffered',
|
|
59
|
-
fetch: handler('GET', request => service.catalog(request.signal))});
|
|
59
|
+
fetch: handler('GET', request => service.catalog(request.signal, new URL(request.url).searchParams.get('includeArchived') === 'true'))});
|
|
60
60
|
// Abort in-flight operations and discard cursor metadata on plugin unload.
|
|
61
61
|
ctx.effect(() => () => service.dispose());
|
|
62
62
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@renyuluo/dsh-deepsearch",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.17",
|
|
4
4
|
"description": "Local-first conversation full-text search for DeepSeek Harness, with Chinese substring matching and native message navigation.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {"access": "public", "registry": "https://registry.npmjs.org/"},
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"dsh": "0.2.2-rc.3"
|
|
32
32
|
},
|
|
33
33
|
"exports": {
|
|
34
|
-
".": "./runtime-0.1.
|
|
34
|
+
".": "./runtime-0.1.17.js",
|
|
35
35
|
"./client": "./client.js",
|
|
36
36
|
"./package.json": "./package.json",
|
|
37
37
|
"./locale/en.json": "./locale/en.json",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"icon": "./icon.svg",
|
|
42
42
|
"files": [
|
|
43
|
-
"runtime-0.1.
|
|
43
|
+
"runtime-0.1.17.js",
|
|
44
44
|
"host.js",
|
|
45
45
|
"search-core.js",
|
|
46
46
|
"client.js",
|
|
@@ -68,6 +68,6 @@
|
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"test": "node --test tests/*.test.js",
|
|
71
|
-
"check": "node --check client.js && node --check host.js && node --check search-core.js && node --check runtime-0.1.
|
|
71
|
+
"check": "node --check client.js && node --check host.js && node --check search-core.js && node --check runtime-0.1.17.js"
|
|
72
72
|
}
|
|
73
73
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './host.js?deepsearch=0.1.17';
|
package/search-core.js
CHANGED
|
@@ -209,13 +209,13 @@ export function createSearchService(services, options = {}) {
|
|
|
209
209
|
return {signal: AbortSignal.any([signal, deadline.signal]), finish() {clearTimeout(timer); deadline.abort();}};
|
|
210
210
|
};
|
|
211
211
|
return {
|
|
212
|
-
async catalog(signal) {
|
|
212
|
+
async catalog(signal, includeArchived = false) {
|
|
213
213
|
signal = signalFor(signal); check(signal);
|
|
214
214
|
const operation = beginOperation(signal); signal = operation.signal;
|
|
215
215
|
try {
|
|
216
|
-
const {rows, workspaces} = await readCatalog(services,
|
|
216
|
+
const {rows, workspaces} = await readCatalog(services, includeArchived === true, signal);
|
|
217
217
|
check(signal);
|
|
218
|
-
return {workspaces, sessions: rows.map(({id, title, archived, workspaceId}) => ({id, title: title.slice(0, 512), archived, ...(workspaceId ? {workspaceId} : {})}))};
|
|
218
|
+
return {workspaces, sessions: rows.map(({id, title, archived, workspaceId, updatedAt}) => ({id, title: title.slice(0, 512), archived, updatedAt, ...(workspaceId ? {workspaceId} : {})}))};
|
|
219
219
|
} finally {operation.finish();}
|
|
220
220
|
},
|
|
221
221
|
async search(raw, signal) {
|
package/runtime-0.1.16.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './host.js?deepsearch=0.1.16';
|