Commit Graph
655 Commits
Author SHA1 Message Date
HuanLinOTO 84d89067d4 Merge PR #696 (ported): fix(editor): 打开文件先问原生 tab 注册表,被认领的类型不再被硬编码 editor 顶掉(移植到 sidebar-file.ts 新载体,Fixes #695 #643)
# Conflicts:
#	src/client/EditorHost.tsx
2026-10-01 17:22:00 +08:00
HuanLinOTO 4836e25aad fix(train): 合车适配——#730 图标改用改名后的 IconPanelLeftOutlineRegular;#736 测试适配 #776 按会话记账签名 2026-10-01 17:21:42 +08:00
HuanLinOTO 56567b3c4d fix(editor): 打开文件先问原生 tab 注册表,被认领的类型不再被硬编码 editor 顶掉(#696 移植到 sidebar-file.ts 新载体,Fixes #695 #643) 2026-10-01 17:21:10 +08:00
HuanLinOTO 37fb9204b0 fix(paths): ~ 是主目录路径而不是会话相对路径,展开后再解析(Fixes #713,随 Phase 2 路径簇顺带修) 2026-10-01 17:20:06 +08:00
HuanLinOTO 3345b72699 Merge PR #744 (extracted): fix(paths): 识别 remote-mirror 工作区命名空间投影(#788 #703;html-cwd 半边已由 d71261ac 覆盖) 2026-10-01 17:18:49 +08:00
HuanLinOTO 0f9c7578c0 Merge PR #677 (ported): fix(files): 目录级别加载失败不再被当成缓存命中,自动加载路径可重试(移植到 loadLevels 新形状) 2026-10-01 17:18:49 +08:00
HuanLinOTO d23bbde0f7 Merge PR #769: fix(open-external): support Termux (platform android) openers 2026-10-01 17:18:31 +08:00
HuanLinOTO 356c3b1dbc Merge PR #682: fix(trust-fence): 允许 bfcache 恢复的图片带过期 cross-site 标记(PNG 预览空白修复)
# Conflicts:
#	tests/trusted-hosts.spec.ts
2026-10-01 17:18:31 +08:00
HuanLinOTO a749b20b68 Merge PR #797: fix(ws): WebSocket 路由改用壳注入的 transport base + 接受桌面壳页面 origin(0.2.0-rc.1 / v0.24.1 基线) 2026-10-01 17:18:19 +08:00
HuanLinOTO e4cf2fd034 Merge PR #763: fix(state): 拖动窗格内最后一个 tab 到自身边缘不再直接丢失该 tab 2026-10-01 17:18:09 +08:00
HuanLinOTO a5c3befc57 Merge PR #664: fix(diff): 二进制/纯重命名/仅改模式的文件行补回路径,并关掉 git 路径 C 转义 2026-10-01 17:18:09 +08:00
HuanLinOTO 65eb0957fb Merge PR #665: fix(diff): 头部 +n/−m 改为 git 口径,一处改写不再两侧各计一次 2026-10-01 17:18:09 +08:00
HuanLinOTO b1c17af429 Merge PR #779: fix(markdown): render anchors without a stray close tag and keep <details> summaries as direct children 2026-10-01 17:18:09 +08:00
HuanLinOTO 8bf14268aa Merge PR #691: fix(sidechat): inherit the parent's CURRENT model selection, not its stale options snapshot
# Conflicts:
#	tests/sidechat-routes.spec.ts
2026-10-01 17:18:08 +08:00
HuanLinOTO 8c37a7e7df Merge PR #663: fix(sidechat): clear the child inbox after create — fork markers alone do not fence the runtime inbox
# Conflicts:
#	AGENTS.md
#	tests/sidechat-seed-validation.spec.ts
2026-10-01 17:17:57 +08:00
HuanLinOTO e10510f29a fix(files): 在途层渲染 loading 行,消除新展开文件夹的空目录闪烁(#789 移植到 loadLevels 新形状)
移植 PR #789 的语义到 v0.24.1(98a446b)重写后的加载形状,原 diff 基于
已不存在的 loadDir 形状,不再适用:

- 核心条件原样保留:renderLevel 对「未请求」(undefined)与「在途标记」
  (loadLevels 非强制路径写入的 {} —— 无 entries 无 error)都画 loading
  行。修复前标记落进 entries ?? [] 渲染零行:展开新目录闪「loading →
  看似又折叠了 → 条目」,且首挂载的根层也是空体。settled 层必带 entries
  (不可读层另带 error),条件不会误伤真实数据。
- 原 PR 改在 per-level loadDir 请求时代;现形状 loadLevels 非强制路径先
  storeLevel(path, {}) 再发批量 fs.trees,在途标记形状未变,故只需渲染
  侧一处扩展,加载逻辑零改动(force 路径保留旧行的语义不受影响)。
- 测试 tests/file-tree-loading.spec.tsx 随形状移植:原版 gate 住单层
  fsTree 路由,现 gate 住批量 fsTrees 的 { levels } envelope;并按真实
  用户流拆成两批——先挂载根层、落地后再展开子目录触发第二批(批量语义
  本身由 file-tree-batch-load.spec.tsx 单独守护)。三个用例语义不变:
  展开期间 loading 行不消失、真空目录渲染零行不卡 loading、整批失败出
  错误行。判别性验证:回退修复后前两用例红(错误路径用例两态都绿,它
  守护边界而非本次回归)。
- 原 PR 未新增词典 key(复用既有 t('loading')),本次同样零词典改动,
  无需触碰 19 份第三语言词典。
- 全套件对照:改动前后均 1485 通过 / 6 失败;6 个失败(locales ja 缺
  2 key、plugin-meta 打包、tasks-model ×4)在干净 origin/main @1499502
  上同样复现,属 main 既有问题,与本提交无关。
2026-10-01 17:15:49 +08:00
HuanLinOTO b0c07c78fb Merge PR #742: fix(security): stop git operands parsing as options, and harden the API dispatch 2026-10-01 17:15:48 +08:00
HuanLinOTO 5ce98edcd0 Merge PR #733: fix(editor): never save a truncated read over the full file (#732) 2026-10-01 17:15:48 +08:00
HuanLinOTO e85ec684ac Merge PR #764: fix(fs): fs.write 改用每请求唯一临时文件,避免并发保存互相损坏
# Conflicts:
#	tests/smoke.spec.ts
2026-10-01 17:15:47 +08:00
HuanLinOTO 24a670c9e8 Merge PR #741: fix(security): sandbox SVG served by the media route 2026-10-01 17:14:59 +08:00
HuanLinOTO 002046cc47 Merge PR #655: fix(server): resolve session-relative paths in fs.write and fs.read
# Conflicts:
#	src/path-security.ts
2026-10-01 17:14:58 +08:00
HuanLinOTO 188fea0328 Merge PR #754: fix(preview): resolve workspace-relative paths against session cwd for HTML and media routes 2026-10-01 17:13:47 +08:00
HuanLinOTO ea76981c0e Merge PR #697: fix(native): 跨会话打开改为排队到上屏重放(Fixes #694)
# Conflicts:
#	src/client/native/surface.ts
2026-10-01 17:13:47 +08:00
HuanLinOTO 5256eef3ab fix(files): 目录级别加载失败不再被当成缓存命中,自动加载路径可重试(#677 移植到 loadLevels 新形状)
PR #677 was written against the pre-0.24.1 loadDir shape (one fs.tree per
directory): its error branch stored { error } in the level cache and the
cache-hit guard `dataRef.current[dir] !== undefined` treated that failure as
"already loaded", so the automatic load path never re-requested a failed
level; only the force path (refresh tick / fence-notice retry) recovered.

FileTree.tsx has since been rewritten around batched loadLevels (one fs.trees
POST for the visible set, commit 98a446b), but the bug survived the rewrite in
a new spot: BOTH failure branches now store an error in the same cache —
(a) a per-level `error` riding an otherwise-successful batch, and
(b) `{ error }` written by the whole-request catch for levels with no listing
    — and the non-force `wanted` filter (`dataRef.current[path] === undefined`)
counted both as cache hits.

Port, in current idioms:

- The non-force filter now admits a cached entry only when it carries no
  `error`: `cached === undefined || cached.error !== undefined`. The host
  guarantees a failed level never carries entries (fs.trees returns
  `{ entries: [], error }` in place), so `error` alone identifies "nothing
  usable cached" for both failure branches.
- The empty `{}` placeholder of an in-flight load is still a hit, so a
  re-render while a batch is open does not duplicate the request.
- The retry rides the batch route (wanted subset only; levels that DID list
  stay cached) and reuses the existing non-force flow, which stores `{}`
  first — same behavior the original fix gave loadDir.
- loadLevels' doc comment gains the "only a LISTING settles a level" rule.

Not ported: the original diff's comment wording about "the fence notice's
retry button" — that notice (and isOutsideWorkspaceMessage usage in the tree)
no longer exists in the current shape; recovery paths today are the refresh
tick and watch-notice/mutation re-lists, and after this fix any automatic
re-load of the expanded set.

Tests: tests/file-tree-level-retry.spec.tsx adapts the PR's spec to the
batched shape (fsTrees mock, batch-load-spec harness): (1) a per-level error
is re-requested as a batch of 1 on the next automatic load (with an added
assertion that an in-flight batch is NOT duplicated), (2) levels stored by a
failed whole request are all retryable. Both go red on the unfixed filter
(verified: "expected to be called 2 times, but got 1"). All 9 file-tree
suites (47 tests) and tsc --noEmit stay green.
2026-10-01 17:13:10 +08:00
HuanLinOTO 86ec5ccc75 Merge PR #736: fix(native): focus through the controller on surface.activate; carry meta on close
# Conflicts:
#	docs/external-plugin-guide.md
#	src/client/native/surface.ts
#	src/client/service.ts
2026-10-01 17:12:53 +08:00
HuanLinOTO 92ab1f83b8 Merge PR #776: fix(native): 按会话记账 + 宿主 keepMounted,原生 tab 状态不再跨切换丢失(#636 #661)
# Conflicts:
#	src/client/native/index.ts
#	src/client/native/tab-adapter.tsx
2026-10-01 17:12:10 +08:00
HuanLinOTO 4e02951fb5 Merge PR #662: fix(native): 文件 tab 图标不再依赖插件侧记录(Fixes #660)
# Conflicts:
#	src/client/native/index.ts
2026-10-01 17:11:37 +08:00
HuanLinOTO 249968f48c fix(paths): 识别 remote-mirror 工作区命名空间投影(#744 摘取 remote-mirror 半边,#788 #703)
摘取 PR #744 中 remote-mirror 命名空间投影这一半:resolveSessionPath 在
win32 上识别 dsh-remote 镜像会话的 cwd(<home>\.dsh\remote-workspaces\
<host-key>\<workspace>),读取镜像根的 .dsh-remote-meta.json 拿到远端
POSIX 工作区路径(mtime 失效的同步缓存),把命名空间下的远端绝对路径
(/srv/app/src/a.ts)投影到本地镜像目录(mirrorRoot\src\a.ts)——否则
win32 把它盘符根化成 C:\srv\... 导致交付物 ENOENT(#788 / #703 的
Windows 远程会话症状)。只投影落在远端工作区内的路径;区外路径
(/etc/hosts)刻意不投影。无元数据/元数据损坏/非 POSIX remotePath 时
一律放行原路径,不破坏请求。

相对 PR 原版的基线适配:main 的 path-security 重写已删除工作区围栏
(resolve-only),因此「区外路径不投影」的后果从「403 containment 拒绝」
变为「保持斜杠根化 → resolve() 盘符根化 → stat 失败报缺失本地文件」,
文档与测试注释已按此改写;投影决策本身不变。

明确丢弃的另一半(html 路由 cwd hint + $c/$r marker + media 路由
resolveWorkspaceRelative + intercept.tsx 取 cwd):
- cwd hint 半边已被 main 的 d71261ac(PR #372)缓解——sessionCwdOf 现有
  header → clientCwd → persistence → process.cwd 回退链,覆盖 detach 场景;
- resolveWorkspaceRelative 与 main 的 resolveTarget 语义重复(后者已把
  会话相对目标 join 到 cwd);
- src/client/intercept.tsx 在 main 上已整体删除(turnTail 交还宿主);
- path-security 报错文案子改动随 5c95002 重写失去载体。
PR 中的 html-route / paths / sandbox-views / smoke 测试改动同属该半边,
一并不取。html 路由 clientCwd 入口仍缺(#819,另由 #754 客户端侧覆盖),
不在本提交范围。

测试:tests/session-path.spec.ts 移植 dsh-remote mirror describe 块
(10 例:区内/根/嵌套会话投影、区外与同名前缀不投影、dot 段归一、盘符
路径保留、无/坏元数据放行、非 win32 不重释),18/18 绿。
2026-10-01 17:10:47 +08:00
HuanLinOTO b47fb12457 Merge PR #652: fix(state): contain a throwing store listener instead of blanking the sidebar 2026-10-01 17:08:18 +08:00
ymac 4f57cf886e test(e2e): read the on-screen seat from the visible panel, not any seat
The lane's `onScreenSession` walked every `[data-sidebar-right-session]` element
and took the first without a `hidden` attribute. On 0.2.x the host marks BOTH
each RETAINED seat (one per Conversation stays in the DOM) AND each seat's panel
with that attribute, so the walk could name a background Conversation and the
A → B → A round trip failed on `selectConversation` (real mount lane: expected
`session-eeb1…`, read `session-b8e4…`, 60s timeout).

Read the panel that is actually laid out (`[data-sidebar-right-panel]:visible`) —
the same `:visible` convention the rest of this lane already uses — and keep a
visible-seat fallback. Mount lane: 10/10 (was 9/10).
2026-10-01 16:47:43 +08:00
ymac d1c8208d56 Merge origin/main (v0.24.1, DSH 0.2.0-rc.1) into fix/native-tab-state-retention
Two conflicts, both in the native tab adapter's per-session work — main's
`5c95002` moved the expansion set into the plugin store's session state while
this branch moved the RECORD identity to `sessionId::tabId`:

- `src/client/native/tab-adapter.tsx`: keep main's store-backed expansion as
  the authority (`attachStore` / `syncExpanded` / `getSessionStates().expanded`)
  and this branch's seat-scoped identity (`views` keyed `sessionId::tabId`,
  `get/has/update/drop/versionOf/retain` take the seat session). `toggleExpanded`
  keeps main's active-`reduce` / background-`reduceFor` split, but locates the
  record by its seat and writes the SCOPE session's set — the set every view of
  that session mirrors.
- `tests/native-surface.spec.ts`: main's five expansion cases adapted to the
  session-scoped API (seat session on `ensure`, two-arg `get`/`drop`, seat on
  `toggleExpanded`); the branch's cases now bind a store before toggling, since
  expansion no longer lives in the record itself.

The `files` takeover guard and its registration invariants come from
main; this merge drops the branch's duplicate.
2026-10-01 16:37:35 +08:00
HuanLinOTO 8c17648962 fix(tabbar): rightActions 按 review 修复 + 回归测试
逐条解决 Copilot review 的 6 条 findings:

1. 空结果不挂载 wrapper:TabBar 先解析 rightActions 节点,
   null/undefined/false 直接不渲染容器(空容器是 flex item,
   会改变所有既有 tab 栏的布局)。
2. resolver 传入 tab/paneId:签名扩为
   (ctx, scope, state, tab, paneId)——single:false 且有分栏时同一类型
   可同时开多个实例、每个 pane 各渲染自己的 tab 栏,工具栏操作必须
   能定位到正确实例;paneId 与 state.activePane 比较可知聚焦 pane。
   API 未发布(本 PR 新增),签名可直接演进。
3. CSS 不再等分:.tabBarRightActions 由 flex:1 改为 0 1 auto
   (内容定宽、可收缩裁切),.tabList 独占剩余空间——等分会让
   极小的工具栏砍掉 tab 滚动区一半宽度。
4. split 递归转发:NodeView 的递归调用补上 getTabRightActions
   (此前 bottomSplits 一旦是 split,所有子 pane 的 resolver
   全部丢失,工具栏静默不渲染)。
5. 指南 §7 canonical features 清单补 'rightActions'。
6. 新增 tests/tab-bar-right-actions.spec.tsx(5 用例):节点渲染
   位置与参数、跟随活跃 tab、null/无 resolver 不挂载、嵌套 split
   树逐 pane 转发(已做变异验证:删掉递归转发该用例即红)。
2026-10-01 16:03:14 +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
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
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
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
张虎 3bc8b4675a feat(sidebar): 文件树跟随会话实际所在的 git worktree(含跨仓库 linked worktree) 2026-09-29 14:40: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 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 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