dsh-content-search-ad 0.27.2 → 0.28.0
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 +53 -12
- package/index.js +1 -1
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -19,7 +19,7 @@ window.__ModuleLoader__.load({
|
|
|
19
19
|
/** Locale namespace owned by this plugin. */
|
|
20
20
|
const NS = 'contentSearch'
|
|
21
21
|
/** Plugin version, shown in the panel so a running build can be identified. */
|
|
22
|
-
const PLUGIN_VERSION = '0.
|
|
22
|
+
const PLUGIN_VERSION = '0.28.0'
|
|
23
23
|
/** Tab-type identity; the body slot registers under the same key. */
|
|
24
24
|
const TAB_ID = 'dsh-content-search-ad/panel'
|
|
25
25
|
/** Page kind opened by the guide card and the strip's add control. */
|
|
@@ -815,6 +815,7 @@ window.__ModuleLoader__.load({
|
|
|
815
815
|
.dcs-results{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:6px 6px 10px}
|
|
816
816
|
.dcs-chat{flex:0 0 auto;display:flex;flex-direction:column;max-height:42%;border-top:1px solid var(--dsw-alias-border-l1);background:var(--dsw-alias-bg-layer-1)}
|
|
817
817
|
.dcs-chat-head{flex:0 0 auto;margin:9px 10px 5px;font-size:.9em;line-height:1.4}
|
|
818
|
+
.dcs-chat-note{margin:0 10px 5px;font-size:.85em;line-height:1.4;color:var(--dsw-alias-label-tertiary)}
|
|
818
819
|
.dcs-chat-list{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:2px 8px 8px;display:flex;flex-direction:column;gap:6px}
|
|
819
820
|
.dcs-question{flex:0 0 auto;min-height:2.4em;width:100%;box-sizing:border-box;padding:.55em .7em;border:1px solid var(--dsw-alias-border-l1);border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-layer-2,transparent);color:var(--dsw-alias-label-secondary);font:inherit;font-size:.95em;line-height:1.55;text-align:left;cursor:pointer;white-space:normal;overflow-wrap:anywhere}
|
|
820
821
|
.dcs-question:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
|
|
@@ -1104,10 +1105,38 @@ window.__ModuleLoader__.load({
|
|
|
1104
1105
|
* message is older than the loaded window.
|
|
1105
1106
|
* @returns whether it was found immediately.
|
|
1106
1107
|
*/
|
|
1107
|
-
|
|
1108
|
+
/** Try several anchor windows, best first, and return the first transcript hit. */
|
|
1109
|
+
function findAnchorAny(blocks, needles) {
|
|
1110
|
+
for (const needle of needles) {
|
|
1111
|
+
if (typeof needle !== 'string') continue
|
|
1112
|
+
const trimmed = needle.trim()
|
|
1113
|
+
if (trimmed.length < 6) continue
|
|
1114
|
+
const hit = findAnchor(blocks, trimmed)
|
|
1115
|
+
if (hit !== undefined) return hit
|
|
1116
|
+
}
|
|
1117
|
+
return undefined
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
/** Anchor windows worth trying for one question message. */
|
|
1121
|
+
function anchorCandidates(anchor, text) {
|
|
1122
|
+
const whole = typeof text === 'string' ? text : ''
|
|
1123
|
+
const tail = whole.length > 20 ? whole.slice(-80) : ''
|
|
1124
|
+
const middle = whole.length > 80 ? whole.slice(20, 100) : ''
|
|
1125
|
+
return [anchor, tail, whole.slice(0, 60), middle, whole.slice(0, 30), anchor.slice(0, 24)]
|
|
1126
|
+
}
|
|
1127
|
+
|
|
1128
|
+
/**
|
|
1129
|
+
* Center one question in the transcript, paging history to it when needed.
|
|
1130
|
+
*
|
|
1131
|
+
* A long prompt can start with pasted code, and the code's rendered text need
|
|
1132
|
+
* not equal the source, so the exact anchor is only the first candidate: the
|
|
1133
|
+
* tail and inner windows are tried next. Resolves to whether it was found.
|
|
1134
|
+
*/
|
|
1135
|
+
async function revealText(sessionId, anchor, seq, text) {
|
|
1108
1136
|
if (typeof anchor !== 'string' || anchor.length < 4) return false
|
|
1109
1137
|
ensureHighlightStyle()
|
|
1110
1138
|
if (!highlightSupported()) return false
|
|
1139
|
+
const needles = anchorCandidates(anchor, text)
|
|
1111
1140
|
/** Mark the whole chat node the anchor landed in, not just the window. */
|
|
1112
1141
|
const paint = (hit) => {
|
|
1113
1142
|
const host = hit.element !== null && typeof hit.element.closest === 'function'
|
|
@@ -1117,20 +1146,23 @@ window.__ModuleLoader__.load({
|
|
|
1117
1146
|
CSS.highlights.set(ACTIVE_NAME, ranges.length > 0 ? new Highlight(...ranges) : new Highlight(hit.range))
|
|
1118
1147
|
revealElement(hit.element)
|
|
1119
1148
|
}
|
|
1120
|
-
const found =
|
|
1149
|
+
const found = findAnchorAny(indexTranscript(true), needles)
|
|
1121
1150
|
if (found !== undefined) {
|
|
1122
1151
|
paint(found)
|
|
1123
1152
|
return true
|
|
1124
1153
|
}
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
}
|
|
1131
|
-
return false
|
|
1154
|
+
let paged = false
|
|
1155
|
+
try {
|
|
1156
|
+
paged = await pageToHit(sessionId, seq)
|
|
1157
|
+
} catch {
|
|
1158
|
+
paged = false
|
|
1159
|
+
}
|
|
1160
|
+
if (!paged) return false
|
|
1161
|
+
const retry = findAnchorAny(indexTranscript(true), needles)
|
|
1162
|
+
if (retry === undefined) return false
|
|
1163
|
+
paint(retry)
|
|
1164
|
+
return true
|
|
1132
1165
|
}
|
|
1133
|
-
|
|
1134
1166
|
//#region component
|
|
1135
1167
|
/**
|
|
1136
1168
|
* Everything the panel needs to survive a tab remount: the sidebar is
|
|
@@ -1206,6 +1238,7 @@ window.__ModuleLoader__.load({
|
|
|
1206
1238
|
setScopeState(value)
|
|
1207
1239
|
}, [])
|
|
1208
1240
|
const [fontPx, setFontPx] = React.useState(readFont)
|
|
1241
|
+
const [locateNote, setLocateNote] = React.useState('')
|
|
1209
1242
|
const [recent, setRecent] = React.useState(readRecent)
|
|
1210
1243
|
const [questions, setQuestions] = React.useState([])
|
|
1211
1244
|
const [questionCount, setQuestionCount] = React.useState(0)
|
|
@@ -1711,6 +1744,7 @@ window.__ModuleLoader__.load({
|
|
|
1711
1744
|
questions.length > 0
|
|
1712
1745
|
? h('div', { className: 'dcs-chat' },
|
|
1713
1746
|
h('p', { className: 'dcs-section dcs-chat-head' }, t('questions.title', { n: questionCount })),
|
|
1747
|
+
locateNote.length > 0 ? h('p', { key: 'note', className: 'dcs-chat-note' }, locateNote) : null,
|
|
1714
1748
|
h('div', { className: 'dcs-chat-list', ref: chatListRef, onScroll: (event) => {
|
|
1715
1749
|
const node = event.currentTarget
|
|
1716
1750
|
chatStickRef.current = node.scrollHeight - node.scrollTop - node.clientHeight < 48
|
|
@@ -1722,7 +1756,14 @@ window.__ModuleLoader__.load({
|
|
|
1722
1756
|
className: 'dcs-question',
|
|
1723
1757
|
'data-hit': hit ? 'true' : 'false',
|
|
1724
1758
|
title: question.text,
|
|
1725
|
-
onClick: () =>
|
|
1759
|
+
onClick: () => {
|
|
1760
|
+
setLocateNote('')
|
|
1761
|
+
revealText(focusSessionId, question.anchor, question.seq, question.text)
|
|
1762
|
+
.then((ok) => {
|
|
1763
|
+
if (!ok) setLocateNote(t('detail.missing'))
|
|
1764
|
+
})
|
|
1765
|
+
.catch(() => setLocateNote(t('detail.missing')))
|
|
1766
|
+
},
|
|
1726
1767
|
}, hit ? highlight(question.text, query, 'q' + index) : question.text)
|
|
1727
1768
|
})))
|
|
1728
1769
|
: null,
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-content-search-ad",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.28.0",
|
|
4
4
|
"description": "DeepSeek Harness (DSH) plugin: full-text search over every conversation's prose from a right sidebar tab, with a jump-to-match detail view.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "zmq6931",
|