@ryuu-64/dsh-find-all 0.1.13 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.14
4
+
5
+ - Fix modern whole-conversation user-text projection using official evaluator semantics and historical facts, with default secret masks and explicit partial coverage for unsupported content.
6
+ - Invalidate stale projections and revalidate actual message ranges before navigation/highlighting; preserve the legacy projection path.
7
+ - Add official DSH `0.2.1-rc.2` to all four DSH peer ranges so normal installation succeeds without a version exemption, while retaining every previously admitted host version.
8
+ - Record isolated Web verification on `0.2.0-rc.2` and `0.2.1-rc.2`, plus packaged Windows Desktop `0.2.1-rc.2` acceptance reported in PR #36. Installer/registry integration and older Desktop hosts were not tested.
9
+
3
10
  ## 0.1.13
4
11
 
5
12
  - Match DSH floating-panel chrome with a compact, title-free move surface instead of a separate six-dot button. Drag empty chrome without intercepting the search field or actions; keep arrow-key movement, Home reset, focus-ring tokens, and aligned status text.
package/README.md CHANGED
@@ -14,7 +14,7 @@ DeepSeek Harness(DSH)的对话查找插件。搜索各工作区对话的标
14
14
  2. 输入 `@ryuu-64/dsh-find-all`,安装并启用。
15
15
  3. 重启 DSH(网页版需重启服务并刷新页面)。
16
16
 
17
- 如果装过 `dsh-find-bar`,请先卸载,避免快捷键冲突。支持的宿主与功能范围见[兼容说明](docs/compatibility.md)。
17
+ 如果装过 `dsh-find-bar`,请先卸载,避免快捷键冲突。现已支持官方 DSH `0.2.1-rc.2`,并保留此前声明的宿主版本;Web 与桌面端的实测范围见[兼容说明](docs/compatibility.md)。
18
18
 
19
19
  ## 使用
20
20
 
@@ -1,6 +1,34 @@
1
+ # Issue 35: modern user-text projection
2
+
3
+ The package now admits official DSH `0.2.1-rc.2` through all four existing DSH peer ranges. Every previously listed release remains admitted; other `0.2.1` prereleases and future versions are not added. Normal installation needs no exact-version exemption. The current release's Web verification and the reported packaged Windows Desktop acceptance are recorded below.
4
+
5
+ The current-conversation whole-session path uses the retained Session's public `uiConversation.userText.createEvaluator()` when the legacy `ui.projectUserText` API is absent. It supplies the historical message's batch-derived session labels and skill names, not the current composer's facts. Official text/display, session/file/folder labels, command/skill names and default secret masks are projected without mounting hidden Chat rows. Unknown or malformed nodes, evaluator/renderer failures, missing capabilities and non-text user attachments produce explicit partial coverage. One failed source does not discard independent usable sources or fall back to its stored raw input.
6
+
7
+ Secret-bearing user text is indexed in its default masked state. The find bar explains this policy. Clicking Show secret changes that message's current display, not the whole-history count; a masked result that no longer matches the live body cannot receive a fabricated highlight. Existing live highlights are revalidated and removed/rebound when their DOM changes. Search never clicks Show secret on the user's behalf. Loaded-content mode continues to describe only the currently rendered content, including text the user explicitly revealed.
8
+
9
+ Session/store generations, evaluator registry revisions, cooperative search-content rules and observable relevant Slot/Factory changes invalidate the cached projection and pending navigation. Relevant durable content/facts changes also invalidate the cut. Navigation loads the durable sequence, resolves its original Chat row and validates the exact UTF-16 DOM Range before highlighting.
10
+
11
+ The public Slot API exposes effective entries, not authenticated renderer provenance. Initial entries are a change baseline only. An already-installed custom replacement using an official key cannot be automatically recognized as custom. Such plugins must use the existing `ryuu.findAllSearchContent` cooperation contract for their changed text semantics; this implementation does not certify arbitrary third-party renderers. Detected subsequent winner changes and renderer errors become partial rather than silently assuming the original display. No third-party file-review plugin was installed for this verification.
12
+
13
+ The historical host matrix below is not rerun automatically by these changes. New host compatibility requires separate real-host acceptance, not merely a wider peer range. The full-text search across conversations is a separate surface and retains its own documented raw/excerpt behavior; this change does not claim that surface masks secrets.
14
+
15
+
16
+ ## Verification status (2026-10-22)
17
+
18
+ - `npm run check`: 196 tests passed. `npm run verify:release`: passed; the packed bundle matched the tested source build.
19
+ - Official DSH `0.2.1-rc.2`, fresh isolated Web profile: the candidate with the expanded peer declarations installed through the normal CLI with no exemption. Real Chat file-label search, two default masked secrets, reveal-local highlight invalidation, second-hit navigation and remount masking passed. The hidden fake-key fragment had zero whole-history matches and one loaded-content match after manual reveal.
20
+ - On that modern host, an 80-turn synthetic conversation initially rendered 25 user messages and 25 assistant replies. Loaded-content counts were 25 each; whole-history counts were 80 each and 160 for their shared prefix, while only 25 turns remained rendered. Independent offscreen navigation to user `001` and assistant `001` loaded the original rows, highlighted the exact query, and remained visible after settling. Query replacement, Close and A/B/A session switching during search passed, as did cross-conversation body search and its retained-query handoff. No page or console errors were recorded.
21
+ - Official DSH `0.2.0-rc.2`, separate isolated Web profile: the unmodified `85e683b` artifact installed normally and passed the same 25/80/160 counts, independent earliest-user/assistant navigation, and query/Close/A/B/A cancellation checks. The prior dependency-download blocker is resolved for this run. The final expanded-declaration package also installed normally on both hosts; direct repository `seedHistory` preparation passed with both persistence-module export shapes.
22
+ - Both Web runs used Windows, Chromium `141.0.7390.37`, a `1400×900` viewport, empty test profiles and completed synthetic messages without model calls. Their production client bundle was byte-identical: SHA-256 `01e6ed3470b4ea42281f1016b88ffdb02246dc9654274666ae978653ba02f0b9`. The support declaration changes no production JavaScript.
23
+ - Chromium previously showed `Aw Snap` error 9 during testing. Its cause was not established. The same tab later recovered and the outstanding assistant navigation passed; this does not claim a browser-crash fix.
24
+ - [PR #36](https://github.com/Ryuu-64/dsh-find-all/pull/36) subsequently reports final `4447dc6` acceptance on packaged Windows Desktop `0.2.1-rc.2`, extracted unchanged from the validly signed official installer and using its bundled CLI. The same candidate tarball passed normal installation, 25/80/160 counts, earliest-user/assistant navigation, cancellation, modern masked-secret/file-label checks and cross-conversation search. Windows installer/registry integration was not tested. Two earlier generic `ERR_FAILED` console entries lacked original URL metadata; follow-up startup/navigation was clean and normal shutdown reproduced the text at `dsh-app://app/plugins/events`, but the earlier entries cannot be individually attributed. This is the PR author's acceptance report, not a new Desktop run by this release preparation.
25
+ - Older Desktop hosts, the other historical host versions and arbitrary third-party renderer replacements were not revalidated by these runs. The repeatable scope and remaining checks are listed in [the regression checklist](issue35-testing.md). No npm publication is implied.
26
+
27
+ ---
28
+
1
29
  # Full-text conversation search
2
30
 
3
- The Full-text conversation search entry targets public DSH `0.2.0-rc.2` at [`639ed015`](https://github.com/deepseek-ai/deepseek-harness/tree/639ed015397290b3745d163aafe02ffee4aa3f84). This is the implementation target, not a new claim that every historical peer version or Electron Desktop has passed acceptance. Package version and peer ranges remain unchanged.
31
+ The Full-text conversation search entry's original contract targets public DSH `0.2.0-rc.2` at [`639ed015`](https://github.com/deepseek-ai/deepseek-harness/tree/639ed015397290b3745d163aafe02ffee4aa3f84). This contract history does not claim that every historical peer version or Electron Desktop has passed acceptance. Current `0.2.1-rc.2` support and verification are recorded above.
4
32
 
5
33
  ## Host and client contract
6
34
 
@@ -115,7 +143,7 @@ Paging errors/stalls and manual stop retain rendered matches and explicitly labe
115
143
  2. **Actual Web runtime + synthetic sessions**: installation of the same packed artifact, real module loader/slot rendering, paging, multiple view transitions and the host-supported disable/re-enable lifecycle must be recorded for each target release. A browser fixture alone cannot pass this layer.
116
144
  3. **Target Electron Desktop smoke**: the same artifact must be checked on the target Desktop build/OS. Web or jsdom success does not pass this layer.
117
145
 
118
- Candidate releases: `0.1.5-rc.2`, `0.1.5-rc.3`, `0.1.6-alpha.1`, `0.1.6-alpha.2`, `0.1.7-alpha.1`, `0.1.7-alpha.2`, `0.1.7-rc.1`, `0.1.7-rc.2`, `0.2.0-rc.1`, `0.2.0-rc.2`.
146
+ Historical scripted matrix targets: `0.1.5-rc.2`, `0.1.5-rc.3`, `0.1.6-alpha.1`, `0.1.6-alpha.2`, `0.1.7-alpha.1`, `0.1.7-alpha.2`, `0.1.7-rc.1`, `0.1.7-rc.2`, `0.2.0-rc.1`, `0.2.0-rc.2`. The separately verified `0.2.1-rc.2` Web run is recorded above; it does not rerun or expand that historical scripted matrix.
119
147
 
120
148
  The 2026-10-02 registry audit compared every published `@deepseek-ai/dsh` version with main's three peer requirements (`>=0.1.5-rc.2 <0.1.6-0 || >=0.1.6-0 <0.2.0-0`) using the official prerequisite rule. The original six-target sample accidentally excluded four releases that the old gate admitted: `0.1.6-alpha.1`, `0.1.7-alpha.1`, `0.1.7-alpha.2`, and `0.1.7-rc.1`. The ten-target candidate includes all currently published versions admitted by that old gate plus both current 0.2 release candidates. The user's Desktop 2.0.14 report identifies its bundled runtime as `0.1.7-rc.1`; Desktop marketing/version labels are not inferred to equal DSH runtime versions.
121
149
 
@@ -0,0 +1,22 @@
1
+ # Issue 35:回归测试清单
2
+
3
+ ## 先知道当前状态
4
+
5
+ 2026-10-22:196 项自动测试和打包检查已通过。官方 DSH `0.2.0-rc.2` 和 `0.2.1-rc.2` 的隔离 Web 回归均已完成,覆盖下列各自适用的场景;新版使用实际声明支持该版本的候选,通过正常安装流程验证。两个宿主的实测内容与 bundle hash 见[兼容说明](compatibility.md)。PR #36 后续报告:同一候选也通过从官方签名安装器原样解包的 Windows Desktop `0.2.1-rc.2` 验收;未测 Windows 安装器/注册表集成及旧版 Desktop。该报告的详细范围与两条未逐一归因的资源错误见[PR #36](https://github.com/Ryuu-64/dsh-find-all/pull/36)。
6
+
7
+ 兼容范围已加入确切的 `0.2.1-rc.2`,其余原有版本保留。复测时不要使用 `allow-version --accept-risk` 绕过安装检查,不要碰真实会话,也不需要调用模型。此前现代测试曾出现浏览器 Error 9,原因未确定;后续通过不能证明修复了该崩溃。
8
+
9
+ ## 按这个顺序测
10
+
11
+ 1. **先跑自动检查。** 检出待测提交,按仓库现有依赖安装方式准备环境,运行 `npm run check` 和 `npm run verify:release`。两项都应通过,打包内容应与当前 `lib/client.js` 一致。
12
+ 2. **在两个目标宿主正常安装。** 分别准备独立的官方 DSH `0.2.0-rc.2` 和 `0.2.1-rc.2` Web 环境与空测试配置,通过正常插件安装流程装入同一份当前候选。记录宿主版本、Git 提交和 bundle SHA-256。不要复用别的任务的运行实例;安装或下载失败就报告阻塞。下列第 3–5 项在两个宿主执行,第 6 项在新版执行。
13
+ 3. **检查“全文”和“已加载”不是同一个数。** 用仓库 `scripts/compat/synthetic-history.mjs` 的 `seedHistory` 在自己的隔离环境准备80轮已结束的假对话。搜索 `FIND_ALL_A_USER_`:全文应有80处;如果页面只加载最后25条,已加载模式应有25处。再搜索 `FIND_ALL_A_REPLY_`,全文应有80处;搜索 `FIND_ALL_A_`,应有160处。
14
+ 4. **检查跳转和高亮。** 在全文结果里跳到第一条用户消息和第一条助手回复。页面应先加载旧消息,再显示001并准确高亮查询文字。等待动作完成后再检查,不能只看刚点击时的结果;不能跳错消息、停在加载中或出现导航失败提示。
15
+ 5. **检查切换和取消。** 搜索时换词、关闭搜索、切到另一条假会话再回来。旧结果不能继续滚动页面或高亮新会话。再搜索应得到对应会话的正确结果。
16
+ 6. **复查现代显示规则时,使用假数据。** 文件引用应按实际显示的文件名找到。两条默认遮挡的假密钥应有2处;手动展开第一条后总数仍为2,第一条旧高亮被清掉并给出提示,第二条仍能跳转。全文不能搜到隐藏的原文片段;已加载模式可以找到手动展开的那一条。切走再回来应重新遮挡并恢复正常定位。此项须用支持这些显示规则的宿主和真实 Chat 消息,不能用独立演示组件代替。安装不兼容就报告,不强行绕过。
17
+
18
+ ## 最后交回什么
19
+
20
+ 简明列出:宿主版本、代码提交、bundle hash、每一步通过/失败/没测、实际计数、导航后的截图。失败时附操作顺序和错误提示,不要附真实密钥、认证链接或整份会话内容。
21
+
22
+ 本清单不授权发布 npm。Electron 桌面端或其他宿主版本需要各自的实机结果,不能用这里的 Web 结果代替。
package/lib/client.js CHANGED
@@ -4221,7 +4221,7 @@ function installConversationSearch(ctx, react, ui, bridge) {
4221
4221
  const pending = data.status === "ready" && body === "pending";
4222
4222
  const empty = data.status === "ready" && query.trim() && body === "ready" && content.complete && !content.failed && !content.skipped && results.items.length === 0;
4223
4223
  const progress = content.scanned > 0 || content.total > 0 ? L.progress(content.scanned, content.total) : "";
4224
- const partial = content.failed || content.skipped ? L.partial(content.failed, content.skipped) : "";
4224
+ const partial2 = content.failed || content.skipped ? L.partial(content.failed, content.skipped) : "";
4225
4225
  const count = L.shown(results.items.length);
4226
4226
  const ready = data.status === "ready" && body === "ready";
4227
4227
  let announcement = "";
@@ -4229,12 +4229,12 @@ function installConversationSearch(ctx, react, ui, bridge) {
4229
4229
  else if (restoreFeedback) announcement = restoreFeedback.text;
4230
4230
  else if (notice) announcement = notice;
4231
4231
  else if (data.status === "ready" && body === "invalid") announcement = L.invalid;
4232
- else if (pending) announcement = [progress || L.pending, partial].filter(Boolean).join(" \xB7 ");
4233
- else if (ready && content.complete && !partial) announcement = count;
4234
- else if (ready && content.cursor) announcement = [L.page(results.items.length), partial].filter(Boolean).join(" \xB7 ");
4235
- else if (ready || body === "stopped" || body === "unavailable") announcement = [status || count, progress, partial].filter(Boolean).join(" \xB7 ");
4232
+ else if (pending) announcement = [progress || L.pending, partial2].filter(Boolean).join(" \xB7 ");
4233
+ else if (ready && content.complete && !partial2) announcement = count;
4234
+ else if (ready && content.cursor) announcement = [L.page(results.items.length), partial2].filter(Boolean).join(" \xB7 ");
4235
+ else if (ready || body === "stopped" || body === "unavailable") announcement = [status || count, progress, partial2].filter(Boolean).join(" \xB7 ");
4236
4236
  else if (data.status !== "ready") announcement = status;
4237
- const emptyStatus = body === "invalid" && data.status === "ready" ? L.invalidShort : empty ? L.noMatches : body === "unavailable" && data.status === "ready" ? L.unavailableShort : body === "stopped" && data.status === "ready" ? L.stoppedShort : status || (partial ? L.partialShort : ready && content.cursor ? L.noMatchesYet : "");
4237
+ const emptyStatus = body === "invalid" && data.status === "ready" ? L.invalidShort : empty ? L.noMatches : body === "unavailable" && data.status === "ready" ? L.unavailableShort : body === "stopped" && data.status === "ready" ? L.stoppedShort : status || (partial2 ? L.partialShort : ready && content.cursor ? L.noMatchesYet : "");
4238
4238
  const requestClose = () => {
4239
4239
  const dialog = details.current?.closest('[role="dialog"]');
4240
4240
  if (dialog && Array.from(document.querySelectorAll('[role="dialog"][aria-modal="true"],[role="menu"]')).pop() === dialog) dismiss();
@@ -4485,6 +4485,62 @@ async function checkLatestVersion(currentVersion, signal) {
4485
4485
  }
4486
4486
  }
4487
4487
 
4488
+ // src/history-revision.js
4489
+ var MESSAGE_KINDS = /* @__PURE__ */ new Set(["user", "steering", "context", "turn-trigger"]);
4490
+ var sequence = (value, minimum = 0) => Number.isSafeInteger(value) && value >= minimum && !Object.is(value, -0);
4491
+ function durable(node) {
4492
+ if (typeof node?.key !== "string" || !node.data || typeof node.data !== "object") return void 0;
4493
+ const data = node.data;
4494
+ if (MESSAGE_KINDS.has(node.kind) && sequence(data.seq)) return { seq: data.seq, value: data };
4495
+ if (node.kind === "assistant-step" && data.finalNode && sequence(data.finalNode.seq)) {
4496
+ return { seq: data.finalNode.seq, value: { finalNode: data.finalNode, blocks: data.blocks } };
4497
+ }
4498
+ return void 0;
4499
+ }
4500
+ function createHistoryRevisionTracker(store) {
4501
+ const baseline = /* @__PURE__ */ new Map(), latest = /* @__PURE__ */ new Map();
4502
+ let changed = false;
4503
+ function capture(node, description) {
4504
+ const previous = latest.get(node.key);
4505
+ const signature = previous?.data === node.data ? previous.signature : JSON.stringify(description.value);
4506
+ if (typeof signature !== "string") throw new Error("Durable Chat data could not be compared");
4507
+ const record3 = { data: node.data, kind: node.kind, seq: description.seq, signature };
4508
+ latest.set(node.key, record3);
4509
+ return record3;
4510
+ }
4511
+ try {
4512
+ if (typeof store?.values !== "function") changed = true;
4513
+ else for (const node of store.values()) {
4514
+ const description = durable(node);
4515
+ if (description) baseline.set(node.key, capture(node, description));
4516
+ }
4517
+ } catch {
4518
+ changed = true;
4519
+ }
4520
+ return {
4521
+ check(currentStore, snapshot) {
4522
+ if (changed) return true;
4523
+ if (currentStore !== store) return changed = true;
4524
+ const throughSeq = snapshot?.throughSeq;
4525
+ const hasCut = sequence(throughSeq, -1);
4526
+ try {
4527
+ for (const node of currentStore.values()) {
4528
+ const description = durable(node);
4529
+ if (!description) continue;
4530
+ if (hasCut && description.seq > throughSeq) return changed = true;
4531
+ const old = baseline.get(node.key);
4532
+ const current = capture(node, description);
4533
+ if (old && (old.kind !== current.kind || old.seq !== current.seq || old.signature !== current.signature)) return changed = true;
4534
+ if (!old) baseline.set(node.key, current);
4535
+ }
4536
+ } catch {
4537
+ changed = true;
4538
+ }
4539
+ return changed;
4540
+ }
4541
+ };
4542
+ }
4543
+
4488
4544
  // src/context.js
4489
4545
  var MAX_CHARS = 2e4;
4490
4546
  var MAX_ENTRIES = 200;
@@ -4712,7 +4768,7 @@ function createContextClassifier() {
4712
4768
 
4713
4769
  // src/history.js
4714
4770
  var TEXT_TYPES = /* @__PURE__ */ new Set(["text", "reasoning"]);
4715
- var BOUNDARIES = /* @__PURE__ */ new Set(["assistant/message", "tool/call", "tool/result", "llm/retry", "turn/end"]);
4771
+ var BOUNDARIES = /* @__PURE__ */ new Set(["assistant/message", "tool/call", "tool/result", "llm/retry", "turn/end", "turn/start"]);
4716
4772
  var NON_BODY_EVENTS = /* @__PURE__ */ new Set([
4717
4773
  "agent-preset/selected",
4718
4774
  "agent/inbox/spliced",
@@ -4851,16 +4907,16 @@ function assembleAttemptText(stream, seq) {
4851
4907
  requireString(chunk.blockType, "blockType", seq);
4852
4908
  ensure(chunk.index, chunk.blockType);
4853
4909
  } else if (chunk.type === "text-delta" || chunk.type === "reasoning-delta") {
4854
- const partial = ensure(chunk.index, chunk.type === "text-delta" ? "text" : "reasoning");
4910
+ const partial2 = ensure(chunk.index, chunk.type === "text-delta" ? "text" : "reasoning");
4855
4911
  const text = requireString(chunk.text, "Assistant delta", seq);
4856
- if (!partial.closed) partial.fragments.push(text);
4912
+ if (!partial2.closed) partial2.fragments.push(text);
4857
4913
  } else if (chunk.type === "block-end") {
4858
4914
  if (!object(chunk.block) || typeof chunk.block.type !== "string") throw failure("invalid-stream", "Assistant block end is invalid", seq);
4859
- const partial = ensure(chunk.index, chunk.block.type);
4860
- if (!partial.closed) {
4861
- partial.type = chunk.block.type;
4862
- partial.fragments = TEXT_TYPES.has(chunk.block.type) ? [requireString(chunk.block.text, "Assistant block", seq)] : [];
4863
- partial.closed = true;
4915
+ const partial2 = ensure(chunk.index, chunk.block.type);
4916
+ if (!partial2.closed) {
4917
+ partial2.type = chunk.block.type;
4918
+ partial2.fragments = TEXT_TYPES.has(chunk.block.type) ? [requireString(chunk.block.text, "Assistant block", seq)] : [];
4919
+ partial2.closed = true;
4864
4920
  }
4865
4921
  } else if (chunk.type === "tool-call-delta") {
4866
4922
  ensure(chunk.index, "tool-call");
@@ -4891,14 +4947,14 @@ function assembleAttemptText(stream, seq) {
4891
4947
  ensure(record3.index, "tool-call");
4892
4948
  if (typeof record3.id !== "string" || !record3.id || record3.name !== void 0 && (typeof record3.name !== "string" || !record3.name)) throw failure("invalid-stream", "Assistant tool stream identity is invalid", seq);
4893
4949
  } else {
4894
- const partial = ensure(record3.index, record3.type === "text-chunks" ? "text" : "reasoning");
4895
- if (!partial.closed) for (const text of members) partial.fragments.push(text);
4950
+ const partial2 = ensure(record3.index, record3.type === "text-chunks" ? "text" : "reasoning");
4951
+ if (!partial2.closed) for (const text of members) partial2.fragments.push(text);
4896
4952
  }
4897
4953
  }
4898
- return [...partials.values()].filter((partial) => TEXT_TYPES.has(partial.type)).map((partial) => ({
4899
- type: partial.type,
4900
- text: partial.fragments.join(""),
4901
- streamIndex: partial.index
4954
+ return [...partials.values()].filter((partial2) => TEXT_TYPES.has(partial2.type)).map((partial2) => ({
4955
+ type: partial2.type,
4956
+ text: partial2.fragments.join(""),
4957
+ streamIndex: partial2.index
4902
4958
  }));
4903
4959
  }
4904
4960
  function extractEntry(event, sessionId, report) {
@@ -4966,6 +5022,8 @@ function extractEntry(event, sessionId, report) {
4966
5022
  const sourceKind = typeof origin.kind === "string" ? origin.kind : "unknown";
4967
5023
  entry.sourceKind = sourceKind;
4968
5024
  entry.referenceLabels = sourceKind === "session-reference" && Array.isArray(origin.references) ? [...new Set(origin.references.filter((ref) => object(ref) && typeof ref.label === "string" && ref.label).map((ref) => ref.label))] : [];
5025
+ entry.referenceFactsInvalid = sourceKind === "session-reference" && (!Array.isArray(origin.references) || origin.references.some((ref) => !object(ref) || typeof ref.label !== "string" || !ref.label));
5026
+ entry.skillFactsInvalid = sourceKind === "skill-invocation" && (typeof origin.name !== "string" || !origin.name);
4969
5027
  entry.skillName = sourceKind === "skill-invocation" && typeof origin.name === "string" ? origin.name : void 0;
4970
5028
  if (type === "user/message" && sourceKind === "user") {
4971
5029
  checkParts(content, /* @__PURE__ */ new Set(["text"]));
@@ -4979,7 +5037,8 @@ function extractEntry(event, sessionId, report) {
4979
5037
  format: "plain",
4980
5038
  referenceLabels: [],
4981
5039
  skillNames: [],
4982
- contentCount: content.length
5040
+ contentCount: content.length,
5041
+ contextErrors: content.some((part) => part?.type !== "text") ? [{ code: "user-attachment-unprojected", message: "User attachment or extra content is not projected" }] : []
4983
5042
  });
4984
5043
  } else {
4985
5044
  entry.contextVisible = content.some((part) => part?.type === "tool-addition" || part?.type === "tool-removal");
@@ -5177,11 +5236,16 @@ function resolveSources(entries, report) {
5177
5236
  const classifier = createContextClassifier();
5178
5237
  let batchMessages = [];
5179
5238
  let batchSkills = [];
5239
+ let invalidBatchSkills = false;
5180
5240
  const flush = () => {
5181
5241
  const names = [...new Set(batchSkills)];
5182
- for (const source of batchMessages) source.skillNames = names;
5242
+ for (const source of batchMessages) {
5243
+ source.skillNames = names;
5244
+ if (invalidBatchSkills) source.invalidUserFacts = true;
5245
+ }
5183
5246
  batchMessages = [];
5184
5247
  batchSkills = [];
5248
+ invalidBatchSkills = false;
5185
5249
  };
5186
5250
  for (const entry of entries) {
5187
5251
  classifier.accept(entry);
@@ -5208,16 +5272,21 @@ function resolveSources(entries, report) {
5208
5272
  bySeq.set(source.seq, source);
5209
5273
  }
5210
5274
  } else {
5211
- if (entry.referenceLabels?.length) {
5275
+ if (entry.referenceLabels?.length || entry.referenceFactsInvalid) {
5212
5276
  const previous = bySeq.get(entry.seq - 1);
5213
- if (previous) previous.referenceLabels = entry.referenceLabels;
5277
+ if (previous) {
5278
+ previous.referenceLabels = entry.referenceLabels;
5279
+ if (entry.referenceFactsInvalid) previous.invalidUserFacts = true;
5280
+ }
5214
5281
  }
5215
5282
  if (entry.skillName) batchSkills.push(entry.skillName);
5283
+ if (entry.skillFactsInvalid) invalidBatchSkills = true;
5216
5284
  }
5217
5285
  } else if (BOUNDARIES.has(entry.type)) flush();
5218
5286
  }
5219
5287
  flush();
5220
5288
  for (const source of sources) {
5289
+ if (source.kind === "user") source.userTextFacts = source.invalidUserFacts ? null : { sessionLabels: [...source.referenceLabels], skillNames: [...source.skillNames] };
5221
5290
  if (source.kind !== "tool-result") continue;
5222
5291
  const call = calls.get(source.callId);
5223
5292
  if (!call) {
@@ -5325,7 +5394,7 @@ function createHistoryReader({ remote, sessionId, generation = 0, onUpdate, proj
5325
5394
  const entries2 = [];
5326
5395
  for (let index = 0; index < page.records.length; index += 1) {
5327
5396
  assertCurrent();
5328
- const entry = extractEntry(page.records[index].event, sessionId, (issue) => coverageErrors.push(issue));
5397
+ const entry = extractEntry(page.records[index].event, sessionId, (issue2) => coverageErrors.push(issue2));
5329
5398
  if (entry) entries2.push(entry);
5330
5399
  if ((index + 1) % 64 === 0) await tick();
5331
5400
  }
@@ -5341,17 +5410,17 @@ function createHistoryReader({ remote, sessionId, generation = 0, onUpdate, proj
5341
5410
  expectedEnd = proof.first - 1;
5342
5411
  const beforeSeq = proof.first;
5343
5412
  page = void 0;
5344
- const result = await pending(remote.session.page({ address, throughSeq, beforeSeq, maxMessages }, controller.signal));
5413
+ const result2 = await pending(remote.session.page({ address, throughSeq, beforeSeq, maxMessages }, controller.signal));
5345
5414
  assertCurrent();
5346
- if (result?.ok !== true) throw failure(typeof result?.error?.code === "string" ? result.error.code : "page-rpc-failed", typeof result?.error?.message === "string" ? result.error.message : "History page RPC failed");
5347
- page = result.value;
5415
+ if (result2?.ok !== true) throw failure(typeof result2?.error?.code === "string" ? result2.error.code : "page-rpc-failed", typeof result2?.error?.message === "string" ? result2.error.message : "History page RPC failed");
5416
+ page = result2.value;
5348
5417
  }
5349
5418
  assertCurrent();
5350
5419
  page = void 0;
5351
5420
  publish({ readComplete: true, coverageComplete: true, status: "projecting" });
5352
5421
  const entries = pageEntries.reverse().flat();
5353
5422
  pageEntries.length = 0;
5354
- const sources = resolveSources(entries, (issue) => coverageErrors.push(issue));
5423
+ const sources = resolveSources(entries, (issue2) => coverageErrors.push(issue2));
5355
5424
  entries.length = 0;
5356
5425
  const documents = [];
5357
5426
  const errors = coverageErrors;
@@ -5359,25 +5428,34 @@ function createHistoryReader({ remote, sessionId, generation = 0, onUpdate, proj
5359
5428
  assertCurrent();
5360
5429
  const source = sources[index];
5361
5430
  if (sessionCwd !== void 0) source.sessionCwd = sessionCwd;
5362
- const projection = await pending(project(source));
5431
+ let projection;
5432
+ try {
5433
+ projection = await pending(project(source));
5434
+ } catch (error) {
5435
+ assertCurrent();
5436
+ projection = { blocks: [], errors: [{ code: "projection-failed", message: "The display projection failed for this source" }] };
5437
+ }
5363
5438
  assertCurrent();
5364
- if (!object(projection) || !Array.isArray(projection.blocks) || projection.blocks.some((block) => !object(block) || typeof block.text !== "string")) throw failure("invalid-projection", "Text projection returned invalid blocks", source.seq);
5365
- const projectedSource = projection.source === void 0 ? source : projection.source;
5366
- if (!object(projectedSource) || ["sessionId", "seq", "id", "kind", "contentIndex"].some((key) => projectedSource[key] !== source[key])) {
5367
- throw failure("invalid-projection", "Text projection changed durable source identity", source.seq);
5439
+ if (!object(projection) || !Array.isArray(projection.blocks) || projection.blocks.some((block) => !object(block) || typeof block.text !== "string")) projection = { blocks: [], errors: [{ code: "invalid-projection", message: "Text projection returned invalid blocks" }] };
5440
+ let projectedSource = projection.source === void 0 ? source : projection.source;
5441
+ if (!object(projectedSource) || ["sessionId", "seq", "id", "kind", "contentIndex", "messageId", "turn", "step", "stepId"].some((key) => projectedSource[key] !== source[key])) {
5442
+ projectedSource = source;
5443
+ projection = { blocks: [], errors: [{ code: "invalid-projection", message: "Text projection changed durable source identity" }] };
5368
5444
  }
5369
5445
  const localErrors = [...source.contextErrors ?? [], ...Array.isArray(projection.errors) ? projection.errors : []];
5370
5446
  const seenErrors = /* @__PURE__ */ new Set();
5371
5447
  for (const error of localErrors) {
5372
- const issue = errorRecord(error, "projection-incomplete");
5373
- const key = issue.code + "\0" + issue.message;
5374
- if (!seenErrors.has(key)) errors.push({ ...issue, seq: source.seq, textKind: source.kind, ...source.sourceKind === void 0 ? {} : { messageSourceKind: source.sourceKind } });
5448
+ const issue2 = errorRecord(error, "projection-incomplete");
5449
+ const key = issue2.code + "\0" + issue2.message;
5450
+ if (!seenErrors.has(key)) errors.push({ ...issue2, seq: source.seq, textKind: source.kind, ...source.sourceKind === void 0 ? {} : { messageSourceKind: source.sourceKind } });
5375
5451
  seenErrors.add(key);
5376
5452
  }
5377
5453
  documents.push({
5378
5454
  ...projectedSource,
5379
5455
  blocks: projection.blocks,
5380
5456
  ...typeof projection.mapping === "string" ? { mapping: projection.mapping } : {},
5457
+ ...projection.defaultMasked === true ? { defaultMasked: true } : {},
5458
+ ...projection.userTextSemantics === "official-inline" ? { userTextSemantics: "official-inline" } : {},
5381
5459
  ...typeof projection.rootClass === "string" ? { rootClass: projection.rootClass } : {},
5382
5460
  ...typeof projection.cardKind === "string" ? { cardKind: projection.cardKind } : {}
5383
5461
  });
@@ -5510,7 +5588,7 @@ function toolPresentation(source) {
5510
5588
  var BLOCK = new Set("ADDRESS ARTICLE ASIDE BLOCKQUOTE DD DETAILS DIALOG DIV DL DT FIELDSET FIGCAPTION FIGURE FOOTER FORM H1 H2 H3 H4 H5 H6 HEADER HR LI MAIN NAV OL P PRE SECTION SUMMARY TABLE TBODY TD TFOOT TH THEAD TR UL".split(" "));
5511
5589
  var imageAltClasses = /* @__PURE__ */ new Set();
5512
5590
  var SKIP = "script,style,noscript,svg,[data-code-block-banner],[data-clock],.sr-only,.katex-mathml,[data-find-projection-chrome]";
5513
- function collectProjectedBlocks(root, excluded, classify) {
5591
+ function collectProjectedBlocks(root, excluded, classify, options) {
5514
5592
  const blocks = [];
5515
5593
  let text = "", segments = [];
5516
5594
  const flush = () => {
@@ -5549,6 +5627,7 @@ function collectProjectedBlocks(root, excluded, classify) {
5549
5627
  if (description) blocks.push({ text: description, segments: [], imageDescription: true });
5550
5628
  return;
5551
5629
  }
5630
+ if (options?.officialUserInline && node.nodeType === 1 && node.matches('svg[aria-hidden="true"]') && node.closest("[data-ref-chip],[data-secret]")) return;
5552
5631
  if (node.nodeType === 1 && (node.matches(SKIP) || node.tagName === "BR")) {
5553
5632
  flush();
5554
5633
  return;
@@ -5630,8 +5709,8 @@ function semanticSubstring(block, text) {
5630
5709
  }));
5631
5710
  return segments.length ? { text, segments } : null;
5632
5711
  }
5633
- function createProjector(ui, react, document2) {
5634
- if (!ui.MarkdownText || typeof ui.projectUserText !== "function" || !/^18\./u.test(react.version || "")) throw Error("Host text projection unavailable");
5712
+ function createProjector(ui, react, document2, projectUser) {
5713
+ if (!ui.MarkdownText || !/^18\./u.test(react.version || "")) throw Error("Host Markdown projection unavailable");
5635
5714
  const { renderToStaticMarkup } = require_server_browser();
5636
5715
  function render(element) {
5637
5716
  const template = document2.createElement("template");
@@ -5718,6 +5797,8 @@ function createProjector(ui, react, document2) {
5718
5797
  return { blocks, mapping: "markdown", rootClass: root.classList[0], errors: [] };
5719
5798
  }
5720
5799
  if (source.kind === "user" && source.sourceKind === "user") {
5800
+ if (typeof projectUser === "function") return projectUser(source);
5801
+ if (typeof ui.projectUserText !== "function") return { blocks: [], mapping: "user", errors: [{ code: "user-projection-unavailable", message: "Host user-text projection is unavailable; user text was not indexed" }] };
5721
5802
  const fragment = render(react.createElement("div", null, ui.projectUserText(source.raw, source.referenceLabels || [], source.skillNames || [], "skill")));
5722
5803
  return { blocks: collectProjectedBlocks(fragment).map((b, index) => ({ text: b.text, index, ...b.imageDescription ? { imageDescription: true } : {} })), mapping: "user", errors: [] };
5723
5804
  }
@@ -5915,16 +5996,277 @@ function mapProjectedDocument(source, node, rows, targetBlockIndex) {
5915
5996
  }
5916
5997
  if (source.mapping === "user") {
5917
5998
  if (node.data?.seq !== source.seq) return { reason: "source-changed" };
5918
- const candidates = minimumCandidates([...new Set(rows.flatMap((row) => [...row.querySelectorAll("div")]))].filter((el) => sameBlocks(source.blocks, collectProjectedBlocks(el))));
5999
+ if (source.messageId && node.data?.messageId && node.data.messageId !== source.messageId) return { reason: "source-changed" };
6000
+ if (Array.isArray(node.data?.content) && node.data.content.filter((part) => part?.type === "text").map((part) => part.text).join("") !== (source.storedRaw ?? source.raw)) return { reason: "source-changed" };
6001
+ const collectUser = (root) => collectProjectedBlocks(root, void 0, void 0, { officialUserInline: source.userTextSemantics === "official-inline" });
6002
+ const candidates = minimumCandidates([...new Set(rows.flatMap((row) => [...row.querySelectorAll("div")]))].filter((el) => sameBlocks(source.blocks, collectUser(el))));
5919
6003
  if (candidates.length !== 1) return { reason: "user-renderer-ambiguous" };
5920
- return { blocks: collectProjectedBlocks(candidates[0]), root: candidates[0] };
6004
+ return { blocks: collectUser(candidates[0]), root: candidates[0] };
5921
6005
  }
5922
6006
  return { reason: "stored-field-not-rendered" };
5923
6007
  }
5924
6008
 
6009
+ // src/user-projection.js
6010
+ var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
6011
+ var strings2 = (value) => Array.isArray(value) && value.every((item) => typeof item === "string");
6012
+ var integer2 = (value) => Number.isSafeInteger(value) && value >= 0 && !Object.is(value, -0);
6013
+ var issue = (code, message) => ({ code, message });
6014
+ var result = (blocks = [], errors = []) => ({ blocks, mapping: "user", userTextSemantics: "official-inline", errors });
6015
+ var unavailable = () => result([], [issue("user-projection-unavailable", "Host user-text evaluation is unavailable; user text was not indexed")]);
6016
+ function displayText(node, raw) {
6017
+ const data = node.data;
6018
+ if (!object2(data)) return void 0;
6019
+ if (node.id === "text") {
6020
+ if (typeof data.text !== "string" || data.text !== raw.slice(node.start, node.end)) return void 0;
6021
+ return data.display == null ? data.text : typeof data.display === "string" ? data.display : void 0;
6022
+ }
6023
+ if (["session", "file", "folder"].includes(node.id)) return typeof data.label === "string" ? data.label : void 0;
6024
+ if (["skill", "command"].includes(node.id)) return typeof data.name === "string" ? `/${data.name}` : void 0;
6025
+ if (node.id === "secret") return typeof data.masked === "string" ? data.masked : void 0;
6026
+ return void 0;
6027
+ }
6028
+ function projectUserTextNodes(nodes, raw) {
6029
+ if (typeof raw !== "string" || !Array.isArray(nodes)) return result([], [issue("invalid-user-projection", "Host user-text evaluation returned an invalid document")]);
6030
+ let cursor = 0;
6031
+ for (const node of nodes) {
6032
+ if (!object2(node) || typeof node.id !== "string" || !integer2(node.start) || !integer2(node.end) || node.start !== cursor || node.end <= node.start || node.end > raw.length) {
6033
+ return result([], [issue("invalid-user-projection", "Host user-text evaluation did not cover the original document in order")]);
6034
+ }
6035
+ cursor = node.end;
6036
+ }
6037
+ if (cursor !== raw.length) return result([], [issue("invalid-user-projection", "Host user-text evaluation did not cover the original document in order")]);
6038
+ const blocks = [], errors = [];
6039
+ let text = "";
6040
+ const flush = () => {
6041
+ if (text !== "") blocks.push({ text, index: blocks.length });
6042
+ text = "";
6043
+ };
6044
+ for (const node of nodes) {
6045
+ const display = displayText(node, raw);
6046
+ if (display === void 0) {
6047
+ flush();
6048
+ errors.push(issue("unsupported-user-node", "A user-text display node is unsupported or invalid; its raw fallback was not indexed"));
6049
+ } else text += display;
6050
+ }
6051
+ flush();
6052
+ return { ...result(blocks, errors), ...nodes.some((node) => node.id === "secret") ? { defaultMasked: true } : {} };
6053
+ }
6054
+ function sourceFacts(source) {
6055
+ const facts = source.userTextFacts === void 0 ? {
6056
+ ...source.referenceLabels === void 0 ? {} : { sessionLabels: source.referenceLabels },
6057
+ ...source.skillNames === void 0 ? {} : { skillNames: source.skillNames }
6058
+ } : source.userTextFacts;
6059
+ if (!object2(facts)) return void 0;
6060
+ for (const key of ["sessionLabels", "skillNames"]) if (facts[key] !== void 0 && !strings2(facts[key])) return void 0;
6061
+ for (const key of ["collapseWhitespace", "trimWhitespace"]) if (facts[key] !== void 0 && typeof facts[key] !== "boolean") return void 0;
6062
+ if (facts.commands !== void 0 && (!Array.isArray(facts.commands) || !facts.commands.every((command) => object2(command) && integer2(command.start) && integer2(command.end) && command.end > command.start && typeof command.name === "string"))) return void 0;
6063
+ return facts;
6064
+ }
6065
+ function createUserTextProjector(userText, { sessionId, verifyRenderer } = {}) {
6066
+ let evaluate;
6067
+ try {
6068
+ if (typeof userText?.createEvaluator === "function") evaluate = userText.createEvaluator();
6069
+ } catch {
6070
+ }
6071
+ return function projectUser(source) {
6072
+ if (typeof evaluate !== "function") return unavailable();
6073
+ if (!object2(source) || typeof source.raw !== "string") return result([], [issue("invalid-user-source", "User source text is unavailable")]);
6074
+ if (sessionId !== void 0 && source.sessionId !== sessionId) return result([], [issue("user-session-mismatch", "User source belongs to a different Session")]);
6075
+ const facts = sourceFacts(source);
6076
+ if (facts === void 0) return result([], [issue("invalid-user-facts", "Durable user-text facts are invalid")]);
6077
+ let nodes;
6078
+ try {
6079
+ nodes = evaluate({ text: source.raw, facts });
6080
+ } catch {
6081
+ return result([], [issue("user-transform-failed", "Host user-text evaluation failed; its raw fallback was not indexed")]);
6082
+ }
6083
+ try {
6084
+ if (verifyRenderer !== void 0 && (typeof verifyRenderer !== "function" || verifyRenderer(nodes, source) !== true)) {
6085
+ return result([], [issue("user-renderer-unavailable", "Official user-text rendering could not be verified; its raw fallback was not indexed")]);
6086
+ }
6087
+ } catch {
6088
+ return result([], [issue("user-renderer-unavailable", "Official user-text rendering could not be verified; its raw fallback was not indexed")]);
6089
+ }
6090
+ return projectUserTextNodes(nodes, source.raw);
6091
+ };
6092
+ }
6093
+
6094
+ // src/user-projection-binding.js
6095
+ var NODE_SLOT = "conversation.user.text.node";
6096
+ var FACTORIES = ["conversation.user.text", "conversation.chat.user.content"];
6097
+ var NODE_IDS = /* @__PURE__ */ new Set(["text", "session", "file", "folder", "skill", "command", "secret"]);
6098
+ var partial = (code, message) => ({ blocks: [], mapping: "user", errors: [{ code, message }] });
6099
+ var service = (ctx, name) => typeof ctx?.get === "function" ? ctx.get(name) : ctx?.[name];
6100
+ var disposeSafely = (dispose) => {
6101
+ try {
6102
+ const completion = dispose?.();
6103
+ if (typeof completion?.catch === "function") completion.catch(() => {
6104
+ });
6105
+ } catch {
6106
+ }
6107
+ };
6108
+ function effectiveEntries(slots) {
6109
+ const entries = slots?.entriesOfSlot?.(NODE_SLOT);
6110
+ if (!Array.isArray(entries)) return void 0;
6111
+ const byKey = /* @__PURE__ */ new Map();
6112
+ for (const entry of entries) {
6113
+ const key = entry?.options?.key;
6114
+ if (typeof key !== "string" || byKey.has(key)) return void 0;
6115
+ byKey.set(key, entry);
6116
+ }
6117
+ return byKey;
6118
+ }
6119
+ function factoriesAvailable(slots) {
6120
+ return FACTORIES.every((name) => {
6121
+ const trees = slots?.snapshot?.(`factory:${name}`);
6122
+ if (!Array.isArray(trees) || trees.length !== 1) return false;
6123
+ const factory = trees[0];
6124
+ if (factory?.type !== "factory" || factory.name !== name || factory.scope !== "session") return false;
6125
+ return name !== "conversation.user.text" || Array.isArray(factory.children) && factory.children.some((child) => child?.type === "slot" && child.name === NODE_SLOT && child.kind === "keyed" && child.scope === "session");
6126
+ });
6127
+ }
6128
+ function createUserProjectionBinding(ctx, onChange) {
6129
+ let slots, baseline, observedEntries, factoryChanged = false, disposed = false;
6130
+ let offSlots, offErrors;
6131
+ const sessions = /* @__PURE__ */ new Map(), registries = /* @__PURE__ */ new Map();
6132
+ const failedNodes = /* @__PURE__ */ new Set();
6133
+ const changed = () => {
6134
+ if (!disposed) {
6135
+ try {
6136
+ onChange?.();
6137
+ } catch {
6138
+ }
6139
+ }
6140
+ };
6141
+ try {
6142
+ slots = service(ctx, "slots");
6143
+ } catch {
6144
+ }
6145
+ const refreshEntries = () => {
6146
+ let current;
6147
+ try {
6148
+ current = effectiveEntries(slots);
6149
+ } catch {
6150
+ return void 0;
6151
+ }
6152
+ if (!current) return void 0;
6153
+ for (const id of failedNodes) if (baseline?.has(id) && current.get(id) === baseline.get(id) && observedEntries && observedEntries.get(id) !== current.get(id)) failedNodes.delete(id);
6154
+ observedEntries = current;
6155
+ return current;
6156
+ };
6157
+ const isFactory = (key) => FACTORIES.some((name) => key === `factory:${name}`);
6158
+ try {
6159
+ offSlots = ctx?.on?.("slots/changed", (key) => {
6160
+ if (disposed || key !== NODE_SLOT && !isFactory(key)) return;
6161
+ if (isFactory(key)) {
6162
+ if (baseline) factoryChanged = true;
6163
+ } else refreshEntries();
6164
+ changed();
6165
+ });
6166
+ offErrors = slots?.onEntryError?.((key, registration) => {
6167
+ if (disposed || key !== NODE_SLOT && !isFactory(key)) return;
6168
+ if (isFactory(key)) factoryChanged = true;
6169
+ else {
6170
+ refreshEntries();
6171
+ const id = registration?.options?.key;
6172
+ if (typeof id === "string" && id) failedNodes.add(id);
6173
+ else for (const known of NODE_IDS) failedNodes.add(known);
6174
+ }
6175
+ changed();
6176
+ });
6177
+ } catch {
6178
+ }
6179
+ function verifyRenderer(nodes) {
6180
+ if (disposed || typeof offSlots !== "function" || factoryChanged || !Array.isArray(nodes)) return false;
6181
+ try {
6182
+ if (!factoriesAvailable(slots)) return false;
6183
+ const current = refreshEntries();
6184
+ if (!current || !nodes.every((node) => NODE_IDS.has(node?.id) && current.has(node.id))) return false;
6185
+ if (!baseline) baseline = current;
6186
+ return nodes.every((node) => !failedNodes.has(node.id) && baseline.has(node.id) && current.get(node.id) === baseline.get(node.id));
6187
+ } catch {
6188
+ return false;
6189
+ }
6190
+ }
6191
+ function release(record3) {
6192
+ if (record3.released) return;
6193
+ record3.released = true;
6194
+ if (sessions.get(record3.id) === record3) sessions.delete(record3.id);
6195
+ const watch = registries.get(record3.registry);
6196
+ watch?.records.delete(record3);
6197
+ if (watch?.records.size === 0) {
6198
+ registries.delete(record3.registry);
6199
+ disposeSafely(watch.dispose);
6200
+ }
6201
+ disposeSafely(record3.disposeScope);
6202
+ }
6203
+ function bind(id, scope, registry) {
6204
+ const record3 = { id, scope, registry, released: false, project: void 0, disposeScope: void 0 };
6205
+ let watch = registries.get(registry);
6206
+ if (!watch) {
6207
+ watch = { records: /* @__PURE__ */ new Set(), dispose: void 0 };
6208
+ watch.dispose = registry.subscribe(() => {
6209
+ if (registries.get(registry) === watch) {
6210
+ refreshEntries();
6211
+ changed();
6212
+ }
6213
+ });
6214
+ if (typeof watch.dispose !== "function") throw new Error("Registry revision observation is unavailable");
6215
+ registries.set(registry, watch);
6216
+ }
6217
+ watch.records.add(record3);
6218
+ sessions.set(id, record3);
6219
+ try {
6220
+ record3.project = createUserTextProjector(registry, { sessionId: id, verifyRenderer });
6221
+ if (typeof scope.effect === "function") record3.disposeScope = scope.effect(() => () => {
6222
+ if (record3.released) return;
6223
+ release(record3);
6224
+ changed();
6225
+ }, "find-all: user projection generation");
6226
+ return record3;
6227
+ } catch (error) {
6228
+ release(record3);
6229
+ throw error;
6230
+ }
6231
+ }
6232
+ return {
6233
+ project(source) {
6234
+ if (disposed) return partial("user-projection-disposed", "User-text projection has been disposed");
6235
+ const id = source?.sessionId;
6236
+ let scope, registry;
6237
+ try {
6238
+ if (typeof id === "string" && id) scope = service(ctx, "sessions")?.scope?.(id);
6239
+ if (scope) registry = service(scope, "uiConversation")?.userText;
6240
+ } catch {
6241
+ }
6242
+ let record3 = sessions.get(id);
6243
+ if (record3 && (record3.scope !== scope || record3.registry !== registry)) {
6244
+ release(record3);
6245
+ record3 = void 0;
6246
+ }
6247
+ if (!scope) return partial("user-session-unavailable", "The user message's retained Session is unavailable; user text was not indexed");
6248
+ if (typeof registry?.createEvaluator !== "function" || typeof registry?.subscribe !== "function") {
6249
+ return partial("user-projection-unavailable", "The Session's public user-text evaluator is unavailable; user text was not indexed");
6250
+ }
6251
+ try {
6252
+ return (record3 ?? bind(id, scope, registry)).project(source);
6253
+ } catch {
6254
+ return partial("user-projection-unavailable", "The Session's user-text projection could not be bound; user text was not indexed");
6255
+ }
6256
+ },
6257
+ dispose() {
6258
+ if (disposed) return;
6259
+ disposed = true;
6260
+ disposeSafely(offSlots);
6261
+ disposeSafely(offErrors);
6262
+ for (const record3 of [...sessions.values()]) release(record3);
6263
+ }
6264
+ };
6265
+ }
6266
+
5925
6267
  // src/search-content.js
5926
6268
  var SEARCH_CONTENT_SERVICE = "ryuu.findAllSearchContent";
5927
- var object2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
6269
+ var object3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
5928
6270
  function createSearchContentService(onChange) {
5929
6271
  const registrations = /* @__PURE__ */ new Map();
5930
6272
  const changed = () => {
@@ -5954,18 +6296,26 @@ function createSearchContentService(onChange) {
5954
6296
  },
5955
6297
  createProjector(project) {
5956
6298
  if (typeof project !== "function") throw new TypeError("Search content needs a text projector");
5957
- const rules = [...registrations.values()].map(({ createRule }) => createRule()).filter((rule) => typeof rule === "function");
6299
+ let rules, ruleFailure = false;
6300
+ try {
6301
+ rules = [...registrations.values()].map(({ createRule }) => createRule());
6302
+ if (rules.some((rule) => typeof rule !== "function")) ruleFailure = true;
6303
+ } catch {
6304
+ ruleFailure = true;
6305
+ }
5958
6306
  return async (source) => {
5959
6307
  let current = { ...source };
6308
+ if (ruleFailure) return { source, blocks: [], errors: [{ code: "search-content-rule-failed", message: "Search content rule initialization failed" }] };
5960
6309
  try {
5961
6310
  for (const rule of rules) {
5962
6311
  const patch = await rule(current);
5963
6312
  if (patch === void 0 || patch === null) continue;
5964
- if (!object2(patch)) throw new TypeError("Search content rule returned an invalid change");
6313
+ if (!object3(patch)) throw new TypeError("Search content rule returned an invalid change");
6314
+ if (["sessionId", "seq", "id", "kind", "contentIndex", "messageId", "turn", "step", "stepId"].some((key) => Object.hasOwn(patch, key) && patch[key] !== source[key])) throw new TypeError("Search content rule changed durable identity");
5965
6315
  current = { ...current, ...patch };
5966
6316
  }
5967
6317
  } catch (error) {
5968
- return { source: current, blocks: [], errors: [{ code: "search-content-rule-failed", message: error instanceof Error ? error.message : String(error) }] };
6318
+ return { source: current, blocks: [], errors: [{ code: "search-content-rule-failed", message: "Search content rule failed" }] };
5969
6319
  }
5970
6320
  const projection = await project(current);
5971
6321
  return { ...projection, source: current };
@@ -6249,16 +6599,16 @@ function createHandlers(ops) {
6249
6599
  }
6250
6600
  async function runPageIn(opts) {
6251
6601
  var pages = 0;
6252
- function result(reason) {
6602
+ function result2(reason) {
6253
6603
  return { pages, reason };
6254
6604
  }
6255
6605
  for (; ; ) {
6256
- if (opts.isCancelled()) return result("cancelled");
6606
+ if (opts.isCancelled()) return result2("cancelled");
6257
6607
  var ready = await opts.waitReady();
6258
- if (opts.isCancelled()) return result("cancelled");
6259
- if (ready.reason) return result(ready.reason);
6260
- if (ready.hasMore === false) return result("done");
6261
- if (pages >= opts.maxPages) return result("capped");
6608
+ if (opts.isCancelled()) return result2("cancelled");
6609
+ if (ready.reason) return result2(ready.reason);
6610
+ if (ready.hasMore === false) return result2("done");
6611
+ if (pages >= opts.maxPages) return result2("capped");
6262
6612
  var before = opts.signature();
6263
6613
  var loaded;
6264
6614
  try {
@@ -6266,25 +6616,25 @@ async function runPageIn(opts) {
6266
6616
  } catch (error) {
6267
6617
  loaded = { reason: "error" };
6268
6618
  }
6269
- if (opts.isCancelled()) return result("cancelled");
6619
+ if (opts.isCancelled()) return result2("cancelled");
6270
6620
  ready = await opts.waitReady(!!(loaded && loaded.reason));
6271
- if (opts.isCancelled()) return result("cancelled");
6272
- if (loaded && loaded.reason) return result(loaded.reason);
6273
- if (ready.reason) return result(ready.reason);
6621
+ if (opts.isCancelled()) return result2("cancelled");
6622
+ if (loaded && loaded.reason) return result2(loaded.reason);
6623
+ if (ready.reason) return result2(ready.reason);
6274
6624
  if (loaded && loaded.deferred) continue;
6275
6625
  if (ready.hasMore !== false) await opts.waitChange(before);
6276
- if (opts.isCancelled()) return result("cancelled");
6626
+ if (opts.isCancelled()) return result2("cancelled");
6277
6627
  ready = await opts.waitReady();
6278
- if (opts.isCancelled()) return result("cancelled");
6279
- if (ready.reason) return result(ready.reason);
6628
+ if (opts.isCancelled()) return result2("cancelled");
6629
+ if (ready.reason) return result2(ready.reason);
6280
6630
  var changed = opts.signature() !== before;
6281
6631
  if (changed) {
6282
6632
  pages += 1;
6283
6633
  if (opts.onProgress) opts.onProgress(pages);
6284
6634
  }
6285
- if (opts.isCancelled()) return result("cancelled");
6286
- if (ready.hasMore === false) return result("done");
6287
- if (!changed) return result("stalled");
6635
+ if (opts.isCancelled()) return result2("cancelled");
6636
+ if (ready.hasMore === false) return result2("done");
6637
+ if (!changed) return result2("stalled");
6288
6638
  }
6289
6639
  }
6290
6640
  function cssText() {
@@ -6422,15 +6772,18 @@ function matchAnchorRect(range) {
6422
6772
  }
6423
6773
  return null;
6424
6774
  }
6775
+ function matchLineMargin(range, rect) {
6776
+ var lineHeight = window.getComputedStyle(range.startContainer.parentElement).lineHeight;
6777
+ var margin = /^\d+(?:\.\d+)?px$/.test(lineHeight) ? parseFloat(lineHeight) : rect.height;
6778
+ return Number.isFinite(margin) && margin > 0 ? margin : rect.height;
6779
+ }
6425
6780
  function matchScrollPlan(range, scroll, viewport, bar, center) {
6426
6781
  var rect = matchAnchorRect(range);
6427
6782
  if (!rect) return null;
6428
6783
  var current = scroll.scrollTop, maximum = Math.max(0, scroll.scrollHeight - scroll.clientHeight);
6429
6784
  var bands = [[viewport.top, viewport.bottom]], margin = 0;
6430
6785
  if (center) {
6431
- var lineHeight = window.getComputedStyle(range.startContainer.parentElement).lineHeight;
6432
- margin = /^\d+(?:\.\d+)?px$/.test(lineHeight) ? parseFloat(lineHeight) : rect.height;
6433
- if (!Number.isFinite(margin) || margin <= 0) margin = rect.height;
6786
+ margin = matchLineMargin(range, rect);
6434
6787
  }
6435
6788
  if (bar && rect.right > bar.left && rect.left < bar.right && bar.bottom > viewport.top && bar.top < viewport.bottom) {
6436
6789
  bands = [
@@ -6641,7 +6994,8 @@ function activateLoadedTurn(target, store, preferredTurn, exactOnly) {
6641
6994
  return !target.root.contains(nav) && (label === "Turn navigation" || label === "\u8F6E\u6B21\u5BFC\u822A");
6642
6995
  });
6643
6996
  if (!navs.length) return exactOnly ? null : false;
6644
- if (navs.length !== 1 || !visible(navs[0])) return false;
6997
+ if (navs.length !== 1) return false;
6998
+ if (!visible(navs[0])) return exactOnly && !navs[0].querySelector("button") ? null : false;
6645
6999
  var loaded = /* @__PURE__ */ new Set();
6646
7000
  Array.prototype.forEach.call(target.root.querySelectorAll("[data-chat-anchor-key][data-chat-turn]"), function(row) {
6647
7001
  var key = row.getAttribute("data-chat-node-key") || row.getAttribute("data-chat-anchor-key");
@@ -6933,13 +7287,15 @@ function navigateToRange(range) {
6933
7287
  var origin = state.origin, token = state.navigationToken, queryToken = state.queryToken, query = state.query, started = Date.now();
6934
7288
  var dataHit = state.scope === "whole" ? state.hits[state.index] : null;
6935
7289
  var selection = state.selection, activated = /* @__PURE__ */ new Set(), announceReturn = false, statusApplied = false;
6936
- var transferred = false, directAttempted = false, corrections = 0, previous = null, stable = 0;
7290
+ var transferred = false, directAttempted = false, corrections = 0, previous = null, stable = 0, navigationPhase = "navigation-loading";
6937
7291
  function retry() {
6938
7292
  state.navigationTimer = setTimeout(check, 100);
6939
7293
  }
6940
- function fail() {
6941
- recordFailure("jump", "render");
7294
+ function fail(code) {
7295
+ var reason = diagnosticCode(code || navigationPhase);
7296
+ recordFailure("jump", reason);
6942
7297
  setStatus(L2.matchRevealFailed, false);
7298
+ state.status.title = L2.matchRevealFailed + " (" + reason + ")";
6943
7299
  if (state.announcement) state.announcement.textContent = L2.matchRevealFailed;
6944
7300
  }
6945
7301
  function check() {
@@ -6977,6 +7333,7 @@ function navigateToRange(range) {
6977
7333
  var geometry = attached && !concealed && matchAnchorRect(current);
6978
7334
  if (attached && (!geometry || concealed)) revealMatchRange(target, current, activated);
6979
7335
  if (!geometry) {
7336
+ navigationPhase = "navigation-geometry";
6980
7337
  previous = null;
6981
7338
  stable = 0;
6982
7339
  retry();
@@ -6986,6 +7343,7 @@ function navigateToRange(range) {
6986
7343
  paint();
6987
7344
  var viewport = readingViewport(target), landing = matchLanding(current, viewport);
6988
7345
  if (!landing) {
7346
+ navigationPhase = "navigation-viewport";
6989
7347
  retry();
6990
7348
  return;
6991
7349
  }
@@ -6993,11 +7351,12 @@ function navigateToRange(range) {
6993
7351
  var row = current.startContainer.parentElement.closest("[data-chat-turn]");
6994
7352
  var turn = row && row.getAttribute("data-chat-turn");
6995
7353
  if (directAttempted) {
6996
- fail();
7354
+ fail("navigation-reversed");
6997
7355
  return;
6998
7356
  }
6999
7357
  var handoff = turn ? activateLoadedTurn(target, store, turn, true) : null;
7000
7358
  if (handoff === false) {
7359
+ navigationPhase = "navigation-control";
7001
7360
  retry();
7002
7361
  return;
7003
7362
  }
@@ -7012,7 +7371,7 @@ function navigateToRange(range) {
7012
7371
  }
7013
7372
  if (!landing.settled) {
7014
7373
  if (corrections >= 2) {
7015
- fail();
7374
+ fail("navigation-reversed");
7016
7375
  return;
7017
7376
  }
7018
7377
  corrections++;
@@ -7056,6 +7415,7 @@ function navigateToRange(range) {
7056
7415
  }) ? stable + 1 : 0;
7057
7416
  previous = sample;
7058
7417
  if (stable < 2) {
7418
+ navigationPhase = "navigation-settling";
7059
7419
  retry();
7060
7420
  return;
7061
7421
  }
@@ -7419,6 +7779,38 @@ function diagnosticCode(code) {
7419
7779
  return "tool-projection-empty";
7420
7780
  case "custom-tool-projection-unverified":
7421
7781
  return "custom-tool-projection-unverified";
7782
+ case "user-projection-unavailable":
7783
+ return "user-projection-unavailable";
7784
+ case "user-session-unavailable":
7785
+ return "user-session-unavailable";
7786
+ case "user-renderer-unavailable":
7787
+ return "user-renderer-unavailable";
7788
+ case "user-transform-failed":
7789
+ return "user-transform-failed";
7790
+ case "invalid-user-facts":
7791
+ return "invalid-user-facts";
7792
+ case "invalid-user-projection":
7793
+ return "invalid-user-projection";
7794
+ case "unsupported-user-node":
7795
+ return "unsupported-user-node";
7796
+ case "user-attachment-unprojected":
7797
+ return "user-attachment-unprojected";
7798
+ case "search-content-rule-failed":
7799
+ return "search-content-rule-failed";
7800
+ case "projection-failed":
7801
+ return "projection-failed";
7802
+ case "navigation-loading":
7803
+ return "navigation-loading";
7804
+ case "navigation-geometry":
7805
+ return "navigation-geometry";
7806
+ case "navigation-viewport":
7807
+ return "navigation-viewport";
7808
+ case "navigation-control":
7809
+ return "navigation-control";
7810
+ case "navigation-reversed":
7811
+ return "navigation-reversed";
7812
+ case "navigation-settling":
7813
+ return "navigation-settling";
7422
7814
  case "render":
7423
7815
  return "render";
7424
7816
  case "position":
@@ -7465,7 +7857,10 @@ function diagnosticState() {
7465
7857
  readComplete: snapshot ? snapshot.readComplete === true : null,
7466
7858
  coverageComplete: snapshot ? snapshot.coverageComplete === true : null,
7467
7859
  projectionComplete: snapshot ? snapshot.projectionComplete === true : null,
7468
- selectedProjectionComplete: snapshot ? selectedProjectionComplete(snapshot) : null
7860
+ selectedProjectionComplete: snapshot ? selectedProjectionComplete(snapshot) : null,
7861
+ projectionCodes: snapshot ? [...new Set(selectedHistoryErrors(snapshot).map(function(error) {
7862
+ return diagnosticCode(error.code);
7863
+ }))] : []
7469
7864
  },
7470
7865
  scan: {
7471
7866
  busy: !!state.scanBusy,
@@ -7504,7 +7899,7 @@ async function copyDiagnostics() {
7504
7899
  feedback.textContent = L2.copyingDiagnostics;
7505
7900
  var copied = false;
7506
7901
  try {
7507
- var summary = { schemaVersion: 1, pluginVersion: "0.1.13", current: diagnosticState(), lastFailure: state.lastFailure };
7902
+ var summary = { schemaVersion: 1, pluginVersion: "0.1.14", current: diagnosticState(), lastFailure: state.lastFailure };
7508
7903
  copied = typeof state.writeClipboard === "function" && await state.writeClipboard(JSON.stringify(summary, null, 2)) === true;
7509
7904
  } catch (error) {
7510
7905
  }
@@ -7556,7 +7951,8 @@ function positionBar() {
7556
7951
  }
7557
7952
  var avoid = state.avoidMatchRange && rangeRect(state.avoidMatchRange);
7558
7953
  if (avoid && left < avoid.right && left + box.width > avoid.left && top < avoid.bottom && top + box.height > avoid.top) {
7559
- var choices = [{ left, top: avoid.bottom + 8 }, { left, top: avoid.top - box.height - 8 }, { left: avoid.left - box.width - 8, top }, { left: avoid.right + 8, top }].filter(function(p) {
7954
+ var verticalGap = 8 + matchLineMargin(state.avoidMatchRange, avoid);
7955
+ var choices = [{ left, top: avoid.bottom + verticalGap }, { left, top: avoid.top - box.height - verticalGap }, { left: avoid.left - box.width - 8, top }, { left: avoid.right + 8, top }].filter(function(p) {
7560
7956
  return p.left >= leftEdge && p.left + box.width <= rightEdge && p.top >= topEdge && p.top + box.height <= bottomEdge;
7561
7957
  });
7562
7958
  choices.sort(function(a, b) {
@@ -7913,10 +8309,10 @@ function renderUpdateCheck() {
7913
8309
  if (!state.updateBtn) return;
7914
8310
  state.updateBtn.setAttribute("aria-disabled", state.updateTask ? "true" : "false");
7915
8311
  if (state.updateBtn.textContent !== L2.checkUpdate) state.updateBtn.textContent = L2.checkUpdate;
7916
- var result = state.updateResult;
7917
- var message = state.updateTask ? L2.checkingUpdate : !result ? "" : result.status === "available" ? L2.updateAvailable.replace("{v}", result.version) : result.status === "current" ? L2.updateCurrent : result.status === "ahead" ? L2.updateAhead.replace("{v}", result.version) : L2.updateFailed;
8312
+ var result2 = state.updateResult;
8313
+ var message = state.updateTask ? L2.checkingUpdate : !result2 ? "" : result2.status === "available" ? L2.updateAvailable.replace("{v}", result2.version) : result2.status === "current" ? L2.updateCurrent : result2.status === "ahead" ? L2.updateAhead.replace("{v}", result2.version) : L2.updateFailed;
7918
8314
  if (state.updateStatus.textContent !== message) state.updateStatus.textContent = message;
7919
- state.updateGuide.hidden = !result || result.status !== "available" || !!state.updateTask;
8315
+ state.updateGuide.hidden = !result2 || result2.status !== "available" || !!state.updateTask;
7920
8316
  }
7921
8317
  function cancelUpdateCheck() {
7922
8318
  var task = state.updateTask;
@@ -7934,8 +8330,8 @@ async function checkForUpdates() {
7934
8330
  state.updateResult = null;
7935
8331
  renderUpdateCheck();
7936
8332
  try {
7937
- var result = await checkLatestVersion("0.1.13", task.signal);
7938
- if (state.mounted && state.updateTask === task) state.updateResult = result;
8333
+ var result2 = await checkLatestVersion("0.1.14", task.signal);
8334
+ if (state.mounted && state.updateTask === task) state.updateResult = result2;
7939
8335
  } catch (error) {
7940
8336
  if (state.mounted && state.updateTask === task) state.updateResult = { status: "failed" };
7941
8337
  } finally {
@@ -8186,6 +8582,21 @@ function activateMatch(index) {
8186
8582
  navigateToRange(range);
8187
8583
  }
8188
8584
  function scheduleRescan() {
8585
+ if (state.scope === "whole" && state.ranges.some(Boolean)) {
8586
+ var hit = state.hits[state.index], target = state.target, store = state.adapter?.nodes(target);
8587
+ var node = hit && sourceNode(hit.source, store), mapped = node && mapProjectedDocument(hit.source, node, sourceRows(target, node), hit.blockIndex);
8588
+ var range = mapped?.blocks && rangeForBlock(mapped.blocks[hit.blockIndex], hit.start, hit.end);
8589
+ if (!range || range.toString() !== hit.text) {
8590
+ cancelNavigation();
8591
+ state.ranges = [];
8592
+ paint();
8593
+ state.sourceNotice = ZH ? "\u6B64\u6D88\u606F\u7684\u663E\u793A\u5DF2\u53D8\u5316\uFF0C\u539F\u9AD8\u4EAE\u5DF2\u6E05\u9664\uFF1B\u5168\u6587\u8BA1\u6570\u4ECD\u6309\u9ED8\u8BA4\u663E\u793A\u8BA1\u7B97\u3002" : "This message display changed; its highlight was cleared. Whole-history counts still use the default display.";
8594
+ historyStatus();
8595
+ } else {
8596
+ state.ranges[state.index] = range;
8597
+ paint();
8598
+ }
8599
+ }
8189
8600
  if (state.scope === "page") {
8190
8601
  state.pageDirty = true;
8191
8602
  cancelCountEdit(false);
@@ -8241,7 +8652,9 @@ function schedulePageIn() {
8241
8652
  }, 150);
8242
8653
  }
8243
8654
  function searchContentChanged() {
8655
+ cancelNavigation();
8244
8656
  cancelPageIn();
8657
+ state.historyRevision = null;
8245
8658
  state.history = null;
8246
8659
  state.historySnapshot = null;
8247
8660
  state.scanQuery = null;
@@ -8272,9 +8685,16 @@ function historyStatus() {
8272
8685
  if (part) text += (text ? " \xB7 " : "") + part;
8273
8686
  }
8274
8687
  if (state.capped) add(L2.cap.replace("{n}", String(MAX_MATCHES)));
8688
+ if (snapshot?.documents?.some(function(doc) {
8689
+ return doc.defaultMasked && contentTypeEnabled(sourceContentType(doc));
8690
+ })) add(ZH ? "\u5168\u6587\u8BA1\u6570\u4F7F\u7528\u9ED8\u8BA4\u906E\u6321\u6587\u5B57\uFF1B\u5C55\u5F00\u53EA\u6539\u53D8\u5F53\u524D\u6D88\u606F\u663E\u793A\u3002" : "Whole-history counts use default masked text; revealing changes only the displayed message.");
8275
8691
  add(state.sourceNotice);
8276
8692
  if (state.liveCount) add((ZH ? "\u5F53\u524D\u6B63\u5728\u751F\u6210\u7684\u56DE\u590D\u4E2D\u53E6\u6709 " : "The reply being generated contains ") + state.liveCount + (state.liveCapped ? "+" : "") + (ZH ? " \u4E2A\u5339\u914D\u3002" : " additional matches."));
8277
8693
  setStatus(text, state.paging || state.scanBusy);
8694
+ var errorCodes = [...new Set(relevantErrors.map(function(error) {
8695
+ return diagnosticCode(error.code);
8696
+ }))].join(", ");
8697
+ state.status.title = text + (errorCodes ? " (" + errorCodes + ")" : "");
8278
8698
  }
8279
8699
  function startPageIn() {
8280
8700
  if (state.scope !== "whole" || !state.query || !isOpen()) return;
@@ -8286,7 +8706,7 @@ function startPageIn() {
8286
8706
  var remote = state.remote && state.remote.session;
8287
8707
  if (!state.projector || !remote || typeof remote.follow !== "function" || typeof remote.page !== "function") {
8288
8708
  recordFailure("capability", "unsupported-host");
8289
- setStatus(ZH ? "\u5B8C\u6574\u4F1A\u8BDD\u641C\u7D22\u4E0D\u53EF\u7528\uFF1A\u5BBF\u4E3B\u7F3A\u5C11\u5B8C\u6574\u5386\u53F2\u63A5\u53E3\u3002\u8BF7\u5207\u6362\u5230\u5DF2\u52A0\u8F7D\u5185\u5BB9" : "Whole-session search unavailable: complete-history API missing. Switch to Loaded content", false);
8709
+ setStatus(ZH ? "\u5B8C\u6574\u4F1A\u8BDD\u641C\u7D22\u4E0D\u53EF\u7528\uFF1A\u5BBF\u4E3B\u7F3A\u5C11\u5386\u53F2\u8BFB\u53D6\u6216\u6587\u672C\u6295\u5F71\u80FD\u529B\u3002\u8BF7\u5207\u6362\u5230\u5DF2\u52A0\u8F7D\u5185\u5BB9" : "Whole-session search unavailable: history or text projection capability missing. Switch to Loaded content", false);
8290
8710
  return;
8291
8711
  }
8292
8712
  if (state.history && state.historySnapshot && state.historySnapshot.sessionId === target.id && !["cancelled", "error"].includes(state.historySnapshot.status)) {
@@ -8294,6 +8714,9 @@ function startPageIn() {
8294
8714
  return;
8295
8715
  }
8296
8716
  var token = ++state.pageToken, errorCount = 0;
8717
+ var nodeStore = state.adapter.nodes(target);
8718
+ var revision = nodeStore ? createHistoryRevisionTracker(nodeStore) : null;
8719
+ state.historyRevision = revision;
8297
8720
  state.paging = true;
8298
8721
  state.sourceNotice = "";
8299
8722
  state.historySnapshot = null;
@@ -8301,6 +8724,10 @@ function startPageIn() {
8301
8724
  var project = state.searchContent ? state.searchContent.createProjector(state.projector) : state.projector;
8302
8725
  state.history = createHistoryReader({ remote: state.remote, sessionId: target.id, generation: token, project, onUpdate: function(snapshot) {
8303
8726
  if (token !== state.pageToken || state.target !== target || !isOpen() || state.scope !== "whole" || !state.adapter.valid(target)) return;
8727
+ if (revision?.check(state.adapter.nodes(target), snapshot)) {
8728
+ searchContentChanged();
8729
+ return;
8730
+ }
8304
8731
  state.historySnapshot = snapshot;
8305
8732
  state.paging = ["reading", "projecting", "idle"].includes(snapshot.status);
8306
8733
  if (snapshot.status !== "cancelled" && snapshot.errors.length > errorCount) {
@@ -8475,7 +8902,7 @@ async function navigateHistoryHit(hit) {
8475
8902
  var target = state.target, source = hit.source, token = state.navigationToken, queryToken = state.queryToken;
8476
8903
  var face = state.adapter.face(target), store = state.adapter.nodes(target), activated = /* @__PURE__ */ new Set();
8477
8904
  function current() {
8478
- return token === state.navigationToken && queryToken === state.queryToken && state.target === target && state.scope === "whole" && isOpen() && state.adapter.valid(target) && state.adapter.face(target) === face && state.hits[state.index] === hit;
8905
+ return token === state.navigationToken && queryToken === state.queryToken && state.target === target && state.scope === "whole" && isOpen() && state.adapter.valid(target) && state.adapter.face(target) === face && state.adapter.nodes(target) === store && state.hits[state.index] === hit;
8479
8906
  }
8480
8907
  function pause() {
8481
8908
  return new Promise((resolve) => setTimeout(resolve, 35));
@@ -8557,10 +8984,9 @@ function syncTarget(target, passive) {
8557
8984
  discardOrigin();
8558
8985
  cancelPageIn();
8559
8986
  stopObserver();
8560
- if (!selected || !state.target || selected.id !== state.target.id) {
8561
- state.history = null;
8562
- state.historySnapshot = null;
8563
- }
8987
+ state.historyRevision = null;
8988
+ state.history = null;
8989
+ state.historySnapshot = null;
8564
8990
  state.target = selected;
8565
8991
  state.sessionId = selected ? selected.id : null;
8566
8992
  if (!isOpen()) return;
@@ -8570,10 +8996,17 @@ function syncTarget(target, passive) {
8570
8996
  startObserver();
8571
8997
  if (selected && state.scope === "whole" && state.query) schedulePageIn();
8572
8998
  }
8999
+ function checkHistoryContent() {
9000
+ var snapshot = state.historySnapshot, store = state.adapter?.nodes(state.target);
9001
+ if (state.scope === "whole" && snapshot?.readComplete && state.historyRevision?.check(store, snapshot)) searchContentChanged();
9002
+ }
8573
9003
  function watchSession() {
8574
9004
  clearInterval(state.sessionTimer);
8575
9005
  state.sessionTimer = setInterval(function() {
8576
- if (isOpen()) syncTarget(null, true);
9006
+ if (isOpen()) {
9007
+ syncTarget(null, true);
9008
+ checkHistoryContent();
9009
+ }
8577
9010
  }, SESSION_POLL_MS);
8578
9011
  }
8579
9012
  function stopWatchingSession() {
@@ -8847,7 +9280,7 @@ function buildBar() {
8847
9280
  updateCommand.className = "history-command update-command";
8848
9281
  var currentVersion = document.createElement("p");
8849
9282
  currentVersion.className = "update-version";
8850
- currentVersion.textContent = L2.currentVersion + " 0.1.13";
9283
+ currentVersion.textContent = L2.currentVersion + " 0.1.14";
8851
9284
  var updateBtn = document.createElement("button");
8852
9285
  updateBtn.type = "button";
8853
9286
  updateBtn.className = "check-update";
@@ -9072,12 +9505,21 @@ function apply(ctx) {
9072
9505
  });
9073
9506
  });
9074
9507
  try {
9075
- state.projector = createProjector(ui, react, document);
9508
+ var userBinding = typeof ui.projectUserText === "function" ? null : createUserProjectionBinding(ctx, searchContentChanged);
9509
+ state.projector = createProjector(ui, react, document, userBinding?.project);
9510
+ if (userBinding) ctx.effect(function() {
9511
+ return function() {
9512
+ userBinding.dispose();
9513
+ };
9514
+ });
9076
9515
  } catch (error) {
9077
9516
  state.projector = null;
9078
9517
  }
9079
9518
  state.adapter = createHostAdapter(ctx, function() {
9080
- if (isOpen()) syncTarget(null, true);
9519
+ if (isOpen()) {
9520
+ syncTarget(null, true);
9521
+ checkHistoryContent();
9522
+ }
9081
9523
  });
9082
9524
  if (typeof ctx.inject === "function") state.conversationSearch = installConversationSearch(ctx, react, ui, {
9083
9525
  closeFind: close,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ryuu-64/dsh-find-all",
3
- "version": "0.1.13",
3
+ "version": "0.1.14",
4
4
  "description": "Find saved conversation text across DeepSeek Harness (DSH), with Ctrl+F / Cmd+F inside a conversation.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -17,6 +17,7 @@
17
17
  "CHANGELOG.md",
18
18
  "NOTICE.md",
19
19
  "docs/compatibility.md",
20
+ "docs/issue35-testing.md",
20
21
  "LICENSE"
21
22
  ],
22
23
  "author": "Ryuu-64",
@@ -36,10 +37,10 @@
36
37
  "registry": "https://registry.npmjs.org/"
37
38
  },
38
39
  "peerDependencies": {
39
- "@deepseek-ai/dsh-api-session-controller": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2",
40
- "@deepseek-ai/dsh-client-ui-chat": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2",
41
- "@deepseek-ai/dsh-client-ui-conversation": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2",
42
- "@deepseek-ai/dsh-client-ui-primitives": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2"
40
+ "@deepseek-ai/dsh-api-session-controller": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.2",
41
+ "@deepseek-ai/dsh-client-ui-chat": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.2",
42
+ "@deepseek-ai/dsh-client-ui-conversation": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.2",
43
+ "@deepseek-ai/dsh-client-ui-primitives": "0.1.5-rc.2 || 0.1.5-rc.3 || 0.1.6-alpha.1 || 0.1.6-alpha.2 || 0.1.7-alpha.1 || 0.1.7-alpha.2 || 0.1.7-rc.1 || 0.1.7-rc.2 || 0.2.0-rc.1 || 0.2.0-rc.2 || 0.2.1-rc.2"
43
44
  },
44
45
  "scripts": {
45
46
  "test": "node --test \"test/**/*.test.mjs\"",