@renyuluo/dsh-deepsearch 0.1.13 → 0.1.16

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 ADDED
@@ -0,0 +1,43 @@
1
+ # Changelog
2
+
3
+ ## 0.1.16
4
+
5
+ - Add public documentation images for the opt-in manual-unread settings, session context menu and left-side indicator, using fictional demo data.
6
+ - Reuse the native DSH `StateDot` unread component in the leading sidebar slot; native running, interaction and completion states retain priority.
7
+ - Stop result-list scrolling on mouse hover while preserving keyboard navigation and wraparound scrolling.
8
+ - Include the archive badges and confirmed restore-and-open workflow from the local 0.1.14–0.1.15 builds in the public release.
9
+ - Preserve existing local appearance and manual-unread preferences; manual unread remains off by default and local to each client.
10
+
11
+ ## 0.1.15
12
+
13
+ - Preserve the concurrently added, opt-in local manual-unread menu, blue dot and settings alongside the archive-navigation fix.
14
+ - Keep the scoped package identity and local preference keys unchanged.
15
+
16
+ ## 0.1.14
17
+
18
+ - Mark archived title and message hits with an explicit “已归档” badge.
19
+ - Confirm restoration before opening archived results in the native conversation.
20
+ - Recheck live workspace state and keep search results visible when restoration fails or is cancelled.
21
+ - Prevent duplicate restoration and stale navigation after closing or changing search scope.
22
+
23
+ ## 0.1.13
24
+
25
+ - Publish the public npm package as `@renyuluo/dsh-deepsearch`; the unscoped package belongs to another author.
26
+ - Align the Cordis bundle package reference and browser module ID with the scoped identity.
27
+ - Preserve product title, repository, local appearance settings and search behavior.
28
+ - Document explicit replacement of this project’s prior unscoped GitHub install to avoid duplicate plugin instances.
29
+
30
+ ## 0.1.12
31
+
32
+ First portable public GitHub release.
33
+
34
+ - Literal, case-insensitive Chinese and English conversation search.
35
+ - Current-session newest-first scanning and automatic bounded continuation.
36
+ - Highlighted compact previews and local minute-precision timestamps.
37
+ - Workspace/project filtering and optional archived sessions.
38
+ - Native conversation opening with exact-event checks and best-effort row navigation; no replacement transcript.
39
+ - Configurable glass, theme and custom appearance; wallpaper-plugin compatibility.
40
+ - Portable package-root bundle entry, localized metadata and manifest exports.
41
+ - No production dependencies, install scripts, external search endpoint or persistent conversation index.
42
+
43
+ Earlier versions were local development builds and are not part of this public repository history.
package/README.en.md ADDED
@@ -0,0 +1,166 @@
1
+ # DeepSearch · Full-text Conversation Search
2
+
3
+ [简体中文](README.md) | **English**
4
+
5
+ A local full-text search plugin for **DeepSeek Harness**. Find a conversation from a fragment you remember, without having to remember its title.
6
+
7
+ - **Search Chinese fragments**: literal substring matching without FTS tokenization, case-insensitive English matching, and literal punctuation.
8
+ - **Search message content**: conversation titles, user messages, and completed final assistant replies. Results show highlighted snippets and the message's local date and time.
9
+ - **Current conversation first**: search its newest messages first, then automatically scan the remaining conversations in batches.
10
+ - **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
+ - **Scope and appearance controls**: project/workspace filters, optional archived conversations, frosted glass, host theme, and custom color, opacity, and blur.
12
+ - **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.
13
+ - **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
+
15
+ ## Feature Preview
16
+
17
+ Except for the explicitly labeled sidebar illustration, these images use the **actual plugin components in an isolated mock host with fictional demo data**. They are not screenshots of your chats or the native DSH conversation page. Native message navigation must be verified in the real host; the demo does not simulate successful navigation. The screenshots show the Chinese UI; this English README does not change the plugin's interface language.
18
+
19
+ ### Full-text search, highlighted snippets, and message timestamps
20
+
21
+ ![Full-text search with Chinese matches and local message timestamps](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/01-search.png)
22
+
23
+ ### Project and workspace filters
24
+
25
+ ![Narrow the search to a project or workspace](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/02-projects.png)
26
+
27
+ ### Archived conversations
28
+
29
+ ![Optionally include archived conversations](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/03-archived.png)
30
+
31
+ ### Three panel appearance modes
32
+
33
+ ![Frosted-glass search panel](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/04-glass.png)
34
+
35
+ ![Use the host theme](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/05-theme.png)
36
+
37
+ ![Customize background color, opacity, and blur](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/06-custom.png)
38
+
39
+ ### Optional extension: manual unread
40
+
41
+ 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
+
43
+ ![Enable manual unread in Settings](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/07-unread-settings.png)
44
+
45
+ ![Session context menu and leading unread indicator demonstration](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16-docs.1/docs/images/08-unread-menu.png)
46
+
47
+ ## Installation
48
+
49
+ The verified host is **DSH Desktop 0.2.2-rc.3**. Other versions and platforms have not completed real-desktop regression testing. The package's compatibility range is currently restricted to this host version.
50
+
51
+ ### Install from npm (recommended)
52
+
53
+ The public package is [@renyuluo/dsh-deepsearch](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch). **0.1.16 has passed packaging and local installation checks, but npm publication is awaiting account two-factor authentication**; npm latest is currently 0.1.13.
54
+
55
+ ```sh
56
+ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
57
+ ```
58
+
59
+ The public package name is **`@renyuluo/dsh-deepsearch`**. The product name and GitHub repository name remain unchanged.
60
+
61
+ ### Install from GitHub
62
+
63
+ ```sh
64
+ dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.16'
65
+ ```
66
+
67
+ Alternatively, download the package from [Releases](https://github.com/luorenyu/dsh-deepsearch/releases), then install it:
68
+
69
+ ```sh
70
+ dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.16.tgz
71
+ ```
72
+
73
+ > **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.
74
+
75
+ If you previously installed this project under its old unscoped name from GitHub, remove that entry before installing the scoped package so that two copies do not load at once:
76
+
77
+ ```sh
78
+ dsh plugin --profile desktop remove dsh-deepsearch
79
+ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
80
+ ```
81
+
82
+ 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
+
84
+ Search and appearance screenshots were originally captured with the 0.1.12 demo components. The manual-unread settings screenshot uses the actual 0.1.16 plugin component in an isolated mock host; the menu scene is a fictional illustration. Version 0.1.16 also includes confirmed archive restoration and the hover-scrolling fix.
85
+
86
+ ### Discover it in the DSH plugin marketplace
87
+
88
+ [Marketplace submission #15379](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin/pull/15379) has been opened as a draft. It is awaiting the repository's 24-hour minimum age before being marked ready for maintainer review. [Awesome DSH Plugin](https://github.com/awesome-dsh-plugin/awesome-dsh-plugin) is the third-party community catalog used by `dshmarket`. Availability depends on the PR being merged and the marketplace being synchronized. **A GitHub release does not mean the plugin is already listed in the marketplace.**
89
+
90
+ Once accepted, search the relevant marketplace for **DeepSearch** or **会话全文搜索**. Check that the source is `luorenyu/dsh-deepsearch`, not another author's similarly named plugin. DSH also supports custom indexes, so catalog sources may differ between clients.
91
+
92
+ ## Usage
93
+
94
+ | Action | Shortcut / control |
95
+ | --- | --- |
96
+ | Open or close search | macOS `⌘⇧K`; Windows/Linux `Ctrl⇧K` (not tested on physical devices) |
97
+ | Select a result | `↑` / `↓` |
98
+ | Open a result | `Enter` |
99
+ | Close the panel | `Esc` or click outside |
100
+ | Set the search scope | All / Conversations / Projects, workspace dropdown, include archived |
101
+ | Adjust the panel and extensions | “设置” (Settings) in the upper-right corner |
102
+
103
+ DeepSearch does not take over DSH's native `⌘K` shortcut or the `⌘F` shortcut commonly used by other search plugins.
104
+
105
+ 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
+
107
+ 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
+
109
+ ### Opening archived results
110
+
111
+ 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.
112
+
113
+ Failures or timeouts keep results visible with an error. DeepSearch does not silently navigate or automatically rearchive. An issued restoration request cannot necessarily be withdrawn: closing the panel or changing the query cancels subsequent navigation, but the host may still finish the explicitly confirmed restoration.
114
+
115
+ ## Appearance
116
+
117
+ - **Frosted glass**: prefer the host input field's glass background and blur only the area behind the search panel.
118
+ - **Follow DSH**: use an opaque background from the host theme.
119
+ - **Custom**: choose a color, opacity from 55–100%, and blur from 0–32px, or restore the defaults.
120
+
121
+ DeepSearch does not dim the screen or blur the entire DSH page. Its compatibility fix for wallpaper plugins' opaque-dialog rules applies only to its own panel. Preferences are saved locally in `localStorage`; if storage is blocked, settings remain usable for the current session. An opaque fallback is used when reduced transparency is requested or backdrop blur is unsupported.
122
+
123
+ ## Optional extension: manual unread markers
124
+
125
+ Enable “会话未读标记” in Settings (off by default). Right-click a sidebar conversation to mark it unread/read; the marker reuses DSH’s native unread `StateDot` component to the left of the title, with host-owned colors and dimensions. Entering a conversation clears its manual marker. Marking the already-open conversation does not immediately clear it.
126
+
127
+ Preferences and markers stay in this client’s local storage, do not sync across devices and do not change native completion notifications. Disabling the extension hides menus and dots but keeps markers. Markers share the native leading status seat; running, pending-interaction and native completion states take priority. Archived and blank conversations do not show manual dots. Storage failures are reported in Settings; changes remain usable for the current session.
128
+
129
+ ## Privacy and Limitations
130
+
131
+ - 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. Archived conversations are excluded unless enabled.
133
+ - 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
+ - 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
+ - Projects come from workspaces registered with the host. DeepSearch **does not search file contents on disk** or provide command search.
136
+ - Message timestamps use the local time zone and the format `YYYY/MM/DD HH:mm`. Missing or invalid timestamps are not invented.
137
+ - Exact positioning uses a DOM compatibility adapter for the current host, not a stable public scrolling API. Folded messages, Markdown transformations, non-Chat views, host upgrades, or native scrolling policies may prevent positioning or exact-text highlighting. The plugin reports these states without blocking the native conversation.
138
+
139
+ ## Development and Testing
140
+
141
+ No build step or third-party production dependencies are required. Use Node.js 22+:
142
+
143
+ ```sh
144
+ git clone https://github.com/luorenyu/dsh-deepsearch.git
145
+ cd dsh-deepsearch
146
+ npm test
147
+ npm run check
148
+ npm pack --ignore-scripts
149
+ ```
150
+
151
+ Core tests cover literal matching, Chinese and Unicode ranges, history projection, reverse pagination, automatic continuation, cancellation/timeouts/cursors, native navigation lifecycle, snippet rendering, timestamps, and appearance. Component screenshots and mock-service tests are not equivalent to real-host acceptance testing across every host version, theme, and platform.
152
+
153
+ Code overview:
154
+
155
+ - [client.js](client.js): search panel, shortcuts, snippets, appearance, and native navigation adapter.
156
+ - [host.js](host.js): authenticated routes and request limits.
157
+ - [search-core.js](search-core.js): conversation catalog, final-reply projection, substring matching, and pagination.
158
+ - [tests](tests): host-independent unit and contract regression tests.
159
+
160
+ Uninstall:
161
+
162
+ ```sh
163
+ dsh plugin --profile desktop remove @renyuluo/dsh-deepsearch
164
+ ```
165
+
166
+ [MIT License](LICENSE) · [Report an issue](https://github.com/luorenyu/dsh-deepsearch/issues)
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # DeepSearch · 会话全文搜索
2
2
 
3
+ **简体中文** | [English](README.en.md)
4
+
3
5
  为 **DeepSeek Harness** 制作的本地全文搜索插件。记得一小段内容,就能找回对应会话,而不必记住标题。
4
6
 
5
7
  - **中文片段也能搜**:不依赖 FTS 分词,支持连续中文子串、英文大小写不敏感和字面符号。
@@ -7,31 +9,40 @@
7
9
  - **当前会话优先**:先从当前会话最新消息往前搜索,再自动逐批扫描其他会话。
8
10
  - **原生会话定位**:打开 DSH 原生会话,加载精确消息并尝试滚动、高亮,不替换详情页。
9
11
  - **范围与外观**:项目 / 工作区过滤、可选归档;毛玻璃、跟随主题、自定义颜色、不透明度与模糊。
10
- - **不上传聊天**:复用宿主认证与历史服务,不开额外生产监听端口,不修改会话。
12
+ - **可选手动未读**:设置开关控制侧栏右键标记,复用原生左侧未读点;再次打开自动已读,标记仅保存在本机。
13
+ - **不上传聊天**:复用宿主认证与历史服务,不开额外生产监听端口,不修改消息;仅在你确认“恢复并打开”时取消归档。
11
14
 
12
15
  ## 功能预览
13
16
 
14
- 以下图片使用**真实插件组件 + 隔离模拟宿主 + 虚构演示数据**生成,并非你的聊天记录或 DSH 原生页面截图。原生消息跳转需在真实宿主中验证,演示页不模拟“定位成功”。
17
+ 除特别标注的侧边栏重绘示意外,以下图片使用**真实插件组件 + 隔离模拟宿主 + 虚构演示数据**生成;均非你的聊天记录或 DSH 原生页面截图。原生消息跳转需在真实宿主中验证,演示页不模拟“定位成功”。
15
18
 
16
19
  ### 全文搜索、命中摘要与准确时间
17
20
 
18
- ![正文搜索:中文命中摘要与消息日期时间](docs/images/01-search.png)
21
+ ![正文搜索:中文命中摘要与消息日期时间](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/01-search.png)
19
22
 
20
23
  ### 项目与工作区范围
21
24
 
22
- ![按项目与工作区缩小搜索范围](docs/images/02-projects.png)
25
+ ![按项目与工作区缩小搜索范围](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/02-projects.png)
23
26
 
24
27
  ### 归档会话
25
28
 
26
- ![可选搜索归档会话](docs/images/03-archived.png)
29
+ ![可选搜索归档会话](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/03-archived.png)
27
30
 
28
31
  ### 三种面板外观
29
32
 
30
- ![局部毛玻璃搜索面板](docs/images/04-glass.png)
33
+ ![局部毛玻璃搜索面板](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/04-glass.png)
34
+
35
+ ![跟随宿主主题](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/05-theme.png)
36
+
37
+ ![自定义底色、不透明度与模糊](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/06-custom.png)
31
38
 
32
- ![跟随宿主主题](docs/images/05-theme.png)
39
+ ### 扩展小功能:手动未读
33
40
 
34
- ![自定义底色、不透明度与模糊](docs/images/06-custom.png)
41
+ 在设置中开启后,通过侧栏右键菜单标记未读 / 已读;再次进入会话自动清除。标记和开关仅保存在本机。设置图来自真实插件组件;右键菜单图使用高还原侧边栏重绘,嵌入统一功能卡片。重绘图不是原生截图或运行验证证据。
42
+
43
+ ![设置中开启会话未读标记](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16/docs/images/07-unread-settings.png)
44
+
45
+ ![右键菜单标记未读与左侧状态点示意](https://raw.githubusercontent.com/luorenyu/dsh-deepsearch/v0.1.16-docs.1/docs/images/08-unread-menu.png)
35
46
 
36
47
  ## 安装
37
48
 
@@ -39,6 +50,8 @@
39
50
 
40
51
  ### 从 npm 安装(推荐)
41
52
 
53
+ 公开包名为 [@renyuluo/dsh-deepsearch](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch)。**0.1.16 已完成打包和本地安装验证,npm 发布尚待账号双重验证**;当前 npm latest 为 0.1.13。
54
+
42
55
  ```sh
43
56
  dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
44
57
  ```
@@ -48,13 +61,13 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
48
61
  ### 从 GitHub 安装
49
62
 
50
63
  ```sh
51
- dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.13'
64
+ dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.16'
52
65
  ```
53
66
 
54
67
  也可以从 [Releases](https://github.com/luorenyu/dsh-deepsearch/releases) 下载安装包后安装:
55
68
 
56
69
  ```sh
57
- dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.13.tgz
70
+ dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.16.tgz
58
71
  ```
59
72
 
60
73
  > **重要:不要运行 `add dsh-deepsearch` 来安装 npm 同名包。** 无作用域的 npm 同名包属于其他作者,与本仓库无关。请使用 `@renyuluo/dsh-deepsearch`,或本仓库 GitHub / Release 地址。
@@ -68,7 +81,7 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
68
81
 
69
82
  这是替换本项目旧安装条目,不是建议卸载其他作者的同名插件。外观存储键保持不变;同一宿主页面来源下已有偏好会继续使用。
70
83
 
71
- 上方功能截图来自 0.1.12 演示组件;0.1.13 仅调整分发身份,不改变搜索功能。
84
+ 全文搜索及外观截图最初来自 0.1.12 演示组件;手动未读设置图由 0.1.16 的真实插件组件在隔离模拟宿主中生成;菜单场景图为虚构内容重绘。0.1.16 同时包含归档恢复确认与鼠标悬浮滚动修复。
72
85
 
73
86
  ### 在 DSH 插件市场中发现
74
87
 
@@ -85,7 +98,7 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
85
98
  | 打开结果 | `Enter` |
86
99
  | 关闭浮层 | `Esc` 或点击外部 |
87
100
  | 搜索范围 | 全部 / 对话 / 项目,工作区下拉,含归档 |
88
- | 调整面板 | 右上角「外观」 |
101
+ | 调整面板与扩展功能 | 右上角「设置」 |
89
102
 
90
103
  不占用 DSH 原生 `⌘K`,也不占用其他搜索插件常用的 `⌘F`。
91
104
 
@@ -93,6 +106,12 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
93
106
 
94
107
  点击正文结果后,插件打开原生会话,使用 `sessionId + seq` 检查精确消息是否存在,随后尝试定位原生行并高亮。提示区可以返回搜索或清除高亮;切换会话或其他功能页时释放定位资源。标题结果仅打开会话,不冒充消息定位成功。
95
108
 
109
+ ### 打开归档结果
110
+
111
+ 勾选“含归档”后,归档会话的标题与正文结果显示 **「已归档」** 标签。点击时保留搜索结果并请求确认;只有选择 **「恢复并打开」** 才调用宿主取消归档,然后进入原生会话并尝试定位。选择「取消」不会改变归档状态。
112
+
113
+ 恢复失败或超时会保留结果并提示原因,不静默跳转,也不自动重新归档。恢复请求发出后不能保证撤回;关闭面板或更换查询只会取消后续自动跳转,宿主仍可能完成已确认的恢复操作。
114
+
96
115
  ## 外观
97
116
 
98
117
  - **毛玻璃**:优先使用宿主输入框玻璃底色,仅对搜索面板覆盖区域模糊。
@@ -101,6 +120,12 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
101
120
 
102
121
  不暗化全屏,不模糊整个 DSH 页面。兼容壁纸插件的实色弹窗覆盖规则,修正只作用于 DeepSearch 自己。偏好存于本机 `localStorage`;禁止存储时仍可在本次使用。系统要求降低透明度或不支持模糊时使用实色回退。
103
122
 
123
+ ## 扩展小功能 · 手动未读
124
+
125
+ 在右上角「设置」开启「会话未读标记」(默认关闭)。右键侧栏会话可标记为未读或已读,未读标记复用 DSH 原生 `StateDot` 未读组件,在会话名称左侧显示,颜色与尺寸跟随宿主。再次进入会话时清除手动标记;在当前会话上标记不会立即清除。
126
+
127
+ 开关与标记保存在当前客户端本机,不跨设备同步,也不修改宿主原生完成提醒。关闭功能隐藏菜单和圆点但保留标记;与原生状态点共用左侧位置,运行中、待交互及原生完成提醒优先显示;归档和空白会话不显示手动圆点。无法保存本机存储时,设置区会提示,本次使用仍有效。
128
+
104
129
  ## 隐私与限制
105
130
 
106
131
  - 通过宿主公开历史服务读取,不直接解析私有聊天文件,不上传聊天、不写入原始消息。搜索 API 使用宿主 `connection.fetch` owner 认证路由。
package/client.js CHANGED
@@ -2,6 +2,7 @@ window.__ModuleLoader__.load({
2
2
  id: '@renyuluo/dsh-deepsearch',
3
3
  factory(require) {
4
4
  const React = require('react'), h = React.createElement;
5
+ const {StateDot} = require('@deepseek-ai/dsh-client-ui-primitives');
5
6
  const MAX_RESULTS = 200;
6
7
  function selectedKeys(chat, seq) {
7
8
  if (!Number.isSafeInteger(seq) || !chat?.order || !chat.nodes?.get) return [];
@@ -143,6 +144,64 @@ window.__ModuleLoader__.load({
143
144
  }
144
145
  return style;
145
146
  }
147
+ // Independent, local-only reminders: never mutate the host's completionUnread status.
148
+ const UNREAD_KEY = 'dsh-deepsearch.manual-unread.v1';
149
+ function unreadPrefs(value) {
150
+ return {enabled: value?.enabled === true, ids: [...new Set(Array.isArray(value?.ids)
151
+ ? value.ids.filter(id => typeof id === 'string' && id.length > 0 && id.length <= 512).slice(0, 10000) : [])]};
152
+ }
153
+ function createUnreadStore(storage) {
154
+ let state;
155
+ try {const raw = storage?.getItem(UNREAD_KEY); state = unreadPrefs(raw?.length > 6e6 ? null : JSON.parse(raw));}
156
+ catch {state = unreadPrefs(null);}
157
+ let active = new Set(), error = '';
158
+ const listeners = new Set();
159
+ const notify = () => {for (const listener of listeners) listener();};
160
+ const commit = next => {
161
+ state = unreadPrefs(next);
162
+ try {storage?.setItem(UNREAD_KEY, JSON.stringify(state)); if (!storage) throw new Error(); error = '';}
163
+ catch {error = '本次已生效,但无法保存到本机;刷新或重启后可能丢失。';}
164
+ notify();
165
+ };
166
+ return {
167
+ getSnapshot: () => state,
168
+ subscribe: listener => {listeners.add(listener); return () => listeners.delete(listener);},
169
+ getError: () => error,
170
+ setEnabled: enabled => commit({...state, enabled}),
171
+ mark: (id, unread) => {
172
+ if (!state.enabled || typeof id !== 'string' || !id || id.length > 512) return;
173
+ commit({...state, ids: unread ? state.ids.concat(id) : state.ids.filter(item => item !== id)});
174
+ },
175
+ observeActive: ids => {
176
+ const next = new Set(ids), entered = [...next].filter(id => !active.has(id)); active = next;
177
+ if (state.enabled && entered.some(id => state.ids.includes(id))) commit({...state, ids: state.ids.filter(id => !entered.includes(id))});
178
+ },
179
+ primeActive: ids => {active = new Set(ids);},
180
+ reload: () => {
181
+ try {const raw = storage?.getItem(UNREAD_KEY); state = unreadPrefs(raw?.length > 6e6 ? null : JSON.parse(raw)); error = ''; notify();} catch {}
182
+ },
183
+ };
184
+ }
185
+ function installUnread(ctx, store) {
186
+ const activeIds = () => Object.values(ctx.sessions.list.getSnapshot()?.byId || {})
187
+ .filter(row => (row.retainedBy?.mainView ?? 0) > 0).map(row => row.id);
188
+ store.primeActive(activeIds());
189
+ const stopSessions = ctx.sessions.list.subscribe(() => store.observeActive(activeIds()));
190
+ const unmenu = ctx.contextMenus.register({id: 'deepsearch.manual-unread', target: 'session', order: 350,
191
+ observe: () => [store],
192
+ resolve: ({sessionId}) => {
193
+ const state = store.getSnapshot(); if (!state.enabled) return [];
194
+ const unread = state.ids.includes(sessionId);
195
+ return [{id: 'deepsearch-toggle-unread', label: unread ? '标记为已读' : '标记为未读',
196
+ run: () => store.mark(sessionId, !unread)}];
197
+ }});
198
+ const onStorage = event => {if (event.key === UNREAD_KEY || event.key === null) store.reload();};
199
+ window.addEventListener('storage', onStorage);
200
+ return () => {
201
+ stopSessions(); unmenu();
202
+ window.removeEventListener('storage', onStorage);
203
+ };
204
+ }
146
205
  function Icon({folder = false}) {
147
206
  return h('svg', {width: 19, height: 19, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, 'aria-hidden': true},
148
207
  folder ? h('path', {d: 'M3 6h6l2 3h10v11H3z'}) : h(React.Fragment, null, h('circle', {cx: 10.5, cy: 10.5, r: 6.7}), h('path', {d: 'm16 16 5 5'})));
@@ -153,16 +212,32 @@ window.__ModuleLoader__.load({
153
212
  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]));
154
213
  }
155
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";
215
+ 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)}';
156
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}}';
217
+ 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}';
157
218
  return {
158
- inject: ['slots', 'layout', 'uiWorkspace', 'uiSession', 'sessions'],
219
+ inject: ['slots', 'layout', 'uiWorkspace', 'uiSession', 'sessions', 'workspaces', 'contextMenus'],
159
220
  apply(ctx) {
160
- let opened = false, intent = null, releaseShell, previousFocus, preferredSessionId;
161
- const listeners = new Set();
221
+ let storage; try {storage = window.localStorage;} catch {}
222
+ const unreadStore = createUnreadStore(storage);
223
+ ctx.effect(() => installUnread(ctx, unreadStore));
224
+ function ManualUnreadDot({sessionId, useManualUnread}) {
225
+ const unread = useManualUnread(state => state.enabled && state.ids.includes(sessionId));
226
+ // The host owns placement and status priority; reuse its exact unread visual.
227
+ return unread ? h('span', {'aria-label': '手动未读', title: 'DeepSearch 手动未读',
228
+ style: {display: 'inline-flex'}}, h(StateDot, {state: 'done'})) : null;
229
+ }
230
+ ctx.slots.inject('sidebar.session.row.leading', () => ctx.slots.register({
231
+ name: 'sidebar.session.row.leading', id: 'deepsearch-manual-unread', order: 50,
232
+ inject: () => ({hooks: {manualUnread: unreadStore}}),
233
+ }, ManualUnreadDot));
234
+ let opened = false, intent = null, releaseShell, previousFocus, preferredSessionId, selectionEpoch = 0, disposed = false;
235
+ const listeners = new Set(), recoveries = new Map();
162
236
  const notify = () => { for (const listener of listeners) listener(); };
163
237
  const subscribe = listener => { listeners.add(listener); return () => listeners.delete(listener); };
164
238
  const setOpen = value => {
165
239
  if (value && !opened) {previousFocus = document.activeElement; preferredSessionId = currentSessionId(ctx.uiSession.adapter.current.getSnapshot(), ctx.sessions.list.getSnapshot());}
240
+ if (!value) selectionEpoch++;
166
241
  opened = value; notify();
167
242
  if (!value && previousFocus?.isConnected) previousFocus.focus?.({preventScroll: true});
168
243
  };
@@ -189,7 +264,16 @@ window.__ModuleLoader__.load({
189
264
  throw failure;
190
265
  }
191
266
  }
267
+ function archiveState(sessionId) {
268
+ const snapshot = ctx.workspaces?.list?.getSnapshot();
269
+ if (snapshot?.phase !== 'ready' || snapshot.state !== 'idle' || !Array.isArray(snapshot.archivedSessionIds)) throw new Error('无法确认会话归档状态,请等待工作区加载后重试');
270
+ return snapshot.archivedSessionIds.includes(sessionId);
271
+ }
192
272
  function beginJump(item, query) {
273
+ // Defense in depth: even imperative callers cannot reopen a known archived session.
274
+ if (disposed) throw new Error('搜索已关闭');
275
+ if (recoveries.has(item.sessionId)) throw new Error('恢复请求仍在进行,请等待完成后重试');
276
+ if (ctx.workspaces?.list && archiveState(item.sessionId)) throw new Error('会话已归档,请先确认恢复并打开');
193
277
  clearIntent();
194
278
  ctx.uiWorkspace.openSession(item.sessionId); ctx.layout.selectPanel(null);
195
279
  if (!Number.isSafeInteger(item.seq)) {setOpen(false); return;}
@@ -299,6 +383,7 @@ window.__ModuleLoader__.load({
299
383
  }
300
384
  function Overlay() {
301
385
  const visible = React.useSyncExternalStore(subscribe, () => opened);
386
+ const unread = React.useSyncExternalStore(unreadStore.subscribe, unreadStore.getSnapshot);
302
387
  const [query, setQuery] = React.useState(''), [tab, setTab] = React.useState('all');
303
388
  const [workspace, setWorkspace] = React.useState(''), [archived, setArchived] = React.useState(false);
304
389
  const [catalog, setCatalog] = React.useState({sessions: [], workspaces: []}), [catalogError, setCatalogError] = React.useState('');
@@ -306,6 +391,9 @@ window.__ModuleLoader__.load({
306
391
  const [busy, setBusy] = React.useState(false), [error, setError] = React.useState(''), [index, setIndex] = React.useState(0), [retry, setRetry] = React.useState(0);
307
392
  const panel = React.useRef(null), input = React.useRef(null), list = React.useRef(null), control = React.useRef(null), generation = React.useRef(0), requestRef = React.useRef(null);
308
393
  const [composing, setComposing] = React.useState(false);
394
+ const [confirmation, setConfirmation] = React.useState(null), [openError, setOpenError] = React.useState('');
395
+ const selection = React.useRef(null);
396
+ const cancelSelection = () => {selection.current?.cancel?.(); selection.current = null; setConfirmation(null); setOpenError('');};
309
397
  const [appearance, setAppearance] = React.useState(() => {try {return readAppearance(window.localStorage);} catch {return appearancePrefs(null);}});
310
398
  const [settings, setSettings] = React.useState(false), [appearanceError, setAppearanceError] = React.useState('');
311
399
  const updateAppearance = value => {
@@ -319,6 +407,7 @@ window.__ModuleLoader__.load({
319
407
  const key = JSON.stringify(request);
320
408
  const renderKey = JSON.stringify([key, tab, visible, composing, retry]);
321
409
  const activeRender = React.useRef(renderKey); activeRender.current = renderKey;
410
+ React.useEffect(() => {cancelSelection(); return () => {selection.current?.cancel?.(); selection.current = null;};}, [renderKey]);
322
411
  React.useEffect(() => {
323
412
  if (!visible) return;
324
413
  input.current?.focus();
@@ -353,15 +442,57 @@ window.__ModuleLoader__.load({
353
442
  const visibleHits = result.renderOwner === renderKey ? result.items : [];
354
443
  const items = tab === 'projects' ? projects : request.query ? (tab === 'all' ? projects.slice(0, 3).concat(visibleHits) : visibleHits) : recent;
355
444
  React.useEffect(() => {setIndex(old => Math.min(old, Math.max(0, items.length - 1)));}, [items.length]);
356
- React.useEffect(() => {list.current?.querySelector('[aria-selected="true"]')?.scrollIntoView({block: 'nearest'});}, [index]);
357
445
  function choose(item) {
358
- if (!item) return;
446
+ if (!item || !opened || disposed || activeRender.current !== renderKey) return;
447
+ if (selection.current?.pending) return;
448
+ cancelSelection();
359
449
  if (item.kind === 'project') {setWorkspace(item.id); setTab('conversations'); setQuery(''); input.current?.focus(); return;}
360
- try {beginJump(item, request.query);} catch (failure) {setError('打开失败:' + failure.message);}
450
+ try {
451
+ const isArchived = archiveState(item.sessionId);
452
+ if (!isArchived && recoveries.has(item.sessionId)) throw new Error('恢复请求仍在进行,请等待完成后重试');
453
+ if (isArchived) {
454
+ const selected = {item, query: request.query, renderOwner: renderKey, epoch: selectionEpoch};
455
+ selection.current = selected; setConfirmation(selected); return;
456
+ }
457
+ beginJump(item, request.query);
458
+ } catch (failure) {setOpenError('打开失败:' + failure.message);}
459
+ }
460
+ async function restoreAndOpen() {
461
+ const selected = selection.current;
462
+ const current = () => selected && selection.current === selected && !disposed && opened && selectionEpoch === selected.epoch && activeRender.current === selected.renderOwner;
463
+ if (!current() || selected.pending) return;
464
+ selected.pending = true; setConfirmation({...selected}); setOpenError('');
465
+ let timer;
466
+ try {
467
+ const stillArchived = archiveState(selected.item.sessionId);
468
+ let recovery = recoveries.get(selected.item.sessionId);
469
+ if (stillArchived || recovery) {
470
+ if (!recovery) {
471
+ if (recoveries.size >= 4) throw new Error('已有多个恢复请求正在进行,请等待完成后重试');
472
+ if (typeof ctx.uiWorkspace.unarchiveSession !== 'function') throw new Error('当前宿主不支持恢复归档会话,请升级后重试');
473
+ recovery = Promise.resolve(ctx.uiWorkspace.unarchiveSession(selected.item.sessionId));
474
+ recoveries.set(selected.item.sessionId, recovery);
475
+ const finished = () => {if (recoveries.get(selected.item.sessionId) === recovery) recoveries.delete(selected.item.sessionId);};
476
+ recovery.then(finished, finished);
477
+ }
478
+ // A timeout/cancel stops this navigation, not the host's already submitted recovery.
479
+ await new Promise((resolve, reject) => {
480
+ selected.cancel = () => {clearTimeout(timer); resolve();};
481
+ timer = setTimeout(() => reject(new Error('恢复超时;请求可能仍在完成,请刷新归档状态后重试')), 15000);
482
+ recovery.then(resolve, reject);
483
+ });
484
+ }
485
+ if (!current()) return;
486
+ if (archiveState(selected.item.sessionId)) throw new Error('恢复尚未确认,会话仍在归档中;请刷新归档状态后重试');
487
+ beginJump(selected.item, selected.query);
488
+ } catch (failure) {
489
+ if (current()) {selected.pending = false; setConfirmation({...selected}); setOpenError('恢复失败:' + failure.message);}
490
+ } finally {clearTimeout(timer); selected.cancel = undefined;}
361
491
  }
362
492
  if (!visible) return null;
363
493
  const more = () => {
364
494
  if (busy || !result.cursor || result.items.length >= MAX_RESULTS) return;
495
+ cancelSelection();
365
496
  control.current?.abort(); const controller = new AbortController(); control.current = controller;
366
497
  const owner = ++generation.current; setBusy(true); setError('');
367
498
  fetchPage(result.cursor, true, owner, request, controller, renderKey);
@@ -370,9 +501,15 @@ window.__ModuleLoader__.load({
370
501
  const status = searchStatus({busy: busy || (request.query && tab !== 'projects' && !composing && result.renderOwner !== renderKey && !error), error, result: displayResult, query: request.query, projects: tab === 'projects'});
371
502
  function onKey(event) {
372
503
  if (event.isComposing || event.nativeEvent?.isComposing || event.keyCode === 229 || composing) return;
373
- if (event.key === 'Escape') {event.preventDefault(); event.stopPropagation(); setOpen(false);}
374
- if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && event.target === input.current) {event.preventDefault(); setIndex(old => items.length ? (old + (event.key === 'ArrowDown' ? 1 : items.length - 1)) % items.length : 0);}
375
- if (event.key === 'Enter' && event.target === input.current) {event.preventDefault(); choose(items[index]);}
504
+ if (event.key === 'Escape') {event.preventDefault(); event.stopPropagation(); if (selection.current) cancelSelection(); else setOpen(false);}
505
+ if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && event.target === input.current) {
506
+ event.preventDefault();
507
+ const next = items.length ? (index + (event.key === 'ArrowDown' ? 1 : items.length - 1)) % items.length : 0;
508
+ setIndex(next);
509
+ // Hover changes highlight only; scrolling belongs exclusively to keyboard navigation.
510
+ if (items.length) list.current?.querySelector('#deepsearch-result-' + next)?.scrollIntoView({block: 'nearest', behavior: 'instant'});
511
+ }
512
+ if (event.key === 'Enter' && event.target === input.current) {event.preventDefault(); if (!selection.current) choose(items[index]);}
376
513
  if (event.key === 'Tab') {
377
514
  const focusable = [...panel.current.querySelectorAll('button:not(:disabled),input,select,[tabindex="0"]')].filter(node => node.tabIndex >= 0 && !node.closest('[hidden],[inert]') && node.getClientRects().length > 0);
378
515
  const first = focusable[0], last = focusable[focusable.length - 1];
@@ -381,44 +518,54 @@ window.__ModuleLoader__.load({
381
518
  }
382
519
  }
383
520
  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},
384
- h('style', null, css + appearanceCss),
521
+ h('style', null, css + appearanceCss + archiveCss + extensionCss),
385
522
  h('header', {className: 'deepsearch-search'}, h(Icon),
386
- 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 => setQuery(event.target.value), onCompositionStart: () => setComposing(true), onCompositionEnd: () => setComposing(false)}),
387
- h('button', {className: 'deepsearch-escape', 'aria-expanded': settings, 'aria-controls': 'deepsearch-appearance', onClick: () => setSettings(value => !value)}, '外观'),
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)}),
524
+ h('button', {className: 'deepsearch-escape', 'aria-expanded': settings, 'aria-controls': 'deepsearch-appearance', onClick: () => setSettings(value => !value)}, '设置'),
388
525
  h('button', {className: 'deepsearch-escape', onClick: () => setOpen(false), 'aria-label': '关闭 DeepSearch'}, 'esc')),
389
- settings && h('div', {className: 'deepsearch-appearance', id: 'deepsearch-appearance', role: 'group', 'aria-label': '面板外观'},
526
+ settings && h('div', {className: 'deepsearch-appearance', id: 'deepsearch-appearance', role: 'group', 'aria-label': 'DeepSearch 设置'},
390
527
  h('label', null, '背景模式', h('select', {value: appearance.mode, onChange: e => updateAppearance({...appearance, mode:e.target.value})},
391
528
  ...[['glass','毛玻璃'],['theme','跟随 DSH'],['custom','自定义']].map(([value,label]) => h('option',{key:value,value},label)))),
392
529
  appearance.mode === 'custom' && h('label', null, '底色', h('input', {type:'color', value:appearance.color, onChange:e=>updateAppearance({...appearance,color:e.target.value})})),
393
530
  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)})})),
394
531
  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)})})),
395
532
  h('button', {onClick:()=>updateAppearance(null)}, '恢复默认'),
396
- appearanceError && h('p', {role:'status'}, appearanceError)),
533
+ appearanceError && h('p', {role:'status'}, appearanceError),
534
+ h('div', {className: 'deepsearch-extension'},
535
+ h('div', null, h('strong', {id: 'deepsearch-unread-label'}, '会话未读标记'), h('p', {id: 'deepsearch-unread-help'}, '扩展小功能 · 右键标记未读,再次打开自动已读。仅存本机;关闭保留标记。')),
536
+ 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())),
397
538
  h('div', {className: 'deepsearch-toolbar'}, h('div', {className: 'deepsearch-tabs', role: 'tablist', 'aria-label': '结果类型'},
398
- ...[['all', '全部'], ['conversations', '对话'], ['projects', '项目']].map(([value, label]) => h('button', {key: value, role: 'tab', 'aria-selected': tab === value, onClick: () => setTab(value)}, label))),
399
- h('select', {'aria-label': '工作区范围', value: workspace, onChange: event => setWorkspace(event.target.value)}, h('option', {value: ''}, '所有工作区'), ...(catalog.workspaces || []).map(project => h('option', {key: project.id, value: project.id}, project.title)))),
539
+ ...[['all', '全部'], ['conversations', '对话'], ['projects', '项目']].map(([value, label]) => h('button', {key: value, role: 'tab', 'aria-selected': tab === value, onClick: () => {cancelSelection(); setTab(value);}}, label))),
540
+ 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)))),
400
541
  h('div', {className: 'deepsearch-caption'}, h('span', null, request.query ? (tab === 'projects' ? '匹配项目' : '标题 · 你的输入 · 助手回复') : '最近对话'),
401
- tab !== 'projects' && h('label', null, h('input', {type: 'checkbox', checked: archived, onChange: event => setArchived(event.target.checked)}), '含归档')),
542
+ tab !== 'projects' && h('label', null, h('input', {type: 'checkbox', checked: archived, onChange: event => {cancelSelection(); setArchived(event.target.checked);}}), '含归档')),
402
543
  h('div', {className: 'deepsearch-results', ref: list, role: 'listbox', id: 'deepsearch-results', 'aria-label': '搜索结果', 'aria-busy': busy},
403
544
  ...items.map((item, i) => 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)},
404
545
  h('span', {className: 'deepsearch-result-icon'}, h(Icon, {folder: item.kind === 'project'})),
405
- h('span', {className: 'deepsearch-result-text'}, h('span', {className: 'deepsearch-result-title'}, item.title || '未命名会话'),
546
+ h('span', {className: 'deepsearch-result-text'}, h('span', {className: 'deepsearch-result-title'}, item.title || '未命名会话', item.archived === true && h('span', {className: 'deepsearch-archived'}, '已归档')),
406
547
  item.snippet && h('span', {className: 'deepsearch-snippet'}, h(Mark, {text: item.snippet, range: item.range})),
407
548
  h('span', {className: 'deepsearch-meta'}, item.kind === 'project' ? '工作区 · 点击限定搜索范围' :
408
549
  [item.role === 'user' ? '你' : item.role === 'assistant' ? '助手' : '会话标题', item.workspaceTitle, formatMessageTime(item.time)].filter(Boolean).join(' · '))), h('span', {className: 'deepsearch-return', 'aria-hidden': true}, '↵'))),
409
550
  !items.length && h('div', {className: 'deepsearch-empty', role: 'status'}, h(Icon), h('strong', null, status.empty),
410
551
  h('p', null, busy ? '逐批读取本地历史,不上传你的对话。' : request.query ? '支持连续中文片段,不需要输入整句话。' : '中文片段、英文关键词,都可以。'))),
552
+ confirmation && h('div', {className: 'deepsearch-confirm', role: 'group', 'aria-label': '恢复归档会话', 'aria-busy': !!confirmation.pending},
553
+ h('strong', null, '此会话已归档'),
554
+ h('p', null, '恢复“' + (confirmation.item.title || '未命名会话') + '”后将在原生会话中打开;取消会保留当前结果。'),
555
+ h('button', {onClick: restoreAndOpen, disabled: !!confirmation.pending}, confirmation.pending ? '正在恢复…' : '恢复并打开'),
556
+ h('button', {onClick: cancelSelection}, '取消')),
557
+ openError && h('div', {className: 'deepsearch-error', role: 'alert'}, openError),
411
558
  (error || catalogError) && h('div', {className: 'deepsearch-error', role: 'alert'}, error || '目录读取失败:' + catalogError, h('button', {onClick: () => error && displayResult.cursor ? more() : setRetry(value => value + 1)}, '重试')),
412
559
  displayResult.warnings?.length > 0 && h('div', {className: 'deepsearch-warning', role: 'status'}, '部分历史读取失败(' + displayResult.warnings.length + ');当前结果可能不完整。'),
413
560
  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 ? '正在继续扫描…' : '继续搜索剩余历史'),
414
- h('footer', {className: 'deepsearch-footer'}, h('span', null, h('strong', null, 'DeepSearch'), ' 0.1.13 / 本地全文'),
561
+ h('footer', {className: 'deepsearch-footer'}, h('span', null, h('strong', null, 'DeepSearch'), ' 0.1.16 / 本地全文'),
415
562
  h('span', {role: 'status'}, status.footer),
416
563
  h('span', {className: 'deepsearch-key-hint'}, '↑↓ 选择 ↵ 打开')));
417
564
  }
418
565
  ctx.effect(() => {
419
566
  const onKey = event => {if (!isShortcut(event)) return; event.preventDefault(); event.stopPropagation(); setOpen(!opened);};
420
567
  window.addEventListener('keydown', onKey, true);
421
- return () => {window.removeEventListener('keydown', onKey, true); setOpen(false); clearIntent();};
568
+ return () => {disposed = true; window.removeEventListener('keydown', onKey, true); setOpen(false); clearIntent();};
422
569
  });
423
570
  ctx.slots.inject('shell.overlay', () => ctx.slots.register({name: 'shell.overlay', id: 'deepsearch'}, Overlay));
424
571
  }
package/host.js CHANGED
@@ -1,4 +1,4 @@
1
- import {createSearchService, SearchError} from './search-core.js?deepsearch=0.1.13';
1
+ import {createSearchService, SearchError} from './search-core.js?deepsearch=0.1.16';
2
2
 
3
3
  export const inject = ['sessionQuery', 'sessionController', 'workspaceController', 'connection'];
4
4
  export const MAX_BODY_BYTES = 16 * 1024;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@renyuluo/dsh-deepsearch",
3
- "version": "0.1.13",
3
+ "version": "0.1.16",
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.13.js",
34
+ ".": "./runtime-0.1.16.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.13.js",
43
+ "runtime-0.1.16.js",
44
44
  "host.js",
45
45
  "search-core.js",
46
46
  "client.js",
@@ -48,6 +48,8 @@
48
48
  "locale",
49
49
  "icon.svg",
50
50
  "README.md",
51
+ "README.en.md",
52
+ "CHANGELOG.md",
51
53
  "LICENSE"
52
54
  ],
53
55
  "dsh": {
@@ -59,12 +61,13 @@
59
61
  "immediately": true,
60
62
  "inject": [
61
63
  "@deepseek-ai/dsh-client-ui-conversation",
62
- "@deepseek-ai/dsh-client-ui-session"
64
+ "@deepseek-ai/dsh-client-ui-session",
65
+ "@deepseek-ai/dsh-client-ui-context-menu"
63
66
  ]
64
67
  }
65
68
  },
66
69
  "scripts": {
67
70
  "test": "node --test tests/*.test.js",
68
- "check": "node --check client.js && node --check host.js && node --check search-core.js && node --check runtime-0.1.13.js"
71
+ "check": "node --check client.js && node --check host.js && node --check search-core.js && node --check runtime-0.1.16.js"
69
72
  }
70
73
  }
@@ -0,0 +1 @@
1
+ export * from './host.js?deepsearch=0.1.16';
package/search-core.js CHANGED
@@ -125,9 +125,9 @@ async function readCatalog(services, includeArchived, signal) {
125
125
  check(signal);
126
126
  if (seen.has(header.id)) continue;
127
127
  seen.add(header.id);
128
- const row = metadata.get(header.id);
129
- if (header.origin === 'subagent' || row?.origin === 'subagent' || row?.blank || (!includeArchived && archived.has(header.id))) continue;
130
- rows.push({id: header.id, title: row?.projections?.values?.title, updatedAt: row?.updatedAt ?? header.createdAt ?? 0,
128
+ const row = metadata.get(header.id), isArchived = archived.has(header.id);
129
+ if (header.origin === 'subagent' || row?.origin === 'subagent' || row?.blank || (!includeArchived && isArchived)) continue;
130
+ rows.push({id: header.id, title: row?.projections?.values?.title, archived: isArchived, updatedAt: row?.updatedAt ?? header.createdAt ?? 0,
131
131
  workspaceId: membership.has(header.id) ? membership.get(header.id) : roots.get(pathKey(row?.cwd ?? header.cwd))});
132
132
  }
133
133
  const missing = rows.filter(row => row.title == null);
@@ -215,7 +215,7 @@ export function createSearchService(services, options = {}) {
215
215
  try {
216
216
  const {rows, workspaces} = await readCatalog(services, false, signal);
217
217
  check(signal);
218
- return {workspaces, sessions: rows.map(({id, title, workspaceId}) => ({id, title: title.slice(0, 512), ...(workspaceId ? {workspaceId} : {})}))};
218
+ return {workspaces, sessions: rows.map(({id, title, archived, workspaceId}) => ({id, title: title.slice(0, 512), archived, ...(workspaceId ? {workspaceId} : {})}))};
219
219
  } finally {operation.finish();}
220
220
  },
221
221
  async search(raw, signal) {
@@ -250,7 +250,7 @@ export function createSearchService(services, options = {}) {
250
250
  while (state.session < state.rows.length && items.length < limits.pageSize && sessions < limits.sessionsPerPage && visited < limits.eventsPerPage) {
251
251
  check(signal);
252
252
  const row = state.rows[state.session], position = state.position;
253
- const common = {sessionId: row.id, title: row.title.slice(0, 512), ...(row.workspaceId ? {workspaceId: row.workspaceId,
253
+ const common = {sessionId: row.id, title: row.title.slice(0, 512), archived: row.archived, ...(row.workspaceId ? {workspaceId: row.workspaceId,
254
254
  workspaceTitle: state.workspaces.find(workspace => workspace.id === row.workspaceId)?.title} : {})};
255
255
  if (!position.titleDone) {
256
256
  const match = await literalSnippet(row.title, input.query, signal); position.titleDone = true;
package/runtime-0.1.13.js DELETED
@@ -1 +0,0 @@
1
- export * from './host.js?deepsearch=0.1.13';