@luziyang2026/dsh-question-nav 0.4.1 → 0.4.2

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/lib/client.js CHANGED
@@ -18,13 +18,21 @@ window.__ModuleLoader__.load({
18
18
  function questionKey(id) {
19
19
  return `13:${MESSAGE_DEFINITION_KIND}${String(id)}`;
20
20
  }
21
+ /** True when entries are already in non-decreasing seq order (the projection
22
+ * appends in event order, so this is the common case and skips the sort). */
23
+ function isSortedBySeq(entries) {
24
+ for (let i = 1; i < entries.length; i++) if (entries[i].seq < entries[i - 1].seq) return false;
25
+ return true;
26
+ }
21
27
  /**
22
28
  * Fold the projection's question list into one dot per turn. Entries arrive
23
29
  * in event order; consecutive same-turn entries merge into a single dot whose
24
- * anchor is the turn's first question.
30
+ * anchor is the turn's first question. The input is expected to be sorted by
31
+ * seq; the defensive sort is skipped when it already is, so a long session
32
+ * never pays an O(n log n) sort on every content update.
25
33
  */
26
34
  function groupQuestionsByTurn(entries) {
27
- const sorted = [...entries].sort((a, b) => a.seq - b.seq);
35
+ const sorted = isSortedBySeq(entries) ? entries : [...entries].sort((a, b) => a.seq - b.seq);
28
36
  const dots = [];
29
37
  for (const entry of sorted) {
30
38
  const key = questionKey(entry.id);
@@ -54,19 +62,41 @@ window.__ModuleLoader__.load({
54
62
  * whose key is already folded into a dot is dropped (the projected copy
55
63
  * wins); the rest become single-question dots with `turn: null`, inserted in
56
64
  * anchor-seq order so the strip stays strictly chronological.
65
+ *
66
+ * Fast path: when nothing new arrives the SAME array is returned (no copy),
67
+ * so the caller can bail out of a re-render on identical reference.
57
68
  */
58
69
  function mergeLiveQuestions(dots, live) {
59
- const known = new Set(dots.flatMap((dot) => dot.memberKeys));
60
- const extras = live.filter((question) => !known.has(question.key)).map((question) => ({
61
- turn: null,
62
- key: question.key,
63
- anchorSeq: question.anchorSeq,
64
- time: question.time,
65
- texts: [question.text],
66
- memberKeys: [question.key]
67
- }));
68
- if (extras.length === 0) return [...dots];
69
- return [...dots, ...extras].sort((a, b) => a.anchorSeq - b.anchorSeq);
70
+ if (live.length === 0) return dots;
71
+ const known = /* @__PURE__ */ new Set();
72
+ for (const dot of dots) for (const key of dot.memberKeys) known.add(key);
73
+ const extras = [];
74
+ for (const question of live) {
75
+ if (known.has(question.key)) continue;
76
+ extras.push({
77
+ turn: null,
78
+ key: question.key,
79
+ anchorSeq: question.anchorSeq,
80
+ time: question.time,
81
+ texts: [question.text],
82
+ memberKeys: [question.key]
83
+ });
84
+ }
85
+ if (extras.length === 0) return dots;
86
+ const out = [];
87
+ let i = 0;
88
+ for (const extra of extras) {
89
+ while (i < dots.length && dots[i].anchorSeq <= extra.anchorSeq) {
90
+ out.push(dots[i]);
91
+ i += 1;
92
+ }
93
+ out.push(extra);
94
+ }
95
+ while (i < dots.length) {
96
+ out.push(dots[i]);
97
+ i += 1;
98
+ }
99
+ return out;
70
100
  }
71
101
  //#endregion
72
102
  //#region \0dsh-css:dsh-question-nav/src/client/question-nav.module.css.mjs
@@ -129,6 +159,19 @@ window.__ModuleLoader__.load({
129
159
  function findConvRoot() {
130
160
  return document.querySelector("[data-slot=\"conversation\"] > div[data-phase]");
131
161
  }
162
+ /** Structural equality of two dot lists (member keys fully capture a dot's
163
+ * folded questions, so identical key sequences mean identical content).
164
+ * Lets the strip skip a re-render when a refresh produced no change. */
165
+ function sameDots(a, b) {
166
+ if (a.length !== b.length) return false;
167
+ for (let i = 0; i < a.length; i++) {
168
+ const da = a[i];
169
+ const db = b[i];
170
+ if (da.key !== db.key || da.memberKeys.length !== db.memberKeys.length) return false;
171
+ for (let j = 0; j < da.memberKeys.length; j++) if (da.memberKeys[j] !== db.memberKeys[j]) return false;
172
+ }
173
+ return true;
174
+ }
132
175
  function QuestionNavStrip(props) {
133
176
  const current = props.useSessions((s) => s.current);
134
177
  const summary = props.useSessions((s) => s.current === void 0 ? void 0 : s.byId[s.current]);
@@ -139,6 +182,7 @@ window.__ModuleLoader__.load({
139
182
  const [tooltip, setTooltip] = (0, react.useState)(null);
140
183
  const panelRef = (0, react.useRef)(null);
141
184
  const hintTimerRef = (0, react.useRef)(null);
185
+ const lastDotsRef = (0, react.useRef)([]);
142
186
  const showHint = (message) => {
143
187
  setHint(message);
144
188
  if (hintTimerRef.current !== null) window.clearTimeout(hintTimerRef.current);
@@ -147,22 +191,26 @@ window.__ModuleLoader__.load({
147
191
  (0, react.useEffect)(() => {
148
192
  if (!visible || current === void 0) {
149
193
  setDots([]);
194
+ lastDotsRef.current = [];
150
195
  return;
151
196
  }
152
197
  const sessionId = current;
153
198
  const face = props.questionProjection(sessionId);
154
199
  const refresh = () => {
155
- const grouped = groupQuestionsByTurn(projectionEntries(face));
156
- setDots(mergeLiveQuestions(grouped, props.readQuestions(sessionId)));
200
+ const next = mergeLiveQuestions(groupQuestionsByTurn(projectionEntries(face)), props.readQuestions(sessionId));
201
+ if (sameDots(next, lastDotsRef.current)) {
202
+ setDots(lastDotsRef.current);
203
+ return;
204
+ }
205
+ lastDotsRef.current = next;
206
+ setDots(next);
157
207
  };
158
208
  refresh();
159
209
  const unsubProjection = face?.subscribe(refresh) ?? (() => {});
160
210
  const unsubContent = props.subscribeContent(sessionId, refresh);
161
- const unsubList = props.subscribeList(refresh);
162
211
  return () => {
163
212
  unsubProjection();
164
213
  unsubContent();
165
- unsubList();
166
214
  };
167
215
  }, [
168
216
  visible,
@@ -180,37 +228,72 @@ window.__ModuleLoader__.load({
180
228
  (0, react.useLayoutEffect)(() => {
181
229
  if (!visible) return;
182
230
  let raf = 0;
183
- let retries = 0;
231
+ let idle = 0;
232
+ let stopped = false;
233
+ let observer = null;
234
+ const observed = {
235
+ frame: null,
236
+ convRoot: null
237
+ };
184
238
  const applyLayout = () => {
185
239
  const panel = panelRef.current;
186
- if (panel === null) return;
240
+ if (panel === null) return false;
187
241
  const frame = panel.closest("[data-shell-overlay]")?.parentElement ?? null;
188
242
  const convRoot = findConvRoot();
189
- if (frame === null || convRoot === null) return;
190
- const frameRect = frame.getBoundingClientRect();
191
- const convRect = convRoot.getBoundingClientRect();
192
- if (convRect.height <= 0) {
193
- if (retries < 20) {
194
- retries += 1;
195
- raf = requestAnimationFrame(applyLayout);
243
+ if (frame === null || convRoot === null) return true;
244
+ if (observer !== null) {
245
+ if (observed.frame !== frame) {
246
+ observer.observe(frame, { box: "border-box" });
247
+ observed.frame = frame;
248
+ }
249
+ if (observed.convRoot !== convRoot) {
250
+ observer.observe(convRoot, { box: "border-box" });
251
+ observed.convRoot = convRoot;
196
252
  }
197
- return;
198
253
  }
199
- retries = 0;
200
- panel.style.top = `${convRect.top - frameRect.top}px`;
201
- panel.style.height = `${convRect.height}px`;
202
- panel.style.left = `${convRect.left - frameRect.left}px`;
254
+ const frameRect = frame.getBoundingClientRect();
255
+ const convRect = convRoot.getBoundingClientRect();
256
+ if (convRect.height <= 0 || convRect.width <= 0) return true;
257
+ const top = `${convRect.top - frameRect.top}px`;
258
+ const height = `${convRect.height}px`;
259
+ const left = `${convRect.left - frameRect.left}px`;
260
+ if (panel.style.top === top && panel.style.height === height && panel.style.left === left) return false;
261
+ panel.style.top = top;
262
+ panel.style.height = height;
263
+ panel.style.left = left;
264
+ return true;
265
+ };
266
+ const loop = () => {
267
+ if (stopped) return;
268
+ raf = 0;
269
+ idle = applyLayout() ? 0 : idle + 1;
270
+ if (idle < 3) raf = requestAnimationFrame(loop);
203
271
  };
204
- applyLayout();
205
- raf = requestAnimationFrame(applyLayout);
206
- const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(applyLayout);
207
- const convRoot = findConvRoot();
208
- observer?.observe(convRoot ?? document.body, { box: "border-box" });
209
- window.addEventListener("resize", applyLayout);
272
+ const wake = () => {
273
+ if (stopped) return;
274
+ idle = 0;
275
+ if (raf === 0) raf = requestAnimationFrame(loop);
276
+ };
277
+ observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(wake);
278
+ if (observer !== null) {
279
+ const frame = panelRef.current?.closest("[data-shell-overlay]")?.parentElement ?? null;
280
+ const convRoot = findConvRoot();
281
+ if (frame !== null) {
282
+ observer.observe(frame, { box: "border-box" });
283
+ observed.frame = frame;
284
+ }
285
+ if (convRoot !== null) {
286
+ observer.observe(convRoot, { box: "border-box" });
287
+ observed.convRoot = convRoot;
288
+ }
289
+ }
290
+ wake();
291
+ window.addEventListener("resize", wake);
210
292
  return () => {
293
+ stopped = true;
211
294
  if (raf !== 0) cancelAnimationFrame(raf);
212
295
  observer?.disconnect();
213
- window.removeEventListener("resize", applyLayout);
296
+ window.removeEventListener("resize", wake);
214
297
  };
215
298
  }, [visible]);
216
299
  (0, react.useEffect)(() => () => {
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","names":["kind","useState","useRef","styles","createPortal"],"sources":["../src/core/turn-dots.ts","../src/client/QuestionNavStrip.tsx","../src/client/locales.ts","../src/core/nodes.ts","../src/core/jump.ts","../src/client/index.ts"],"sourcesContent":["/**\n * Turn-aligned dot model for the question-nav strip. Pure transforms over the\n * `questionIndex` projection value plus the live chat window — no React, no\n * DOM — so the grouping and merging rules are unit-testable in isolation.\n *\n * One dot per turn that claimed at least one user question; turns without a\n * question (retry, goal continuation, cancelled empty turns) produce no dot,\n * so dot turn labels may skip numbers but always match the Trajectory view.\n */\n\nimport type { QuestionEntry } from './question-entry.ts'\nimport type { QuestionNode } from './nodes.ts'\n\n/** The conversation Definition kind whose key a user question node uses. */\nexport const MESSAGE_DEFINITION_KIND = 'input-message'\n\n/**\n * The engine-owned stable chat key for a user question — mirrors\n * `conversationContextKey('input-message', String(id))` from the DSH runtime\n * (verified against that formula in the unit test).\n */\nexport function questionKey(id: unknown): string {\n const kind = MESSAGE_DEFINITION_KIND\n return `${kind.length}:${kind}${String(id)}`\n}\n\n/** One strip dot: a turn's questions (grouped) or one ungrouped live question. */\nexport interface TurnDot {\n /** Owning turn number; null for live questions the projection has not seen. */\n readonly turn: number | null\n /** Jump anchor: the chat key of the turn's FIRST question. */\n readonly key: string\n /** Anchor seq of the first question (ordering + jump target). */\n readonly anchorSeq: number\n /** Unix ms of the first question. */\n readonly time: number\n /** Every question text of this dot, in order (tooltip lists them all). */\n readonly texts: readonly string[]\n /** Chat keys of every question folded into this dot (live-merge dedupe). */\n readonly memberKeys: readonly string[]\n}\n\n/**\n * Fold the projection's question list into one dot per turn. Entries arrive\n * in event order; consecutive same-turn entries merge into a single dot whose\n * anchor is the turn's first question.\n */\nexport function groupQuestionsByTurn(entries: readonly QuestionEntry[]): TurnDot[] {\n const sorted = [...entries].sort((a, b) => a.seq - b.seq)\n const dots: TurnDot[] = []\n for (const entry of sorted) {\n const key = questionKey(entry.id)\n const last = dots.at(-1)\n if (last !== undefined && last.turn === entry.turn) {\n dots[dots.length - 1] = {\n ...last,\n texts: [...last.texts, entry.text],\n memberKeys: [...last.memberKeys, key],\n }\n continue\n }\n dots.push({\n turn: entry.turn,\n key,\n anchorSeq: entry.seq,\n time: entry.time,\n texts: [entry.text],\n memberKeys: [key],\n })\n }\n return dots\n}\n\n/**\n * Merge live-window questions the projection has not recorded yet (the brief\n * window before the session/projection push frame lands). A live question\n * whose key is already folded into a dot is dropped (the projected copy\n * wins); the rest become single-question dots with `turn: null`, inserted in\n * anchor-seq order so the strip stays strictly chronological.\n */\nexport function mergeLiveQuestions(\n dots: readonly TurnDot[],\n live: readonly QuestionNode[],\n): TurnDot[] {\n const known = new Set(dots.flatMap(dot => dot.memberKeys))\n const extras: TurnDot[] = live\n .filter(question => !known.has(question.key))\n .map(question => ({\n turn: null,\n key: question.key,\n anchorSeq: question.anchorSeq,\n time: question.time,\n texts: [question.text],\n memberKeys: [question.key],\n }))\n if (extras.length === 0) return [...dots]\n return [...dots, ...extras].sort((a, b) => a.anchorSeq - b.anchorSeq)\n}\n","/**\n * Question-nav minimap. Renders a vertical column of small round dots overlaid\n * on the LEFT edge of the conversation column (via the frame-wide\n * `shell.overlay` floating layer), vertically centered: one dot per turn that\n * claimed at least one user question — strictly aligned with the Trajectory\n * view's turn numbering (turns without a question produce no dot). Hover\n * enlarges a dot and shows an instant tooltip (portal-rendered, no native\n * delay) with the turn label and the turn's question text(s); clicking jumps\n * the chat to that turn's first question.\n *\n * Data source: the host-folded `questionIndex` session projection (whole\n * history, persisted host-side, pushed live through session/projection\n * frames) read through the injected `questionProjection` face, plus the live\n * chat window's questions merged on top for the brief window before a\n * just-sent question lands in the projection. No render-window expansion, no\n * client-side history paging.\n *\n * Data arrives through the props shares: the framework `useSessions` hook\n * (current session), the registrant inject face (read/subscribe/project/\n * jump), and the bound locale translator.\n */\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\nimport type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { SessionId } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: pulls the ui-layout SlotMap merge ('shell.overlay').\nimport type {} from '@deepseek-ai/dsh-client-ui-layout/client'\nimport type { QuestionNode } from '../core/nodes.ts'\nimport type { QuestionEntry } from '../core/question-entry.ts'\nimport { groupQuestionsByTurn, mergeLiveQuestions, type TurnDot } from '../core/turn-dots.ts'\nimport type { JumpFailureCode } from '../core/jump.ts'\nimport type { QuestionNavKey } from './locales.ts'\nimport styles from './question-nav.module.css'\n\n/** Minimal observable shape of a session projection face. */\nexport interface ObservableFace {\n /** Current projection value (unknown — validated structurally at read). */\n getSnapshot: () => unknown\n /** Subscribe to value changes; returns an unsubscribe. */\n subscribe: (listener: () => void) => () => void\n}\n\n/** Values the registrant inject face supplies (wired in src/client/index.ts). */\nexport interface QuestionNavInjected {\n /** Extract the user questions of a session's currently loaded window. */\n readQuestions: (sessionId: SessionId) => QuestionNode[]\n /** Subscribe to the session list; returns an unsubscribe. */\n subscribeList: (cb: () => void) => () => void\n /** Subscribe to a session's content; returns an unsubscribe. */\n subscribeContent: (sessionId: SessionId, cb: () => void) => () => void\n /** The session's `questionIndex` projection face, when the host unit is registered. */\n questionProjection: (sessionId: SessionId) => ObservableFace | undefined\n /** Jump the chat to a question row (pages the window on demand). */\n jump: (sessionId: SessionId, key: string) => void\n}\n\ntype ComponentProps = PropsRuntime<'shell.overlay'> & QuestionNavInjected & PropsLocale<'question-nav'>\n\nconst FAILURE_HINTS: Record<JumpFailureCode, QuestionNavKey> = {\n VIEW_INACTIVE: 'jump.inactive',\n TARGET_HIDDEN: 'jump.hidden',\n NOT_FOUND: 'jump.notfound',\n TIMEOUT: 'jump.timeout',\n}\n\n/** Live position of the instant hover tooltip. */\ninterface TooltipState {\n /** Turn label line (e.g. \"Turn 32\"); null for ungrouped live questions. */\n title: string | null\n /** Question text lines (one per question folded into the dot). */\n lines: readonly string[]\n left: number\n top: number\n}\n\n/** Read the projection face value as a question-entry list (structural guard). */\nfunction projectionEntries(face: ObservableFace | undefined): QuestionEntry[] {\n const value = face?.getSnapshot()\n if (!Array.isArray(value)) return []\n return value.filter((item): item is QuestionEntry =>\n typeof item === 'object' && item !== null\n && typeof (item as QuestionEntry).id === 'string'\n && typeof (item as QuestionEntry).seq === 'number'\n && typeof (item as QuestionEntry).turn === 'number')\n}\n\nfunction findConvRoot(): HTMLElement | null {\n return document.querySelector<HTMLElement>('[data-slot=\"conversation\"] > div[data-phase]')\n}\n\nexport function QuestionNavStrip(props: ComponentProps): React.JSX.Element | null {\n const current = props.useSessions((s) => s.current)\n const summary = props.useSessions((s) => (s.current === undefined ? undefined : s.byId[s.current]))\n const visible = current !== undefined && summary !== undefined && summary.blank !== true\n\n const [dots, setDots] = useState<TurnDot[]>([])\n const [jumpingKey, setJumpingKey] = useState<string | null>(null)\n const [hint, setHint] = useState<string | null>(null)\n const [tooltip, setTooltip] = useState<TooltipState | null>(null)\n const panelRef = useRef<HTMLDivElement | null>(null)\n const hintTimerRef = useRef<number | null>(null)\n\n const showHint = (message: string): void => {\n setHint(message)\n if (hintTimerRef.current !== null) window.clearTimeout(hintTimerRef.current)\n hintTimerRef.current = window.setTimeout(() => setHint(null), 1800)\n }\n\n // Recompute the dot list from the projection + live window; subscribe to\n // the projection push frames, session content, and the session list.\n useEffect(() => {\n if (!visible || current === undefined) {\n setDots([])\n return\n }\n const sessionId = current\n const face = props.questionProjection(sessionId)\n const refresh = (): void => {\n const grouped = groupQuestionsByTurn(projectionEntries(face))\n setDots(mergeLiveQuestions(grouped, props.readQuestions(sessionId)))\n }\n refresh()\n const unsubProjection = face?.subscribe(refresh) ?? (() => {})\n const unsubContent = props.subscribeContent(sessionId, refresh)\n const unsubList = props.subscribeList(refresh)\n return () => {\n unsubProjection()\n unsubContent()\n unsubList()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [visible, current, props])\n\n // Listen for jump-failure events and surface the hint.\n useEffect(() => {\n const onJumpFailed = (event: Event): void => {\n const code = (event as CustomEvent<JumpFailureCode>).detail\n showHint(props.t(FAILURE_HINTS[code] ?? 'jump.timeout'))\n }\n window.addEventListener('question-nav:jump-failed', onJumpFailed)\n return () => window.removeEventListener('question-nav:jump-failed', onJumpFailed)\n }, [props])\n\n // Anchor the minimap to the conversation column: position it at the left\n // edge of the conversation root and reserve a thin rail with padding-left.\n useLayoutEffect(() => {\n if (!visible) return\n let raf = 0\n let retries = 0\n const applyLayout = (): void => {\n const panel = panelRef.current\n if (panel === null) return\n const frame = panel.closest('[data-shell-overlay]')?.parentElement ?? null\n const convRoot = findConvRoot()\n if (frame === null || convRoot === null) return\n const frameRect = frame.getBoundingClientRect()\n const convRect = convRoot.getBoundingClientRect()\n if (convRect.height <= 0) {\n if (retries < 20) {\n retries += 1\n raf = requestAnimationFrame(applyLayout)\n }\n return\n }\n retries = 0\n panel.style.top = `${convRect.top - frameRect.top}px`\n panel.style.height = `${convRect.height}px`\n panel.style.left = `${convRect.left - frameRect.left}px`\n }\n applyLayout()\n raf = requestAnimationFrame(applyLayout)\n const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(applyLayout)\n const convRoot = findConvRoot()\n observer?.observe(convRoot ?? document.body, { box: 'border-box' })\n window.addEventListener('resize', applyLayout)\n return () => {\n if (raf !== 0) cancelAnimationFrame(raf)\n observer?.disconnect()\n window.removeEventListener('resize', applyLayout)\n }\n }, [visible])\n\n // Clear any pending hint timer on unmount.\n useEffect(() => () => {\n if (hintTimerRef.current !== null) window.clearTimeout(hintTimerRef.current)\n }, [])\n\n if (!visible) return null\n\n const onJump = (dot: TurnDot): void => {\n if (current === undefined) return\n setJumpingKey(dot.key)\n props.jump(current, dot.key)\n window.setTimeout(() => setJumpingKey((k) => (k === dot.key ? null : k)), 600)\n }\n\n const openTooltip = (dot: TurnDot, target: HTMLElement): void => {\n const r = target.getBoundingClientRect()\n setTooltip({\n title: dot.turn === null ? null : `Turn ${dot.turn}`,\n lines: dot.texts,\n left: r.right + 10,\n top: r.top,\n })\n }\n\n const t = props.t\n\n return (\n <div ref={panelRef} className={styles.rail} data-question-nav=\"rail\">\n {hint !== null ? <div className={styles.hint} role=\"status\">{hint}</div> : null}\n <div className={styles.list}>\n {dots.length === 0 ? (\n <div className={styles.empty}>{t('strip.empty')}</div>\n ) : (\n <div className={styles.dots}>\n <span className={styles.count}>{dots.length}</span>\n {dots.map((dot) => (\n <button\n key={dot.key}\n className={jumpingKey === dot.key ? `${styles.dot} ${styles.active}` : styles.dot}\n aria-label={dot.texts[0] ?? ''}\n onMouseEnter={(e) => openTooltip(dot, e.currentTarget)}\n onMouseLeave={() => setTooltip(null)}\n onClick={() => onJump(dot)}\n />\n ))}\n </div>\n )}\n </div>\n {tooltip !== null\n ? createPortal(\n <div className={styles.tooltip} style={{ left: tooltip.left, top: tooltip.top }}>\n {tooltip.title !== null ? <div className={styles.tooltipTitle}>{tooltip.title}</div> : null}\n {tooltip.lines.map((line, index) => (\n <div key={index} className={styles.tooltipLine}>{line}</div>\n ))}\n </div>,\n document.body,\n )\n : null}\n </div>\n )\n}\n","/**\n * Locale dictionaries for the question-nav surface (zh/en). Registered under\n * the `question-nav` namespace; keys are consumed through the bound translator.\n */\nexport const zh = {\n 'strip.empty': '本会话还没有提问',\n 'jump.inactive': '聊天视图未激活',\n 'jump.hidden': '目标无独立气泡,已定位到邻近内容',\n 'jump.notfound': '目标未加载或不存在(可能已压缩)',\n 'jump.timeout': '加载历史超时,可重试',\n} as const\n\nexport const en = {\n 'strip.empty': 'No questions in this session yet',\n 'jump.inactive': 'Chat view is not active',\n 'jump.hidden': 'No dedicated bubble; landed on nearby content',\n 'jump.notfound': 'Target not loaded or missing (maybe compacted)',\n 'jump.timeout': 'Timed out loading history; retry',\n} as const\n\nexport type QuestionNavKey = keyof typeof zh\n","/**\n * Pure node-indexing logic for the question-nav plugin. No React, no DOM, no\n * Cordis — every function here is a pure transform over chat-node data so it\n * can be unit-tested in isolation (and reused by the browser half).\n */\n\n/** One user question as shown in the strip and targeted by a jump. */\nexport interface QuestionNode {\n /** Chat anchor key, matches a `[data-chat-anchor-key]` row in the scrollport. */\n key: string\n /** Monotone anchor sequence for ordering and window-min detection. */\n anchorSeq: number\n /** Event seq of the user message. */\n seq: number\n /** Unix ms timestamp. */\n time: number\n /** Full question text — shown in the hover tooltip (not truncated). */\n text: string\n}\n\n/** Minimal shape a chat node must expose for indexing (structural, not SDK-bound). */\nexport interface ChatNodeLike {\n key: string\n anchorSeq: number\n visibility?: string\n kind?: string\n /** Kind-specific payload (a UserMessageNode for `user`/`steering`). */\n data?: unknown\n}\n\n/** Kinds counted as a user question (turn-opening and steering admissions). */\nexport const QUESTION_KINDS = ['user', 'steering'] as const\n\n/** Narrow `node.data` to the user-message payload we read. */\ninterface UserDataLike {\n content?: readonly { type?: string; text?: string }[]\n seq?: number\n time?: number\n}\n\nfunction userData(data: unknown): UserDataLike | undefined {\n if (typeof data !== 'object' || data === null) return undefined\n return data as UserDataLike\n}\n\n/** First text block of a user message; falls back to the raw first block. */\nexport function messageText(content: readonly { type?: string; text?: string }[] | undefined): string {\n if (content === undefined || content.length === 0) return ''\n const first = content[0]\n if (typeof first?.text === 'string') return first.text\n return ''\n}\n\n/** Extract the user questions from a chat-node window, ordered by anchorSeq. */\nexport function extractQuestions(nodes: Iterable<ChatNodeLike>): QuestionNode[] {\n const out: QuestionNode[] = []\n for (const node of nodes) {\n if (!QUESTION_KINDS.includes(node.kind as (typeof QUESTION_KINDS)[number])) continue\n const payload = userData(node.data)\n out.push({\n key: node.key,\n anchorSeq: node.anchorSeq,\n seq: payload?.seq ?? -1,\n time: payload?.time ?? 0,\n // Full question text: shown in the hover tooltip (not truncated).\n text: messageText(payload?.content),\n })\n }\n out.sort((a, b) => a.anchorSeq - b.anchorSeq)\n return out\n}\n\n/** Whether a node is actually rendered (visible rows only are scroll targets). */\nexport function isRenderable(node: ChatNodeLike): boolean {\n return node.visibility !== 'hidden'\n}\n\n/** The row of the window that renders the given key (exact match). */\nexport function findQuestionRow(nodes: Iterable<ChatNodeLike>, key: string): ChatNodeLike | null {\n for (const node of nodes) {\n if (node.key === key) return node\n }\n return null\n}\n\n/** Nearest renderable row for a key that is absent or hidden (compaction, windowing). */\nexport function nearestRenderable(\n nodes: Iterable<{ key: string; anchorSeq: number; visibility?: string }>,\n excludeKey: string | undefined,\n): { key: string; anchorSeq: number } | null {\n let best: { key: string; anchorSeq: number } | null = null\n for (const node of nodes) {\n if (node.visibility === 'hidden') continue\n if (node.key === excludeKey) continue\n if (best === null || node.anchorSeq < best.anchorSeq) best = { key: node.key, anchorSeq: node.anchorSeq }\n }\n return best\n}\n","/**\n * Jump-to-question orchestration. Pure-ish: takes injected ports (snapshot\n * read, loadOlder, DOM row lookup, view liveness, scroll, timers) so the\n * paging/timeout/fallback loop is unit-testable without a real browser or\n * session. The browser half wires these ports to ctx.sessions + the DOM.\n */\n\nimport { nearestRenderable } from './nodes.ts'\n\n/** The bits of a session snapshot the jump loop needs. */\nexport interface JumpSnapshot {\n openState: string\n hasMore: boolean\n loadingOlder: boolean\n /** Renderable chat rows as a key->renderable map (or iterable of rows). */\n rows: Iterable<{ key: string; anchorSeq: number; visibility?: string }>\n}\n\nexport interface JumpPorts {\n /** Read the current snapshot; undefined when the session/view is unavailable. */\n snapshot: () => JumpSnapshot | undefined\n /** Expand the window backwards; rejects/throws on failure. */\n loadOlder: () => Promise<void>\n /** True while the chat view is active (a `[data-chat-flow]` is mounted). */\n isViewActive: () => boolean\n /** Find the DOM row for a chat anchor key; null when not rendered. */\n findRow: (key: string) => HTMLElement | null\n /** Scroll a row into view at the top. */\n scrollIntoView: (row: HTMLElement) => void\n /** Monotonic ms clock. */\n now: () => number\n /** Async sleep. */\n sleep: (ms: number) => Promise<void>\n /** Report a terminal failure to the caller (for a hint). */\n report?: (code: JumpFailureCode, fallback?: boolean) => void\n}\n\nexport type JumpFailureCode = 'VIEW_INACTIVE' | 'TARGET_HIDDEN' | 'NOT_FOUND' | 'TIMEOUT'\n\nexport interface JumpResult {\n ok: boolean\n code?: JumpFailureCode\n /** True when we landed on a fallback row rather than the exact target. */\n fallback?: boolean\n}\n\nexport interface JumpOptions {\n /** Total wall-clock budget for loadOlder paging. */\n totalTimeoutMs?: number\n /** Max loadOlder pages before giving up. */\n maxPages?: number\n /** Poll interval for the row to render after it is known to be in the window. */\n rowWaitMs?: number\n /** Poll interval for state transitions (loadingOlder / openState). */\n pollMs?: number\n}\n\nconst DEFAULTS = {\n totalTimeoutMs: 15_000,\n maxPages: 100,\n rowWaitMs: 8_000,\n pollMs: 60,\n}\n\nfunction minAnchorSeq(rows: Iterable<{ anchorSeq: number }>): number | null {\n let min: number | null = null\n for (const row of rows) {\n if (min === null || row.anchorSeq < min) min = row.anchorSeq\n }\n return min\n}\n\nfunction renderable(rows: Iterable<{ key: string; anchorSeq: number; visibility?: string }>): { key: string; anchorSeq: number }[] {\n const out: { key: string; anchorSeq: number }[] = []\n for (const row of rows) {\n if (row.visibility === 'hidden') continue\n out.push({ key: row.key, anchorSeq: row.anchorSeq })\n }\n return out\n}\n\n/**\n * Jump to the row for `key`, paging older content until it is rendered (or the\n * budget is exhausted). Falls back to the nearest renderable row when the\n * exact row is hidden/absent.\n */\nexport async function jumpToQuestion(ports: JumpPorts, key: string, options: JumpOptions = {}): Promise<JumpResult> {\n const cfg = { ...DEFAULTS, ...options }\n const fail = (code: JumpFailureCode, fallback = false): JumpResult => {\n ports.report?.(code, fallback)\n return fallback ? { ok: false, code, fallback: true } : { ok: false, code }\n }\n\n if (!ports.isViewActive()) return fail('VIEW_INACTIVE')\n\n const deadline = ports.now() + cfg.totalTimeoutMs\n let pages = 0\n\n // Phase 1: page older until the key appears in the loaded window.\n while (true) {\n const snap = ports.snapshot()\n if (snap === undefined) return fail('VIEW_INACTIVE')\n const rows = renderable(snap.rows)\n if (rows.some((r) => r.key === key)) break\n if (snap.openState !== 'open') {\n if (snap.openState === 'error' || ports.now() > deadline) {\n return fail(snap.openState === 'error' ? 'VIEW_INACTIVE' : 'TIMEOUT')\n }\n await ports.sleep(cfg.pollMs)\n continue\n }\n if (snap.hasMore !== true) return fail('NOT_FOUND')\n if (pages >= cfg.maxPages || ports.now() > deadline) return fail('TIMEOUT')\n if (snap.loadingOlder) {\n await ports.sleep(cfg.pollMs)\n continue\n }\n const before = minAnchorSeq(rows)\n await ports.loadOlder()\n pages += 1\n const afterSnap = ports.snapshot()\n const after = minAnchorSeq(afterSnap === undefined ? [] : afterSnap.rows)\n if (after === null || (before !== null && after >= before)) return fail('NOT_FOUND')\n }\n\n // Phase 2: wait for the row to render, then scroll. Fall back if hidden.\n const waitedFor = async (rowKey: string): Promise<HTMLElement | null> => {\n for (let waited = 0; waited <= cfg.rowWaitMs; waited += cfg.pollMs) {\n if (!ports.isViewActive()) return null\n const row = ports.findRow(rowKey)\n if (row !== null) return row\n await ports.sleep(cfg.pollMs)\n }\n return null\n }\n\n const row = await waitedFor(key)\n if (row !== null) {\n ports.scrollIntoView(row)\n return { ok: true }\n }\n\n const snap = ports.snapshot()\n const fallback = nearestRenderable(snap === undefined ? [] : snap.rows, key)\n if (fallback !== null) {\n const fbRow = await waitedFor(fallback.key)\n if (fbRow !== null) {\n ports.scrollIntoView(fbRow)\n return fail('TARGET_HIDDEN', true)\n }\n }\n return fail('TARGET_HIDDEN', false)\n}\n","/**\n * Browser-half entry for the dsh-question-nav plugin.\n *\n * Registers one surface into the frame-wide floating layer (`shell.overlay`):\n * a vertical strip on the LEFT edge of the conversation column listing every\n * user question in the current session as a small button, one dot per turn.\n * Clicking a button scrolls the chat to that turn's first question.\n *\n * The dots are driven by the host-folded `questionIndex` session projection\n * (registered by the plugin's host half): the projection registry folds the\n * WHOLE event log without touching the chat's paged render window, the\n * projection cache persists it, and the standard carriers (history tail-page\n * baseline + session/projection push frames) keep it live. Live-window\n * questions not yet recorded by the projection are merged on top so a\n * just-sent question appears immediately.\n *\n * Failure policy: nothing here throws at apply time — an external plugin must\n * never take the GUI down.\n */\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { SessionId } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: pulls ui-layout's SlotMap merge ('shell.overlay').\nimport type {} from '@deepseek-ai/dsh-client-ui-layout/client'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport { QuestionNavStrip, type ObservableFace, type QuestionNavInjected } from './QuestionNavStrip.tsx'\nimport { en, zh, type QuestionNavKey } from './locales.ts'\nimport { extractQuestions } from '../core/nodes.ts'\nimport { jumpToQuestion, type JumpFailureCode, type JumpPorts } from '../core/jump.ts'\n\n/** Locale namespace this plugin owns. */\nconst NS = 'question-nav'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** question-nav surface copy. */\n 'question-nav': QuestionNavKey\n }\n}\n\n/** Services required by this plugin. */\nexport const inject = ['slots', 'locale', 'sessions']\n\n/** Single-instance guard: a duplicated client injection must not mount twice. */\ndeclare global {\n // eslint-disable-next-line no-var\n var __dshQuestionNavApplied: boolean | undefined\n}\n\nfunction claimApply(): boolean {\n if (globalThis.__dshQuestionNavApplied === true) return false\n globalThis.__dshQuestionNavApplied = true\n return true\n}\n\nfunction releaseApply(): void {\n globalThis.__dshQuestionNavApplied = undefined\n}\n\n/** Map the session snapshot to the jump-loop port surface. */\nfunction jumpPortsFor(ctx: ClientContext, sessionId: SessionId): JumpPorts {\n return {\n snapshot: () => {\n const binding = ctx.sessions.binding(sessionId)\n const snap = binding?.session.getSnapshot()\n if (snap === undefined) return undefined\n return {\n openState: snap.openState,\n hasMore: snap.hasMore,\n loadingOlder: snap.loadingOlder,\n rows: snap.chat.nodes.values(),\n }\n },\n loadOlder: async () => {\n const binding = ctx.sessions.binding(sessionId)\n if (binding === undefined) throw new Error('session unavailable')\n await binding.session.loadOlder()\n },\n isViewActive: () => document.querySelector('[data-chat-flow]') !== null,\n findRow: (key: string) => {\n for (const candidate of Array.from(document.querySelectorAll<HTMLElement>('[data-chat-anchor-key]'))) {\n if (candidate.dataset.chatAnchorKey === key) return candidate\n }\n return null\n },\n scrollIntoView: (row) => row.scrollIntoView({ block: 'start' }),\n now: () => Date.now(),\n sleep: (ms) => new Promise((resolve) => window.setTimeout(resolve, ms)),\n }\n}\n\n/**\n * The session's `questionIndex` projection face (getSnapshot + subscribe).\n * Undefined when the session is not bound or the host unit is not registered\n * (e.g. a headless composition) — the strip then shows live-window dots only.\n */\nfunction questionProjectionOf(ctx: ClientContext, sessionId: SessionId): ObservableFace | undefined {\n const face = ctx.sessions.binding(sessionId)?.session.projections.faceOf('questionIndex')\n if (face === undefined) return undefined\n return {\n getSnapshot: () => face.getSnapshot(),\n subscribe: (listener) => face.subscribe(listener),\n }\n}\n\nfunction createInject(ctx: ClientContext): QuestionNavInjected {\n return {\n readQuestions: (sessionId) => {\n const snap = ctx.sessions.binding(sessionId)?.session.getSnapshot()\n if (snap === undefined) return []\n return extractQuestions(snap.chat.nodes.values())\n },\n subscribeList: (cb) => ctx.sessions.list.subscribe(cb),\n subscribeContent: (sessionId, cb) => {\n const binding = ctx.sessions.binding(sessionId)\n if (binding === undefined) return () => {}\n return binding.session.subscribe(cb)\n },\n questionProjection: (sessionId) => questionProjectionOf(ctx, sessionId),\n jump: (sessionId, key) => {\n const ports = jumpPortsFor(ctx, sessionId)\n ports.report = (code: JumpFailureCode) => {\n // Surface the failure through the component via a DOM event the\n // strip listens for; simplest reliable cross-boundary channel here.\n window.dispatchEvent(new CustomEvent('question-nav:jump-failed', { detail: code }))\n }\n void jumpToQuestion(ports, key)\n },\n }\n}\n\n/**\n * Register the question-nav surface.\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n if (!claimApply()) return\n ctx.effect(() => releaseApply, 'question-nav: apply claim')\n\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'question-nav: dictionaries')\n\n const injected = createInject(ctx)\n\n ctx.slots.inject('shell.overlay', () => ctx.slots.register({\n name: 'shell.overlay',\n id: 'question-nav',\n order: 900,\n locale: NS,\n inject: () => injected,\n }, QuestionNavStrip))\n}\n"],"mappings":";;;;;;;;;;;EAcA,MAAa,0BAA0B;;;;;;EAOvC,SAAgB,YAAY,IAAqB;GAE/C,OAAO,MAAkBA,0BAAO,OAAO,EAAE;EAC3C;;;;;;EAuBA,SAAgB,qBAAqB,SAA8C;GACjF,MAAM,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,MAAM,GAAG,MAAM,EAAE,MAAM,EAAE,GAAG;GACxD,MAAM,OAAkB,CAAC;GACzB,KAAK,MAAM,SAAS,QAAQ;IAC1B,MAAM,MAAM,YAAY,MAAM,EAAE;IAChC,MAAM,OAAO,KAAK,GAAG,EAAE;IACvB,IAAI,SAAS,KAAA,KAAa,KAAK,SAAS,MAAM,MAAM;KAClD,KAAK,KAAK,SAAS,KAAK;MACtB,GAAG;MACH,OAAO,CAAC,GAAG,KAAK,OAAO,MAAM,IAAI;MACjC,YAAY,CAAC,GAAG,KAAK,YAAY,GAAG;KACtC;KACA;IACF;IACA,KAAK,KAAK;KACR,MAAM,MAAM;KACZ;KACA,WAAW,MAAM;KACjB,MAAM,MAAM;KACZ,OAAO,CAAC,MAAM,IAAI;KAClB,YAAY,CAAC,GAAG;IAClB,CAAC;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WAAW,aAAa,GAAG;GAEjC,IAAI,MAAM,OAAO,uBAAuB,IAAI,MAAM,SAAS;IACzD,MAAM;IACN,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,cAAc;GAChB,GAAG,gBAAgB,CAAC;EACtB"}
1
+ {"version":3,"file":"client.js","names":["kind","useState","useRef","styles","createPortal"],"sources":["../src/core/turn-dots.ts","../src/client/QuestionNavStrip.tsx","../src/client/locales.ts","../src/core/nodes.ts","../src/core/jump.ts","../src/client/index.ts"],"sourcesContent":["/**\n * Turn-aligned dot model for the question-nav strip. Pure transforms over the\n * `questionIndex` projection value plus the live chat window — no React, no\n * DOM — so the grouping and merging rules are unit-testable in isolation.\n *\n * One dot per turn that claimed at least one user question; turns without a\n * question (retry, goal continuation, cancelled empty turns) produce no dot,\n * so dot turn labels may skip numbers but always match the Trajectory view.\n */\n\nimport type { QuestionEntry } from './question-entry.ts'\nimport type { QuestionNode } from './nodes.ts'\n\n/** The conversation Definition kind whose key a user question node uses. */\nexport const MESSAGE_DEFINITION_KIND = 'input-message'\n\n/**\n * The engine-owned stable chat key for a user question — mirrors\n * `conversationContextKey('input-message', String(id))` from the DSH runtime\n * (verified against that formula in the unit test).\n */\nexport function questionKey(id: unknown): string {\n const kind = MESSAGE_DEFINITION_KIND\n return `${kind.length}:${kind}${String(id)}`\n}\n\n/** One strip dot: a turn's questions (grouped) or one ungrouped live question. */\nexport interface TurnDot {\n /** Owning turn number; null for live questions the projection has not seen. */\n readonly turn: number | null\n /** Jump anchor: the chat key of the turn's FIRST question. */\n readonly key: string\n /** Anchor seq of the first question (ordering + jump target). */\n readonly anchorSeq: number\n /** Unix ms of the first question. */\n readonly time: number\n /** Every question text of this dot, in order (tooltip lists them all). */\n readonly texts: readonly string[]\n /** Chat keys of every question folded into this dot (live-merge dedupe). */\n readonly memberKeys: readonly string[]\n}\n\n/** True when entries are already in non-decreasing seq order (the projection\n * appends in event order, so this is the common case and skips the sort). */\nfunction isSortedBySeq(entries: readonly QuestionEntry[]): boolean {\n for (let i = 1; i < entries.length; i++) {\n if (entries[i].seq < entries[i - 1].seq) return false\n }\n return true\n}\n\n/**\n * Fold the projection's question list into one dot per turn. Entries arrive\n * in event order; consecutive same-turn entries merge into a single dot whose\n * anchor is the turn's first question. The input is expected to be sorted by\n * seq; the defensive sort is skipped when it already is, so a long session\n * never pays an O(n log n) sort on every content update.\n */\nexport function groupQuestionsByTurn(entries: readonly QuestionEntry[]): TurnDot[] {\n const sorted = isSortedBySeq(entries) ? entries : [...entries].sort((a, b) => a.seq - b.seq)\n const dots: TurnDot[] = []\n for (const entry of sorted) {\n const key = questionKey(entry.id)\n const last = dots.at(-1)\n if (last !== undefined && last.turn === entry.turn) {\n dots[dots.length - 1] = {\n ...last,\n texts: [...last.texts, entry.text],\n memberKeys: [...last.memberKeys, key],\n }\n continue\n }\n dots.push({\n turn: entry.turn,\n key,\n anchorSeq: entry.seq,\n time: entry.time,\n texts: [entry.text],\n memberKeys: [key],\n })\n }\n return dots\n}\n\n/**\n * Merge live-window questions the projection has not recorded yet (the brief\n * window before the session/projection push frame lands). A live question\n * whose key is already folded into a dot is dropped (the projected copy\n * wins); the rest become single-question dots with `turn: null`, inserted in\n * anchor-seq order so the strip stays strictly chronological.\n *\n * Fast path: when nothing new arrives the SAME array is returned (no copy),\n * so the caller can bail out of a re-render on identical reference.\n */\nexport function mergeLiveQuestions(\n dots: readonly TurnDot[],\n live: readonly QuestionNode[],\n): TurnDot[] {\n if (live.length === 0) return dots as TurnDot[]\n const known = new Set<string>()\n for (const dot of dots) {\n for (const key of dot.memberKeys) known.add(key)\n }\n const extras: TurnDot[] = []\n for (const question of live) {\n if (known.has(question.key)) continue\n extras.push({\n turn: null,\n key: question.key,\n anchorSeq: question.anchorSeq,\n time: question.time,\n texts: [question.text],\n memberKeys: [question.key],\n })\n }\n // Nothing new from the live window — reuse the input array unchanged.\n if (extras.length === 0) return dots as TurnDot[]\n // Both `dots` and `extras` are sorted by anchorSeq (dots from the projection\n // order, extras from the live window order): merge linearly instead of\n // re-sorting the whole list. Ties keep the projected dot first (stable\n // sort semantics), matching the previous [...dots, ...extras].sort().\n const out: TurnDot[] = []\n let i = 0\n for (const extra of extras) {\n while (i < dots.length && dots[i].anchorSeq <= extra.anchorSeq) {\n out.push(dots[i])\n i += 1\n }\n out.push(extra)\n }\n while (i < dots.length) {\n out.push(dots[i])\n i += 1\n }\n return out\n}\n","/**\n * Question-nav minimap. Renders a vertical column of small round dots overlaid\n * on the LEFT edge of the conversation column (via the frame-wide\n * `shell.overlay` floating layer), vertically centered: one dot per turn that\n * claimed at least one user question — strictly aligned with the Trajectory\n * view's turn numbering (turns without a question produce no dot). Hover\n * enlarges a dot and shows an instant tooltip (portal-rendered, no native\n * delay) with the turn label and the turn's question text(s); clicking jumps\n * the chat to that turn's first question.\n *\n * Data source: the host-folded `questionIndex` session projection (whole\n * history, persisted host-side, pushed live through session/projection\n * frames) read through the injected `questionProjection` face, plus the live\n * chat window's questions merged on top for the brief window before a\n * just-sent question lands in the projection. No render-window expansion, no\n * client-side history paging.\n *\n * Data arrives through the props shares: the framework `useSessions` hook\n * (current session), the registrant inject face (read/subscribe/project/\n * jump), and the bound locale translator.\n */\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport { createPortal } from 'react-dom'\nimport type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { SessionId } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: pulls the ui-layout SlotMap merge ('shell.overlay').\nimport type {} from '@deepseek-ai/dsh-client-ui-layout/client'\nimport type { QuestionNode } from '../core/nodes.ts'\nimport type { QuestionEntry } from '../core/question-entry.ts'\nimport { groupQuestionsByTurn, mergeLiveQuestions, type TurnDot } from '../core/turn-dots.ts'\nimport type { JumpFailureCode } from '../core/jump.ts'\nimport type { QuestionNavKey } from './locales.ts'\nimport styles from './question-nav.module.css'\n\n/** Minimal observable shape of a session projection face. */\nexport interface ObservableFace {\n /** Current projection value (unknown — validated structurally at read). */\n getSnapshot: () => unknown\n /** Subscribe to value changes; returns an unsubscribe. */\n subscribe: (listener: () => void) => () => void\n}\n\n/** Values the registrant inject face supplies (wired in src/client/index.ts). */\nexport interface QuestionNavInjected {\n /** Extract the user questions of a session's currently loaded window. */\n readQuestions: (sessionId: SessionId) => QuestionNode[]\n /** Subscribe to the session list; returns an unsubscribe. */\n subscribeList: (cb: () => void) => () => void\n /** Subscribe to a session's content; returns an unsubscribe. */\n subscribeContent: (sessionId: SessionId, cb: () => void) => () => void\n /** The session's `questionIndex` projection face, when the host unit is registered. */\n questionProjection: (sessionId: SessionId) => ObservableFace | undefined\n /** Jump the chat to a question row (pages the window on demand). */\n jump: (sessionId: SessionId, key: string) => void\n}\n\ntype ComponentProps = PropsRuntime<'shell.overlay'> & QuestionNavInjected & PropsLocale<'question-nav'>\n\nconst FAILURE_HINTS: Record<JumpFailureCode, QuestionNavKey> = {\n VIEW_INACTIVE: 'jump.inactive',\n TARGET_HIDDEN: 'jump.hidden',\n NOT_FOUND: 'jump.notfound',\n TIMEOUT: 'jump.timeout',\n}\n\n/** Live position of the instant hover tooltip. */\ninterface TooltipState {\n /** Turn label line (e.g. \"Turn 32\"); null for ungrouped live questions. */\n title: string | null\n /** Question text lines (one per question folded into the dot). */\n lines: readonly string[]\n left: number\n top: number\n}\n\n/** Read the projection face value as a question-entry list (structural guard). */\nfunction projectionEntries(face: ObservableFace | undefined): QuestionEntry[] {\n const value = face?.getSnapshot()\n if (!Array.isArray(value)) return []\n return value.filter((item): item is QuestionEntry =>\n typeof item === 'object' && item !== null\n && typeof (item as QuestionEntry).id === 'string'\n && typeof (item as QuestionEntry).seq === 'number'\n && typeof (item as QuestionEntry).turn === 'number')\n}\n\nfunction findConvRoot(): HTMLElement | null {\n return document.querySelector<HTMLElement>('[data-slot=\"conversation\"] > div[data-phase]')\n}\n\n/** Structural equality of two dot lists (member keys fully capture a dot's\n * folded questions, so identical key sequences mean identical content).\n * Lets the strip skip a re-render when a refresh produced no change. */\nfunction sameDots(a: readonly TurnDot[], b: readonly TurnDot[]): boolean {\n if (a.length !== b.length) return false\n for (let i = 0; i < a.length; i++) {\n const da = a[i]\n const db = b[i]\n if (da.key !== db.key || da.memberKeys.length !== db.memberKeys.length) return false\n for (let j = 0; j < da.memberKeys.length; j++) {\n if (da.memberKeys[j] !== db.memberKeys[j]) return false\n }\n }\n return true\n}\n\nexport function QuestionNavStrip(props: ComponentProps): React.JSX.Element | null {\n const current = props.useSessions((s) => s.current)\n const summary = props.useSessions((s) => (s.current === undefined ? undefined : s.byId[s.current]))\n const visible = current !== undefined && summary !== undefined && summary.blank !== true\n\n const [dots, setDots] = useState<TurnDot[]>([])\n const [jumpingKey, setJumpingKey] = useState<string | null>(null)\n const [hint, setHint] = useState<string | null>(null)\n const [tooltip, setTooltip] = useState<TooltipState | null>(null)\n const panelRef = useRef<HTMLDivElement | null>(null)\n const hintTimerRef = useRef<number | null>(null)\n // Last rendered dot list, for the change-detection bail-out below.\n const lastDotsRef = useRef<TurnDot[]>([])\n\n const showHint = (message: string): void => {\n setHint(message)\n if (hintTimerRef.current !== null) window.clearTimeout(hintTimerRef.current)\n hintTimerRef.current = window.setTimeout(() => setHint(null), 1800)\n }\n\n // Recompute the dot list from the projection + live window. Subscribed to\n // the projection push frames and the session's content only — session\n // switches are covered by `current` below (the effect re-runs on change),\n // so the session-list feed is not subscribed: it would re-run the full\n // recompute for unrelated list churn.\n useEffect(() => {\n if (!visible || current === undefined) {\n setDots([])\n lastDotsRef.current = []\n return\n }\n const sessionId = current\n const face = props.questionProjection(sessionId)\n const refresh = (): void => {\n const grouped = groupQuestionsByTurn(projectionEntries(face))\n const next = mergeLiveQuestions(grouped, props.readQuestions(sessionId))\n // Identical content (a streaming update that added no question): re-use\n // the previous array reference so React bails out of re-rendering the\n // strip — the common case during assistant streaming.\n if (sameDots(next, lastDotsRef.current)) {\n setDots(lastDotsRef.current)\n return\n }\n lastDotsRef.current = next\n setDots(next)\n }\n refresh()\n const unsubProjection = face?.subscribe(refresh) ?? (() => {})\n const unsubContent = props.subscribeContent(sessionId, refresh)\n return () => {\n unsubProjection()\n unsubContent()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [visible, current, props])\n\n // Listen for jump-failure events and surface the hint.\n useEffect(() => {\n const onJumpFailed = (event: Event): void => {\n const code = (event as CustomEvent<JumpFailureCode>).detail\n showHint(props.t(FAILURE_HINTS[code] ?? 'jump.timeout'))\n }\n window.addEventListener('question-nav:jump-failed', onJumpFailed)\n return () => window.removeEventListener('question-nav:jump-failed', onJumpFailed)\n }, [props])\n\n // Anchor the minimap to the conversation column: position it at the left\n // edge of the conversation root and reserve a thin rail with padding-left.\n //\n // A layout-correction loop keeps the rail pinned to the conversation even\n // when an outside panel (e.g. a browser-extension sidebar like Doubao) moves\n // or resizes the frame without resizing the browser window: `window resize`\n // never fires for in-page panels, and a ResizeObserver on the conversation\n // root alone misses remounts and the tail of the frame's grid-column\n // transition, which used to leave the rail drifting into the session list.\n // The loop runs while the layout is still moving, then parks itself after a\n // few stable frames; observers re-wake it on the next change.\n useLayoutEffect(() => {\n if (!visible) return\n let raf = 0\n let idle = 0\n let stopped = false\n let observer: ResizeObserver | null = null\n const observed = { frame: null as Element | null, convRoot: null as Element | null }\n\n const applyLayout = (): boolean => {\n const panel = panelRef.current\n if (panel === null) return false\n const frame = panel.closest('[data-shell-overlay]')?.parentElement ?? null\n const convRoot = findConvRoot()\n // Keep looping while the anchors are not both present (conversation not\n // mounted yet / mid-reflow), so a late mount still aligns.\n if (frame === null || convRoot === null) return true\n // Keep observing the live nodes: the conversation root may remount\n // (e.g. after a panel-triggered reflow), which silently detaches an\n // earlier ResizeObserver target.\n if (observer !== null) {\n if (observed.frame !== frame) {\n observer.observe(frame, { box: 'border-box' })\n observed.frame = frame\n }\n if (observed.convRoot !== convRoot) {\n observer.observe(convRoot, { box: 'border-box' })\n observed.convRoot = convRoot\n }\n }\n const frameRect = frame.getBoundingClientRect()\n const convRect = convRoot.getBoundingClientRect()\n // Never snap onto a transient box: keep correcting until the\n // conversation has a real footprint again.\n if (convRect.height <= 0 || convRect.width <= 0) return true\n const top = `${convRect.top - frameRect.top}px`\n const height = `${convRect.height}px`\n const left = `${convRect.left - frameRect.left}px`\n if (panel.style.top === top && panel.style.height === height && panel.style.left === left) {\n return false\n }\n panel.style.top = top\n panel.style.height = height\n panel.style.left = left\n return true\n }\n\n const loop = (): void => {\n if (stopped) return\n raf = 0\n idle = applyLayout() ? 0 : idle + 1\n if (idle < 3) raf = requestAnimationFrame(loop)\n }\n const wake = (): void => {\n if (stopped) return\n idle = 0\n if (raf === 0) raf = requestAnimationFrame(loop)\n }\n\n observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(wake)\n if (observer !== null) {\n const panel = panelRef.current\n const frame = panel?.closest('[data-shell-overlay]')?.parentElement ?? null\n const convRoot = findConvRoot()\n if (frame !== null) { observer.observe(frame, { box: 'border-box' }); observed.frame = frame }\n if (convRoot !== null) { observer.observe(convRoot, { box: 'border-box' }); observed.convRoot = convRoot }\n }\n\n // Initial alignment; the loop keeps correcting through layout transitions.\n wake()\n window.addEventListener('resize', wake)\n return () => {\n stopped = true\n if (raf !== 0) cancelAnimationFrame(raf)\n observer?.disconnect()\n window.removeEventListener('resize', wake)\n }\n }, [visible])\n\n // Clear any pending hint timer on unmount.\n useEffect(() => () => {\n if (hintTimerRef.current !== null) window.clearTimeout(hintTimerRef.current)\n }, [])\n\n if (!visible) return null\n\n const onJump = (dot: TurnDot): void => {\n if (current === undefined) return\n setJumpingKey(dot.key)\n props.jump(current, dot.key)\n window.setTimeout(() => setJumpingKey((k) => (k === dot.key ? null : k)), 600)\n }\n\n const openTooltip = (dot: TurnDot, target: HTMLElement): void => {\n const r = target.getBoundingClientRect()\n setTooltip({\n title: dot.turn === null ? null : `Turn ${dot.turn}`,\n lines: dot.texts,\n left: r.right + 10,\n top: r.top,\n })\n }\n\n const t = props.t\n\n return (\n <div ref={panelRef} className={styles.rail} data-question-nav=\"rail\">\n {hint !== null ? <div className={styles.hint} role=\"status\">{hint}</div> : null}\n <div className={styles.list}>\n {dots.length === 0 ? (\n <div className={styles.empty}>{t('strip.empty')}</div>\n ) : (\n <div className={styles.dots}>\n <span className={styles.count}>{dots.length}</span>\n {dots.map((dot) => (\n <button\n key={dot.key}\n className={jumpingKey === dot.key ? `${styles.dot} ${styles.active}` : styles.dot}\n aria-label={dot.texts[0] ?? ''}\n onMouseEnter={(e) => openTooltip(dot, e.currentTarget)}\n onMouseLeave={() => setTooltip(null)}\n onClick={() => onJump(dot)}\n />\n ))}\n </div>\n )}\n </div>\n {tooltip !== null\n ? createPortal(\n <div className={styles.tooltip} style={{ left: tooltip.left, top: tooltip.top }}>\n {tooltip.title !== null ? <div className={styles.tooltipTitle}>{tooltip.title}</div> : null}\n {tooltip.lines.map((line, index) => (\n <div key={index} className={styles.tooltipLine}>{line}</div>\n ))}\n </div>,\n document.body,\n )\n : null}\n </div>\n )\n}\n","/**\n * Locale dictionaries for the question-nav surface (zh/en). Registered under\n * the `question-nav` namespace; keys are consumed through the bound translator.\n */\nexport const zh = {\n 'strip.empty': '本会话还没有提问',\n 'jump.inactive': '聊天视图未激活',\n 'jump.hidden': '目标无独立气泡,已定位到邻近内容',\n 'jump.notfound': '目标未加载或不存在(可能已压缩)',\n 'jump.timeout': '加载历史超时,可重试',\n} as const\n\nexport const en = {\n 'strip.empty': 'No questions in this session yet',\n 'jump.inactive': 'Chat view is not active',\n 'jump.hidden': 'No dedicated bubble; landed on nearby content',\n 'jump.notfound': 'Target not loaded or missing (maybe compacted)',\n 'jump.timeout': 'Timed out loading history; retry',\n} as const\n\nexport type QuestionNavKey = keyof typeof zh\n","/**\n * Pure node-indexing logic for the question-nav plugin. No React, no DOM, no\n * Cordis — every function here is a pure transform over chat-node data so it\n * can be unit-tested in isolation (and reused by the browser half).\n */\n\n/** One user question as shown in the strip and targeted by a jump. */\nexport interface QuestionNode {\n /** Chat anchor key, matches a `[data-chat-anchor-key]` row in the scrollport. */\n key: string\n /** Monotone anchor sequence for ordering and window-min detection. */\n anchorSeq: number\n /** Event seq of the user message. */\n seq: number\n /** Unix ms timestamp. */\n time: number\n /** Full question text — shown in the hover tooltip (not truncated). */\n text: string\n}\n\n/** Minimal shape a chat node must expose for indexing (structural, not SDK-bound). */\nexport interface ChatNodeLike {\n key: string\n anchorSeq: number\n visibility?: string\n kind?: string\n /** Kind-specific payload (a UserMessageNode for `user`/`steering`). */\n data?: unknown\n}\n\n/** Kinds counted as a user question (turn-opening and steering admissions). */\nexport const QUESTION_KINDS = ['user', 'steering'] as const\n\n/** Narrow `node.data` to the user-message payload we read. */\ninterface UserDataLike {\n content?: readonly { type?: string; text?: string }[]\n seq?: number\n time?: number\n}\n\nfunction userData(data: unknown): UserDataLike | undefined {\n if (typeof data !== 'object' || data === null) return undefined\n return data as UserDataLike\n}\n\n/** First text block of a user message; falls back to the raw first block. */\nexport function messageText(content: readonly { type?: string; text?: string }[] | undefined): string {\n if (content === undefined || content.length === 0) return ''\n const first = content[0]\n if (typeof first?.text === 'string') return first.text\n return ''\n}\n\n/** Extract the user questions from a chat-node window, ordered by anchorSeq. */\nexport function extractQuestions(nodes: Iterable<ChatNodeLike>): QuestionNode[] {\n const out: QuestionNode[] = []\n for (const node of nodes) {\n if (!QUESTION_KINDS.includes(node.kind as (typeof QUESTION_KINDS)[number])) continue\n const payload = userData(node.data)\n out.push({\n key: node.key,\n anchorSeq: node.anchorSeq,\n seq: payload?.seq ?? -1,\n time: payload?.time ?? 0,\n // Full question text: shown in the hover tooltip (not truncated).\n text: messageText(payload?.content),\n })\n }\n out.sort((a, b) => a.anchorSeq - b.anchorSeq)\n return out\n}\n\n/** Whether a node is actually rendered (visible rows only are scroll targets). */\nexport function isRenderable(node: ChatNodeLike): boolean {\n return node.visibility !== 'hidden'\n}\n\n/** The row of the window that renders the given key (exact match). */\nexport function findQuestionRow(nodes: Iterable<ChatNodeLike>, key: string): ChatNodeLike | null {\n for (const node of nodes) {\n if (node.key === key) return node\n }\n return null\n}\n\n/** Nearest renderable row for a key that is absent or hidden (compaction, windowing). */\nexport function nearestRenderable(\n nodes: Iterable<{ key: string; anchorSeq: number; visibility?: string }>,\n excludeKey: string | undefined,\n): { key: string; anchorSeq: number } | null {\n let best: { key: string; anchorSeq: number } | null = null\n for (const node of nodes) {\n if (node.visibility === 'hidden') continue\n if (node.key === excludeKey) continue\n if (best === null || node.anchorSeq < best.anchorSeq) best = { key: node.key, anchorSeq: node.anchorSeq }\n }\n return best\n}\n","/**\n * Jump-to-question orchestration. Pure-ish: takes injected ports (snapshot\n * read, loadOlder, DOM row lookup, view liveness, scroll, timers) so the\n * paging/timeout/fallback loop is unit-testable without a real browser or\n * session. The browser half wires these ports to ctx.sessions + the DOM.\n */\n\nimport { nearestRenderable } from './nodes.ts'\n\n/** The bits of a session snapshot the jump loop needs. */\nexport interface JumpSnapshot {\n openState: string\n hasMore: boolean\n loadingOlder: boolean\n /** Renderable chat rows as a key->renderable map (or iterable of rows). */\n rows: Iterable<{ key: string; anchorSeq: number; visibility?: string }>\n}\n\nexport interface JumpPorts {\n /** Read the current snapshot; undefined when the session/view is unavailable. */\n snapshot: () => JumpSnapshot | undefined\n /** Expand the window backwards; rejects/throws on failure. */\n loadOlder: () => Promise<void>\n /** True while the chat view is active (a `[data-chat-flow]` is mounted). */\n isViewActive: () => boolean\n /** Find the DOM row for a chat anchor key; null when not rendered. */\n findRow: (key: string) => HTMLElement | null\n /** Scroll a row into view at the top. */\n scrollIntoView: (row: HTMLElement) => void\n /** Monotonic ms clock. */\n now: () => number\n /** Async sleep. */\n sleep: (ms: number) => Promise<void>\n /** Report a terminal failure to the caller (for a hint). */\n report?: (code: JumpFailureCode, fallback?: boolean) => void\n}\n\nexport type JumpFailureCode = 'VIEW_INACTIVE' | 'TARGET_HIDDEN' | 'NOT_FOUND' | 'TIMEOUT'\n\nexport interface JumpResult {\n ok: boolean\n code?: JumpFailureCode\n /** True when we landed on a fallback row rather than the exact target. */\n fallback?: boolean\n}\n\nexport interface JumpOptions {\n /** Total wall-clock budget for loadOlder paging. */\n totalTimeoutMs?: number\n /** Max loadOlder pages before giving up. */\n maxPages?: number\n /** Poll interval for the row to render after it is known to be in the window. */\n rowWaitMs?: number\n /** Poll interval for state transitions (loadingOlder / openState). */\n pollMs?: number\n}\n\nconst DEFAULTS = {\n totalTimeoutMs: 15_000,\n maxPages: 100,\n rowWaitMs: 8_000,\n pollMs: 60,\n}\n\nfunction minAnchorSeq(rows: Iterable<{ anchorSeq: number }>): number | null {\n let min: number | null = null\n for (const row of rows) {\n if (min === null || row.anchorSeq < min) min = row.anchorSeq\n }\n return min\n}\n\nfunction renderable(rows: Iterable<{ key: string; anchorSeq: number; visibility?: string }>): { key: string; anchorSeq: number }[] {\n const out: { key: string; anchorSeq: number }[] = []\n for (const row of rows) {\n if (row.visibility === 'hidden') continue\n out.push({ key: row.key, anchorSeq: row.anchorSeq })\n }\n return out\n}\n\n/**\n * Jump to the row for `key`, paging older content until it is rendered (or the\n * budget is exhausted). Falls back to the nearest renderable row when the\n * exact row is hidden/absent.\n */\nexport async function jumpToQuestion(ports: JumpPorts, key: string, options: JumpOptions = {}): Promise<JumpResult> {\n const cfg = { ...DEFAULTS, ...options }\n const fail = (code: JumpFailureCode, fallback = false): JumpResult => {\n ports.report?.(code, fallback)\n return fallback ? { ok: false, code, fallback: true } : { ok: false, code }\n }\n\n if (!ports.isViewActive()) return fail('VIEW_INACTIVE')\n\n const deadline = ports.now() + cfg.totalTimeoutMs\n let pages = 0\n\n // Phase 1: page older until the key appears in the loaded window.\n while (true) {\n const snap = ports.snapshot()\n if (snap === undefined) return fail('VIEW_INACTIVE')\n const rows = renderable(snap.rows)\n if (rows.some((r) => r.key === key)) break\n if (snap.openState !== 'open') {\n if (snap.openState === 'error' || ports.now() > deadline) {\n return fail(snap.openState === 'error' ? 'VIEW_INACTIVE' : 'TIMEOUT')\n }\n await ports.sleep(cfg.pollMs)\n continue\n }\n if (snap.hasMore !== true) return fail('NOT_FOUND')\n if (pages >= cfg.maxPages || ports.now() > deadline) return fail('TIMEOUT')\n if (snap.loadingOlder) {\n await ports.sleep(cfg.pollMs)\n continue\n }\n const before = minAnchorSeq(rows)\n await ports.loadOlder()\n pages += 1\n const afterSnap = ports.snapshot()\n const after = minAnchorSeq(afterSnap === undefined ? [] : afterSnap.rows)\n if (after === null || (before !== null && after >= before)) return fail('NOT_FOUND')\n }\n\n // Phase 2: wait for the row to render, then scroll. Fall back if hidden.\n const waitedFor = async (rowKey: string): Promise<HTMLElement | null> => {\n for (let waited = 0; waited <= cfg.rowWaitMs; waited += cfg.pollMs) {\n if (!ports.isViewActive()) return null\n const row = ports.findRow(rowKey)\n if (row !== null) return row\n await ports.sleep(cfg.pollMs)\n }\n return null\n }\n\n const row = await waitedFor(key)\n if (row !== null) {\n ports.scrollIntoView(row)\n return { ok: true }\n }\n\n const snap = ports.snapshot()\n const fallback = nearestRenderable(snap === undefined ? [] : snap.rows, key)\n if (fallback !== null) {\n const fbRow = await waitedFor(fallback.key)\n if (fbRow !== null) {\n ports.scrollIntoView(fbRow)\n return fail('TARGET_HIDDEN', true)\n }\n }\n return fail('TARGET_HIDDEN', false)\n}\n","/**\n * Browser-half entry for the dsh-question-nav plugin.\n *\n * Registers one surface into the frame-wide floating layer (`shell.overlay`):\n * a vertical strip on the LEFT edge of the conversation column listing every\n * user question in the current session as a small button, one dot per turn.\n * Clicking a button scrolls the chat to that turn's first question.\n *\n * The dots are driven by the host-folded `questionIndex` session projection\n * (registered by the plugin's host half): the projection registry folds the\n * WHOLE event log without touching the chat's paged render window, the\n * projection cache persists it, and the standard carriers (history tail-page\n * baseline + session/projection push frames) keep it live. Live-window\n * questions not yet recorded by the projection are merged on top so a\n * just-sent question appears immediately.\n *\n * Failure policy: nothing here throws at apply time — an external plugin must\n * never take the GUI down.\n */\nimport type { ClientContext } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { SessionId } from '@deepseek-ai/dsh-client-connection/client'\n// Type-only: pulls ui-layout's SlotMap merge ('shell.overlay').\nimport type {} from '@deepseek-ai/dsh-client-ui-layout/client'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\nimport { QuestionNavStrip, type ObservableFace, type QuestionNavInjected } from './QuestionNavStrip.tsx'\nimport { en, zh, type QuestionNavKey } from './locales.ts'\nimport { extractQuestions } from '../core/nodes.ts'\nimport { jumpToQuestion, type JumpFailureCode, type JumpPorts } from '../core/jump.ts'\n\n/** Locale namespace this plugin owns. */\nconst NS = 'question-nav'\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** question-nav surface copy. */\n 'question-nav': QuestionNavKey\n }\n}\n\n/** Services required by this plugin. */\nexport const inject = ['slots', 'locale', 'sessions']\n\n/** Single-instance guard: a duplicated client injection must not mount twice. */\ndeclare global {\n // eslint-disable-next-line no-var\n var __dshQuestionNavApplied: boolean | undefined\n}\n\nfunction claimApply(): boolean {\n if (globalThis.__dshQuestionNavApplied === true) return false\n globalThis.__dshQuestionNavApplied = true\n return true\n}\n\nfunction releaseApply(): void {\n globalThis.__dshQuestionNavApplied = undefined\n}\n\n/** Map the session snapshot to the jump-loop port surface. */\nfunction jumpPortsFor(ctx: ClientContext, sessionId: SessionId): JumpPorts {\n return {\n snapshot: () => {\n const binding = ctx.sessions.binding(sessionId)\n const snap = binding?.session.getSnapshot()\n if (snap === undefined) return undefined\n return {\n openState: snap.openState,\n hasMore: snap.hasMore,\n loadingOlder: snap.loadingOlder,\n rows: snap.chat.nodes.values(),\n }\n },\n loadOlder: async () => {\n const binding = ctx.sessions.binding(sessionId)\n if (binding === undefined) throw new Error('session unavailable')\n await binding.session.loadOlder()\n },\n isViewActive: () => document.querySelector('[data-chat-flow]') !== null,\n findRow: (key: string) => {\n for (const candidate of Array.from(document.querySelectorAll<HTMLElement>('[data-chat-anchor-key]'))) {\n if (candidate.dataset.chatAnchorKey === key) return candidate\n }\n return null\n },\n scrollIntoView: (row) => row.scrollIntoView({ block: 'start' }),\n now: () => Date.now(),\n sleep: (ms) => new Promise((resolve) => window.setTimeout(resolve, ms)),\n }\n}\n\n/**\n * The session's `questionIndex` projection face (getSnapshot + subscribe).\n * Undefined when the session is not bound or the host unit is not registered\n * (e.g. a headless composition) — the strip then shows live-window dots only.\n */\nfunction questionProjectionOf(ctx: ClientContext, sessionId: SessionId): ObservableFace | undefined {\n const face = ctx.sessions.binding(sessionId)?.session.projections.faceOf('questionIndex')\n if (face === undefined) return undefined\n return {\n getSnapshot: () => face.getSnapshot(),\n subscribe: (listener) => face.subscribe(listener),\n }\n}\n\nfunction createInject(ctx: ClientContext): QuestionNavInjected {\n return {\n readQuestions: (sessionId) => {\n const snap = ctx.sessions.binding(sessionId)?.session.getSnapshot()\n if (snap === undefined) return []\n return extractQuestions(snap.chat.nodes.values())\n },\n subscribeList: (cb) => ctx.sessions.list.subscribe(cb),\n subscribeContent: (sessionId, cb) => {\n const binding = ctx.sessions.binding(sessionId)\n if (binding === undefined) return () => {}\n return binding.session.subscribe(cb)\n },\n questionProjection: (sessionId) => questionProjectionOf(ctx, sessionId),\n jump: (sessionId, key) => {\n const ports = jumpPortsFor(ctx, sessionId)\n ports.report = (code: JumpFailureCode) => {\n // Surface the failure through the component via a DOM event the\n // strip listens for; simplest reliable cross-boundary channel here.\n window.dispatchEvent(new CustomEvent('question-nav:jump-failed', { detail: code }))\n }\n void jumpToQuestion(ports, key)\n },\n }\n}\n\n/**\n * Register the question-nav surface.\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n if (!claimApply()) return\n ctx.effect(() => releaseApply, 'question-nav: apply claim')\n\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'question-nav: dictionaries')\n\n const injected = createInject(ctx)\n\n ctx.slots.inject('shell.overlay', () => ctx.slots.register({\n name: 'shell.overlay',\n id: 'question-nav',\n order: 900,\n locale: NS,\n inject: () => injected,\n }, QuestionNavStrip))\n}\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9C,IAAI,CAAC,WAAW,GAAG;GACnB,IAAI,aAAa,cAAc,2BAA2B;GAE1D,IAAI,aAAa,IAAI,OAAO,SAAS,IAAI;IAAE;IAAI;GAAG,CAAC,GAAG,4BAA4B;GAElF,MAAM,WAAW,aAAa,GAAG;GAEjC,IAAI,MAAM,OAAO,uBAAuB,IAAI,MAAM,SAAS;IACzD,MAAM;IACN,IAAI;IACJ,OAAO;IACP,QAAQ;IACR,cAAc;GAChB,GAAG,gBAAgB,CAAC;EACtB"}
@@ -35,7 +35,9 @@ export interface TurnDot {
35
35
  /**
36
36
  * Fold the projection's question list into one dot per turn. Entries arrive
37
37
  * in event order; consecutive same-turn entries merge into a single dot whose
38
- * anchor is the turn's first question.
38
+ * anchor is the turn's first question. The input is expected to be sorted by
39
+ * seq; the defensive sort is skipped when it already is, so a long session
40
+ * never pays an O(n log n) sort on every content update.
39
41
  */
40
42
  export declare function groupQuestionsByTurn(entries: readonly QuestionEntry[]): TurnDot[];
41
43
  /**
@@ -44,5 +46,8 @@ export declare function groupQuestionsByTurn(entries: readonly QuestionEntry[]):
44
46
  * whose key is already folded into a dot is dropped (the projected copy
45
47
  * wins); the rest become single-question dots with `turn: null`, inserted in
46
48
  * anchor-seq order so the strip stays strictly chronological.
49
+ *
50
+ * Fast path: when nothing new arrives the SAME array is returned (no copy),
51
+ * so the caller can bail out of a re-render on identical reference.
47
52
  */
48
53
  export declare function mergeLiveQuestions(dots: readonly TurnDot[], live: readonly QuestionNode[]): TurnDot[];
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@luziyang2026/dsh-question-nav",
3
3
  "description": "In-session question navigator for the DSH web GUI: a vertical minimap of round dots overlaid on the left edge of the conversation column, one dot per user question — hover enlarges and shows the full question text, click jumps to that message.",
4
- "version": "0.4.1",
4
+ "version": "0.4.2",
5
5
  "type": "module",
6
6
  "packageManager": "pnpm@11.7.0",
7
7
  "engines": {
@@ -88,6 +88,22 @@ function findConvRoot(): HTMLElement | null {
88
88
  return document.querySelector<HTMLElement>('[data-slot="conversation"] > div[data-phase]')
89
89
  }
90
90
 
91
+ /** Structural equality of two dot lists (member keys fully capture a dot's
92
+ * folded questions, so identical key sequences mean identical content).
93
+ * Lets the strip skip a re-render when a refresh produced no change. */
94
+ function sameDots(a: readonly TurnDot[], b: readonly TurnDot[]): boolean {
95
+ if (a.length !== b.length) return false
96
+ for (let i = 0; i < a.length; i++) {
97
+ const da = a[i]
98
+ const db = b[i]
99
+ if (da.key !== db.key || da.memberKeys.length !== db.memberKeys.length) return false
100
+ for (let j = 0; j < da.memberKeys.length; j++) {
101
+ if (da.memberKeys[j] !== db.memberKeys[j]) return false
102
+ }
103
+ }
104
+ return true
105
+ }
106
+
91
107
  export function QuestionNavStrip(props: ComponentProps): React.JSX.Element | null {
92
108
  const current = props.useSessions((s) => s.current)
93
109
  const summary = props.useSessions((s) => (s.current === undefined ? undefined : s.byId[s.current]))
@@ -99,6 +115,8 @@ export function QuestionNavStrip(props: ComponentProps): React.JSX.Element | nul
99
115
  const [tooltip, setTooltip] = useState<TooltipState | null>(null)
100
116
  const panelRef = useRef<HTMLDivElement | null>(null)
101
117
  const hintTimerRef = useRef<number | null>(null)
118
+ // Last rendered dot list, for the change-detection bail-out below.
119
+ const lastDotsRef = useRef<TurnDot[]>([])
102
120
 
103
121
  const showHint = (message: string): void => {
104
122
  setHint(message)
@@ -106,27 +124,38 @@ export function QuestionNavStrip(props: ComponentProps): React.JSX.Element | nul
106
124
  hintTimerRef.current = window.setTimeout(() => setHint(null), 1800)
107
125
  }
108
126
 
109
- // Recompute the dot list from the projection + live window; subscribe to
110
- // the projection push frames, session content, and the session list.
127
+ // Recompute the dot list from the projection + live window. Subscribed to
128
+ // the projection push frames and the session's content only session
129
+ // switches are covered by `current` below (the effect re-runs on change),
130
+ // so the session-list feed is not subscribed: it would re-run the full
131
+ // recompute for unrelated list churn.
111
132
  useEffect(() => {
112
133
  if (!visible || current === undefined) {
113
134
  setDots([])
135
+ lastDotsRef.current = []
114
136
  return
115
137
  }
116
138
  const sessionId = current
117
139
  const face = props.questionProjection(sessionId)
118
140
  const refresh = (): void => {
119
141
  const grouped = groupQuestionsByTurn(projectionEntries(face))
120
- setDots(mergeLiveQuestions(grouped, props.readQuestions(sessionId)))
142
+ const next = mergeLiveQuestions(grouped, props.readQuestions(sessionId))
143
+ // Identical content (a streaming update that added no question): re-use
144
+ // the previous array reference so React bails out of re-rendering the
145
+ // strip — the common case during assistant streaming.
146
+ if (sameDots(next, lastDotsRef.current)) {
147
+ setDots(lastDotsRef.current)
148
+ return
149
+ }
150
+ lastDotsRef.current = next
151
+ setDots(next)
121
152
  }
122
153
  refresh()
123
154
  const unsubProjection = face?.subscribe(refresh) ?? (() => {})
124
155
  const unsubContent = props.subscribeContent(sessionId, refresh)
125
- const unsubList = props.subscribeList(refresh)
126
156
  return () => {
127
157
  unsubProjection()
128
158
  unsubContent()
129
- unsubList()
130
159
  }
131
160
  // eslint-disable-next-line react-hooks/exhaustive-deps
132
161
  }, [visible, current, props])
@@ -143,40 +172,90 @@ export function QuestionNavStrip(props: ComponentProps): React.JSX.Element | nul
143
172
 
144
173
  // Anchor the minimap to the conversation column: position it at the left
145
174
  // edge of the conversation root and reserve a thin rail with padding-left.
175
+ //
176
+ // A layout-correction loop keeps the rail pinned to the conversation even
177
+ // when an outside panel (e.g. a browser-extension sidebar like Doubao) moves
178
+ // or resizes the frame without resizing the browser window: `window resize`
179
+ // never fires for in-page panels, and a ResizeObserver on the conversation
180
+ // root alone misses remounts and the tail of the frame's grid-column
181
+ // transition, which used to leave the rail drifting into the session list.
182
+ // The loop runs while the layout is still moving, then parks itself after a
183
+ // few stable frames; observers re-wake it on the next change.
146
184
  useLayoutEffect(() => {
147
185
  if (!visible) return
148
186
  let raf = 0
149
- let retries = 0
150
- const applyLayout = (): void => {
187
+ let idle = 0
188
+ let stopped = false
189
+ let observer: ResizeObserver | null = null
190
+ const observed = { frame: null as Element | null, convRoot: null as Element | null }
191
+
192
+ const applyLayout = (): boolean => {
151
193
  const panel = panelRef.current
152
- if (panel === null) return
194
+ if (panel === null) return false
153
195
  const frame = panel.closest('[data-shell-overlay]')?.parentElement ?? null
154
196
  const convRoot = findConvRoot()
155
- if (frame === null || convRoot === null) return
197
+ // Keep looping while the anchors are not both present (conversation not
198
+ // mounted yet / mid-reflow), so a late mount still aligns.
199
+ if (frame === null || convRoot === null) return true
200
+ // Keep observing the live nodes: the conversation root may remount
201
+ // (e.g. after a panel-triggered reflow), which silently detaches an
202
+ // earlier ResizeObserver target.
203
+ if (observer !== null) {
204
+ if (observed.frame !== frame) {
205
+ observer.observe(frame, { box: 'border-box' })
206
+ observed.frame = frame
207
+ }
208
+ if (observed.convRoot !== convRoot) {
209
+ observer.observe(convRoot, { box: 'border-box' })
210
+ observed.convRoot = convRoot
211
+ }
212
+ }
156
213
  const frameRect = frame.getBoundingClientRect()
157
214
  const convRect = convRoot.getBoundingClientRect()
158
- if (convRect.height <= 0) {
159
- if (retries < 20) {
160
- retries += 1
161
- raf = requestAnimationFrame(applyLayout)
162
- }
163
- return
215
+ // Never snap onto a transient box: keep correcting until the
216
+ // conversation has a real footprint again.
217
+ if (convRect.height <= 0 || convRect.width <= 0) return true
218
+ const top = `${convRect.top - frameRect.top}px`
219
+ const height = `${convRect.height}px`
220
+ const left = `${convRect.left - frameRect.left}px`
221
+ if (panel.style.top === top && panel.style.height === height && panel.style.left === left) {
222
+ return false
164
223
  }
165
- retries = 0
166
- panel.style.top = `${convRect.top - frameRect.top}px`
167
- panel.style.height = `${convRect.height}px`
168
- panel.style.left = `${convRect.left - frameRect.left}px`
224
+ panel.style.top = top
225
+ panel.style.height = height
226
+ panel.style.left = left
227
+ return true
228
+ }
229
+
230
+ const loop = (): void => {
231
+ if (stopped) return
232
+ raf = 0
233
+ idle = applyLayout() ? 0 : idle + 1
234
+ if (idle < 3) raf = requestAnimationFrame(loop)
235
+ }
236
+ const wake = (): void => {
237
+ if (stopped) return
238
+ idle = 0
239
+ if (raf === 0) raf = requestAnimationFrame(loop)
169
240
  }
170
- applyLayout()
171
- raf = requestAnimationFrame(applyLayout)
172
- const observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(applyLayout)
173
- const convRoot = findConvRoot()
174
- observer?.observe(convRoot ?? document.body, { box: 'border-box' })
175
- window.addEventListener('resize', applyLayout)
241
+
242
+ observer = typeof ResizeObserver === 'undefined' ? null : new ResizeObserver(wake)
243
+ if (observer !== null) {
244
+ const panel = panelRef.current
245
+ const frame = panel?.closest('[data-shell-overlay]')?.parentElement ?? null
246
+ const convRoot = findConvRoot()
247
+ if (frame !== null) { observer.observe(frame, { box: 'border-box' }); observed.frame = frame }
248
+ if (convRoot !== null) { observer.observe(convRoot, { box: 'border-box' }); observed.convRoot = convRoot }
249
+ }
250
+
251
+ // Initial alignment; the loop keeps correcting through layout transitions.
252
+ wake()
253
+ window.addEventListener('resize', wake)
176
254
  return () => {
255
+ stopped = true
177
256
  if (raf !== 0) cancelAnimationFrame(raf)
178
257
  observer?.disconnect()
179
- window.removeEventListener('resize', applyLayout)
258
+ window.removeEventListener('resize', wake)
180
259
  }
181
260
  }, [visible])
182
261
 
@@ -40,13 +40,24 @@ export interface TurnDot {
40
40
  readonly memberKeys: readonly string[]
41
41
  }
42
42
 
43
+ /** True when entries are already in non-decreasing seq order (the projection
44
+ * appends in event order, so this is the common case and skips the sort). */
45
+ function isSortedBySeq(entries: readonly QuestionEntry[]): boolean {
46
+ for (let i = 1; i < entries.length; i++) {
47
+ if (entries[i].seq < entries[i - 1].seq) return false
48
+ }
49
+ return true
50
+ }
51
+
43
52
  /**
44
53
  * Fold the projection's question list into one dot per turn. Entries arrive
45
54
  * in event order; consecutive same-turn entries merge into a single dot whose
46
- * anchor is the turn's first question.
55
+ * anchor is the turn's first question. The input is expected to be sorted by
56
+ * seq; the defensive sort is skipped when it already is, so a long session
57
+ * never pays an O(n log n) sort on every content update.
47
58
  */
48
59
  export function groupQuestionsByTurn(entries: readonly QuestionEntry[]): TurnDot[] {
49
- const sorted = [...entries].sort((a, b) => a.seq - b.seq)
60
+ const sorted = isSortedBySeq(entries) ? entries : [...entries].sort((a, b) => a.seq - b.seq)
50
61
  const dots: TurnDot[] = []
51
62
  for (const entry of sorted) {
52
63
  const key = questionKey(entry.id)
@@ -77,22 +88,49 @@ export function groupQuestionsByTurn(entries: readonly QuestionEntry[]): TurnDot
77
88
  * whose key is already folded into a dot is dropped (the projected copy
78
89
  * wins); the rest become single-question dots with `turn: null`, inserted in
79
90
  * anchor-seq order so the strip stays strictly chronological.
91
+ *
92
+ * Fast path: when nothing new arrives the SAME array is returned (no copy),
93
+ * so the caller can bail out of a re-render on identical reference.
80
94
  */
81
95
  export function mergeLiveQuestions(
82
96
  dots: readonly TurnDot[],
83
97
  live: readonly QuestionNode[],
84
98
  ): TurnDot[] {
85
- const known = new Set(dots.flatMap(dot => dot.memberKeys))
86
- const extras: TurnDot[] = live
87
- .filter(question => !known.has(question.key))
88
- .map(question => ({
99
+ if (live.length === 0) return dots as TurnDot[]
100
+ const known = new Set<string>()
101
+ for (const dot of dots) {
102
+ for (const key of dot.memberKeys) known.add(key)
103
+ }
104
+ const extras: TurnDot[] = []
105
+ for (const question of live) {
106
+ if (known.has(question.key)) continue
107
+ extras.push({
89
108
  turn: null,
90
109
  key: question.key,
91
110
  anchorSeq: question.anchorSeq,
92
111
  time: question.time,
93
112
  texts: [question.text],
94
113
  memberKeys: [question.key],
95
- }))
96
- if (extras.length === 0) return [...dots]
97
- return [...dots, ...extras].sort((a, b) => a.anchorSeq - b.anchorSeq)
114
+ })
115
+ }
116
+ // Nothing new from the live window — reuse the input array unchanged.
117
+ if (extras.length === 0) return dots as TurnDot[]
118
+ // Both `dots` and `extras` are sorted by anchorSeq (dots from the projection
119
+ // order, extras from the live window order): merge linearly instead of
120
+ // re-sorting the whole list. Ties keep the projected dot first (stable
121
+ // sort semantics), matching the previous [...dots, ...extras].sort().
122
+ const out: TurnDot[] = []
123
+ let i = 0
124
+ for (const extra of extras) {
125
+ while (i < dots.length && dots[i].anchorSeq <= extra.anchorSeq) {
126
+ out.push(dots[i])
127
+ i += 1
128
+ }
129
+ out.push(extra)
130
+ }
131
+ while (i < dots.length) {
132
+ out.push(dots[i])
133
+ i += 1
134
+ }
135
+ return out
98
136
  }