Commit Graph
1190 Commits
Author SHA1 Message Date
多玩幻灵qwq 084677665a Merge pull request #810 from xlennart/codex/register-dsh-side-chat
docs: register dsh-side-chat in the tab catalog
2026-10-01 15:16:15 +08:00
多玩幻灵qwq 32812f3f44 Merge pull request #795 from OMSociety/feat/omsociety-plugin-entries
feat(plugin-list): 把 dsh-git-forge 与 dsh-ssh-tunnel 两条指向维护中的仓库与 npm 包
2026-10-01 15:15:48 +08:00
多玩幻灵qwq d99d42acce Merge pull request #711 from Lukeknow0/main
docs: add Markdown output link preview plugin
2026-10-01 15:15:21 +08:00
多玩幻灵qwq 7c32c110f2 Merge pull request #688 from KannaKuron/feat/plugin-entry-dsh-ide-git
feat(catalog): add dsh-ide-git to the tab plugin catalog
2026-10-01 15:14:55 +08:00
多玩幻灵qwq e21b5c19ce Merge pull request #585 from modusensus/catalog-dsh-mneme
feat(catalog): add dsh-mneme to the tab plugin catalog
2026-10-01 15:13:58 +08:00
多玩幻灵qwq 8d9183746c Merge pull request #544 from Andor-Z/feat/dsh-turn-outline-listing
feat: list dsh-turn-outline in the plugin ecosystem (README + catalog)
2026-10-01 15:12:57 +08:00
多玩幻灵qwq aa095e6b33 Merge pull request #514 from kp-z/add-dsh-dev-git-graph
Add dsh-dev-git-graph to the tab plugin catalog
2026-10-01 15:10:24 +08:00
MXY e1c7ac3491 fix(ws): fence 接受桌面壳页面 origin,补全自定义协议下的 WebSocket 修复
上一个提交把 WebSocket 的 base 改到 `__DSH_TRANSPORT__.streamBaseUrl`,解决了
`ws://app` 解析不了的问题;但握手仍然失败。桌面壳页面位于 `dsh-app://app`,
它的 WebSocket 升级直连 Host 的 loopback 地址(壳的 `protocol.handle` 不承载
upgrade),Chromium 因此带上 `Origin: dsh-app://app`。fence 按 hostname 比较,
字面量 `app` 永远不等于 `127.0.0.1`,socket 在 `handleUpgrade` 之前就被销毁。

HTTP 路由不受影响,原因在壳自己:它转发前会删掉 origin 头,Host 侧看到的是
无 Origin 请求,fence 本就放行。所以同一个 fence 只在 WebSocket 路径上暴露。

改动:fence 在 Host 检查通过之后接受精确字符串 `dsh-app://app` —— 与壳自身
request forwarder 的信任集合(非 null 时只认这一个)逐字一致。同 scheme 的
其他 origin、跨站 origin 仍然拒绝;无 Origin 的请求本来就走放行分支,因此这
不是在既有信任面之外新增入口。

测试:`tests/trusted-hosts.spec.ts` 新增 4 例,其中两条是负向控制(Host 非
我方时仍拒、精确匹配而非前缀匹配)。两条新断言各做过一次变异验证:禁用该
分支只让「接受」一例变红,改成前缀匹配只让「精确」一例变红。
2026-10-01 02:30:26 +08:00
Andor 2af19166b0 feat(catalog): unpin dsh-turn-outline prerequisite after 0.18.0 co-test
plugin 0.2.7 declares dsh-better-sidebar@^0.17.0 || ^0.18.0 and is
co-tested on better-sidebar 0.18.0 + DSH 0.1.2-rc.1, so the catalog
install line no longer needs the 0.17.1 stable-line pin.
2026-09-30 15:48:24 +08:00
Andor 737276b256 feat: list dsh-turn-outline in the plugin ecosystem (README + catalog)
Adds Andor-Z/dsh-turn-outline (turn-outline tab) to the ecosystem:
- README.md / README_EN.md tab-plugin table rows + header count 24 -> 26
  (aligns with the actual row count, which was already 25)
- recommended-catalog entry in plugins-tabs.ts (npm install; better-sidebar
  prereq pinned to 0.17.1 - stable-line policy, see the entry comment)
- pluginTurnOutlineName/pluginTurnOutlineDesc i18n keys across all 20
  dictionaries (locales.ts zh/en + 19 locale chunks)
2026-09-30 15:48:24 +08:00
kola a9a7a9901a Merge upstream main and preserve absolute preview paths
Resolve client preview paths against the session cwd. Limit the server file fallback to relative input and retain upstream absolute HTML path semantics. Cover nested assets, Windows/UNC paths, and external files with workspace shadows.
2026-09-30 13:26:10 +08:00
xlli67 bb0c4649c8 docs: 注释去掉终端插件举例,保持通用接口描述 2026-09-30 13:13:42 +08:00
xlli67 e556ebb378 fix(service): SIDEBAR_FEATURES 新增 rightActions 能力声明
rightActions 字段已加入 TabDescriptor,但 SIDEBAR_FEATURES 数组遗漏了
能力声明,导致消费方 features.includes('rightActions') 探测返回 false,
误走降级路径。
2026-09-30 13:08:28 +08:00
xlli67 679889d8a9 feat(tabbar): 新增 TabDescriptor.rightActions,活跃 tab 可注入 tab 栏右侧操作区
TabBar 新增 getTabRightActions prop,活跃 tab 的 descriptor 声明 rightActions
时,返回的 ReactNode 渲染在 tab 栏右端(+ 按钮右侧、面板关闭按钮左侧,
右对齐)。让 tab 把自己的工具栏(如终端 tab 的新建 / 拆分 / 重启)直接放进
tab 栏,而不是在内容区顶部再单独渲染一行头部。

TabDescriptor.rightActions 与 badge 同签名 (ctx, scope, state) => ReactNode,
抛错被吞掉(不渲染操作),每次活跃 tab 渲染调用——保持廉价。

文档同步:docs/external-plugin-guide.md §4.1 TabDescriptor 字段。
2026-09-30 13:00:28 +08:00
mengge237 a12a97bbfd fix(sidebar): 后台自动激活不再顶掉右侧栏正在看的页面
子代理 / 新后台任务的自动激活原先只判断「栏是否收起」,没有判断「栏里现在是谁」:
宿主 openContent 每次打开都 planSetExpanded(true) 并把焦点落到新开的 tab,
所以当右侧栏是展开的、用户正在看一个文件(例如刚产出的 .md)时,
每来一个子代理 / 新任务就把那一页顶掉,读者正在读的东西被换走。

窄屏那半边(#162 的 park)已经承认「栏在用就别动它」,这里把同一条判据补到宽屏:
仅当目标会话在屏、栏已展开、且当前页不是任务页时,后台激活直接返回;
栏收起时不挡(屏幕上看不到任何东西可被顶掉,两个开关的承诺照旧),
已经在任务页上是原地聚焦(单实例语义,无副作用),
拓扑跳回是用户手势,不走这条闸。
2026-09-30 02:45:41 +08:00
ZinChl 910c71ed16 fix(tasks): 任务页折叠守卫的三处不一致(根卡死控制 / run 成员绕过 leaf 测试 / 文档矛盾)(#784)
1. **根卡的折叠 chevron 是死控制**:绘制条件只有 `settled || state === 'idle'`,
   没有「非根」判断;跳进子会话后 `current` 为假,已结算的根卡就会画出 chevron。
   而模型里根节点是无条件 push 的,`foldedIds` 全模型只在子层与 run 成员两处消费,
   根节点不查 → 点了没有任何变化。改为**根卡不画**:`parentId` 只在根行缺席,用它
   做守卫;根卡是页面的锚点,本就不该被折叠(既有的
   「The root IS the current session: never foldable」用例固化的就是这个语义)。

2. **run 成员折叠绕过 leaf 测试**:`tasks-model.ts` 的 run 成员分支只做
   `(folded || foldedIds) && nodeFoldable(...)`,注释声称成员「leaves by
   construction」,但成员常常是从 `agentChildren` **重挂载**过来的真实目录节点
   (带 `hasChildren` 与 team 富集)——于是页面级折叠会把一个分支连同整棵子树
   收进聚合,正是 `isAutoFoldable` 注释声称要防的形态。改为对**自动**触发器
   走 `isAutoFoldable`(结构守卫:分支节点与自己有 run 的节点不折叠)。roster
   守卫不适用(成员不是该父级的 roster 行,idle 人数是 roster 扫描规则),
   注释里明确写下这条有意保留的差异。

3. **`foldedIds` 的接口文档自相矛盾**:文档写「never a branching one」,而实现
   (`nodeFoldable`)只有 running/current 守卫。按 a7338be 的意图(chevron 画在
   每张已结算卡上,加分支守卫只会制造更多死控制)实现是对的,删掉文档里那句。

测试(`tests/tasks-page.spec.tsx` +2,均实测回退即红):
- 根卡:读者身处子会话、根已结算时,根卡**不得**有折叠键(回退 TasksGraph 后红:
  `expected <button> to be null`)。
- run 成员:重挂载的分支成员**不得**被自动折叠,而同批的叶子兄弟照常收进聚合
  (回退 tasks-model 后红:`expected null not to be null`)。
2026-09-30 02:31:38 +08:00
ZinChl e38aa56fec fix(tasks): 会话「驻留」不再当作「agent 在跑」——崩溃重启后的子代理状态(#800)
宿主目录行的 `activity` 是**会话驻留**而非运行态(宿主自己的字段注释:
"recursive catalog listing observed a resident Session … does not encode a
durable outcome or guarantee continuation delivery")。崩溃重启后,DSH 打开
被中断子会话的历史流会把它 prepare → retain → attach 成驻留 Session,但不会
启动 agent,于是 `activity === 'running'` 成立、卡片显示「运行中」并附带实时
预览行,而实际上没有任何东西在跑。

权威运行位其实早就在手边:会话摘要的 `running`(根卡片已经在用,
`subagent-lineage` 统计后代也在用,DSH 官方子代理下拉同样用它)。改为
「摘要的 running 优先、目录标志兜底」:

- `src/client/tasks-model.ts`:子节点 activity/state 由
  `summary.running ?? (view.running === true)` 决定。摘要没有该字段的老宿主
  继续走目录标志,行为不变。
- `src/client/team-projection.ts`:同一规则(原先恰好相反,优先了驻留标志)。

测试:
- `tests/tasks-page.spec.tsx` 新增两条:驻留但未运行 → 不是 running 卡片
  (旧代码下断言 `data-running` 为 null 会红);摘要无 running 字段 → 回落到
  目录标志(旧行为保留)。同时把两条既有用例的 fixture 修正为两路一致
  (原先 live 说 running、摘要说 false,本身自相矛盾)。
- `tests/team-projection.spec.ts` 新增两条:摘要 false + live true → idle;
  摘要 true + live false → running。
2026-09-30 02:24:36 +08:00
ZinChl 38a82db0e3 fix(files): fs.trees 按宿主上限分块,展开集 ≥64 的会话不再整树报错(#799)
宿主对一次 `fs.trees` 批量请求有硬上限 `FS_TREES_MAX_PATHS = 64`,超限
**整批** `bad-request`;而客户端把 root + 全部展开目录放进**一次**请求
(loadLevels)。展开集按会话持久化,所以累计展开到 64+ 的用户每次挂载/刷新
都被整批拒绝,catch 把所有无缓存层写成 error —— 整棵树报错,只能手动折叠。

改动:
- 新增 `src/fs-batch.ts`:把行上限放成**两半共用的零依赖模块**(`prefs-shared.ts`
  的同一模式),宿主 `src/index.ts` 改为 re-export,客户端按同一常量分块,
  两边不会再漂移。
- `src/client/FileTree.tsx` 的 `loadLevels`:把可见集按上限切块、并发请求,
  并保留批量路由的**逐层错误粒度**——某一批失败只标记它自己携带的层,
  不会再把其它批已经拿到的列表一起标红(原先单请求失败时会标记全部
  wanted)。缓存/代际(generation)语义不变。
- 宿主上限保持不动(那是针对恶意超大批量的防线)。

测试:`tests/file-tree-batch-load.spec.tsx` 新增两例——71 个可见路径切成
64 + 7 两批且每个路径恰好出现一次;某一批失败时另一批的层仍正常渲染。
回退 FileTree 的分块后这两例当场红、原有 8 例仍绿(已实测)。
2026-09-30 01:56:11 +08:00
cxl 06377fbc5f docs: register dsh-side-chat in the tab catalog 2026-09-30 01:55:02 +08:00
ZinChl 214bf451a0 fix(files): 修 v0.24.1「压缩并下载」必然失败——archive.status 缺 sessionId + ready 交接无护栏(#798)
同一条轮询链上的两处,都在 #782 新增的 archive 功能里:

1. `archiveStatus(id)` 只发 `{ id }`,而宿主 `archive.status` 对 id 与
   sessionId 都 `requireString`(src/index.ts)→ 第一次轮询即 400
   `missing or invalid "sessionId"`,`state === 'ready'` 永远到不了,
   整条链只有 build 成功。同族的 `archive.build` 与下载 URL 都带 scope,
   只有这一处漏了。改为 `archiveStatus(scope, id)` 走 `scopePayload`。

2. `saveArchive` 是 fire-and-forget,`settleArchive()` 只在完成回调里执行,
   于是 ready 之后 250ms 轮询照跑:下载路由是消费式的(GET 服务后释放任务),
   首个 GET 未完成时会并发第二次 `save`(双下载),已完成时下一次 `status`
   404 → 已成功的下载旁边同时挂一条 zipFailed。改为 ready 时先
   `setArchiveJobId(null)` 停轮询,并用 `archiveHandedOffRef` 保证恰好一次交接。

测试:新增 `tests/archive-client.spec.ts` 钉客户端**真实载荷形状**(此前的
用例要么整体 mock 掉本模块、要么只测宿主侧),并给 FileTree 加一条
「ready 恰好交接一次」用例。回退 api.ts 的两个载荷断言、回退 FileTree 的
交接护栏,对应用例分别当场红(已实测)。
2026-09-30 01:52:59 +08:00
graydovee 78a7dbd272 fix(client): 空白新会话里恢复「打开底部工作台」入口(#698 / #623)
0.2.0-rc.1 实测:空白会话里宿主仍渲染会话头,但只渲染 leading + corner(宿主自己的
「Open right sidebar」按钮);header.utilities / header.actions 两个槽不渲染,插件挂在
utilities 上的底部工作台开关随之不可达。

- 判定来源不用 DOM 探测:host 半区新增只读路由 session.phase,读
  ctx.sessions.get(id).snapshotEvents(),按宿主会话列表投影同一规则判定 blank
  (无 user/message 与 assistant/message)。
- 客户端 useSessionPhase(sessionId):挂载/会话切换取一次;blank 期间每 1s 轮询;
  发出第一条消息即翻转停止。路由/宿主不支持时按非 blank 降级。
- 备用入口放在 conversation.composer.dock(list 槽,blank 态渲染且为空;hero 行的
  workspace 槽是 single 且被宿主 WorkspacePicker 占用,实测抢占会使客户端条目激活失败,
  不用)。仅在 blank 相位渲染,因此与会话头里的入口天然互斥、恒定一套。
- 备用按钮 position:fixed,按宿主「Open right sidebar」按钮的 rect 对齐到其左侧紧邻
  (随 resize 与 500ms 周期重对齐),经 portal 到 document.body(z 40:高于 AppFrame(20)
  与会话头、低于浮层 100+),否则会被会话头 titleRow 拦截点击(实测)。
- mount / perf 的入口断言从「attached 恰好 1 个」升级为「可见的第一个可 attached/点击」:
  宿主会为每个保留会话渲染隐藏的会话头副本(transform 移出视口、rect 仍在),节点计数
  会把副本算进去;「屏幕内恰好 1 个」的强不变量由新增用例的 on-screen 计数负责。
- 单测 tests/dock-fallback.spec.tsx(4 条,mock session.phase):blank 渲染且点击写 store;
  非 blank 不渲染;相位未到达不渲染;路由不可用降级。
- 部署级 tests/e2e/blank-session-dock-entry.e2e.ts:空白会话入口可见可点、宿主侧边栏按钮
  仍在旁、屏幕内恒定一套;发消息后退场、入口回会话头;无 console/pageerror。
- docs/plans/2026-09-29-blank-session-dock-entry.md:根因、实测、排除方案、判据。
2026-09-29 17:54:53 +08:00
ZinChl cb6da1cdd7 fix(files): 搜索结果里的目录行改为导航文件树,不再当文件打开 (#801)
根因:`fs.search` 有意把目录名也算命中(「提示命中项所在的目录」),而搜索面板把
`matches` 里每一行都当成文件交给 `onOpenFile` → `fs.read`。宿主 `readText` 对目录
显式抛 `"<path>" is a directory`(src/index.ts:197),于是点目录名必然报红。

改动:
- `src/fs-search.ts`:结果新增 `dirs`(`matches` 里属于目录的子集,同种相对
  '/'-分隔形式)。目录判定跟随符号链接(`stat`),与文件树行、`fs.read` 的
  行为一致;悬空链接退回普通条目。
- `src/client/TreePanel.tsx`:目录行画文件夹字形(`data-dsh-search-dir`)并改为
  **在树里展开该目录及其祖先**(`onToggle` 是翻转,故只碰折叠中的路径),同时清空
  搜索框让树成为下一步看到的界面;文件行行为不变。
- `src/client/state.ts`:把 `revealPaths` 里的祖先目录推导抽成可复用的
  `ancestorDirs(cwd, files)`(行为不变,UNC / Windows 前缀逻辑单点维护);顺带修掉
  该注释里一个损坏的 `→` 字节。
- `src/client/sidebar.module.css`:结果行改 flex 并给目录行加令牌色,省略号移到
  标签节点上(视觉对文件行不变,`tests/theme.spec.ts` 仍绿)。

验证:
- `tests/fs-search.spec.ts`:`dirs` 上报 + 符号链接按目标分类(含悬空链接)。
- `tests/file-tree-search-persist.spec.tsx`:新增三条 jsdom 用例——目录命中只导航
  不调 `onOpenFile`、嵌套命中只展开折叠祖先(已展开的父级不会被翻回去)、文件命中
  仍走 `onOpenFile` 且保留结果列表。**回退 TreePanel.tsx 后前两条即红**(已实测)。
- `tests/state.spec.ts`:`ancestorDirs` 的 POSIX / 盘符 / UNC / 去重与过滤用例。
- `make check` 全绿:typecheck → lint → build → 137 文件 1498 用例 → check:consumer-types。
2026-09-29 17:04:42 +08:00
mengjiapeng d3134d7334 fix(git): scope status snapshots to the selected repository
Carry repoRoot through status requests and cache keys so an attached session cannot reset child selection through its authoritative cwd. Cover branch labels, changed files, and switching back in the view regression.
2026-09-29 16:13:12 +08:00
mengjiapeng 2f6c4f9760 fix(git): resolve worktrees from the selected repository
Validate selected checkouts against the discovered child repository when the session workspace is a non-Git container. This restores branch and history requests after switching repositories while retaining the worktree allowlist.
2026-09-29 16:03:11 +08:00
张虎 ef9c750df0 fix(sidebar): 原生右侧栏文件树也跟随会话实际 worktree(共享 useSessionRoot) 2026-09-29 14:56:06 +08:00
张虎 3bc8b4675a feat(sidebar): 文件树跟随会话实际所在的 git worktree(含跨仓库 linked worktree) 2026-09-29 14:40:03 +08:00
MXY 27187256c9 fix(client): WebSocket 路由改用壳注入的 transport base(0.2.0-rc.1 / v0.24.1 基线)
桌面壳把页面放在 dsh-app://app/ 下,location.origin 的 host 是字面量 app,拼出的 ws://app/... 永远解析不了。改用 __DSH_TRANSPORT__.streamBaseUrl(壳经 DESKTOP_IPC.boot 注入);普通 http(s) 页面下与 location.origin 等价。

本 PR 是 #768 同一份修复在 0.24.1 上的重放:原 PR 基于 0.22.x,而 v0.24.0 起支持线已前移到 ^0.2.0-rc.1,旧基线无法合并,故新开。
2026-09-29 01:51:46 +08:00
Atlas Zeng 492661a3ea Update README.md 2026-09-29 00:45:34 +08:00
Atlas Zeng a2751cfbde Merge pull request #782: 文件页/文件变动页 UIUX 重构 + DSH 0.2.0 适配(v0.24.1)
汇总自 v0.22.1 以来的全部更新:文件页多选 / Git 着色 / 新建文件夹 / 压缩下载进度 / 打开方式双源 / 菜单层级 / 性能(fs.tree 22.8→3.8ms、批量 fs.trees),文件变动页重构为层级树,删除工作区路径检测(放开权限,安全相关),DSH 0.2.0-rc.1 支持线(无运行时兼容分支),以及展开整树重建、在侧边打开、展开状态重置等修复。

CI:ci / ci-windows / plugin-mount 三绿(1-review 规则按仓库 bootstrap 免审名单由 owner 账号放行)。本地 137 文件 / 1491 用例、真实宿主 lane 9/9。
v0.24.1
2026-09-28 23:28:46 +08:00
山海学社OMSociety e3215e7e2a feat(plugin-list): 把 dsh-git-forge 与 dsh-ssh-tunnel 两条指向维护中的仓库与 npm 包
这两个插件的维护线在 OMSociety,且已发布到 npm(条目 id 即 npm 包名):

- url: thirsty5034/<repo> → OMSociety/<repo>
- install: GitHub 源形态 → npm 形态(dsh plugin --profile web add <pkg>@1.0.0)
- 注释里「package is GitHub-sourced until npm publish」同步改为已发布 npm
- README.md / README_EN.md 对应两行的链接与 stars 徽章同步

条目 id 与 locale 串不变,tests/plugin-list.spec.ts 的唯一性与形态断言不受影响。
2026-09-28 23:26:03 +08:00
Menghuan1918 52be73e176 test(zip): 让两条断言平台正确,修 ci-windows 红
ci-windows(首次在本分支跑)报 tests/zip.spec.ts 两条失败,均为**测试可移植性**问题,不是产品缺陷:

1. 「keeps a backslash as part of the file name (POSIX names are literal)」:
   Windows 上反斜杠就是路径分隔符,join(root, 'a\b.txt') 得到 root\a\b.txt,父目录不存在 →
   writeFileSync 报 ENOENT。该语义在 Windows 上根本不存在 → 按仓库既有约定
   it.skipIf(isWin32) 跳过,并在注释里写明理由。
2. 「passes unzip -t when the binary exists」:断言 outMode === inMode & 0o644 在 Windows 上
   无意义(两边 statSync().mode 都是 0o666 → expected 420, received 438)。CRC 与解压断言保留,
   只把 mode 一致性放进 !isWin32 分支。

本地:tests/zip.spec.ts 37/37 通过;全量 typecheck / lint / test 绿(137 文件 / 1491 通过)。
2026-09-28 23:21:06 +08:00
Menghuan1918 0ac62b3a49 Merge origin/main (v0.22.1 与三个热修 PR) into feat/files-changes-uiux
冲突面 11 个文件,逐项裁决如下:

1. src/client/native/index.ts —— **取 main 版**。main 的 v0.22.1 在同一处做了更强的修复
   (清理循环同样跳过 FILES_KIND,另加 `disposeSafely` 与「注册失败必须回滚已占用 id /
   已建槽位」),是我们那行守卫的超集。
   ⚠️ 但 main 分支从来没有过我们 task-19 的 `records.attachStore(store)` 调用,整文件
   采用会**静默丢掉**它(records 拿不到 store → `toggleExpanded` 直接 return → 点目录
   树毫无反应),且 jsdom 单测看不见(它们自己绑 records)。已按原注释恢复该调用,并在
   注释里记下这次合并教训。真实宿主 lane 证明:恢复前 `zz-expand-refresh` 红(请求为
   空、`big` 不展开),恢复后 9/9 全绿。
2. package.json / dsh.plugin.json / src/client/service.ts —— 版本相关冲突取我们的
   0.24.1(支持线 ^0.2.0-rc.1 不变)。
3. CHANGELOG / README(中英各一)—— 双方版本节全部保留:我们的 v0.24.1 / v0.24.0 +
   **新增缺失的 v0.23.0 节**(开发线,内容随 v0.24.1 发布)+ main 的 v0.22.1。
   同时修正两处事实错误:① 「0.1.7 线请固定 v0.23.0」→ **v0.22.1**(0.23.0 从未发布);
   ② 安装对照表里 0.1.7 行的安装命令同改。README 并补上 v0.23.0 摘要(含 ⚠️ 删除工作区
   路径检测这一安全相关的行为变更)。
4. docs/external-plugin-guide.md —— 版本行取我们的(0.2.0 线)。

验证(合并后的树):pnpm typecheck / lint / test = **137 文件 / 1491 通过 / 9 跳过**
(含 main 新增的 native-registration.spec.ts);pnpm build ✓;
DSH_CMD='npx -y --package @deepseek-ai/dsh@0.2.0-rc.1 dsh' pnpm test:mount = **9/9**
(mount 5 + perf 2 + main 的 native-reload 1 + 我们的 zz-expand-refresh 1)。
2026-09-28 23:13:36 +08:00
Menghuan1918 98a446bbfc fix(sidebar): 点击展开时文件树整体重建(两处根因)+ v0.24.1
用户报告:「点击展开的时候,文件树会频繁整体刷新,看起来非常难受」。

根因 1(主):src/client/native/index.ts 的 sync() 把 files 接管项当成多余注册。
它按 KIND 记账、永远不在 wanted 里,于是每次 sync 都被 dispose + 重建;而
disposeSubscriptions 同时订阅了 service 与 store,**任何会话状态写入**(展开/收起、
切 tab、拖底部工作台、选中…)都会跑一遍 sync。替换 slot 注册 = 宿主换 slot entry →
插件 tab body 被 unmount/remount → 文件树丢失层缓存、滚动位置与目录 watcher,并重新
fs.trees([root, ...expanded]) 重列整棵可见树。机械证明(临时插桩,已回退):
  [probe-sync] enter live=[editor,git,subagent,sidechat,diff,files]
  [probe-registerSlots] slot inject ran for dsh-better-sidebar:files
  [probe-body] unmount tab3 kind=files
  [probe-body] mount tab3 kind=files
修法:wantsFiles 提前,删除循环里对 files 接管项 skip(禁用 editor 时仍照旧释放)。

根因 2(次):FileTree.tsx 的 retryDir 先把该层缓存删掉再请求,行被「Loading…」
占位替换后重建——目录有外部写入(构建 / 格式化 / 模型跑 bash)时整层闪空。
修法:复用既有 force 路径 loadLevels([dir], { force: true }),保留旧行直到新答案到达
(与 refreshTick 的强制刷新路径行为一致)。

判别性证据(回退任一修复即红)
- tests/native-surface.spec.ts:三次 store 写入不得产生任何注册/注销 → 回退后
  registered 6 → 12、disposed 全是 dsh-better-sidebar:files
- tests/file-tree-batch-load.spec.tsx:重列期间旧行仍在屏 → 回退后层被删空
- 新增真实宿主 lane tests/e2e/zz-expand-refresh.e2e.ts(quiescence 判据,无固定 sleep;
  zz- 前缀保证它最后跑,因为它会自建 workspace + session):A1 展开只请求被展开那一层、
  A2 tab body 存活(不重开 watch socket)、A3 屏上行数不归零;回退修复 1 后退出码 1
  (Error: expanding a folder must ask for that folder, not the whole visible set)

修复后实测(40 子项目录,同一探针/机器/工作区)
| 阶段 | fs.trees payload | 新开 ws | DOM +/- | 被删行 | body 替换 | 层内最小行数 |
| 展开 big | [big](原 [root, big]) | 0(原 1) | +41/-1 | 0(原 45) | 0(原是) | 40(原 40) |
| 外部写入 big | [big] | 0 | +1/-0(原 +41/-40) | 0 | 0 | 40(原 0) |
| 展开 bravo | [bravo] | 0 | +2/-1 | 0(原 45) | 0(原是) | 41 |

证伪记录:新建 fs.watch(dir,{persistent:false}) 在 macOS 上无改动时 0 事件(Node 微
探针两遍 + 8 轮真实时序 + 浏览器侧从未收到 {dir} 陈旧帧)→ src/fs-watch.ts 与
use-dir-watch.ts 一行未改。

验证:pnpm typecheck / lint / test(136 文件 1486 通过 9 跳过,基线 1484 + 新增 2)/ build
全绿;DSH_CMD='npx -y --package @deepseek-ai/dsh@0.2.0-rc.1 dsh' pnpm test:mount = 8/8。
版本 0.24.0 → 0.24.1(package.json / dsh.plugin.json / SIDEBAR_SERVICE_VERSION /
README×2 / CHANGELOG×2 同步)。
2026-09-28 22:33:30 +08:00
Menghuan1918 b7825e1bd0 docs(dsh): 记录 profile overrides 必须与宿主同批抬版本的坑(0.2.0 升级实测)
升级 3080 后出现「加载提供商目录失败: settings service is absent」,根因是 profile 的
pnpm-workspace.yaml 里上一轮留下的 overrides '@deepseek-ai/dsh-settings': 0.1.7-rc.2——
它让 profile 顶层留住 0.1.7-rc.2 的 dsh-settings,后者用精确版本拉来 dsh-config-editor
0.1.7-rc.2 并遮蔽 bundle 自带的 0.2.0-rc.1,于是 0.2.0 的启动预检禁用 config-editor 行,
settings 行永远 pending (waiting for service: configEditor)。

已修:override 抬到 0.2.0-rc.1(profile 顶层全部收敛到 0.2.0-rc.1,.pnpm 里 0.1.7 副本归零)。
文档:适配记录新增 §5.1(含原始日志证据),AGENTS §3.0 增加「用户 profile 自己的 pin 也要
同批抬」一条。
2026-09-28 21:38:58 +08:00
Menghuan1918 b91675ae61 feat(dsh): 适配 DSH 0.2.0-rc.1(单线支持)+ v0.24.0
支持线从 ^0.1.7-rc.1 整体前移到 ^0.2.0-rc.1;0.1.7 线(含 npm latest 的
0.1.7-rc.2)停留在 v0.23.0。适配前实测确认这是纯增量,故本版无运行时兼容分支。

必改项(否则装不上/不加载)
- 14 条 DSH peer → ^0.2.0-rc.1。实测 caret 跨 minor 不成立:`^0.1.7-rc.1`
  展开为 >=0.1.7-rc.1 <0.2.0-0,对 0.2.0-rc.1 判定 false(includePrerelease
  也救不了)。判别性验证:把 peer 回退成 ^0.1.7-rc.1 后,在 0.2.0-rc.1 宿主上
  `dsh plugin add` 直接拒绝并回滚包树——
  "installation rejected: Plugin dsh-better-sidebar@0.24.0 is incompatible with
   dsh 0.2.0-rc.1: peerDependencies {…^0.1.7-rc.1…}";恢复 ^0.2.0-rc.1 后安装通过
- 28 个 @deepseek-ai/* devDependencies 精确钉 0.2.0-rc.1(cordis 4.0.4 /
  cordis-plugin-group 1.0.4 / cordis-plugin-include 1.0.9 不变)
- 新增 @deepseek-ai/dsh-util-code-language@0.2.0-rc.1:0.2.0 的 ui-primitives
  产物裸 import 它(0.1.7 的产物同样 import,只是旧树里恰好被传递提供),
  不补则所有加载 ui-primitives 的 20 个 spec 在收集期失败

实测证据(写进 docs/plans/2026-09-28-dsh-0.2.0-rc.1-adaptation.md)
- 本插件消费的 19 个宿主包零值导出删除(对比 export {} / exports.x=)
- 类型面仅 3 处且全为增量:ui-primitives(DisclosureRow/TextShimmer/Tooltip
  新增可选 prop、overlay 顶部内距)、dsh-session(新增 ToolCallRecovery)、
  dsh-api-remotes(新增 product-analytics remote)
- 会话格式仍 v4、SUBAGENT_DESCRIPTOR_VERSION 仍 3、dsh/lib/bin.js 与
  dsh-client-modules 运行时逐字节相同、web profile 客户端 inject 列表相同、
  ui-primitives 裸 import 集合不变、agent-team 四包类型逐字相同
- 宿主 web profile:新增 desktop-only product-analytics/telemetry(web 上
  disabled);time-context/schedule/ui-schedule(本就 disabled)移入可选
  dsh-experimental-schedule-bundle;插件不依赖宿主 schedule

其余同步
- CI 与挂载 lane 钉 @deepseek-ai/dsh@0.2.0-rc.1(scripts/e2e-common.sh 的
  DSH_NPX_SPEC/DSH_EXPECT_VERSION、ci.yml),注释记下「0.2.0 首个候选版只挂
  next」与「caret 跨 minor 必失效」两条教训
- tests/market-manifest.spec.ts 的 peer 形状断言钉当前基线 tuple
- dsh.plugin.json engines.dsh → >=0.2.0-rc.1;SIDEBAR_SERVICE_VERSION → 0.24.0
- README/README_EN、CHANGELOG/CHANGELOG_EN、AGENTS.md(§2 钉版句 + §3 改为
  「DSH 版本适配要点」并新增 §3.0 当前基线,0.1.7 内容降为历史分节)、
  docs/external-plugin-guide.md 全部同步

验证:pnpm peers check 仅剩上游 better-locale 的 5 条 unmet(非本插件 peer);
typecheck / lint / test(136 文件 1484 通过 9 跳过)/ build 全绿;
DSH_CMD='npx -y --package @deepseek-ai/dsh@0.2.0-rc.1 dsh' pnpm test:mount = 7/7;
pnpm test:mount:aggregate 通过(聚合双挂载退让)
2026-09-28 21:21:45 +08:00
Menghuan1918 5c95002641 perf(sidebar): fs.tree 22.8ms→3.8ms + 删除工作区路径检测(放开权限)+ 树展开状态按会话
用户实测反馈:

1) `/sidebar/api/fs.tree` 性能极差 —— 先测后改(10k 条目目录、热缓存、中位数):
   - 冷调用 cap=1000:22.76ms → **3.77ms**;TTL 内重复:≈23ms → **0.000ms**
   - 改法:opendir for-await → readdir(withFileTypes) 一次取回;只为 cap 条建行
     (slice + 定长数组);路径用字符串拼接而非 path.join;排序弃 localeCompare
     (14.6ms/10k → 0.35ms)改小写比较 + 原名码点兜底;新增 1.5s 目录级缓存
     (键 绝对路径\0cap,上限 512),由 fs.write/rename/remove/mkdir/upload 与
     fs-watch 的变更通知显式失效
   - 契约逐字不变;新增 tests/fs-tree.spec.ts 6 例 + fs-watch 失效用例(判别性验证)

2) 删除工作区路径检测(默认不检测、放开权限):
   - path-security 变纯词法解析(realpath/包含性判定删除)、fs-operations 去 fence
     分支、所有 fs 路由不再读 fence、403 分支消失、config 删 workspaceFence 字段
     (schemastery 容忍未知键,旧 profile 不会加载失败)、settings 开关删除
   - ⚠️ 安全影响:插件 fs 路由(tree/read/write/rename/remove/mkdir/媒体/HTML/
     upload/archive)现在可读写宿主用户可访问的任意路径,只受 OS 权限约束;
     指南 §8.1 已加醒目声明
   - 死代码清理:FenceErrorNotice 组件 + EditorHost 分支 + 4 个词条(settingsFence*、
     fenceErrorReason、fenceDisableAction)+ isOutsideWorkspace* 助手 + TreePanel 的
     store prop + 相关 CSS 块

3) 批量列举路由 `fs.trees`(单层失败只在该层带 error)+ 客户端批量加载:
   挂载/刷新时的 N+1 请求变为 1 个(8 个展开目录:9 → 1,探针断言)
   refreshTick 不再先清缓存(旧行保留到新答案;失败保留旧行 + warn 提示)

4) 修复「关闭文件后返回文件树,展开状态被重置」:
   原生承载面的展开集合原来存在每个 tab 的记录里(drop 即丢),改为**每会话状态**
   的投影(ensure 从会话态读、toggleExpanded 写回会话态、registerNativeSurface 用
   attachStore 订阅);同一会话多 tab 共享、不同会话隔离;revealed 保持 per-tab

验证:typecheck / lint / test(136 文件 / 1484 通过 / 9 跳过)/ build 全绿;
DSH_CMD='npx -y --package @deepseek-ai/dsh@0.1.7-rc.1 dsh' pnpm test:mount 7/7 通过;
版本镜像同步(dsh.plugin.json + SIDEBAR_SERVICE_VERSION)
2026-09-28 20:37:56 +08:00
Menghuan1918 f29743f03f chore(release): v0.23.0 —— 文件页/文件变动页重构、菜单层级与性能、ZIP 进度、修复在侧边打开
本地安装需要与已发布的 0.22.0 区分(同一路径的 tarball 会被 pnpm 复用旧解析),
故把版本抬到 0.23.0;正式发版流程(tag → release.yml)不受影响。
2026-09-28 20:12:48 +08:00
Menghuan1918 ee1fe05067 feat(sidebar): 菜单层级/性能 + 选中条吸底 + 打包进度 + 修复「在侧边打开」
用户实测反馈 5 条:

1) 文件列表性能 / 右键菜单不再刷屏(先测量后改,探针 tests/file-tree-menu-perf.spec.tsx)
   - 宿主应用列表按路径缓存:N 次打开菜单只请求 1 次(原每次 1 次 + Loading 帧)
   - 行上的 git 数据改为原始值(tone/letter):共享 store 每次轮询重建对象不再触达行
     (探针:开窗 folderIcons 4 → 0;root 行也 memo 化)
   - 菜单开关不触发目录重列(fsTree=0);实测「菜单打开期间暂停轮询」会让变更行瞬时
     掉色并多两次重渲染,故按测量结果放弃该做法(数字与理由写进探针注释)

2) 「已选择 N 项」条移到底部:滚动容器最后一个内容子节点 + sticky bottom(不遮最后
   一行),窄栏 flex-wrap 换行不出横向滚动条

3) 菜单层级重构:一级只留默认动作(宿主默认应用 / 打开方式 ▸ / 在文件管理器中显示 /
   新 Tab / 在侧边打开 / 下载 / 压缩并下载 / 复制路径 / 重命名 / 删除;目录行另有
   新建文件夹、上传到此处),应用列表整体收进「打开方式」子菜单;宿主探测到本机关联
   应用时默认不显示插件自研 open-with 项目,新增设置开关 openWithPluginTargets
   (editor descriptor 的 pluginToggles)可强制并存;宿主不可用时插件项目照旧

4) 压缩并下载显示进度:宿主改为可观测任务(archive.build / archive.status /
   /sidebar/archive?id=,4 并发 + 5 分钟 TTL + sessionId 绑定,buildZip 逐条目
   onProgress),客户端轮询 250ms 显示「正在打包 done/total · N%」,ready 后 blob 下载,
   失败进 zipFailed

5) 修复「在侧边打开没有效果」:根因是它只写插件底部工作台(原生右侧栏的 tab 不在
   bottomSplits 里),现按承载面分流 —— 原生 tab 走 service.openTab(target:'side') →
   宿主 openResource(preferNewPane, revealIfOpened:false) 真正分栏;底部工作台行为不变
   (接入 API 变更已同步 docs/external-plugin-guide.md)

验证:typecheck / lint / test(135 文件 1461 通过)/ build 全绿;
DSH_CMD='npx -y --package @deepseek-ai/dsh@0.1.7-rc.1 dsh' pnpm test:mount 7/7 通过;
新增/更新测试:menu-perf(3)、archive(10)、open-in-app(18)、open-with(10)、multiselect(9)、
zip(37)、service(64)、editor-host(11)、builtins(23)、locales(20)
2026-09-28 20:11:46 +08:00
Menghuan1918 13d4bae321 fix(sidebar): 二轮独立验证的 9 项缺陷 + 目录级暂存
verifier 二轮报告(F1–F9)全部修复,每条都有「临时回退即变红」的判别性验证:

- F1【高】中文等非 latin1 下载名 → 真实宿主 500:content-disposition 改用
  RFC 5987(ASCII 回退 + filename*=UTF-8'');补真 node:http 用例与根因对照断言
- F2【中】多选同名文件归档重名(解压互相覆盖):冲突项逐级上溯父目录消歧
- F3【中低】maxBytes 在读完之后才判定;budget<=0 的 0 字节 FIFO 会永久阻塞:
  改为先 stat、读取前拒绝(FIFO 探针验证)
- F4【中低】SSH 模式 + 宿主不可用时 reveal 整条消失:保留 kind==='reveal' 目标
- F5【低】图钉嵌套交互语义非法且键盘不可达:改为诚实的鼠标热区,键盘入口归设置面板
- F6【低】变更树空闲 tick 全量重渲染:行 memo + 恒定 props + 内容键派生 +
  共享 store 的 sameStatus 保住快照身份
- F7【低】排序随运行时 locale 漂移:显式 'en' collation + 码点兜底
- F8【低】POSIX 文件名的反斜杠被当成层级:不再替换
- F9【低】打包中重复点击静默、无反馈:busy 行(role=status)+ in-flight 守卫
- 新增:目录行「暂存/取消暂存该目录」(git pathspec 语义,不触发折叠)

验证:typecheck / lint / test(134 文件 1441 通过)/ build 全绿;
DSH_CMD='npx -y --package @deepseek-ai/dsh@0.1.7-rc.1 dsh' pnpm test:mount 7/7 通过
2026-09-28 18:20:08 +08:00
Menghuan1918 b011be1e98 feat(sidebar): 打开方式双源并存 + 多选压缩下载 + 文件变动层级树
用户追加三条需求,全部落地:

1) 打开方式 = 宿主探测应用 + 插件自研 open-with(并存)
- 逐字恢复 src/client/open-with.ts / open-with-settings.tsx / plugin-settings.ts /
  src/open-external.ts / open.external 路由 / api.openExternal / editor descriptor
  的 settings.render,以及 20 个 openWith* 词条(19 份词典从 main 取回原文)
- 恢复 menu-flip.ts + layout.css 子菜单翻转规则(子菜单回来了)
- FileTree 菜单段(无标题行):宿主行 → 分隔线 → 插件 pinned + 「在应用中打开 >」
  子菜单(图钉 / SSH 后缀原样)→ 分隔线 → 宿主 reveal;宿主可用时过滤插件
  explorer 目标,宿主不可用时插件行照旧(SSH 远端场景保持可用)
- 死键清理:菜单去掉标题行后 openInApp 词条无引用,已从 21 份词典删除

2) 文件页多选右键「压缩并打包下载」
- 新增 src/zip.ts(自研 ZIP:方法 0/8 按收益二选一、UTF-8 bit 11、目录条目、
  自实现 CRC32、无第三方依赖)+ src/archive-route.ts(名净化 + 递归收集)+
  GET /sidebar/archive(同一道 workspace fence、目录递归跳过符号链接、
  10000 条目 / 256 MiB 上限)+ api.archiveUrl
- FileTree:多选 ≥2 项或单选目录时出现;fetch → blob → objectURL 下载,
  路由错误(超限 / fence / 非 GET)以 zipFailed 显示在错误条
- 修掉真实缺陷:central directory 只写 MS-DOS 位而 version-made-by 声称 Unix,
  Info-ZIP 会把每个文件解成 mode 000;改为 Unix 语义(0o100644 * 0x10000,
  << 16 会溢出 int32)。系统 unzip 复验:mode 644/755、unzip -t 无错

3) 文件变动页层级树 + 视觉打磨
- 新增 src/client/changes/change-tree.ts:单子目录链压缩成一行、目录先于文件、
  大小写不敏感排序、文件带 GitFileStatus、目录带下级变更数
- GitLens 两组各自渲染树:折叠状态按「组+路径」独立、默认展开;分组头吸顶 +
  计数胶囊;Stage all/Unstage all 改为带 aria-label 的 IconButton;选中 =
  interactive-bg-active + 2px 内嵌强调条;12px/级缩进 + l1 参考线;
  历史行 hash 徽标 / ref 胶囊 / 作者·时间右对齐

验证:typecheck / lint / test(134 文件 1422 通过)/ build 全绿;
DSH_CMD='npx -y --package @deepseek-ai/dsh@0.1.7-rc.1 dsh' pnpm test:mount 7/7 通过;
真实宿主截图确认三条需求(多选+双源菜单+zip 项、变动页树形层级)
2026-09-28 18:08:21 +08:00
gyixuan bc1c6be747 test(native): pin activate-focus and close-meta; document the native lifecycle
- five cases over the real createNativeSurface: activate rides
  ISidebarRight.focus for a known record (and stays a no-op for unknown
  ids), close hands the record meta back and rides the on-screen face
  for the mounted session (per-session face otherwise)
- one service-level case: closeTab hands the native close meta through
  to descriptor.onClose
- guide: activateTab's native path (focus via ISidebarRight.focus,
  dsh >= 0.1.5) and the close-meta carry, including the standing gap
  that a user-initiated x-close never reaches onClose
2026-09-28 14:38:12 +08:00
gyixuan 9489f41068 fix(native): focus through the controller on surface.activate; carry meta on close
surface.activate() only returned records.has(tabId) without focusing, so
external plugins with multi-instance native tabs (dsh-sidenote's side
chats) could never bring an existing tab to the front programmatically.
Focus via ISidebarRight.focus (dsh >= 0.1.5), which focuses the tab and
its pane.

surface.close() now also returns the record's meta so service.closeTab
can hand it to descriptor.onClose — native closes previously dropped it,
leaving meta-driven lifecycle consumers (e.g. recently-closed records)
starved.
2026-09-28 14:32:50 +08:00
Atlas Zeng 9b5834f74a Merge pull request #787 from omdsh-dev/chore/release-0.22.1
chore(release): v0.22.1——修复 files 接管 id 孤儿化与 macOS 拖拽失效
v0.22.1
2026-09-28 11:35:31 +08:00
Menghuan1918 a18e0f000d docs(release): 修正 v0.22.1 条目里的测试计数与「3/3」措辞(独立 review 发现)
- 单测计数:`122 files / 1292 passed / 9 skipped` → **1293**。1292 是 #785 当时的数字,
  本 commit 自己的 `make check` 两次都报 1293(`tests/` 与 main 逐字相同,122 个 spec +
  `it.each` 展开 = 1293)。涉及 CHANGELOG.md / CHANGELOG_EN.md / README.md / README_EN.md
  与事故文档。
- 「3/3 红 / 3/3 绿」措辞改为「连续 3 次运行全红 / 全绿」并注明该 lane 里只有 1 个用例、
  是重复跑三次——原措辞会被读成「3 个用例各红一次」。涉及上述四份发布文档 + 事故文档
  + AGENTS.md §2(同一句话在那边也有)。
- 其余 review 结论均已满足:版本三处锁步 + 两个守护用例绿、无遗留 0.22.0 引用、
  zh/en 段落一一对应、「最近更新」保持两条并把指针下移为 v0.21.1 → v0.12.3、
  release.yml 的 tag 校验与 `latest` dist-tag 都能过、lockfile 无需改动。
2026-09-28 11:30:29 +08:00
ymac 77887e2d93 test(e2e): pin the three painted-state losses a kept-alive body must prevent
The comparison with PR #712 left three of its cases uncovered here: #712
parked an unsaved editor draft, an unsaved commit message and the chosen
worktree in module-level memory and tested each by unmounting. This branch
claims the host's `keepMounted` makes that memory unnecessary, but the claim
was only ever exercised for tree expansion and scroll — the draft was
explicitly recorded as unverified, and it is the one loss a reader cannot
re-derive by looking again.

All three are now measured on a real host, in the retention lane's A -> B -> A
round trip:

- an unsaved EDIT typed into the file's editor must still be in the document;
- an unsaved COMMIT MESSAGE must still be in the changes tab's box;
- the CHOSEN WORKTREE must still be selected, rather than re-derived from the
  inventory.

The lane's workspace becomes a real git repo (idempotently: it persists across
local runs) with one staged change — that is what renders a usable commit box —
plus a linked checkout for the worktree choice. Two host details the lane has
to respect, both recorded in comments: the worktree selector only renders when
the inventory holds more than one entry, and paths are compared through
`realpathSync` because macOS /var is a symlink to /private/var while git
reports the resolved form.

Measured: 8/8 on 0.1.7-rc.1 + headless Chromium, and the full unit suite
(113 files / 1141 tests) stays green.
2026-09-28 11:27:50 +08:00
ymac c390bd6540 test(e2e): prove a kept-alive body does not re-read what it already holds
"State survived" is not the same claim as "nothing was silently reloaded":
the retention lane asserted the visible vector (expansion, scroll, chip) but
never looked at the network, so a body that remounted and refetched
everything would have passed it.

The lane now counts the plugin's own reads. These routes are POSTs, so the
path being listed or read travels in the BODY — the counter parses it, which
is what lets one level or file be told apart from a fresh read. It then opens
a real file in conversation A and requires, on return:

- the file is still open as a tab, and selecting it shows the editor without
  a second `fs.read` of its bytes;
- no `fs.read` of that file happened anywhere in the round trip.

Measured against the real host (0.1.7-rc.1, headless Chromium): zero plugin
reads on returning to A — the seat lands on its previous tab and shows the
content it already holds.

One ordering fact this lane had to be taught: opening a file in merged mode
swaps THAT tab's content to the editor, so the tree component unmounts and
its scroll starts over by design (attributed with a probe: hide/show keeps
320, opening a file drops it to 0). The lane therefore re-builds the scroll
offset after the file step before measuring the conversation round trip,
which is the claim the offset is actually evidence for.
2026-09-28 11:27:50 +08:00
ymac aec7101374 feat(native): keep visited tab bodies mounted, and pin state retention end to end
DSH 0.1.7 gives a tab TYPE the `keepMounted` switch: a marked body stays
mounted through hiding, tab selection and Session switches. That is exactly
what the plugin tried to fake with module-level memory, so declare it on
every plugin type (the descriptor types and the `files` takeover) and let
the host hold the component state — tree scroll, unsaved drafts, chip
renames — with no plugin-side memory at all.

With the bodies staying up, the per-session record registry from the
previous commit is what keeps co-resident sessions apart; both halves are
required, because a body may still be remounted by the host (type disposal,
session teardown) and the records must outlive that.

Verification on a real host (`scripts/e2e-mount.sh`: npm pack -> fresh
scratch profile -> real `dsh web` pinned to 0.1.7-rc.1 -> headless Chromium),
new lane `tests/e2e/tree-scroll.e2e.ts`: build state in conversation A,
switch to B, come back, and compare the whole observable vector (tree
expansion, scroll offset, chip title) — plus the negative half, that B does
not inherit A's state.

That lane also exposed a defect in the old one: it picked its "second
conversation" by row index, but the session tree's first row is a WORKSPACE
row and a seeded session with no messages takes no row at all, so the
"A -> B -> A" round trip was re-selecting the same session and every
assertion held vacuously. It now identifies sessions by
`data-row-key="session:<id>"` and creates a real second session through the
rail.

`tests/e2e/mount.e2e.ts` reaches the side-chat tab through its guide entry
now: with the record retained, the chip shows the thread's own title, so
the old `/Side Chat/` chip match no longer names it.

Docs: AGENTS.md records the two facts that must hold together, and
docs/plans/2026-09-25-native-tab-state-retention-keepmounted.md replaces the
park/archive design (PR #712) with this one.
2026-09-28 11:27:50 +08:00
ymac 7cf962652e fix(native): key a tab record by (session, tab id), not the bare id
Native tab ids restart in every session (`tab1`, `tab2`, …), and DSH 0.1.7
keeps a visited tab body mounted across hiding, tab selection and Session
switches, so several sessions' same-named tabs are alive at once. The
plugin's registry was a single-keyed map, which made the entering session's
body adopt the leaving one's record — and the leaving body's unmount cleanup
then delete it. The visible result was #636: after a conversation switch the
explorer stopped responding entirely (no request sent), in both directions.

Records are now filed under `sessionId::tabId`, and the seat session is
carried explicitly instead of inferred:

- `createNativeTabRecords` takes the seat session on `ensure`, and
  `get/has/update/drop/toggleExpanded/versionOf` all take it too;
  `retain(sessions)` reclaims the records of sessions that are gone;
- the title slot gets its own seat `sessionId` — the chip is drawn BEFORE
  the body, so it used to read whichever record the live slot happened to
  hold (another conversation's title on the switch frame);
- `SidebarSurface.update/has/activate` take an optional `sessionId`: with
  one, it names the session; without, the mounted seat answers, a unique
  match still resolves, and an id that names a tab in several sessions
  resolves to none rather than guessing (writing into another conversation
  is worse than refusing);
- `BetterSidebarService.updateTab` forwards it, and the six call sites that
  know their own scope (EditorHost, SideChatView, ChangesTab,
  tree-mutations) pass theirs.

Tests (native-surface.spec.ts, +8): per-seat-session identity (same-named
tabs stay apart, a patch/drop hits exactly one session, `retain` reclaims),
and surface resolution (explicit session wins, mounted seat is the
fallback, an ambiguous bare id is refused, close plus dead-session reclaim).
Each is red without this change.
2026-09-28 11:27:50 +08:00
ymac 673707cef7 fix(native): stop rebuilding the files takeover on every state pulse
`sync()`'s cleanup loop compared the live registrations against the
DESCRIPTOR list, which never contains the `files` takeover (its key is
`FILES_KIND`, not a descriptor id). Every store/service notification — a
Session switch is one — therefore disposed and immediately rebuilt it:

  [native] DISPOSE type dsh-better-sidebar:files
  [native] register type dsh-better-sidebar:files

Disposal unmounts that kind's body, so the explorer's own component state
(its scroll offset) was rebuilt on every pulse even when the plugin-side
record survived. Its lifetime really belongs to the editor type's switch,
which the loop below already handles; skip it in the cleanup pass.

Pinned by "keeps the files takeover registered across a Session switch
pulse": reverting the guard turns it red (`expected 2 to be 1` — 2 is the
rebuilt registration count).

Rebased onto #777 (`4099700`): the guard itself now lives on `main` — its
cleanup pass already skips `FILES_KIND` and releases through `disposeSafely`
— so what remains in this commit is the comment above that guard, recording
the second reason it is load-bearing (a re-registration on an already
inactive context orphaned the id), plus the regression spec below.
2026-09-28 11:27:50 +08:00
Menghuan1918 2e94b56c36 chore(release): v0.22.1——修复 files 接管 id 孤儿化与 macOS 拖拽失效
- package.json / dsh.plugin.json / SIDEBAR_SERVICE_VERSION → 0.22.1(三者锁步由
  tests/service.spec.ts 与 tests/manifest-consistency.spec.ts 断言)
- README / README_EN:新增 v0.22.1 条目、同步三处徽章与 latest/支持线表格、
  切回 npm 通道的示例版本号;「最近更新」保持两条(v0.22.1 + v0.22.0),
  更早版本指针区间随之下移为 v0.21.1 → v0.12.3
- docs/external-plugin-guide.md:当前版本行 → v0.22.1
- CHANGELOG / CHANGELOG_EN:补 v0.22.1 条目(两个缺陷的根因链、真机证据、
  修复要点与守卫清单)

支持线**不变**:仅 DSH 0.1.7-rc.1+(peer 下限 ^0.1.7-rc.1,CI 钉 0.1.7-rc.1);
0.21.1 / 0.22.0 用户直接升级;0.1.6-alpha.2 及更早仍固定 v0.19.1。

内容提要:① 修复客户端条目替换后 `dsh-better-sidebar:files` id 被孤儿化
(#777 + #785:清理循环跳过 FILES_KIND + 注册失败回滚已占用的 id 与槽位,
并新增部署级回归门 tests/e2e/native-reload.e2e.ts);② 修复 macOS 桌面版
窗口拖拽/双击缩放失效(#773 + #786:视口层用 initial !important 退出
app-region 计算,补齐放大视图,探针改用真实级联计算值)。

验证:make check 全绿(typecheck / lint / build / test 122 files 1293 passed
9 skipped / check:consumer-types);此外本地 pnpm test:mount 与
pnpm test:mount:aggregate 绿,npm 0.22.0 与修复版在 scratch profile 上的
红→绿对照见 PR #785 / #786。
2026-09-28 11:23:48 +08:00