my-dsh-message-search 0.2.0 → 0.2.1
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/client.js +5 -33
- package/host.js +1 -1
- package/package.json +4 -2
package/client.js
CHANGED
|
@@ -16,7 +16,7 @@ window.__ModuleLoader__.load({
|
|
|
16
16
|
const h = React.createElement
|
|
17
17
|
const NS = 'messageSearch'
|
|
18
18
|
const ROUTE = 'api/message-search'
|
|
19
|
-
const UI_REVISION = '2026-11-
|
|
19
|
+
const UI_REVISION = '2026-11-18.1'
|
|
20
20
|
|
|
21
21
|
const zh = {
|
|
22
22
|
title: '检索消息',
|
|
@@ -40,8 +40,6 @@ window.__ModuleLoader__.load({
|
|
|
40
40
|
emptyNoSession: '当前没有打开的会话;可切到「工作区」或「全部会话」。',
|
|
41
41
|
hint: '↑↓ 选择 · Enter 打开 · Esc 关闭',
|
|
42
42
|
close: '关闭检索',
|
|
43
|
-
roundsLabel: '定位轮数 {count}',
|
|
44
|
-
roundsHint: '命中后最多滚动多少轮去定位该消息',
|
|
45
43
|
untitled: '未命名会话',
|
|
46
44
|
ungrouped: '未分组',
|
|
47
45
|
roleUser: '我',
|
|
@@ -71,8 +69,6 @@ window.__ModuleLoader__.load({
|
|
|
71
69
|
emptyNoSession: 'No session is open; switch to Workspace or All sessions.',
|
|
72
70
|
hint: '↑↓ select · Enter open · Esc close',
|
|
73
71
|
close: 'Close search',
|
|
74
|
-
roundsLabel: 'Scroll rounds {count}',
|
|
75
|
-
roundsHint: 'How many scroll rounds to spend locating the message',
|
|
76
72
|
untitled: 'Untitled session',
|
|
77
73
|
ungrouped: 'No workspace',
|
|
78
74
|
roleUser: 'You',
|
|
@@ -167,9 +163,6 @@ body[data-ds-dark-theme] .msn-layer{background:rgba(0,0,0,.55)}
|
|
|
167
163
|
.msn-menu-empty{padding:8px 10px;font-size:12.5px;color:var(--dsw-alias-label-caption)}
|
|
168
164
|
.msn-status{display:flex;align-items:center;gap:10px;padding:10px 24px 6px;font-size:12.5px;color:var(--dsw-alias-label-caption);min-height:28px}
|
|
169
165
|
.msn-status-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
170
|
-
.msn-rounds{display:inline-flex;align-items:center;gap:8px;flex:none;font-size:12px;color:var(--dsw-alias-label-caption)}
|
|
171
|
-
.msn-rounds-label{white-space:nowrap;font-variant-numeric:tabular-nums}
|
|
172
|
-
.msn-range{width:96px;accent-color:var(--dsw-alias-label-primary);cursor:pointer}
|
|
173
166
|
.msn-status-error{color:var(--dsw-alias-state-error-primary)}
|
|
174
167
|
.msn-note{padding:0 24px 8px;font-size:12px;color:var(--dsw-alias-label-caption)}
|
|
175
168
|
.msn-list{flex:1;margin:0;padding:6px 14px 10px;list-style:none;overflow:auto;border-top:0.5px solid var(--dsw-alias-border-l4);min-height:0}
|
|
@@ -251,17 +244,16 @@ body[data-ds-dark-theme] .msn-layer{background:rgba(0,0,0,.55)}
|
|
|
251
244
|
/**
|
|
252
245
|
* 定位入口:包一层 try/catch,出错时给出明确提示而不是静默。
|
|
253
246
|
* @param {{snippet?: string, turn?: number}} hit - 命中。
|
|
254
|
-
* @param {number} maxRounds - 轮数上限。
|
|
255
247
|
*/
|
|
256
|
-
function locateMessage(hit,
|
|
248
|
+
function locateMessage(hit, keyword = '') {
|
|
257
249
|
try {
|
|
258
|
-
locateMessageInner(hit,
|
|
250
|
+
locateMessageInner(hit, keyword)
|
|
259
251
|
} catch (error) {
|
|
260
252
|
locateFailed(error instanceof Error ? error.message : String(error))
|
|
261
253
|
}
|
|
262
254
|
}
|
|
263
255
|
|
|
264
|
-
function locateMessageInner(hit,
|
|
256
|
+
function locateMessageInner(hit, keyword = '') {
|
|
265
257
|
if (typeof document === 'undefined') return
|
|
266
258
|
// 优先用从关键词开始的 match:片段开头是前置上下文,拿它定位会偏到上一行
|
|
267
259
|
const raw = String(hit?.match ?? hit?.snippet ?? '').replace(/^…/, '').replace(/…$/, '')
|
|
@@ -586,13 +578,6 @@ body[data-ds-dark-theme] .msn-layer{background:rgba(0,0,0,.55)}
|
|
|
586
578
|
const [workspaces, setWorkspaces] = React.useState([])
|
|
587
579
|
const [workspaceId, setWorkspaceId] = React.useState('')
|
|
588
580
|
const [menuOpen, setMenuOpen] = React.useState(false)
|
|
589
|
-
const [maxRounds, setMaxRounds] = React.useState(() => {
|
|
590
|
-
try {
|
|
591
|
-
const stored = Number(window.localStorage.getItem('msn.maxRounds'))
|
|
592
|
-
if (Number.isFinite(stored) && stored >= 20) return Math.min(400, stored)
|
|
593
|
-
} catch { /* 读不到用默认 */ }
|
|
594
|
-
return 120
|
|
595
|
-
})
|
|
596
581
|
const [phase, setPhase] = React.useState('idle')
|
|
597
582
|
const [result, setResult] = React.useState(null)
|
|
598
583
|
const [failure, setFailure] = React.useState(null)
|
|
@@ -726,7 +711,7 @@ body[data-ds-dark-theme] .msn-layer{background:rgba(0,0,0,.55)}
|
|
|
726
711
|
const openSession = (id, hit) => {
|
|
727
712
|
setOpen(false)
|
|
728
713
|
props.openSession(id)
|
|
729
|
-
if (hit !== undefined) locateMessage(hit,
|
|
714
|
+
if (hit !== undefined) locateMessage(hit, query.trim())
|
|
730
715
|
}
|
|
731
716
|
|
|
732
717
|
// 边输边搜:输入、范围、工作区任一变,250ms 无新输入就自动检索,不用回车。
|
|
@@ -928,19 +913,6 @@ body[data-ds-dark-theme] .msn-layer{background:rgba(0,0,0,.55)}
|
|
|
928
913
|
]),
|
|
929
914
|
h('div', { key: 'status', className: `msn-status ${phase === 'error' ? 'msn-status-error' : ''}`, 'aria-live': 'polite' }, [
|
|
930
915
|
h('span', { key: 'txt', className: 'msn-status-text' }, statusText),
|
|
931
|
-
h('label', { key: 'rounds', className: 'msn-rounds', title: tr('roundsHint') }, [
|
|
932
|
-
h('span', { key: 'l', className: 'msn-rounds-label' }, tr('roundsLabel', { count: String(maxRounds) })),
|
|
933
|
-
h('input', {
|
|
934
|
-
key: 'i', type: 'range', className: 'msn-range',
|
|
935
|
-
min: 20, max: 400, step: 20, value: maxRounds,
|
|
936
|
-
'aria-label': tr('roundsLabel', { count: String(maxRounds) }),
|
|
937
|
-
onChange: (event) => {
|
|
938
|
-
const next = Number(event.target.value)
|
|
939
|
-
setMaxRounds(next)
|
|
940
|
-
try { window.localStorage.setItem('msn.maxRounds', String(next)) } catch { /* 存不了就算了 */ }
|
|
941
|
-
},
|
|
942
|
-
}),
|
|
943
|
-
]),
|
|
944
916
|
]),
|
|
945
917
|
result !== null && result.truncated ? h('div', { key: 'trunc', className: 'msn-note' }, tr('truncated', { max: String(result.maxHits) })) : null,
|
|
946
918
|
h('div', { key: 'body', className: 'msn-body' },
|
package/host.js
CHANGED
|
@@ -23,7 +23,7 @@ export const name = 'message-search'
|
|
|
23
23
|
/** Client 页面读取的私有路由。 */
|
|
24
24
|
const HTTP_PATH = '/api/message-search'
|
|
25
25
|
/** Host 构建标记。 */
|
|
26
|
-
const HOST_REVISION = '2026-11-
|
|
26
|
+
const HOST_REVISION = '2026-11-18.1'
|
|
27
27
|
/** 一次检索最多返回多少条命中。 */
|
|
28
28
|
const DEFAULT_MAX_HITS = 200
|
|
29
29
|
/** 片段前后各取多少字符。 */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "my-dsh-message-search",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "跨会话消息检索:Ctrl+F 打开,按当前会话 / 工作区 / 全部会话检索消息正文",
|
|
6
6
|
"repository": {
|
|
@@ -23,7 +23,9 @@
|
|
|
23
23
|
"README.md"
|
|
24
24
|
],
|
|
25
25
|
"dsh": {
|
|
26
|
-
"bundle": {
|
|
26
|
+
"bundle": {
|
|
27
|
+
"patch": "./cordis.patch.yml"
|
|
28
|
+
},
|
|
27
29
|
"client": {
|
|
28
30
|
"platform": "web",
|
|
29
31
|
"immediately": true,
|