@renyuluo/dsh-deepsearch 0.1.13 → 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 +54 -0
- package/README.en.md +194 -0
- package/README.md +68 -15
- package/client.js +446 -39
- package/host.js +2 -2
- package/package.json +8 -5
- package/runtime-0.1.17.js +1 -0
- package/search-core.js +7 -7
- package/runtime-0.1.13.js +0 -1
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Changelog
|
|
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
|
+
|
|
14
|
+
## 0.1.16
|
|
15
|
+
|
|
16
|
+
- Add public documentation images for the opt-in manual-unread settings, session context menu and left-side indicator, using fictional demo data.
|
|
17
|
+
- Reuse the native DSH `StateDot` unread component in the leading sidebar slot; native running, interaction and completion states retain priority.
|
|
18
|
+
- Stop result-list scrolling on mouse hover while preserving keyboard navigation and wraparound scrolling.
|
|
19
|
+
- Include the archive badges and confirmed restore-and-open workflow from the local 0.1.14–0.1.15 builds in the public release.
|
|
20
|
+
- Preserve existing local appearance and manual-unread preferences; manual unread remains off by default and local to each client.
|
|
21
|
+
|
|
22
|
+
## 0.1.15
|
|
23
|
+
|
|
24
|
+
- Preserve the concurrently added, opt-in local manual-unread menu, blue dot and settings alongside the archive-navigation fix.
|
|
25
|
+
- Keep the scoped package identity and local preference keys unchanged.
|
|
26
|
+
|
|
27
|
+
## 0.1.14
|
|
28
|
+
|
|
29
|
+
- Mark archived title and message hits with an explicit “已归档” badge.
|
|
30
|
+
- Confirm restoration before opening archived results in the native conversation.
|
|
31
|
+
- Recheck live workspace state and keep search results visible when restoration fails or is cancelled.
|
|
32
|
+
- Prevent duplicate restoration and stale navigation after closing or changing search scope.
|
|
33
|
+
|
|
34
|
+
## 0.1.13
|
|
35
|
+
|
|
36
|
+
- Publish the public npm package as `@renyuluo/dsh-deepsearch`; the unscoped package belongs to another author.
|
|
37
|
+
- Align the Cordis bundle package reference and browser module ID with the scoped identity.
|
|
38
|
+
- Preserve product title, repository, local appearance settings and search behavior.
|
|
39
|
+
- Document explicit replacement of this project’s prior unscoped GitHub install to avoid duplicate plugin instances.
|
|
40
|
+
|
|
41
|
+
## 0.1.12
|
|
42
|
+
|
|
43
|
+
First portable public GitHub release.
|
|
44
|
+
|
|
45
|
+
- Literal, case-insensitive Chinese and English conversation search.
|
|
46
|
+
- Current-session newest-first scanning and automatic bounded continuation.
|
|
47
|
+
- Highlighted compact previews and local minute-precision timestamps.
|
|
48
|
+
- Workspace/project filtering and optional archived sessions.
|
|
49
|
+
- Native conversation opening with exact-event checks and best-effort row navigation; no replacement transcript.
|
|
50
|
+
- Configurable glass, theme and custom appearance; wallpaper-plugin compatibility.
|
|
51
|
+
- Portable package-root bundle entry, localized metadata and manifest exports.
|
|
52
|
+
- No production dependencies, install scripts, external search endpoint or persistent conversation index.
|
|
53
|
+
|
|
54
|
+
Earlier versions were local development builds and are not part of this public repository history.
|
package/README.en.md
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
# DeepSearch · Full-text Conversation Search
|
|
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
|
+
|
|
9
|
+
[简体中文](README.md) | **English**
|
|
10
|
+
|
|
11
|
+
A local full-text search plugin for **DeepSeek Harness**. Find a conversation from a fragment you remember, without having to remember its title.
|
|
12
|
+
|
|
13
|
+
- **Search Chinese fragments**: literal substring matching without FTS tokenization, case-insensitive English matching, and literal punctuation.
|
|
14
|
+
- **Search message content**: conversation titles, user messages, and completed final assistant replies. Results show highlighted snippets and the message's local date and time.
|
|
15
|
+
- **Current conversation first**: search its newest messages first, then automatically scan the remaining conversations in batches.
|
|
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.
|
|
17
|
+
- **Scope and appearance controls**: project/workspace filters, optional archived conversations, frosted glass, host theme, and custom color, opacity, and blur.
|
|
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.
|
|
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.
|
|
22
|
+
|
|
23
|
+
## Feature Preview
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
### Full-text search, highlighted snippets, and message timestamps
|
|
28
|
+
|
|
29
|
+

|
|
30
|
+
|
|
31
|
+
### Project and workspace filters
|
|
32
|
+
|
|
33
|
+

|
|
34
|
+
|
|
35
|
+
### Archived conversations
|
|
36
|
+
|
|
37
|
+

|
|
38
|
+
|
|
39
|
+
### Three panel appearance modes
|
|
40
|
+
|
|
41
|
+

|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+

|
|
46
|
+
|
|
47
|
+
### Optional extension: manual unread
|
|
48
|
+
|
|
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.
|
|
50
|
+
|
|
51
|
+

|
|
52
|
+
|
|
53
|
+

|
|
54
|
+
|
|
55
|
+
### Search history and compact settings
|
|
56
|
+
|
|
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
|
+

|
|
62
|
+
|
|
63
|
+
## Installation
|
|
64
|
+
|
|
65
|
+
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.
|
|
66
|
+
|
|
67
|
+
### Install from npm (recommended)
|
|
68
|
+
|
|
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.
|
|
70
|
+
|
|
71
|
+
```sh
|
|
72
|
+
dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
The public package name is **`@renyuluo/dsh-deepsearch`**. The product name and GitHub repository name remain unchanged.
|
|
76
|
+
|
|
77
|
+
### Install from GitHub
|
|
78
|
+
|
|
79
|
+
```sh
|
|
80
|
+
dsh plugin --profile desktop add 'https://github.com/luorenyu/dsh-deepsearch.git#v0.1.17'
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
Alternatively, download the package from [Releases](https://github.com/luorenyu/dsh-deepsearch/releases), then install it:
|
|
84
|
+
|
|
85
|
+
```sh
|
|
86
|
+
dsh plugin --profile desktop add /path/to/renyuluo-dsh-deepsearch-0.1.17.tgz
|
|
87
|
+
```
|
|
88
|
+
|
|
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.
|
|
90
|
+
|
|
91
|
+
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:
|
|
92
|
+
|
|
93
|
+
```sh
|
|
94
|
+
dsh plugin --profile desktop remove dsh-deepsearch
|
|
95
|
+
dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
96
|
+
```
|
|
97
|
+
|
|
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.
|
|
99
|
+
|
|
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.
|
|
101
|
+
|
|
102
|
+
### Discover it in the DSH plugin marketplace
|
|
103
|
+
|
|
104
|
+
[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.**
|
|
105
|
+
|
|
106
|
+
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.
|
|
107
|
+
|
|
108
|
+
## Usage
|
|
109
|
+
|
|
110
|
+
| Action | Shortcut / control |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| Open or close search | macOS `⌘⇧K`; Windows/Linux `Ctrl⇧K` (not tested on physical devices) |
|
|
113
|
+
| Select a result | `↑` / `↓` |
|
|
114
|
+
| Open a result | `Enter`; clicking a project result or pressing Enter starts a native conversation in that workspace |
|
|
115
|
+
| Close the panel | `Esc` or click outside |
|
|
116
|
+
| Set the search scope | All / Conversations / Projects, workspace dropdown, include archived |
|
|
117
|
+
| Adjust the panel and extensions | “设置” (Settings) in the upper-right corner |
|
|
118
|
+
|
|
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.
|
|
124
|
+
|
|
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.
|
|
126
|
+
|
|
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.
|
|
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
|
+
|
|
137
|
+
### Opening archived results
|
|
138
|
+
|
|
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.
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
## Appearance
|
|
144
|
+
|
|
145
|
+
- **Frosted glass**: prefer the host input field's glass background and blur only the area behind the search panel.
|
|
146
|
+
- **Follow DSH**: use an opaque background from the host theme.
|
|
147
|
+
- **Custom**: choose a color, opacity from 55–100%, and blur from 0–32px, or restore the defaults.
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
## Optional extension: manual unread markers
|
|
152
|
+
|
|
153
|
+
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.
|
|
154
|
+
|
|
155
|
+
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.
|
|
156
|
+
|
|
157
|
+
## Privacy and Limitations
|
|
158
|
+
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
163
|
+
- Projects come from workspaces registered with the host. DeepSearch **does not search file contents on disk** or provide command search.
|
|
164
|
+
- Message timestamps use the local time zone and the format `YYYY/MM/DD HH:mm`. Missing or invalid timestamps are not invented.
|
|
165
|
+
- 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.
|
|
166
|
+
|
|
167
|
+
## Development and Testing
|
|
168
|
+
|
|
169
|
+
No build step or third-party production dependencies are required. Use Node.js 22+:
|
|
170
|
+
|
|
171
|
+
```sh
|
|
172
|
+
git clone https://github.com/luorenyu/dsh-deepsearch.git
|
|
173
|
+
cd dsh-deepsearch
|
|
174
|
+
npm test
|
|
175
|
+
npm run check
|
|
176
|
+
npm pack --ignore-scripts
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
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.
|
|
180
|
+
|
|
181
|
+
Code overview:
|
|
182
|
+
|
|
183
|
+
- [client.js](client.js): search panel, shortcuts, snippets, appearance, and native navigation adapter.
|
|
184
|
+
- [host.js](host.js): authenticated routes and request limits.
|
|
185
|
+
- [search-core.js](search-core.js): conversation catalog, final-reply projection, substring matching, and pagination.
|
|
186
|
+
- [tests](tests): host-independent unit and contract regression tests.
|
|
187
|
+
|
|
188
|
+
Uninstall:
|
|
189
|
+
|
|
190
|
+
```sh
|
|
191
|
+
dsh plugin --profile desktop remove @renyuluo/dsh-deepsearch
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
[MIT License](LICENSE) · [Report an issue](https://github.com/luorenyu/dsh-deepsearch/issues)
|
package/README.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
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
|
+
|
|
9
|
+
**简体中文** | [English](README.en.md)
|
|
10
|
+
|
|
3
11
|
为 **DeepSeek Harness** 制作的本地全文搜索插件。记得一小段内容,就能找回对应会话,而不必记住标题。
|
|
4
12
|
|
|
5
13
|
- **中文片段也能搜**:不依赖 FTS 分词,支持连续中文子串、英文大小写不敏感和字面符号。
|
|
@@ -7,31 +15,50 @@
|
|
|
7
15
|
- **当前会话优先**:先从当前会话最新消息往前搜索,再自动逐批扫描其他会话。
|
|
8
16
|
- **原生会话定位**:打开 DSH 原生会话,加载精确消息并尝试滚动、高亮,不替换详情页。
|
|
9
17
|
- **范围与外观**:项目 / 工作区过滤、可选归档;毛玻璃、跟随主题、自定义颜色、不透明度与模糊。
|
|
10
|
-
-
|
|
18
|
+
- **可选手动未读**:设置开关控制侧栏右键标记,复用原生左侧未读点;再次打开自动已读,标记仅保存在本机。
|
|
19
|
+
- **本机搜索历史**:停顿 1 秒记录关键词,最多 30 条;重搜、删除和默认起始 Tab 偏好,不存聊天正文。
|
|
20
|
+
- **项目直达与快捷键**:项目结果开启原生新会话并尝试展开侧栏;macOS 可选接管 `⌘K`,关闭恢复原绑定。
|
|
21
|
+
- **不上传聊天**:复用宿主认证与历史服务,不开额外生产监听端口,不修改消息;仅在你确认“恢复并打开”时取消归档。
|
|
11
22
|
|
|
12
23
|
## 功能预览
|
|
13
24
|
|
|
14
|
-
|
|
25
|
+
除特别标注的侧边栏重绘示意外,以下图片使用**真实插件组件 + 隔离模拟宿主 + 虚构演示数据**生成;均非你的聊天记录或 DSH 原生页面截图。原生消息跳转需在真实宿主中验证,演示页不模拟“定位成功”。
|
|
15
26
|
|
|
16
27
|
### 全文搜索、命中摘要与准确时间
|
|
17
28
|
|
|
18
|
-

|
|
29
|
+

|
|
19
30
|
|
|
20
31
|
### 项目与工作区范围
|
|
21
32
|
|
|
22
|
-

|
|
33
|
+

|
|
23
34
|
|
|
24
35
|
### 归档会话
|
|
25
36
|
|
|
26
|
-

|
|
37
|
+

|
|
27
38
|
|
|
28
39
|
### 三种面板外观
|
|
29
40
|
|
|
30
|
-

|
|
41
|
+

|
|
42
|
+
|
|
43
|
+

|
|
44
|
+
|
|
45
|
+

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

|
|
33
52
|
|
|
34
|
-

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

|
|
60
|
+
|
|
61
|
+

|
|
35
62
|
|
|
36
63
|
## 安装
|
|
37
64
|
|
|
@@ -39,6 +66,8 @@
|
|
|
39
66
|
|
|
40
67
|
### 从 npm 安装(推荐)
|
|
41
68
|
|
|
69
|
+
公开包名为 [@renyuluo/dsh-deepsearch](https://www.npmjs.com/package/@renyuluo/dsh-deepsearch)。本次功能版本为 **0.1.17**。请使用下方命令安装;发布状态以 npm 版本页与 GitHub Release 为准。
|
|
70
|
+
|
|
42
71
|
```sh
|
|
43
72
|
dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
44
73
|
```
|
|
@@ -48,13 +77,13 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
48
77
|
### 从 GitHub 安装
|
|
49
78
|
|
|
50
79
|
```sh
|
|
51
|
-
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'
|
|
52
81
|
```
|
|
53
82
|
|
|
54
83
|
也可以从 [Releases](https://github.com/luorenyu/dsh-deepsearch/releases) 下载安装包后安装:
|
|
55
84
|
|
|
56
85
|
```sh
|
|
57
|
-
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
|
|
58
87
|
```
|
|
59
88
|
|
|
60
89
|
> **重要:不要运行 `add dsh-deepsearch` 来安装 npm 同名包。** 无作用域的 npm 同名包属于其他作者,与本仓库无关。请使用 `@renyuluo/dsh-deepsearch`,或本仓库 GitHub / Release 地址。
|
|
@@ -68,7 +97,7 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
68
97
|
|
|
69
98
|
这是替换本项目旧安装条目,不是建议卸载其他作者的同名插件。外观存储键保持不变;同一宿主页面来源下已有偏好会继续使用。
|
|
70
99
|
|
|
71
|
-
|
|
100
|
+
组件截图已按 0.1.17 更新;菜单场景仍保留已批准的虚构侧边栏重绘。所有演示使用隔离宿主和虚构数据,不展示私人会话;原生导航、快捷键持久化等须以真实宿主验证为准。
|
|
72
101
|
|
|
73
102
|
### 在 DSH 插件市场中发现
|
|
74
103
|
|
|
@@ -82,17 +111,35 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
82
111
|
| --- | --- |
|
|
83
112
|
| 打开或关闭搜索 | macOS `⌘⇧K`;Windows / Linux `Ctrl⇧K`(未实机验证) |
|
|
84
113
|
| 选择结果 | `↑` / `↓` |
|
|
85
|
-
| 打开结果 | `Enter
|
|
114
|
+
| 打开结果 | `Enter`;项目结果点击或回车将在该项目下开启原生新会话 |
|
|
86
115
|
| 关闭浮层 | `Esc` 或点击外部 |
|
|
87
116
|
| 搜索范围 | 全部 / 对话 / 项目,工作区下拉,含归档 |
|
|
88
|
-
|
|
|
117
|
+
| 调整面板与扩展功能 | 右上角「设置」 |
|
|
118
|
+
|
|
119
|
+
默认不占用 DSH 原生 `⌘K`,可在设置中选择接管;不占用其他搜索插件常用的 `⌘F`。
|
|
89
120
|
|
|
90
|
-
|
|
121
|
+
「含归档」默认勾选,可手动取消。未输入关键词时,最近对话显示所属项目与会话最后更新时间(本机时区,`年/月/日 时:分`);缺失的项目或时间分别显示「未分配项目」「时间未知」。外观恢复默认使用模糊滑条后的回转箭头图标,悬停可见说明。
|
|
122
|
+
|
|
123
|
+
未输入关键词时,可切换「最近对话 / 搜索历史」。「默认历史」位于「含归档」左侧,勾选后「搜索历史」排在第一位,取消后「最近对话」排在第一位;切换偏好不跳走当前内容,每次重新打开选中第一项(仅本机保存)。关键词停顿 1 秒后记录,中文输入法组词期间不记录;最多 30 条、同词去重、最近使用优先。点击或回车选择历史会重新搜索,不会直接打开会话;支持单条删除与清空,不保存结果或聊天正文。
|
|
91
124
|
|
|
92
125
|
输入中文片段或英文关键词后,搜索自动继续,不需要逐页点击。结果随扫描逐步出现;只有扫描完成且没有命中才显示没有找到。读取失败、超时、未完成与 200 条结果上限会单独提示。切换关键词或关闭面板会取消旧任务。
|
|
93
126
|
|
|
94
127
|
点击正文结果后,插件打开原生会话,使用 `sessionId + seq` 检查精确消息是否存在,随后尝试定位原生行并高亮。提示区可以返回搜索或清除高亮;切换会话或其他功能页时释放定位资源。标题结果仅打开会话,不冒充消息定位成功。
|
|
95
128
|
|
|
129
|
+
项目结果会先进入该项目的原生新会话页,再尝试一次性展开左侧目标项目及折叠的父级,并将项目和新会话滚动到可见区域。手动滚动、继续操作或打开其他结果会终止定位;侧栏收起、平铺/筛选视图或宿主结构变化时可跳过,不影响新会话打开。工作区下拉仍只筛选搜索范围。
|
|
130
|
+
|
|
131
|
+
### 可选接管原生 ⌘K
|
|
132
|
+
|
|
133
|
+
在「设置」开启「使用 ⌘K 打开 DeepSearch」后,macOS 桌面端通过 DSH 官方快捷键接口将原生会话搜索让位给 DeepSearch;⌘⇧K 保留。默认关闭,关闭时恢复开启前的原绑定,而不是强制重置你的自定义快捷键。该选项会写入 DSH 快捷键配置,并在本机保存恢复备份;刷新后保留。
|
|
134
|
+
|
|
135
|
+
**卸载插件前请先关闭接管。** 直接卸载不会自动恢复宿主配置;可在 DSH 快捷键设置中恢复「会话搜索」,并清除 DeepSearch 的绑定。若写入失败或期间被其他设置修改,插件会尝试安全回滚,保留备份并提示恢复,不覆盖新配置。当前只支持 macOS 桌面端,不是任意快捷键录入器。
|
|
136
|
+
|
|
137
|
+
### 打开归档结果
|
|
138
|
+
|
|
139
|
+
勾选“含归档”后,归档会话的标题与正文结果显示 **「已归档」** 标签。点击时保留搜索结果并请求确认;只有选择 **「恢复并打开」** 才调用宿主取消归档,然后进入原生会话并尝试定位。选择「取消」不会改变归档状态。
|
|
140
|
+
|
|
141
|
+
恢复失败或超时会保留结果并提示原因,不静默跳转,也不自动重新归档。恢复请求发出后不能保证撤回;关闭面板或更换查询只会取消后续自动跳转,宿主仍可能完成已确认的恢复操作。
|
|
142
|
+
|
|
96
143
|
## 外观
|
|
97
144
|
|
|
98
145
|
- **毛玻璃**:优先使用宿主输入框玻璃底色,仅对搜索面板覆盖区域模糊。
|
|
@@ -101,10 +148,16 @@ dsh plugin --profile desktop add @renyuluo/dsh-deepsearch
|
|
|
101
148
|
|
|
102
149
|
不暗化全屏,不模糊整个 DSH 页面。兼容壁纸插件的实色弹窗覆盖规则,修正只作用于 DeepSearch 自己。偏好存于本机 `localStorage`;禁止存储时仍可在本次使用。系统要求降低透明度或不支持模糊时使用实色回退。
|
|
103
150
|
|
|
151
|
+
## 扩展小功能 · 手动未读
|
|
152
|
+
|
|
153
|
+
在右上角「设置」开启「会话未读标记」(默认关闭)。右键侧栏会话可标记为未读或已读,未读标记复用 DSH 原生 `StateDot` 未读组件,在会话名称左侧显示,颜色与尺寸跟随宿主。再次进入会话时清除手动标记;在当前会话上标记不会立即清除。
|
|
154
|
+
|
|
155
|
+
开关与标记保存在当前客户端本机,不跨设备同步,也不修改宿主原生完成提醒。关闭功能隐藏菜单和圆点但保留标记;与原生状态点共用左侧位置,运行中、待交互及原生完成提醒优先显示;归档和空白会话不显示手动圆点。无法保存本机存储时,设置区会提示,本次使用仍有效。
|
|
156
|
+
|
|
104
157
|
## 隐私与限制
|
|
105
158
|
|
|
106
159
|
- 通过宿主公开历史服务读取,不直接解析私有聊天文件,不上传聊天、不写入原始消息。搜索 API 使用宿主 `connection.fetch` owner 认证路由。
|
|
107
|
-
-
|
|
160
|
+
- 默认搜索普通会话标题、用户输入及已完成助手最终回复;排除工具输出、推理、子智能体与未完成回复。界面默认勾选「含归档」,可手动关闭;底层 API 仍需显式请求归档。
|
|
108
161
|
- 搜索采用有界内存、短期游标和逐批扫描,**不是持久增量索引**。超长历史首次查询可能较慢;最多显示 200 条命中,游标闲置两分钟过期后需重搜。
|
|
109
162
|
- 每个会话首次读取的历史切面构成本次范围;扫描期间新追加内容需要重新搜索才会出现。版本变更或历史截断会明确要求重新搜索。
|
|
110
163
|
- 项目来自宿主已登记工作区,**不搜索磁盘文件内容**,也不提供命令搜索。
|
package/client.js
CHANGED
|
@@ -2,7 +2,73 @@ 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;
|
|
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
|
+
}
|
|
6
72
|
function selectedKeys(chat, seq) {
|
|
7
73
|
if (!Number.isSafeInteger(seq) || !chat?.order || !chat.nodes?.get) return [];
|
|
8
74
|
return chat.order.filter(key => {
|
|
@@ -53,6 +119,116 @@ window.__ModuleLoader__.load({
|
|
|
53
119
|
return (event.metaKey || event.ctrlKey) && event.shiftKey && !event.altKey &&
|
|
54
120
|
event.key.toLowerCase() === 'k' && !event.isComposing && !event.repeat;
|
|
55
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
|
+
}
|
|
56
232
|
function joinItems(previous, next) {
|
|
57
233
|
const seen = new Set(previous.map(item => item.id));
|
|
58
234
|
return previous.concat(next.filter(item => !seen.has(item.id) && seen.add(item.id))).slice(0, MAX_RESULTS);
|
|
@@ -143,6 +319,99 @@ window.__ModuleLoader__.load({
|
|
|
143
319
|
}
|
|
144
320
|
return style;
|
|
145
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
|
+
}
|
|
357
|
+
// Independent, local-only reminders: never mutate the host's completionUnread status.
|
|
358
|
+
const UNREAD_KEY = 'dsh-deepsearch.manual-unread.v1';
|
|
359
|
+
function unreadPrefs(value) {
|
|
360
|
+
return {enabled: value?.enabled === true, ids: [...new Set(Array.isArray(value?.ids)
|
|
361
|
+
? value.ids.filter(id => typeof id === 'string' && id.length > 0 && id.length <= 512).slice(0, 10000) : [])]};
|
|
362
|
+
}
|
|
363
|
+
function createUnreadStore(storage) {
|
|
364
|
+
let state;
|
|
365
|
+
try {const raw = storage?.getItem(UNREAD_KEY); state = unreadPrefs(raw?.length > 6e6 ? null : JSON.parse(raw));}
|
|
366
|
+
catch {state = unreadPrefs(null);}
|
|
367
|
+
let active = new Set(), error = '';
|
|
368
|
+
const listeners = new Set();
|
|
369
|
+
const notify = () => {for (const listener of listeners) listener();};
|
|
370
|
+
const commit = next => {
|
|
371
|
+
state = unreadPrefs(next);
|
|
372
|
+
try {storage?.setItem(UNREAD_KEY, JSON.stringify(state)); if (!storage) throw new Error(); error = '';}
|
|
373
|
+
catch {error = '本次已生效,但无法保存到本机;刷新或重启后可能丢失。';}
|
|
374
|
+
notify();
|
|
375
|
+
};
|
|
376
|
+
return {
|
|
377
|
+
getSnapshot: () => state,
|
|
378
|
+
subscribe: listener => {listeners.add(listener); return () => listeners.delete(listener);},
|
|
379
|
+
getError: () => error,
|
|
380
|
+
setEnabled: enabled => commit({...state, enabled}),
|
|
381
|
+
mark: (id, unread) => {
|
|
382
|
+
if (!state.enabled || typeof id !== 'string' || !id || id.length > 512) return;
|
|
383
|
+
commit({...state, ids: unread ? state.ids.concat(id) : state.ids.filter(item => item !== id)});
|
|
384
|
+
},
|
|
385
|
+
observeActive: ids => {
|
|
386
|
+
const next = new Set(ids), entered = [...next].filter(id => !active.has(id)); active = next;
|
|
387
|
+
if (state.enabled && entered.some(id => state.ids.includes(id))) commit({...state, ids: state.ids.filter(id => !entered.includes(id))});
|
|
388
|
+
},
|
|
389
|
+
primeActive: ids => {active = new Set(ids);},
|
|
390
|
+
reload: () => {
|
|
391
|
+
try {const raw = storage?.getItem(UNREAD_KEY); state = unreadPrefs(raw?.length > 6e6 ? null : JSON.parse(raw)); error = ''; notify();} catch {}
|
|
392
|
+
},
|
|
393
|
+
};
|
|
394
|
+
}
|
|
395
|
+
function installUnread(ctx, store) {
|
|
396
|
+
const activeIds = () => Object.values(ctx.sessions.list.getSnapshot()?.byId || {})
|
|
397
|
+
.filter(row => (row.retainedBy?.mainView ?? 0) > 0).map(row => row.id);
|
|
398
|
+
store.primeActive(activeIds());
|
|
399
|
+
const stopSessions = ctx.sessions.list.subscribe(() => store.observeActive(activeIds()));
|
|
400
|
+
const unmenu = ctx.contextMenus.register({id: 'deepsearch.manual-unread', target: 'session', order: 350,
|
|
401
|
+
observe: () => [store],
|
|
402
|
+
resolve: ({sessionId}) => {
|
|
403
|
+
const state = store.getSnapshot(); if (!state.enabled) return [];
|
|
404
|
+
const unread = state.ids.includes(sessionId);
|
|
405
|
+
return [{id: 'deepsearch-toggle-unread', label: unread ? '标记为已读' : '标记为未读',
|
|
406
|
+
run: () => store.mark(sessionId, !unread)}];
|
|
407
|
+
}});
|
|
408
|
+
const onStorage = event => {if (event.key === UNREAD_KEY || event.key === null) store.reload();};
|
|
409
|
+
window.addEventListener('storage', onStorage);
|
|
410
|
+
return () => {
|
|
411
|
+
stopSessions(); unmenu();
|
|
412
|
+
window.removeEventListener('storage', onStorage);
|
|
413
|
+
};
|
|
414
|
+
}
|
|
146
415
|
function Icon({folder = false}) {
|
|
147
416
|
return h('svg', {width: 19, height: 19, viewBox: '0 0 24 24', fill: 'none', stroke: 'currentColor', strokeWidth: 1.6, 'aria-hidden': true},
|
|
148
417
|
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'})));
|
|
@@ -152,21 +421,47 @@ window.__ModuleLoader__.load({
|
|
|
152
421
|
if (!preview.range) return preview.text;
|
|
153
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]));
|
|
154
423
|
}
|
|
155
|
-
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";
|
|
156
|
-
const
|
|
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";
|
|
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)}';
|
|
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}';
|
|
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}';
|
|
157
429
|
return {
|
|
158
|
-
inject: ['slots', 'layout', 'uiWorkspace', 'uiSession', 'sessions'],
|
|
430
|
+
inject: ['slots', 'layout', 'uiWorkspace', 'uiSession', 'sessions', 'workspaces', 'contextMenus', 'shortcuts'],
|
|
159
431
|
apply(ctx) {
|
|
160
|
-
let
|
|
161
|
-
const
|
|
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
|
+
});
|
|
439
|
+
const unreadStore = createUnreadStore(storage);
|
|
440
|
+
ctx.effect(() => installUnread(ctx, unreadStore));
|
|
441
|
+
function ManualUnreadDot({sessionId, useManualUnread}) {
|
|
442
|
+
const unread = useManualUnread(state => state.enabled && state.ids.includes(sessionId));
|
|
443
|
+
// The host owns placement and status priority; reuse its exact unread visual.
|
|
444
|
+
return unread ? h('span', {'aria-label': '手动未读', title: 'DeepSearch 手动未读',
|
|
445
|
+
style: {display: 'inline-flex'}}, h(StateDot, {state: 'done'})) : null;
|
|
446
|
+
}
|
|
447
|
+
ctx.slots.inject('sidebar.session.row.leading', () => ctx.slots.register({
|
|
448
|
+
name: 'sidebar.session.row.leading', id: 'deepsearch-manual-unread', order: 50,
|
|
449
|
+
inject: () => ({hooks: {manualUnread: unreadStore}}),
|
|
450
|
+
}, ManualUnreadDot));
|
|
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;
|
|
454
|
+
const listeners = new Set(), recoveries = new Map();
|
|
162
455
|
const notify = () => { for (const listener of listeners) listener(); };
|
|
163
456
|
const subscribe = listener => { listeners.add(listener); return () => listeners.delete(listener); };
|
|
164
457
|
const setOpen = value => {
|
|
165
|
-
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());}
|
|
459
|
+
if (!value) selectionEpoch++;
|
|
166
460
|
opened = value; notify();
|
|
167
461
|
if (!value && previousFocus?.isConnected) previousFocus.focus?.({preventScroll: true});
|
|
168
462
|
};
|
|
169
463
|
function clearIntent() {
|
|
464
|
+
cancelProjectReveal?.(); cancelProjectReveal = undefined;
|
|
170
465
|
const current = intent; intent = null;
|
|
171
466
|
const release = releaseShell; releaseShell = undefined;
|
|
172
467
|
current?.cancelDOM?.(); release?.(); window.CSS?.highlights?.delete('deepsearch-hit'); notify();
|
|
@@ -189,7 +484,16 @@ window.__ModuleLoader__.load({
|
|
|
189
484
|
throw failure;
|
|
190
485
|
}
|
|
191
486
|
}
|
|
487
|
+
function archiveState(sessionId) {
|
|
488
|
+
const snapshot = ctx.workspaces?.list?.getSnapshot();
|
|
489
|
+
if (snapshot?.phase !== 'ready' || snapshot.state !== 'idle' || !Array.isArray(snapshot.archivedSessionIds)) throw new Error('无法确认会话归档状态,请等待工作区加载后重试');
|
|
490
|
+
return snapshot.archivedSessionIds.includes(sessionId);
|
|
491
|
+
}
|
|
192
492
|
function beginJump(item, query) {
|
|
493
|
+
// Defense in depth: even imperative callers cannot reopen a known archived session.
|
|
494
|
+
if (disposed) throw new Error('搜索已关闭');
|
|
495
|
+
if (recoveries.has(item.sessionId)) throw new Error('恢复请求仍在进行,请等待完成后重试');
|
|
496
|
+
if (ctx.workspaces?.list && archiveState(item.sessionId)) throw new Error('会话已归档,请先确认恢复并打开');
|
|
193
497
|
clearIntent();
|
|
194
498
|
ctx.uiWorkspace.openSession(item.sessionId); ctx.layout.selectPanel(null);
|
|
195
499
|
if (!Number.isSafeInteger(item.seq)) {setOpen(false); return;}
|
|
@@ -299,13 +603,21 @@ window.__ModuleLoader__.load({
|
|
|
299
603
|
}
|
|
300
604
|
function Overlay() {
|
|
301
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');
|
|
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);
|
|
302
611
|
const [query, setQuery] = React.useState(''), [tab, setTab] = React.useState('all');
|
|
303
|
-
const [workspace, setWorkspace] = React.useState(''), [archived, setArchived] = React.useState(
|
|
612
|
+
const [workspace, setWorkspace] = React.useState(''), [archived, setArchived] = React.useState(true);
|
|
304
613
|
const [catalog, setCatalog] = React.useState({sessions: [], workspaces: []}), [catalogError, setCatalogError] = React.useState('');
|
|
305
614
|
const [result, setResult] = React.useState({items: [], cursor: null, scanned: 0, totalSessions: 0, warnings: []});
|
|
306
615
|
const [busy, setBusy] = React.useState(false), [error, setError] = React.useState(''), [index, setIndex] = React.useState(0), [retry, setRetry] = React.useState(0);
|
|
307
616
|
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
617
|
const [composing, setComposing] = React.useState(false);
|
|
618
|
+
const [confirmation, setConfirmation] = React.useState(null), [openError, setOpenError] = React.useState('');
|
|
619
|
+
const selection = React.useRef(null);
|
|
620
|
+
const cancelSelection = () => {selection.current?.cancel?.(); selection.current = null; setConfirmation(null); setOpenError('');};
|
|
309
621
|
const [appearance, setAppearance] = React.useState(() => {try {return readAppearance(window.localStorage);} catch {return appearancePrefs(null);}});
|
|
310
622
|
const [settings, setSettings] = React.useState(false), [appearanceError, setAppearanceError] = React.useState('');
|
|
311
623
|
const updateAppearance = value => {
|
|
@@ -313,18 +625,28 @@ window.__ModuleLoader__.load({
|
|
|
313
625
|
let saved = false; try {saved = saveAppearance(window.localStorage, next);} catch {}
|
|
314
626
|
setAppearanceError(saved ? '' : '本次外观已应用,但浏览器禁止保存;重新打开后可能恢复默认。');
|
|
315
627
|
};
|
|
316
|
-
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]);
|
|
317
638
|
const request = {query: query.trim(), ...(workspace ? {workspaceId: workspace} : {}), ...(preferredSessionId ? {preferredSessionId} : {}), includeArchived: archived};
|
|
318
639
|
requestRef.current = request;
|
|
319
640
|
const key = JSON.stringify(request);
|
|
320
641
|
const renderKey = JSON.stringify([key, tab, visible, composing, retry]);
|
|
321
642
|
const activeRender = React.useRef(renderKey); activeRender.current = renderKey;
|
|
643
|
+
React.useEffect(() => {cancelSelection(); return () => {selection.current?.cancel?.(); selection.current = null;};}, [renderKey]);
|
|
322
644
|
React.useEffect(() => {
|
|
323
645
|
if (!visible) return;
|
|
324
646
|
input.current?.focus();
|
|
325
647
|
const controller = new AbortController();
|
|
326
648
|
setCatalogError('');
|
|
327
|
-
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);});
|
|
328
650
|
const outside = event => {if (panel.current && !panel.current.contains(event.target)) {event.preventDefault(); event.stopPropagation(); setOpen(false);}};
|
|
329
651
|
document.addEventListener('pointerdown', outside, true);
|
|
330
652
|
return () => {controller.abort(); document.removeEventListener('pointerdown', outside, true);};
|
|
@@ -349,19 +671,72 @@ window.__ModuleLoader__.load({
|
|
|
349
671
|
}, [key, visible, tab, composing, retry]);
|
|
350
672
|
const projects = (catalog.workspaces || []).filter(project => (!workspace || project.id === workspace) &&
|
|
351
673
|
(!request.query || (project.title || '').toLocaleLowerCase().includes(request.query.toLocaleLowerCase()))).map(project => ({...project, kind: 'project'}));
|
|
352
|
-
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 || '未分配项目'}));
|
|
353
675
|
const visibleHits = result.renderOwner === renderKey ? result.items : [];
|
|
354
|
-
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;
|
|
355
678
|
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
679
|
function choose(item) {
|
|
358
|
-
if (!item) return;
|
|
359
|
-
if (
|
|
360
|
-
|
|
680
|
+
if (!item || !opened || disposed || activeRender.current !== renderKey) return;
|
|
681
|
+
if (selection.current?.pending) return;
|
|
682
|
+
cancelSelection();
|
|
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
|
+
}
|
|
695
|
+
const isArchived = archiveState(item.sessionId);
|
|
696
|
+
if (!isArchived && recoveries.has(item.sessionId)) throw new Error('恢复请求仍在进行,请等待完成后重试');
|
|
697
|
+
if (isArchived) {
|
|
698
|
+
const selected = {item, query: request.query, renderOwner: renderKey, epoch: selectionEpoch};
|
|
699
|
+
selection.current = selected; setConfirmation(selected); return;
|
|
700
|
+
}
|
|
701
|
+
beginJump(item, request.query);
|
|
702
|
+
} catch (failure) {setOpenError('打开失败:' + failure.message);}
|
|
703
|
+
}
|
|
704
|
+
async function restoreAndOpen() {
|
|
705
|
+
const selected = selection.current;
|
|
706
|
+
const current = () => selected && selection.current === selected && !disposed && opened && selectionEpoch === selected.epoch && activeRender.current === selected.renderOwner;
|
|
707
|
+
if (!current() || selected.pending) return;
|
|
708
|
+
selected.pending = true; setConfirmation({...selected}); setOpenError('');
|
|
709
|
+
let timer;
|
|
710
|
+
try {
|
|
711
|
+
const stillArchived = archiveState(selected.item.sessionId);
|
|
712
|
+
let recovery = recoveries.get(selected.item.sessionId);
|
|
713
|
+
if (stillArchived || recovery) {
|
|
714
|
+
if (!recovery) {
|
|
715
|
+
if (recoveries.size >= 4) throw new Error('已有多个恢复请求正在进行,请等待完成后重试');
|
|
716
|
+
if (typeof ctx.uiWorkspace.unarchiveSession !== 'function') throw new Error('当前宿主不支持恢复归档会话,请升级后重试');
|
|
717
|
+
recovery = Promise.resolve(ctx.uiWorkspace.unarchiveSession(selected.item.sessionId));
|
|
718
|
+
recoveries.set(selected.item.sessionId, recovery);
|
|
719
|
+
const finished = () => {if (recoveries.get(selected.item.sessionId) === recovery) recoveries.delete(selected.item.sessionId);};
|
|
720
|
+
recovery.then(finished, finished);
|
|
721
|
+
}
|
|
722
|
+
// A timeout/cancel stops this navigation, not the host's already submitted recovery.
|
|
723
|
+
await new Promise((resolve, reject) => {
|
|
724
|
+
selected.cancel = () => {clearTimeout(timer); resolve();};
|
|
725
|
+
timer = setTimeout(() => reject(new Error('恢复超时;请求可能仍在完成,请刷新归档状态后重试')), 15000);
|
|
726
|
+
recovery.then(resolve, reject);
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
if (!current()) return;
|
|
730
|
+
if (archiveState(selected.item.sessionId)) throw new Error('恢复尚未确认,会话仍在归档中;请刷新归档状态后重试');
|
|
731
|
+
beginJump(selected.item, selected.query);
|
|
732
|
+
} catch (failure) {
|
|
733
|
+
if (current()) {selected.pending = false; setConfirmation({...selected}); setOpenError('恢复失败:' + failure.message);}
|
|
734
|
+
} finally {clearTimeout(timer); selected.cancel = undefined;}
|
|
361
735
|
}
|
|
362
736
|
if (!visible) return null;
|
|
363
737
|
const more = () => {
|
|
364
738
|
if (busy || !result.cursor || result.items.length >= MAX_RESULTS) return;
|
|
739
|
+
cancelSelection();
|
|
365
740
|
control.current?.abort(); const controller = new AbortController(); control.current = controller;
|
|
366
741
|
const owner = ++generation.current; setBusy(true); setError('');
|
|
367
742
|
fetchPage(result.cursor, true, owner, request, controller, renderKey);
|
|
@@ -370,9 +745,15 @@ window.__ModuleLoader__.load({
|
|
|
370
745
|
const status = searchStatus({busy: busy || (request.query && tab !== 'projects' && !composing && result.renderOwner !== renderKey && !error), error, result: displayResult, query: request.query, projects: tab === 'projects'});
|
|
371
746
|
function onKey(event) {
|
|
372
747
|
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) {
|
|
375
|
-
|
|
748
|
+
if (event.key === 'Escape') {event.preventDefault(); event.stopPropagation(); if (selection.current) cancelSelection(); else setOpen(false);}
|
|
749
|
+
if ((event.key === 'ArrowDown' || event.key === 'ArrowUp') && event.target === input.current) {
|
|
750
|
+
event.preventDefault();
|
|
751
|
+
const next = items.length ? (index + (event.key === 'ArrowDown' ? 1 : items.length - 1)) % items.length : 0;
|
|
752
|
+
setIndex(next);
|
|
753
|
+
// Hover changes highlight only; scrolling belongs exclusively to keyboard navigation.
|
|
754
|
+
if (items.length) list.current?.querySelector('#deepsearch-result-' + next)?.scrollIntoView({block: 'nearest', behavior: 'instant'});
|
|
755
|
+
}
|
|
756
|
+
if (event.key === 'Enter' && event.target === input.current) {event.preventDefault(); if (!selection.current) choose(items[index]);}
|
|
376
757
|
if (event.key === 'Tab') {
|
|
377
758
|
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
759
|
const first = focusable[0], last = focusable[focusable.length - 1];
|
|
@@ -381,44 +762,70 @@ window.__ModuleLoader__.load({
|
|
|
381
762
|
}
|
|
382
763
|
}
|
|
383
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},
|
|
384
|
-
h('style', null, css + appearanceCss),
|
|
765
|
+
h('style', null, css + appearanceCss + archiveCss + extensionCss + historyCss),
|
|
385
766
|
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)}, '
|
|
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)}),
|
|
768
|
+
h('button', {className: 'deepsearch-escape', 'aria-expanded': settings, 'aria-controls': 'deepsearch-appearance', onClick: () => setSettings(value => !value)}, '设置'),
|
|
388
769
|
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': '
|
|
390
|
-
h('label', null, '背景模式', h('select', {value: appearance.mode, onChange: e => updateAppearance({...appearance, mode:e.target.value})},
|
|
770
|
+
settings && h('div', {className: 'deepsearch-appearance', id: 'deepsearch-appearance', role: 'group', 'aria-label': 'DeepSearch 设置'},
|
|
771
|
+
h('div', {className: 'deepsearch-appearance-controls'}, h('label', null, '背景模式', h('select', {value: appearance.mode, onChange: e => updateAppearance({...appearance, mode:e.target.value})},
|
|
391
772
|
...[['glass','毛玻璃'],['theme','跟随 DSH'],['custom','自定义']].map(([value,label]) => h('option',{key:value,value},label)))),
|
|
392
773
|
appearance.mode === 'custom' && h('label', null, '底色', h('input', {type:'color', value:appearance.color, onChange:e=>updateAppearance({...appearance,color:e.target.value})})),
|
|
393
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)})})),
|
|
394
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)})})),
|
|
395
|
-
h('button', {onClick:()=>updateAppearance(null)}, '
|
|
396
|
-
appearanceError && h('p', {role:'status'}, appearanceError)
|
|
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'})))),
|
|
777
|
+
appearanceError && h('p', {role:'status'}, appearanceError),
|
|
778
|
+
h('div', {className: 'deepsearch-extension'},
|
|
779
|
+
h('div', null, h('strong', {id: 'deepsearch-unread-label'}, '会话未读标记'), h('p', {id: 'deepsearch-unread-help'}, '扩展小功能 · 右键标记未读,再次打开自动已读。仅存本机;关闭保留标记。')),
|
|
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}))),
|
|
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)}, '恢复原快捷键绑定')),
|
|
397
789
|
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)))),
|
|
400
|
-
h('div', {className: 'deepsearch-caption'},
|
|
401
|
-
tab !== 'projects'
|
|
402
|
-
|
|
403
|
-
|
|
790
|
+
...[['all', '全部'], ['conversations', '对话'], ['projects', '项目']].map(([value, label]) => h('button', {key: value, role: 'tab', 'aria-selected': tab === value, onClick: () => {cancelSelection(); setTab(value);}}, label))),
|
|
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)))),
|
|
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)},
|
|
404
805
|
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 || '未命名会话'),
|
|
806
|
+
h('span', {className: 'deepsearch-result-text'}, h('span', {className: 'deepsearch-result-title'}, item.title || '未命名会话', item.archived === true && h('span', {className: 'deepsearch-archived'}, '已归档')),
|
|
406
807
|
item.snippet && h('span', {className: 'deepsearch-snippet'}, h(Mark, {text: item.snippet, range: item.range})),
|
|
407
|
-
h('span', {className: 'deepsearch-meta'}, item.kind === 'project' ? '工作区 ·
|
|
408
|
-
[item.role === 'user' ? '你' : item.role === 'assistant' ? '助手' : '会话标题', item.workspaceTitle, formatMessageTime(item.time)].filter(Boolean).join(' · '))), h('span', {className: 'deepsearch-return', 'aria-hidden': true}, '↵'))),
|
|
409
|
-
!items.length && h('div', {className: 'deepsearch-empty', role: 'status'}, h(Icon), h('strong', null, status.empty),
|
|
410
|
-
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 ? '支持连续中文片段,不需要输入整句话。' : '中文片段、英文关键词,都可以。'))),
|
|
812
|
+
confirmation && h('div', {className: 'deepsearch-confirm', role: 'group', 'aria-label': '恢复归档会话', 'aria-busy': !!confirmation.pending},
|
|
813
|
+
h('strong', null, '此会话已归档'),
|
|
814
|
+
h('p', null, '恢复“' + (confirmation.item.title || '未命名会话') + '”后将在原生会话中打开;取消会保留当前结果。'),
|
|
815
|
+
h('button', {onClick: restoreAndOpen, disabled: !!confirmation.pending}, confirmation.pending ? '正在恢复…' : '恢复并打开'),
|
|
816
|
+
h('button', {onClick: cancelSelection}, '取消')),
|
|
817
|
+
openError && h('div', {className: 'deepsearch-error', role: 'alert'}, openError),
|
|
411
818
|
(error || catalogError) && h('div', {className: 'deepsearch-error', role: 'alert'}, error || '目录读取失败:' + catalogError, h('button', {onClick: () => error && displayResult.cursor ? more() : setRetry(value => value + 1)}, '重试')),
|
|
412
819
|
displayResult.warnings?.length > 0 && h('div', {className: 'deepsearch-warning', role: 'status'}, '部分历史读取失败(' + displayResult.warnings.length + ');当前结果可能不完整。'),
|
|
413
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 ? '正在继续扫描…' : '继续搜索剩余历史'),
|
|
414
|
-
h('footer', {className: 'deepsearch-footer'}, h('span', null, h('strong', null, 'DeepSearch'), ' 0.1.
|
|
415
|
-
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),
|
|
416
823
|
h('span', {className: 'deepsearch-key-hint'}, '↑↓ 选择 ↵ 打开')));
|
|
417
824
|
}
|
|
418
825
|
ctx.effect(() => {
|
|
419
826
|
const onKey = event => {if (!isShortcut(event)) return; event.preventDefault(); event.stopPropagation(); setOpen(!opened);};
|
|
420
827
|
window.addEventListener('keydown', onKey, true);
|
|
421
|
-
return () => {window.removeEventListener('keydown', onKey, true); setOpen(false); clearIntent();};
|
|
828
|
+
return () => {disposed = true; window.removeEventListener('keydown', onKey, true); setOpen(false); clearIntent();};
|
|
422
829
|
});
|
|
423
830
|
ctx.slots.inject('shell.overlay', () => ctx.slots.register({name: 'shell.overlay', id: 'deepsearch'}, Overlay));
|
|
424
831
|
}
|
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",
|
|
@@ -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.
|
|
71
|
+
"check": "node --check client.js && node --check host.js && node --check search-core.js && node --check runtime-0.1.17.js"
|
|
69
72
|
}
|
|
70
73
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './host.js?deepsearch=0.1.17';
|
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 &&
|
|
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);
|
|
@@ -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, workspaceId}) => ({id, title: title.slice(0, 512), ...(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) {
|
|
@@ -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';
|