dsh-client-ui-quote 0.12.3-lab.28 → 0.12.3-lab.29
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 +3 -2
- package/README.md +7 -7
- package/lib/client.js +35 -2
- package/package.json +1 -1
- package/test/capsule.mjs +48 -5
package/CHANGELOG.md
CHANGED
|
@@ -6,11 +6,12 @@
|
|
|
6
6
|
|
|
7
7
|
- 侧边对话默认内置隐藏线程,不再需要安装 dsh-better-sidebar:宿主半注册 `POST /ui-quote/api/sidechat.start`(同源围栏),从在线父会话复制种子,用宿主 `agents.create` 建 `origin: "subagent"` 子会话,并在宿主内置 `subagentchat` 页签打开;descriptor 与会话标题使用与 better-sidebar 共享的 `Side: ` 约定,装不装它都不冲突。宿主半不可用(旧宿主 / 父会话不在线 / 创建被拒)时自动退回 `sessions.fork` + 本插件原生 `quote-sidechat` 页签;`sideChatBackend: "better"` 才优先走 better-sidebar。
|
|
8
8
|
- 侧边线程记忆与清单:新增 `dsh-client-ui-quote:v1:sidechat-target` 记录隐藏线程的父会话;读取线程时用 subagent 地址 `{parentSessionId, childSessionId, mode:"continuable"}`;线程列表同时扫描会话列表里的 `Side:` 子会话,所以 better-sidebar(或旧版本)创建的线程也能在本插件里打开、带回和导出。
|
|
9
|
-
- 离线断言 **
|
|
9
|
+
- 离线断言 **647 组**(check 12 + capsule 442 + panel 153 + host 40);新增原生页签的地址解析、标题、资源 retain/release、页签注册与卸载断言,以及宿主半的种子复制 / 继承切点 / 回合收口 / 悬挂工具调用截断 / `agents.create` 参数 / 探针与围栏断言。
|
|
10
10
|
|
|
11
11
|
### Fixed
|
|
12
12
|
|
|
13
|
-
- 隐藏线程的侧聊页一打开就「历史加载失败:subagent descriptor is unavailable」:种子把 `subagent/descriptor` 放在继承前缀里、又用整段种子的长度当 `inheritedEventCount`,宿主的 `api-session-controller` 要求 descriptor 的 `seq` 不小于继承切点,于是整条子会话的历史都读不出来。现在种子先落一条 `session/end-seed { inherited: true }` 标出切点,回合收口、工作目录与 descriptor 全部排在切点之后;嵌套侧聊的父 descriptor
|
|
13
|
+
- 隐藏线程的侧聊页一打开就「历史加载失败:subagent descriptor is unavailable」:种子把 `subagent/descriptor` 放在继承前缀里、又用整段种子的长度当 `inheritedEventCount`,宿主的 `api-session-controller` 要求 descriptor 的 `seq` 不小于继承切点,于是整条子会话的历史都读不出来。现在种子先落一条 `session/end-seed { inherited: true }` 标出切点,回合收口、工作目录与 descriptor 全部排在切点之后;嵌套侧聊的父 descriptor 留在继承前缀里,我们自己的那条排在后面(投影按最后一次生效)。
|
|
14
|
+
- 修复前造出的坏线程会被反复打开:`sessions.retain` 对它们**照样成功**(只有历史 RPC 拒绝),所以「试开一次」判断不出来。现在客户端给新建的线程盖形状版本戳(`dsh-client-ui-quote:v1:sidechat-target` 里的 `v: 2`),只复用自己盖过章的线程;better-sidebar 的、旧版本的、扫描发现的线程一律丢弃重建——一次误杀换永久自愈。
|
|
14
15
|
- 正文以 ``` 或 `~~~` 开头的普通引用在回读时丢了首行:识别代码引用只看首行围栏,却没有要求块尾有配对的收尾围栏,于是引用一段 Markdown 源码时那行被当围栏剥掉(只有一行的引用会整条消失,胶囊、悬停卡片与引用清单都少字)。现在围栏必须成对才算传输层——写出去的代码引用收尾围栏始终成对,旧消息解析不变;不成对的孤围栏按正文还原。
|
|
15
16
|
|
|
16
17
|
## 0.12.2 — 2026-10-22
|
package/README.md
CHANGED
|
@@ -139,7 +139,7 @@ link 的优点是改完刷新即生效;**日常运行请用方式一**,不
|
|
|
139
139
|
|
|
140
140
|
本机切换这三档(这台开发机专用的辅助脚本,不在仓库里):`node .dsh-quote-work/profile-mode.mjs link|lab|stable|status`。换完在窗口里 `Ctrl+Shift+R` 生效;只有宿主半有改动时才需要重启桌面端。
|
|
141
141
|
|
|
142
|
-
两条线的断言入口相同:`npm test`(
|
|
142
|
+
两条线的断言入口相同:`npm test`(647 项:check 12 + capsule 442 + panel 153 + host 40);`.github/workflows/test.yml` 在每次 push / PR 上用 Node 18/20/22 各跑一遍,`publish.yml` 里 `prepublishOnly` 再跑一次才发。
|
|
143
143
|
|
|
144
144
|
**推送通道**:`git push` 优先,但本机 `github.com:443` **时通时不通**(2026-10-19 实测:短时可用、随后连续超时,每次失败等约 21 秒)。日常用工作区根的 `promote.ps1`:先试 git,失败自动转 REST 兜底(`.dsh-quote-work/publish-release.mjs`、`.dsh-quote-work/push-branch.mjs`,`-Channel rest` 可跳过探测),并核对远端 SHA。**别混用两条通道**:REST 重建的提交时区归一到 `+0000`,内容相同但 SHA 不同,同一分支混推会分叉(`git status` 看着干净,远端却多一条平行提交);恢复就先 `git fetch`、确认 `git diff <本地> <远端>` 为空,再把本地线 reset 到远端。
|
|
145
145
|
|
|
@@ -326,7 +326,7 @@ transcript 侧的 `.dshq-cap` 胶囊:一颗胶囊同时装引用与评论,`
|
|
|
326
326
|
1. **语义而不是机制**:引用与评论是同一颗节点(对齐 Kimi 的 `quote` 节点 `{text, comment}`),一颗芯片 → 一个块 → 一颗胶囊 → 一张卡片 → 一次复制;机制(reference chip、DOM 增强)谁都能抄,这条链子不好抄。
|
|
327
327
|
2. **引用是带坐标的活对象**:`跳回原文` 在自己的会话面板里找行、按宿主的方式对齐到 24px,行被虚拟列表藏起来或没挂载都能找回来;坐标以「人可读来源头 + base64 尾巴」随消息走——前者让模型知道出处,后者让插件跨刷新回读。base64 确实占一点 prompt,这是用「不依赖本地表」换来的取舍。
|
|
328
328
|
3. **引用有下落**:清单页(搜索 / 跳转 / 导出 Markdown)+ 侧边线程回流(结论写回主会话草稿 / 导出线程),这两件事在同类里仍是少数。
|
|
329
|
-
4. **工程化**:
|
|
329
|
+
4. **工程化**:647 项离线断言(含真跑 `sessions.retain` / `setDraft` / `agents.create` 参数 / 下载链路)、每个宿主契约都在 README 里写明出处、每个版本都有可回读的 release。同类里做到同等断言规模的仍是少数。
|
|
330
330
|
|
|
331
331
|
反过来也要说清楚:**本插件不做的**——不做翻译/解释/改写/飞书投递类选区动作;不做图片/截图引用(**明确取舍**:图片引用要的是另一套胶囊/卡片/附件语义,是第二个产品的量级,塞进这里只会把「文本引用带坐标」这条主线冲淡;`dsh-selection-toolbar` 与 Kimi 桌面端已经做了,真要做建议独立成插件);不做完整 Topic 系统;不做常显大块引用。它只把「引用」这一件事做穿——但「做穿」包括发送后的管理、来源闭环和审阅,不只是浮层。
|
|
332
332
|
|
|
@@ -363,7 +363,7 @@ locale/zh.json 插件页卡片文案(中文)
|
|
|
363
363
|
locale/en.json 插件页卡片文案(英文)
|
|
364
364
|
test/check.mjs 离线自检(清单 + 组件契约)
|
|
365
365
|
test/dom.mjs 给离线自检用的最小 DOM / MutationObserver 垫片
|
|
366
|
-
test/capsule.mjs 离线自检(发送后胶囊 + 悬停卡片 + 跳回原文 + 键位 + 改这条引用 + 代码引用 + 文件路径打开 + 聊天代码块划选 + 选区保结构 + 回合级引用 + 逐条回应双语 + 草稿引用编辑/持久化 + 聚合条移除/无障碍 + 行范围标记 + 浮层不随座位失效,
|
|
366
|
+
test/capsule.mjs 离线自检(发送后胶囊 + 悬停卡片 + 跳回原文 + 键位 + 改这条引用 + 代码引用 + 文件路径打开 + 聊天代码块划选 + 选区保结构 + 回合级引用 + 逐条回应双语 + 草稿引用编辑/持久化 + 聚合条移除/无障碍 + 行范围标记 + 浮层不随座位失效,442 项断言)
|
|
367
367
|
test/panel.mjs 离线自检(引用清单:解析 / 搜索 / Markdown / 读取 / 导出 / 页面注册 + 文件路径打开 + 侧边线程回流 + 审阅工作台(状态 / 标签 / 批量)+ JSON 导出 + 本地索引,153 项断言)
|
|
368
368
|
test/host.mjs 离线自检(宿主半:标签 / 种子复制 / 开回合收口 / 悬挂工具调用截断 / 嵌套 descriptor 替换 / agents.create 参数 / 探针 / 围栏 / 路由注册与卸载,40 项断言)
|
|
369
369
|
test/capsule.html 真浏览器里跑同一套胶囊断言(51 项,可选)
|
|
@@ -416,7 +416,7 @@ React 重渲染不会出现第二颗、引用变了就地重建、消息被删
|
|
|
416
416
|
修订不改写引用原文本身、清空引用正文时确认按钮禁用、改后的正文随新芯片发出;
|
|
417
417
|
**浮层不跟着座位生死**(`conversation.input.overlay` 没挂载也能选中出栏、挂上两个会话座位既不叠加也不丢监听、
|
|
418
418
|
座位不在时用输入框自己的 `actions` 落芯片、无处可插时给 toast 而不是静默返回、effect 卸载/重装后监听恰好一份);
|
|
419
|
-
(共
|
|
419
|
+
(共 442 项,含文件路径与逐条回应的线上形态、`parseCodeSource`/`fileAddressFor` 与「卡片/清单点击打开 session 文件并带上起始行」、**表格单元格 / 表格行 / 段落 / 列表项 / `<br>` 边界的引用高亮**、**输入框已有文字时引用置顶并将原文另起一行**、聊天代码块划选的语言探测与跨界降级、选区的链接/行内代码保真与纯文本回退、回合级引用的取文与坐标、英文逐条指令与「Quote N」徽章、草稿芯片索引的跨刷新恢复与聚合条编辑/移除、回复徽章的建立/重建/卸载与悬停卡片复用、原生 `quote-sidechat` 页签的注册 / 地址 / 标题 / retain-release、内置 subagentchat 的降级与复用,以及评论框两个输入区的自适应高度——引用正文那格曾经在被挂进栏之前就量高,读到 0 后被写成 `height:0`,首行因此被裁掉)。
|
|
420
420
|
`test/capsule.html` 是同一套断言的真浏览器版(51 项),用 `file://` 打开即可(页面会把结果写进标题与 `#probe-out`)。这一版修好了它**缺失的 `<body>` 标签**——脚本在 `<head>` 里执行时 `document.body` 为 null,这个页面以前在真浏览器里是直接坏的;并补上真 `Range` 的链接/行内代码断言(真浏览器的 `cloneContents()` 返回的是 DocumentFragment,不是元素——序列化器只认元素的话,链接在真浏览器里会退化成纯文本;离线桩现在也用真片段,不再放过这一类),另外补了 `CSS.highlights` 选区保持与关闭清理。
|
|
421
421
|
|
|
422
422
|
`test/panel.mjs` 单独跑引用清单页与侧边线程回流(153 项):只认**持久**的 `user/message`(`transient`、助手消息、`data: null` 都跳过)、
|
|
@@ -437,13 +437,13 @@ Markdown 的标题/编号/块引用/评论行/时间戳与空列表兜底、超
|
|
|
437
437
|
|
|
438
438
|
`test/host.mjs` 不需要浏览器:它直接 import 宿主半,用桩 `agents` / `agentPresets` / `sessionTitle` / `webServer` 驱动。断言包括:`Side: ` 标签的前缀与截断、父日志逐字复制、开着的回合补 `step/end` + `turn/end{interrupted}`、悬挂工具调用截到回合前并丢掉尾部 inbox splice、嵌套侧聊的父 descriptor 留在继承前缀、我们的排在切点之后、继承切点(`session/end-seed{inherited:true}`)落在 descriptor 之前、seq 连续、窗口化日志拒绝;`agents.create` 收到 `origin: "subagent"` / `parentSession` / `isSeeded` / `inheritedEventCount` / 父会话当前模型路由 / preset setup / 清空继承 inbox / 固定标题;探针、409、503、403、405、404 与 `apply` 的注册/卸载全部有断言。
|
|
439
439
|
|
|
440
|
-
合计 **
|
|
440
|
+
合计 **647 组**(check 12 + capsule 442 + panel 153 + host 40),`npm test` 全绿。
|
|
441
441
|
|
|
442
442
|
## 已知限制
|
|
443
443
|
|
|
444
444
|
- **内置隐藏线程依赖宿主内部契约**(app.asar 0.2.1-rc.3 实测):宿主半 `lib/index.js` 用 `ctx.inject(["webServer"])` 注册 `POST /ui-quote/api/sidechat.start`,在宿主服务就绪后从父会话 `snapshotEvents()` 复制种子,再用 `ctx.get("agents").create({ meta: { parentSession, isSeeded: true, origin: "subagent", delegationDepth, agentPreset }, seed, inheritedEventCount, agentOptions, setup })` 建子会话;descriptor 为 `{version: 3, mode: "continuable", provider: "ui-quote", label}`,标题 `Side: <引用首行>`。`webServer` / `connection.requestRejection` / `agents` 缺失时探针失败,客户端退回 fork;`agents.create` 失败只影响这一条线程。
|
|
445
445
|
**种子必须标出继承切点**:复制来的父日志之后先放一条 `session/end-seed { inherited: true }`,`inheritedEventCount` 就是它的下标;我们自己的事件(回合收口、工作目录、descriptor)必须排在这条标记**之后**。宿主读子会话身份时走 `subagent` 投影(最后一次 descriptor 生效),并在 `api-session-controller` 里要求 `identity.seq >= inheritedEventCount`,否则整个子会话的历史都打不开(`subagent/catalog-diagnostic` · "subagent descriptor is unavailable")。不标切点时构造器会把整段种子当成继承前缀、再把标记补在末尾,descriptor 就落到切点之前——0.12.3-lab.26 就是这么坏的,0.12.3-lab.27 修好。嵌套侧聊(父会话本身是侧线程)沿用这条规则:父 descriptor 留在继承前缀里,我们自己的那条排在切点之后,投影按“最后一条生效”取到它。
|
|
446
|
-
|
|
446
|
+
**旧线程靠形状版本戳识别,不靠 `sessions.retain`**:retain 对这类坏线程**照样成功**(只有历史 RPC 会拒),所以客户端给新建的线程在 `dsh-client-ui-quote:v1:sidechat-target` 里盖 `v: 2`,只复用自己盖过章的线程;better-sidebar 的、旧版本的、清单里扫描发现的线程一律丢弃重建——点一次就自愈,代价是最多重建一条线程。隐藏线程是 `continuable` 子会话,**父会话在线时可继续**;父会话关闭后宿主内置 `subagentchat` 页按自己的规则只读,重新打开父会话即可继续。宿主升级改了 `agents.create` / 种子格式时,线程创建会失败并自动退回 `sessions.fork`,不会白屏或报错。
|
|
447
447
|
想优先用 dsh-better-sidebar(实测 0.28.0)的侧聊 UI,把 `sideChatBackend` 设成 `"better"`;它仍走自己的 `POST /sidebar/api/sidechat.start`,父会话未运行时会收到 409。两边共享 `Side: ` 标题约定,装不装都不会互相抢自动打开的焦点。
|
|
448
448
|
- **「改这条引用」是追加,不是原地编辑**:DSH 的 transcript 只追加(侦察确认全树没有 `editMessage` / `updateMessage` / `rewriteMessage` / 回收 API,只有**尚未进入会话**的队列条目可改)。所以修订发出一条新引用(评论、引用正文都可改),旧胶囊只挂 `已修订` 标记——标记存在**本机** `localStorage`(`dsh-client-ui-quote:v1:quote-revised`,按 **`ref + 引用原文`** 归一键、上限 60 条),同一句话从两个不同位置引用时互不影响;没有 ref 的旧引用仍按原文键读写。它不会跨标签页、跨设备同步,也不进入模型上下文;模型看到的是那条改后的新引用。正文改过后键仍是旧原文:`已修订` 挂在**旧**胶囊上(它的卡片里显示改后的原文与评论),改后的新胶囊不挂标。
|
|
449
449
|
- **代码引用的识别靠首行围栏**:块首是 `> ❝ ``` `、块尾有配对的收尾围栏时,这块按代码解析(围栏剥掉、胶囊等宽)。因此一条**普通**引用如果正文恰好以 ``` 或 `~~~` 开头(比如在 Markdown 文件预览里引用了源码),只要它没有配对的收尾围栏,就仍然按正文读回——首行不会被当成围栏吃掉,引用与清单里都是原文。写成代码引用时收尾围栏始终成对,所以正文自带 ``` 的代码引用改用 `~~~` 也不会与这条规则打架。
|
|
@@ -481,7 +481,7 @@ Markdown 的标题/编号/块引用/评论行/时间戳与空列表兜底、超
|
|
|
481
481
|
- **Markdown 预览的行号**:要精修就得读源文件,而客户端必须声明 `remote` 才能拿到它;声明错会让 client bundle 在不匹配的宿主上**静默失效**(`dsh-quote-annotate` 上游就是这么死的)。所以先不声明——文件仍然打开,只是落在顶部而不是行上。
|
|
482
482
|
- **表格/列表/LaTeX 的结构保真**:链接与行内代码已做;表格要还原成 Markdown 表格,列表要还原成缩进,成本明显更高,留到有人真的需要时再做。
|
|
483
483
|
- **图片/截图引用**:明确不做(理由见「本插件不做的」)。真要做请独立成插件:图片引用要的是另一套胶囊/卡片/附件语义。
|
|
484
|
-
- **真机验证**:这一轮的宿主契约全部来自 `app.asar` 的一手文档,功能路径有
|
|
484
|
+
- **真机验证**:这一轮的宿主契约全部来自 `app.asar` 的一手文档,功能路径有 647 项离线断言;隐藏线程的 `agents.create` / 种子格式已在**隔离的 DSH web 实例**(临时 `DSH_HOME`,端口 8791,CLI 0.2.1-rc.3)里确认:宿主半通过 `ctx.inject(["webServer"])` 晚到注册,`POST /ui-quote/api/sidechat.start` 的探针返回 `{"ok":true,"value":{"available":true,"version":1}}`,说明 `agents` 服务与同源围栏都就绪。本轮又在**运行中的桌面端**(link 模式,重启后加载 `lib/index.js`)核对过一次:`/ui-quote/api/*` 下任意路径都先被围栏拦成 `403 {"code":"forbidden"}`,而同样方法打一个不存在的顶层路径是 `404`,说明前缀路由确实挂上了、并且先过围栏。原生侧聊页签的 `SessionProvider` / `conversation.content` 嵌入契约还需要在真实窗口里重开一次侧边对话确认(离线桩只覆盖注册、地址、标题与 retain/release,不渲染宿主组件)。真浏览器(1600×2000 视口)同一套断言本轮复核 **51/51**。欢迎页的交互点击被安全闸门拦下,因此下面五条仍需在真实窗口逐项点:聚合条编辑、回合尾的两个按钮、打开文件与行范围标记、另开侧边对话、JSON 导出。
|
|
485
485
|
- **市场收录与首屏**:README 已有截图、徽章、「30 秒上手」与 24 秒静态轮播 GIF;还差把插件提交到 dsh.market / dsh-plugin.org / dsh.pub / awesome-deepseek-harness —— 这些需要外部账号,是人工动作。
|
|
486
486
|
|
|
487
487
|
## 变更记录
|
package/lib/client.js
CHANGED
|
@@ -500,6 +500,14 @@ window.__ModuleLoader__.load({
|
|
|
500
500
|
*/
|
|
501
501
|
const SIDECHAT_TARGET_KEY = "dsh-client-ui-quote:v1:sidechat-target";
|
|
502
502
|
const SIDECHAT_TARGET_LIMIT = 200;
|
|
503
|
+
/**
|
|
504
|
+
* Shape version stamped on a hidden thread this build minted. Version 2
|
|
505
|
+
* puts the descriptor after the inherited cut, which is the only shape
|
|
506
|
+
* the host will read back; anything older (a plain better-sidebar id, a
|
|
507
|
+
* child from the first build, a thread found by scanning) is replaced on
|
|
508
|
+
* the next click instead of reopened.
|
|
509
|
+
*/
|
|
510
|
+
const HIDDEN_THREAD_VERSION = 2;
|
|
503
511
|
const SIDECHAT_PROBE_MS = 1500;
|
|
504
512
|
const SIDECHAT_START_MS = 15000;
|
|
505
513
|
/**
|
|
@@ -5770,6 +5778,16 @@ box-shadow:0 1px 3px rgba(0,0,0,.25)}
|
|
|
5770
5778
|
if (!(await probeBuiltinSideChat())) return false;
|
|
5771
5779
|
const bound = typeof quoteKey === "string" && quoteKey !== "" ? threadForQuote(sessionId, quoteKey) : null;
|
|
5772
5780
|
let threadId = mode === "new" ? null : bound ?? storedSideThread(sessionId);
|
|
5781
|
+
// Reuse only a thread this build minted. Anything older — a plain
|
|
5782
|
+
// better-sidebar id, or a child whose descriptor sits before the
|
|
5783
|
+
// inherited cut (the host refuses its history forever) — is replaced
|
|
5784
|
+
// instead of reopened. `sessions.retain` cannot tell them apart: it
|
|
5785
|
+
// succeeds where the history RPC refuses, so the version stamp is
|
|
5786
|
+
// the only honest signal.
|
|
5787
|
+
if (threadId !== null && targetOfThread(threadId).kind === "hidden" && !mintedHiddenThread(threadId)) {
|
|
5788
|
+
forgetSideThread(sessionId, threadId);
|
|
5789
|
+
threadId = null;
|
|
5790
|
+
}
|
|
5773
5791
|
if (threadId !== null && !(await hiddenThreadReadable(threadId))) {
|
|
5774
5792
|
forgetSideThread(sessionId, threadId);
|
|
5775
5793
|
threadId = null;
|
|
@@ -5782,7 +5800,7 @@ box-shadow:0 1px 3px rgba(0,0,0,.25)}
|
|
|
5782
5800
|
threadId = null;
|
|
5783
5801
|
}
|
|
5784
5802
|
if (threadId === null) return false;
|
|
5785
|
-
const target = { kind: "hidden", parentId: sessionId };
|
|
5803
|
+
const target = { kind: "hidden", parentId: sessionId, v: HIDDEN_THREAD_VERSION };
|
|
5786
5804
|
rememberThreadTarget(threadId, target);
|
|
5787
5805
|
rememberSideThread(sessionId, threadId, target);
|
|
5788
5806
|
if (typeof quoteKey === "string" && quoteKey !== "") rememberQuoteThread(sessionId, quoteKey, threadId, target);
|
|
@@ -6059,18 +6077,31 @@ box-shadow:0 1px 3px rgba(0,0,0,.25)}
|
|
|
6059
6077
|
function rememberThreadTarget(threadId, target) {
|
|
6060
6078
|
if (typeof threadId !== "string" || threadId === "") return;
|
|
6061
6079
|
const map = readThreadTargets();
|
|
6080
|
+
const previous = map[threadId];
|
|
6062
6081
|
const parentId = target !== null && target !== undefined && typeof target.parentId === "string" ? target.parentId : "";
|
|
6063
6082
|
if (parentId === "") {
|
|
6064
6083
|
delete map[threadId];
|
|
6065
6084
|
writeThreadTargets(map);
|
|
6066
6085
|
return;
|
|
6067
6086
|
}
|
|
6068
|
-
|
|
6087
|
+
// An explicit version wins; a scan of someone else's thread must not
|
|
6088
|
+
// upgrade it, so an unknown entry stays unversioned.
|
|
6089
|
+
const explicit = target !== null && target !== undefined && typeof target.v === "number" ? target.v : undefined;
|
|
6090
|
+
const inherited = previous !== null && typeof previous === "object" && typeof previous.v === "number" ? previous.v : undefined;
|
|
6091
|
+
const version = explicit ?? inherited;
|
|
6092
|
+
map[threadId] = { parentId, kind: "hidden", ...(version === undefined ? {} : { v: version }) };
|
|
6069
6093
|
const keys = Object.keys(map);
|
|
6070
6094
|
for (const key of keys.slice(0, Math.max(0, keys.length - SIDECHAT_TARGET_LIMIT))) delete map[key];
|
|
6071
6095
|
writeThreadTargets(map);
|
|
6072
6096
|
}
|
|
6073
6097
|
|
|
6098
|
+
/** Whether this build minted the thread (its binding carries the shape version). */
|
|
6099
|
+
function mintedHiddenThread(threadId) {
|
|
6100
|
+
if (typeof threadId !== "string" || threadId === "") return false;
|
|
6101
|
+
const stored = readThreadTargets()[threadId];
|
|
6102
|
+
return stored !== null && typeof stored === "object" && stored.v === HIDDEN_THREAD_VERSION;
|
|
6103
|
+
}
|
|
6104
|
+
|
|
6074
6105
|
/** better-sidebar's map, read backwards, for threads our own map predates. */
|
|
6075
6106
|
function hostParentOfThread(threadId) {
|
|
6076
6107
|
if (typeof threadId !== "string" || threadId === "") return null;
|
|
@@ -8388,6 +8419,8 @@ border-top:1px solid color-mix(in srgb,currentColor 18%,transparent)}
|
|
|
8388
8419
|
cleanSideThreadTitle,
|
|
8389
8420
|
rememberThreadTarget,
|
|
8390
8421
|
targetOfThread,
|
|
8422
|
+
mintedHiddenThread,
|
|
8423
|
+
HIDDEN_THREAD_VERSION,
|
|
8391
8424
|
threadRetainTarget,
|
|
8392
8425
|
readThreadTargets,
|
|
8393
8426
|
knownSideThreadIds,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-client-ui-quote",
|
|
3
|
-
"version": "0.12.3-lab.
|
|
3
|
+
"version": "0.12.3-lab.29",
|
|
4
4
|
"description": "Turn any DSH selection into a reviewable quote — comment / add to chat / side chat, source highlights and jump-back, a searchable review list, side threads, revisions, and per-quote reply badges.",
|
|
5
5
|
"icon": "icon.svg",
|
|
6
6
|
"license": "MIT",
|
package/test/capsule.mjs
CHANGED
|
@@ -962,6 +962,11 @@ try {
|
|
|
962
962
|
JSON.stringify(testing.targetOfThread("session-hidden-1")) === JSON.stringify({ kind: "hidden", parentId: "session-hidden-main" }),
|
|
963
963
|
JSON.stringify(testing.targetOfThread("session-hidden-1"))
|
|
964
964
|
);
|
|
965
|
+
check(
|
|
966
|
+
"a thread this build minted carries the shape version",
|
|
967
|
+
testing.mintedHiddenThread("session-hidden-1") === true,
|
|
968
|
+
JSON.stringify(testing.readThreadTargets()["session-hidden-1"])
|
|
969
|
+
);
|
|
965
970
|
check(
|
|
966
971
|
"reading a hidden thread uses the subagent address",
|
|
967
972
|
JSON.stringify(testing.threadRetainTarget("session-hidden-1")) ===
|
|
@@ -1002,13 +1007,13 @@ try {
|
|
|
1002
1007
|
JSON.stringify(sessionReads.at(-1))
|
|
1003
1008
|
);
|
|
1004
1009
|
|
|
1005
|
-
//
|
|
1006
|
-
//
|
|
1007
|
-
// cut). Reopening it can never load, so the next click mints a new one.
|
|
1010
|
+
// A thread with the current stamp whose address the host still refuses
|
|
1011
|
+
// (deleted child, or a host that changed the rule) is replaced too.
|
|
1008
1012
|
const staleMain = "session-hidden-stale";
|
|
1009
1013
|
const staleThread = "session-hidden-stale-child";
|
|
1010
|
-
|
|
1011
|
-
testing.
|
|
1014
|
+
const staleTarget = { kind: "hidden", parentId: staleMain, v: testing.HIDDEN_THREAD_VERSION };
|
|
1015
|
+
testing.rememberThreadTarget(staleThread, staleTarget);
|
|
1016
|
+
testing.rememberSideThread(staleMain, staleThread, staleTarget);
|
|
1012
1017
|
installShell("session-hidden-fresh");
|
|
1013
1018
|
sessionReadImpl = (address) => {
|
|
1014
1019
|
if (address !== null && typeof address === "object" && address.childSessionId === staleThread) throw new Error("subagent descriptor is unavailable");
|
|
@@ -1038,6 +1043,44 @@ try {
|
|
|
1038
1043
|
JSON.stringify(testing.targetOfThread(staleThread))
|
|
1039
1044
|
);
|
|
1040
1045
|
|
|
1046
|
+
// The pre-fix build stamped nothing. Such a child keeps a perfectly
|
|
1047
|
+
// valid parent binding — `sessions.retain` succeeds and only the history
|
|
1048
|
+
// RPC refuses it — so the shape version is the only honest signal left.
|
|
1049
|
+
const legacyMain = "session-hidden-legacy";
|
|
1050
|
+
const legacyThread = "session-hidden-legacy-child";
|
|
1051
|
+
testing.rememberThreadTarget(legacyThread, { kind: "hidden", parentId: legacyMain });
|
|
1052
|
+
testing.rememberSideThread(legacyMain, legacyThread, { kind: "hidden", parentId: legacyMain });
|
|
1053
|
+
installShell("session-hidden-legacy-new");
|
|
1054
|
+
sessionReadImpl = () => ({
|
|
1055
|
+
ready: Promise.resolve(),
|
|
1056
|
+
binding: { session: { eventSource: { getSnapshot: () => ({ entries: [] }) }, getSnapshot: () => ({ hasMore: false }) } },
|
|
1057
|
+
release() {}
|
|
1058
|
+
});
|
|
1059
|
+
globalThis.fetch = async (url, options) => {
|
|
1060
|
+
const payload = JSON.parse(options.body);
|
|
1061
|
+
fetches.push({ url, payload });
|
|
1062
|
+
if (payload.probe === true) {
|
|
1063
|
+
return { ok: true, status: 200, json: async () => ({ ok: true, value: { available: true, version: 1 } }) };
|
|
1064
|
+
}
|
|
1065
|
+
return { ok: true, status: 200, json: async () => ({ ok: true, value: { childId: "session-hidden-legacy-new", parentId: legacyMain } }) };
|
|
1066
|
+
};
|
|
1067
|
+
openedResources.length = 0;
|
|
1068
|
+
const migrated = await testing.hiddenSideChatRequest(legacyMain, "老线程引用", false, null, "", "reuse", "老线程引用");
|
|
1069
|
+
check(
|
|
1070
|
+
"a thread from before the fix is replaced even though the host retains it",
|
|
1071
|
+
migrated === true &&
|
|
1072
|
+
testing.storedSideThread(legacyMain) === "session-hidden-legacy-new" &&
|
|
1073
|
+
testing.mintedHiddenThread("session-hidden-legacy-new") === true &&
|
|
1074
|
+
openedResources.length === 1 &&
|
|
1075
|
+
String(openedResources[0]?.address).includes("session-hidden-legacy-new"),
|
|
1076
|
+
JSON.stringify({ stored: testing.storedSideThread(legacyMain), targets: testing.readThreadTargets() })
|
|
1077
|
+
);
|
|
1078
|
+
check(
|
|
1079
|
+
"the unversioned thread stops being a hidden target",
|
|
1080
|
+
testing.targetOfThread(legacyThread).kind === "fork" && testing.mintedHiddenThread(legacyThread) === false,
|
|
1081
|
+
JSON.stringify(testing.targetOfThread(legacyThread))
|
|
1082
|
+
);
|
|
1083
|
+
|
|
1041
1084
|
// Reading the thread goes through the subagent address.
|
|
1042
1085
|
sessionReadImpl = () => {
|
|
1043
1086
|
return {
|