dsh-content-search-ad 0.22.0 → 0.23.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/README.md CHANGED
@@ -63,6 +63,10 @@ is a subsequence, which turns the list into match-everything noise.
63
63
  - Ordering is legible: more hits first, then the most recent match. Title-only
64
64
  matches come last.
65
65
  - **Recent searches** appear in the empty state; one click re-runs one.
66
+ - **This chat** is listed under them: every question **you** asked in the current
67
+ conversation, one row each (injected context and tool output are filtered out
68
+ by the message source). Clicking a row scrolls to that message in the
69
+ transcript and marks it red, paging history first when it is not loaded yet.
66
70
 
67
71
  ## The detail view
68
72
 
@@ -146,6 +150,6 @@ Plugins → Add plugin → <absolute path to this directory>
146
150
 
147
151
  Or add `dsh-content-search-ad` to `dsh.profile.bundles` in the target profile.
148
152
 
149
- A known-good snapshot of the 0.13.0 tree is kept at
150
- `.scratch/backup-content-search-v0.13.0`; copying those files back over this
151
- directory and reloading the plugin returns to that version.
153
+ To roll back, check out a previous tag (`git checkout v0.22.0`) and reload the
154
+ plugin: the profile links this directory, so the running Host loads whatever is
155
+ checked out.
package/client.js CHANGED
@@ -49,6 +49,7 @@ window.__ModuleLoader__.load({
49
49
  'field.placeholder': 'Search the content of every conversation…',
50
50
  'field.clear': 'Clear search',
51
51
  'recent.title': 'Recent searches',
52
+ 'questions.title': 'This chat · {n} questions',
52
53
  'command.open': 'Search conversation content',
53
54
  'hint.idle': 'Type a keyword to search every conversation body and title.',
54
55
  'hint.shortcut': 'Press {keys} anywhere to open this panel.',
@@ -765,7 +766,10 @@ window.__ModuleLoader__.load({
765
766
  .dcs-count{flex:0 0 auto;padding:0 6px;border-radius:999px;background:var(--dsw-alias-interactive-bg-hover-accent,var(--dsw-alias-bg-layer-3));font-size:11px;line-height:17px;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-secondary)}
766
767
  .dcs-row-snippet{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;font-size:12px;line-height:1.55;color:var(--dsw-alias-label-secondary);overflow-wrap:anywhere}
767
768
  .dcs-row-meta{font-size:11px;color:var(--dsw-alias-label-tertiary);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
768
- .dcs-chevron{flex:0 0 auto;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1}.dcs-recent{display:flex;flex-wrap:wrap;gap:6px;padding:0 10px 4px}
769
+ .dcs-chevron{flex:0 0 auto;color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1}.dcs-questions{display:flex;flex-direction:column;gap:2px;padding:0 6px 6px}
770
+ .dcs-question{width:100%;box-sizing:border-box;padding:6px 8px;border:0;border-radius:var(--dsw-radius-sm);background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:1.5;text-align:left;cursor:pointer;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;overflow-wrap:anywhere}
771
+ .dcs-question:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
772
+ .dcs-recent{display:flex;flex-wrap:wrap;gap:6px;padding:0 10px 4px}
769
773
  .dcs-recent-chip{max-width:100%;padding:0 9px;height:24px;border:1px solid var(--dsw-alias-border-l2);border-radius:999px;background:transparent;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;cursor:pointer;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
770
774
  .dcs-recent-chip:hover{background:var(--dsw-alias-interactive-bg-hover);color:var(--dsw-alias-label-primary)}
771
775
  .dcs-scope{display:flex;gap:2px;margin-top:8px;padding:2px;border-radius:var(--dsw-radius-sm);background:var(--dsw-alias-bg-layer-1)}
@@ -855,8 +859,6 @@ window.__ModuleLoader__.load({
855
859
  }
856
860
  return hidden
857
861
  }
858
- /** Whether the search page is the one on screen right now. */
859
- let panelShown = false
860
862
 
861
863
  /** Recent queries, newest first. */
862
864
  function readRecent() {
@@ -982,6 +984,57 @@ window.__ModuleLoader__.load({
982
984
  }
983
985
  //#endregion
984
986
 
987
+ /**
988
+ * The user's own messages in this conversation, for the "what did I ask"
989
+ * list. The Host reads the log; the browser only renders the answer.
990
+ */
991
+ async function fetchQuestions(sessionId, signal) {
992
+ if (typeof sessionId !== 'string' || sessionId.length === 0) return { questions: [], count: 0 }
993
+ const response = await fetch('/content-search/questions?focus=' + encodeURIComponent(sessionId), {
994
+ signal,
995
+ credentials: 'same-origin',
996
+ headers: { accept: 'application/json' },
997
+ })
998
+ if (!response.ok) throw new Error('questions unavailable (HTTP ' + response.status + ')')
999
+ const payload = await response.json()
1000
+ if (payload === null || typeof payload !== 'object' || payload.ok !== true) throw new Error('questions failed')
1001
+ const questions = Array.isArray(payload.questions) ? payload.questions : []
1002
+ return {
1003
+ count: typeof payload.count === 'number' ? payload.count : questions.length,
1004
+ questions: questions.map((question) => ({
1005
+ seq: question.seq,
1006
+ time: typeof question.time === 'number' ? question.time : 0,
1007
+ text: typeof question.text === 'string' ? question.text : '',
1008
+ anchor: typeof question.anchor === 'string' ? question.anchor : '',
1009
+ })),
1010
+ }
1011
+ }
1012
+
1013
+ /**
1014
+ * Center one question in the transcript, paging history to it when the
1015
+ * message is older than the loaded window.
1016
+ * @returns whether it was found immediately.
1017
+ */
1018
+ function revealText(sessionId, anchor, seq) {
1019
+ if (typeof anchor !== 'string' || anchor.length < 4) return false
1020
+ ensureHighlightStyle()
1021
+ if (!highlightSupported()) return false
1022
+ const found = findAnchor(indexTranscript(true), anchor)
1023
+ if (found !== undefined) {
1024
+ CSS.highlights.set(ACTIVE_NAME, new Highlight(found.range))
1025
+ revealElement(found.element)
1026
+ return true
1027
+ }
1028
+ pageToHit(sessionId, seq).then((paged) => {
1029
+ if (!paged) return
1030
+ const retry = findAnchor(indexTranscript(true), anchor)
1031
+ if (retry === undefined) return
1032
+ CSS.highlights.set(ACTIVE_NAME, new Highlight(retry.range))
1033
+ revealElement(retry.element)
1034
+ }).catch(() => {})
1035
+ return false
1036
+ }
1037
+
985
1038
  //#region component
986
1039
  /**
987
1040
  * Everything the panel needs to survive a tab remount: the sidebar is
@@ -1029,9 +1082,6 @@ window.__ModuleLoader__.load({
1029
1082
  const t = makeText(props === undefined ? undefined : props.t)
1030
1083
  /** The conversation this sidebar belongs to. */
1031
1084
  const focusSessionId = props === undefined ? undefined : props.sessionId
1032
- /** Visibility seat: the shortcut collapses only while this page is shown. */
1033
- const tabInfo = props !== undefined && typeof props.useTabInfo === 'function' ? props.useTabInfo() : undefined
1034
- const tabVisible = tabInfo === undefined || tabInfo.tab === undefined ? false : tabInfo.tab.visible !== false
1035
1085
  /**
1036
1086
  * The conversation the query was typed in. A jump re-opens this panel in
1037
1087
  * the target conversation, but the result list must not regroup itself.
@@ -1058,6 +1108,8 @@ window.__ModuleLoader__.load({
1058
1108
  setScopeState(value)
1059
1109
  }, [])
1060
1110
  const [recent, setRecent] = React.useState(readRecent)
1111
+ const [questions, setQuestions] = React.useState([])
1112
+ const [questionCount, setQuestionCount] = React.useState(0)
1061
1113
 
1062
1114
  const subscribeList = React.useCallback((notify) => {
1063
1115
  const store = runtime === null ? undefined : runtime.sessions && runtime.sessions.list
@@ -1098,6 +1150,18 @@ window.__ModuleLoader__.load({
1098
1150
  if (activeInput === inputRef.current) activeInput = null
1099
1151
  }
1100
1152
  }, [])
1153
+ // The "what did I ask" list belongs to the conversation this panel is on.
1154
+ React.useEffect(() => {
1155
+ if (typeof focusSessionId !== 'string' || focusSessionId.length === 0) return undefined
1156
+ const controller = new AbortController()
1157
+ fetchQuestions(focusSessionId, controller.signal).then((outcome) => {
1158
+ if (controller.signal.aborted) return
1159
+ setQuestions(outcome.questions)
1160
+ setQuestionCount(outcome.count)
1161
+ }).catch(() => {})
1162
+ return () => controller.abort()
1163
+ }, [focusSessionId])
1164
+
1101
1165
  const trimmed = query.trim()
1102
1166
 
1103
1167
  React.useEffect(() => {
@@ -1346,6 +1410,19 @@ window.__ModuleLoader__.load({
1346
1410
  },
1347
1411
  }, value))))
1348
1412
  }
1413
+ if (questions.length > 0) {
1414
+ body.push(h('p', { key: 'questions-title', className: 'dcs-section' },
1415
+ t('questions.title', { n: questionCount })))
1416
+ body.push(h('div', { key: 'questions', className: 'dcs-questions' }, questions.map((question, index) => h('button', {
1417
+ key: String(question.seq) + ':' + index,
1418
+ type: 'button',
1419
+ className: 'dcs-question',
1420
+ title: question.text,
1421
+ onClick: () => {
1422
+ revealText(focusSessionId, question.anchor, question.seq)
1423
+ },
1424
+ }, question.text))))
1425
+ }
1349
1426
  } else if (phase === 'ready' && ordered.length === 0) {
1350
1427
  body.push(h('p', { key: 'empty', className: 'dcs-note' }, t('hint.empty')))
1351
1428
  } else {
@@ -1572,7 +1649,6 @@ window.__ModuleLoader__.load({
1572
1649
  }
1573
1650
  }, 'dsh-content-search-ad: shortcut')
1574
1651
  })
1575
- console.info('[content-search] ready — right sidebar tab "' + t('tab.title') + '"')
1576
1652
  }
1577
1653
 
1578
1654
  return {
package/index.js CHANGED
@@ -64,7 +64,7 @@ const FUZZY_MAX_CHARS = 12
64
64
  /** Shortest query, in code points, still worth a fuzzy pass. */
65
65
  const FUZZY_MIN_CHARS = 4
66
66
 
67
- const VERSION = '0.22.0'
67
+ const VERSION = '0.23.0'
68
68
 
69
69
  //#region http helpers
70
70
  function writeJson(res, status, value) {
@@ -569,6 +569,58 @@ async function scanCorpus(ctx, parsed, focusId, scope) {
569
569
  }
570
570
  //#endregion
571
571
 
572
+ //#region questions
573
+ /** How many user messages the panel lists for one conversation. */
574
+ const QUESTIONS_MAX = 200
575
+ /** Longest question text sent for display. */
576
+ const QUESTION_TEXT_CHARS = 220
577
+ /** Longest anchor sent for locating the question in the transcript. */
578
+ const QUESTION_ANCHOR_CHARS = 80
579
+
580
+ /**
581
+ * The user's own messages in one conversation, oldest first.
582
+ *
583
+ * This is the "what did I ask" list: only `user/message` events, only their
584
+ * text blocks, displayed as written and anchored for the transcript locator.
585
+ * @returns `{ questions, count }` for the panel.
586
+ */
587
+ async function questionsFor(ctx, sessionId) {
588
+ const query = ctx.sessionQuery
589
+ const surface = await query.readSurface(sessionId)
590
+ const events = surface !== null && surface !== undefined && Array.isArray(surface.events) ? surface.events : []
591
+ const questions = []
592
+ for (const event of events) {
593
+ if (event === null || typeof event !== 'object' || event.type !== 'user/message') continue
594
+ const data = event.data === null || event.data === undefined ? {} : event.data
595
+ // Injected context also arrives as a user message; only the human `user`
596
+ // source counts as something the person actually asked.
597
+ const source = data.source === null || data.source === undefined ? {} : data.source
598
+ if (source.kind !== 'user') continue
599
+ const content = data.content
600
+ if (!Array.isArray(content)) continue
601
+ const parts = []
602
+ for (const block of content) {
603
+ if (block === null || typeof block !== 'object') continue
604
+ if (block.type !== 'text') continue
605
+ if (typeof block.text !== 'string' || block.text.length === 0) continue
606
+ parts.push(block.text)
607
+ }
608
+ if (parts.length === 0) continue
609
+ const raw = parts.join('\n').replace(/\s+/gu, ' ').trim()
610
+ if (raw.length === 0) continue
611
+ const plain = plainOf(parts.join('\n'))
612
+ questions.push({
613
+ seq: event.seq,
614
+ time: typeof event.time === 'number' ? event.time : 0,
615
+ text: raw.slice(0, QUESTION_TEXT_CHARS),
616
+ anchor: plain.slice(0, QUESTION_ANCHOR_CHARS),
617
+ })
618
+ }
619
+ const tail = questions.length > QUESTIONS_MAX ? questions.slice(-QUESTIONS_MAX) : questions
620
+ return { questions: tail, count: questions.length }
621
+ }
622
+ //#endregion
623
+
572
624
  //#region handler
573
625
  async function handleApi(req, res, ctx) {
574
626
  if (!isTrustedRequest(req)) {
@@ -619,6 +671,17 @@ async function handleApi(req, res, ctx) {
619
671
  return
620
672
  }
621
673
 
674
+ if (route === '/questions' && req.method === 'GET') {
675
+ const focusId = url.searchParams.get('focus')
676
+ if (typeof focusId !== 'string' || focusId.length === 0) {
677
+ fail(res, 400, 'focus-required', 'the focus parameter is required')
678
+ return
679
+ }
680
+ const outcome = await questionsFor(ctx, focusId)
681
+ writeJson(res, 200, { ok: true, sessionId: focusId, ...outcome })
682
+ return
683
+ }
684
+
622
685
  fail(res, 404, 'not-found', 'unknown route')
623
686
  }
624
687
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-content-search-ad",
3
- "version": "0.22.0",
3
+ "version": "0.23.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",