Commit Graph
28 Commits
Author SHA1 Message Date
unsc9 e876aa9667 fix(tabs): 改名/删除的页签调解覆盖右侧栏原生页签,并让改名不再重载文档
文件树改名/删除后的页签调解只走 `state.bottomSplits`(插件自己的底部工作台),
而当前架构下文件默认开在 **DSH 原生右侧栏**:有原生承载面时 `service.openTab`
直接走 native,从不写 store。那些页签因此从不参与调解——

- 改名后:页签仍绑旧路径,`EditorHost` 的保存按旧名字写盘;旧名字已被改掉,
  `fs.write` 的 `mkdir -p` + 写入把旧文件(连同被一并删掉的父目录)重建出来,
  界面还报「已保存」。仓库里于是同时留下新旧两份,新名字那份是旧内容。
- 删除后:连「有未保存改动,确定关吗」都不弹(`closePathTabs` 同样只遍历底部
  工作台),Ctrl+S 直接复活刚删掉的文件。

改动:

- `NativeTabRecords.pathTabs()` 按路径枚举原生记录(带 seat session),
  `NativeSurface.fileTabs()` 把它交给调解;`installedNativeSurface()` 是插件自身
  读原生承载面的句柄(模块级,与 `editor-dirty.ts` 同款「每次激活一份」)。
- `tree-mutations.ts`:两个页签空间一起遍历;改名按**子树**匹配(与删除同口径,
  此前只有删除覆盖子树,目录改名时子树里的页签连底部工作台也不改道);原生页签
  的关闭带上自己的 seat session。
- 改名**不重载文档**:`path` 变化原本会让编辑器重载,而重载会换掉文档并丢掉只存在
  于编辑器实例里的草稿——可改名并没有改字节。现在 `retargetPathTabs` 用
  `markRetargetedPath` / `consumeRetargetedPath` 把这次移动交给编辑器认领:文档与
  草稿留着,下一次保存落到新名字;没有这个标记的 `path` 变化(真实切换文件)照旧
  加载。
- `tab-adapter.tsx` 的 `ensure()`:`path` 与 `meta` 一样,只被「尚未采纳的导航修订」
  覆盖。原生承载面每次渲染都重投同一次导航,无条件按地址改 `path` 会把插件侧的
  改址当渲染垃圾丢掉——调解刚改完,下一次渲染就改回旧名字。
- 设计文档补实施偏差:`docs/plans/2026-09-04-file-tree-rename-delete-design.md`。

用例:`tests/editor-unsaved-guard.spec.tsx` 新增 `tree rename/delete
reconciliation`(原生页签改名改址、目录改名两个空间都改道、改名不重读文件且草稿
仍在、删除时脏页签先问、目录删除连子树关);`tests/native-surface.spec.ts` 新增
`path enumeration and the navigation gate`(枚举只含带路径的记录、插件侧改址扛得住
同修订重投、新修订仍按地址改回)。

复查后收紧(三支独立评审小队 + 自查收敛到同一处):

- `retargetedPaths` 的键由「tab id」改成「编辑器看到的那一侧会话 + tab id」
  (`pathTabKey`,写方与读方共用同一处定义):原生 tab id 每会话各自计数(`tab1`
  每个会话都有),只按 id 记键时两个会话的编辑器共用一个槽——其中一个(哪怕它自己
  的路径没动)在清理时会抹掉另一个尚未认领的移动,被抹掉的那个照旧重载、照旧丢草稿。
  同一键仍允许一个移动被认领多次(两个席位显示同一会话的文件时)。
- 生命周期补齐:`clear` 现在按细键生效,编辑器卸载时回收,删除关闭页签时也回收
  (原先只增不减:每次「改名没被已挂载编辑器认领」都会留一条)。
- `View` 记下 seat session:`pathTabs()` 不必再从视图键里拆 session,`retain()` 也
  不再重复同一份拆分(键只是内部编码,不该被别处解析)。
- 子树尾段改用 `paths.ts` 的 `relativeTo`(分隔符与大小写口径与全仓其它相对路径
  统一;原先手写的 slice 在旧路径带尾分隔符或大小写不同拼写时会算错);顺手删掉
  一条与既有用例重复的回归用例(`native-surface.spec.ts` 既有的「同记录二次
  ensure 且无 revision 时 path 跟着走」已经钉住同一事实)。
- **两种路径拼写**:聊天文件链接打开的页签,`path` 来自地址,而 `fileAddressFor`
  在工作区内一律写相对拼写(`src/a.ts`);文件树改名给的却是绝对路径。最初按原样
  比较,这类页签(正是默认打开方式)会整条判成「无关」,仍绑在刚被改名掉的旧名字
  上。现在比较统一在「按会话 cwd 解析后的绝对拼写」上进行,写回记录时用调用方给的
  新名;`movedPath` 的相等判断改用 `relativeTo` 的 `.`(字符串相等在 `E:/a` 与
  `E:\a` 混拼时会把 `新名/.` 写进记录)。
2026-10-10 22:19:07 +08:00
ymac 415d517fb0 fix(editor): make a file reference land on its line (#826 second half)
`fileParamsOf` already split the `path:line` spec off the address (#828)
but kept only `spec.path` — so both spellings opened the file and left the
reader on line 1: `path:131` dropped the parsed line, and the host's own
`#L131` fragment was already delivered as `navigation.params.line` and
dropped just the same.

Carry the line the rest of the way: address → `SidebarTab.line` →
`FileViewerProps.line` → one reveal in the text editor. Both spellings
land on the same row.

Three decisions:

- `line` is transient: `sanitizePersistedTab` copies a whitelist and this
  field is deliberately left out of it, so a reload does not yank the
  reader back to a line a link named days ago. Same treatment as
  `revealed`.
- markdown/html flip out of preview when a line is present: preview has no
  source lines to put a cursor on, and its own mount-time scroll restore
  would fight the jump (both write the same `scrollTop`). The reference
  asked for source, so the flip does not record the key and the re-run
  after the mode change does the jump — which also dissolves the conflict
  instead of arbitrating it.
- A range keeps only its first line and the column is dropped: the editor
  has exactly one cursor.

The record must also be able to DROP the line, not only set it — an
in-place switch from `a.ts:131` to a bare `a.ts` would otherwise leave 131
behind and the editor would bounce the reader back on every notification.
Comparing against the current value instead of "was one passed" also keeps
the synthetic record's identity when neither side has one, which matters
because the host keeps visited bodies mounted.
2026-10-05 22:17:44 +08:00
Menghuan1918 acea3c9a65 fix(sidechat): bind the native side chat tab to its thread across re-navigation
The native right sidebar keeps at most ONE page tab per kind, so a side chat
tab is never a copy: every open re-delivers the same tab with fresh navigation
params and an incremented `navigation.revision` (verified in the pinned host's
client bundle: `TabDomain.navigate` replaces the whole target and bumps the
revision, and `openContent` settles an already-held page tab through it). Two
opposite mistakes followed from that: `records.ensure` only read the seed
`meta` when it MINTED a record (so the header thread menu closed and nothing
changed — #762), while adopting it on every pass would clobber the thread id
the view writes back through `updateTab` (the orphan `Side: New thread` half of
#684).

Adopt a navigation's `params.meta` exactly once per revision, and reattach an
unbound auto-creating tab to the thread its session was last in instead of
minting another empty one.

Rewritten against the current dev tree rather than merged from the PR:

- #776 (7cf9626) made a record key `(seat session, native tab id)`; the
  revision ledger is keyed the same way and is dropped together with the
  record — in `drop` AND in `retain(sessions)`, which also forgets records.
- dev's existing branch never wrote `meta` and folds a url seed into
  `nextPath`, so the PR's url/meta merge has no counterpart here and is
  deliberately not ported: "revision unchanged" simply leaves `meta` alone,
  which is what keeps #684's other half fixed.
- `updateTab` takes the seat session as its third argument (same commit), so
  the reattach names it like the rest of the view does.
- The "newest real thread, placeholders last" heuristic already exists on dev
  (477f627, the archive fallback); it is extracted into `newestThreadId` and
  reused instead of being copied a second time.
- The remembered thread uses the client store's key space
  (`dsh-sidebar:v1:sidechat-thread`), not the PR's `dsh-better-sidebar:*`.
- `openNewThread` starts the thread first and parks it for `createTab`, and an
  auto-creating tab no longer offers a manual create button while it binds.

Tests (the PR reported none): the revision gate, its no-revision guard (both
fail on the unported adapter), the call-site wiring through `NativeTabBody`,
plus the two dev-side records cases around them.

Refs #839
2026-10-05 02:19:58 +08:00
Menghuan1918 582f814d5e merge #828 into dev(fileParamsOf 剥掉 path:line 行号后缀,解上下文冲突)
贡献者 PR #828(fix/826-file-link-line-suffix,2c5b762)修 issue #826:
宿主 markdown 语法只认 `#L131`,`path:131` 会被 parseFileLink 整串当文件名,
editor tab 于是去读一个叫 `CMakeLists.txt:131` 的文件并报「文件不存在」。
改法是在插件唯一把文件地址转成合成记录的那一步(native/index.ts 的
fileParamsOf)切掉尾部行号规格,tab 标题同源修正;新增纯函数
src/client/path-line.ts 与 tests/path-line.spec.ts。

解冲突:只有 tests/native-surface.spec.ts 的第 9 行 import 块冲突。
dev 侧多了 `import { createNativeSurface } from '../src/client/native/surface.ts'`
(PR #696 移植),PR 侧把同一行改成 `import { fileParamsOf, registerNativeSurface }`。
两边都要,合为两行;docs/external-plugin-guide.md 由 git 三方合并自动解掉
(PR 新增的「地址里的行号(#826)」行与 dev 新增的「文件打开的认领判定」行并存)。
未改贡献者任何实现意图,未 rebase / squash 其提交。

Refs #828
2026-10-05 01:30:34 +08:00
ymac 2c5b7621dd fix(editor): 正文里 [path](path:131) 的链接去掉行号后缀再打开 (#826)
DSH 的 markdown 链接语法只认 GitHub 的 `#L131` 片段:目的地没有 `#` 时
`parseFileLink` 把整串当文件名返回。于是模型按编译器诊断的通用写法输出的
`[a/b.c](a/b.c:131)` 变成一次对 `b.c:131` 的文件打开,编辑器读不到、右侧栏
红字报「文件不存在」。

宿主源码不可改,纠正放在插件唯一把文件地址变成合成记录的那一步
(native/index.ts 的 fileParamsOf):尾部行号规格(`:行` / `:起-止` /
`:行:列`)在这里切掉,tab 标题按切完的文件名给(宿主用同一个字符串推导标题,
否则芯片上会写 `b.c:131`)。切完之后读、写、"打开方式"、去重、viewer 匹配
拿到的都是真实路径,所以没有需要重试或记住的状态。

切分规则与宿主的 `#L` 语法对齐:1 起、无前导零、锚在串尾(`data:2024.csv`
和盘符 `C:` 因此原样通过),并拒绝空前缀、只剩一个字符的前缀(`C:131`)和
倒序区间(`a.c:20-12`)。

取舍:从聊天链接打开一个真名以 `:数字` 结尾的文件会丢掉后缀。文件树 / 搜索 /
插件自有流程的路径不经过这一步(只有 `openResource` 的地址会),而 `:` 在
Windows 上本就不是合法文件名字符。

测试:新增 tests/path-line.spec.ts(9 例,含全部「必须原样通过」的反例);
tests/native-surface.spec.ts 补 fileParamsOf 四例 + editor 类型对带行号地址的
标题。typecheck / lint 全绿;全量 1503 passed,tests/locales.spec.ts 的 ja
词典缺 key 在干净 origin/main 上同样失败(既有问题,不在本 PR 范围)。
2026-10-01 22:05:56 +08:00
HuanLinOTO 4836e25aad fix(train): 合车适配——#730 图标改用改名后的 IconPanelLeftOutlineRegular;#736 测试适配 #776 按会话记账签名 2026-10-01 17:21:42 +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
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
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 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
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
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 1d01ad942c fix(editor): reclaim the nine formats DSH has no preview for
The alpha.1 handover refused 27 extensions so DSH's own document preview
could own them, but nine of those have NO host renderer at all: `avif` and
`ods` sit in `document/unviewable.ts`'s "known binary, no renderer" list
and get the unsupported empty state directly, while `xlsb` / `xlt` /
`xltx` / `xltm` / `ots` / `dot` / `dotx` fall through to the plain-text
body, fail the binary check and land on the same dead end.

Before that handover these files reached the plugin's `code` catch-all and
rendered the binary-download pane, so refusing them was a user-visible
regression we introduced ourselves — and rc.1 did not restore it. They are
claimed again (`fods` stays handed over: the host shows that flat XML as
plain text, which beats a download pane).

`canOpen` had zero test coverage, which is exactly why the regression went
unnoticed, so `tests/native-surface.spec.ts` now pins both directions:
every format the host renders must be refused, every format it cannot
render must be claimed. Reverting to the old list makes it fail with
`macro.xlsb: expected false to be true`.
2026-09-23 22:25:19 +08:00
Menghuan1918 5912274e41 feat: yield the terminal and browser to DSH 0.1.6's own sidebar types
DSH 0.1.6-alpha.2 ships a right-Sidebar terminal and a right-Sidebar browser
of its own. Both were things this plugin had built from scratch, so keeping
them meant two implementations of one surface plus a plugin that shadows a
host type the product is actively developing.

Terminal: the plugin's whole PTY stack goes — the UI-tab manager, the
agent-owned registry, the lazy node-pty loader, the eight model-facing
terminal_* tools, the xterm view and its font/link/scrollback helpers, and
the cross-session 'pinned terminal' rail that existed only to keep a terminal
alive across a session switch. The host's terminal kind becomes the only
provider, which also retires the node-pty dependency, its pnpm allowBuilds
entry, and the installer's -Repair mode (issue #140's whole class of
'node-pty failed to load' support).

Model-facing capability note: the plugin used to inject terminal_* tools
(off by default). Those are the model's only cross-call persistent terminal,
and DSH's own equivalent (@deepseek-ai/dsh-tool-terminal) is not mounted by
any shipped bundle, so removing them leaves the model with the one-shot
bash/pwsh tools only. That is the accepted cost of not maintaining a second
PTY surface; the README documents how to enable the upstream toolset.

Browser: the plugin's browser tab type is dropped, so the host's own browser
kind owns embedded pages. The DOM-level link takeover STAYS (it is the only
thing that can route an https link to the system browser by protocol, which
the host does not do) but now delegates to the host's browser tab via
ctx.sidebarRight.openTab('browser', …) with a window.open fallback, and the
two settings that only ever configured the plugin's own iframe (sandbox
escape hatch, loopback allowlist) go with it — along with the host-side
browser.probe route they fed.

Cards: the empty-pane welcome cards adopt the host's guide-capsule recipe
(0.5px l4 hairline, 24px radius, layer-1 fill, 56px floor, 14px/20px padding)
so the plugin's 'pick what opens here' surface reads as the same design as
DSH's own. A theme.spec guard pins the geometry and the token-only paint —
including that the upstream-only --dsw-alias-bg-l1/-l2 spellings (defined
nowhere, so their declarations are silently dropped upstream) never appear
here.

Also drops the dead state the removed features left behind (SidebarTab.pin,
nextTerminal, agentWaits, bottomOpenedOnce, the agent-tab helpers, the
pinned-tab memo key), re-points every test fixture that used them at
surviving equivalents, and prunes the specs of the deleted features.
2026-09-21 20:35:11 +08:00
Menghuan1918 58ba17d462 fix(native): meet DSH 0.1.6-alpha.2 guide-id and turn-tail contracts
DSH 0.1.6-alpha.2 made two plugin-facing contracts stricter, and both broke
this plugin silently:

- `SidebarRightGuideEntry.id` is now required and unique per provider. The
  native tab registrations sent guide entries without one, so the second kind
  collided on `undefined` and `SidebarRightTabRegistry.register` threw
  'duplicate guide entry id'. The throw happens inside `ctx.inject`'s callback
  body, which cordis swallows, so the whole native surface stayed empty with no
  symptom beyond a missing guide row.
- `conversation.chat.turnTail` changed from a `chain` to an additive `list`.
  The chain's `select` made one entry render and let this plugin REPLACE the
  host's produced-files row; a list cannot express that, and the registration
  now throws 'list slot ... requires options.id'. Upstream chose the list
  deliberately ('An additive list lets both plugins contribute without either
  knowing the other's data or rendering'), so the plugin's row can only ever
  duplicate the host's deliverables row -- which itself opens files through the
  host's openFile, i.e. into this plugin's editor. The contribution is removed
  and the row is the host's alone.

The file-opening half survives as `sidebar-file.ts` (the changes tab and the
editor host still use it), and `resolveSidebarPath` moves to the `paths.ts`
path-helper module beside its siblings. `registerNativeSurface` grows an
optional `reportFailure` so a future contract break reaches the visible
diagnostic strip instead of a silently empty guide, and one bad descriptor can
no longer take the remaining registrations down with it.
2026-09-21 20:18:16 +08:00
HuanLinOTO d6a816a374 fix(native): keep component tabs' path seeds on the page open (#632)
The native openTab branch rerouted EVERY path seed into openResource (a
dsh-resource://file/... open) without looking at seed.type, so any
component tab opened with a path landed in the editor (the only
dsh-resource://file/** claimant) and its registered component never
mounted. This also contradicted the guide, whose TabDescriptor/openTab
contract and WebDocsView example document path-seed component tabs.

Route by type instead: only the editor kind (the only registration with
dsh-resource://file/** patterns) turns its path seeds into resource
opens; every other kind keeps the page open and carries the path in the
navigation params, which NativeTabRecords.ensure already merges back
onto the synthetic record's tab.path for the component. The bottom
workbench path is untouched, editor opens behave exactly as before, and
onOpen still receives the synthetic tab with the path seed.
2026-09-11 21:12:15 +08:00
Menghuan1918 22e772ce45 feat(icons): file icons and tab glyphs in color, from the host's own artwork
Issue #611 asked for file-type icons like the official explorer's, and #429
built a colored theme for them. DSH 0.1.5-rc.2 makes most of that work
unnecessary: `@deepseek-ai/dsh-client-ui-primitives` now exports
`FileTypeIcon` / `CodeFileIcon` with the host's own 48-type full-color code
artwork plus category-colored sheet glyphs (and its classifier behind them).
So the plugin renders the host's icons instead of shipping a color table, and
color becomes the only behaviour rather than an opt-in theme.

File icons (src/client/file-icons.tsx)
- `builtinFileIcon(path, size)` → `<FileTypeIcon path size />`; folders use the
  host's folder category. The plugin's own per-extension VSCodicon map is gone.
- The public `registerFileIcon` API from #531 is unchanged and still outranks
  the built-ins, so an external plugin can take over any row. One semantic
  consequence, now documented and tested: because the host classifier covers
  every path, a registered catch-all (`exts: []`) claims rows it used to lose
  to the built-in map. An unregistered catch-all (the old icon theme's shape)
  is unaffected.
- Nothing is lazy any more: the artwork lives in a platform module the client
  already holds, so `lib/client-file-icons.js` and its 563-entry dataset (255
  kB) are deleted outright — the core bundle grew by 10 kB (0.85 → 0.86 MB).
- `src/client/file-icon-theme.ts`, the `fileIconTheme` pref (prefs-shared /
  config / client prefs), the settings-page select row and the six
  `settingsFileIconTheme*` keys in all 20 dictionaries are removed with it.

Tab glyphs (src/client/builtins/tab-icons.tsx)
- Every built-in tab type now declares a colored glyph: files (the host's
  folder artwork), changes/diff (commit), tasks (checklist), side chat
  (discussion), terminal (shell), browser (globe).
- The color comes from a `--dsw-alias-*` token through a wrapper class, never
  from a literal — the skin contract (§12) holds and `tests/theme.spec.ts`
  enforces both halves (no literals in the module, every color declaration in
  the stylesheet resolves to a token).

Native right Sidebar chips (src/client/native/tab-adapter.tsx)
- The host's tab definition has no icon field, but the
  `sidebar.right.pane.tab.title` slot IS the chip's content, so the plugin
  draws the glyph itself: an editor tab with a path shows that file's icon,
  every other tab shows its descriptor's icon — the same `descriptor.icon` the
  workbench strip and the guide capsules already render, so the three cannot
  drift. The glyph is `aria-hidden`, which keeps the chip's accessible name
  exactly the title the mount lane matches on.

Gates: typecheck / lint / check:consumer-types green; pnpm test 127 files /
1342 passed / 9 skipped (3 new chip cases, 1 rewritten built-in case).
2026-09-11 15:28:49 +08:00
Menghuan1918 e567bf6924 docs: record the rc.2 baseline (README badges, guide, AGENTS, plan)
- docs/plans/2026-09-10-dsh-0.1.5-rc.2-adaptation.md: the adaptation plan —
  the upstream rc.1 -> rc.2 delta per affected area, why there is no
  plugin-side code change, and the CI failure taxonomy (A real Windows
  timeouts, B the two silent worker deaths, C the mount lane's npm
  ETARGET/OOM) with the evidence and the fix for each.
- AGENTS.md §2/§3: CI pins rc.2, the mount lane's npm flags and their reason
  (floating transitives + staged prerelease publishing), the Windows lane's
  bounded pool and why, and the primitives-dependencies note extended to rc.2.
- README.md / README_EN.md: support badge (v0.19.1, verified on rc.2), the
  install section's stable-release note (rc.1 hosts need no upgrade — the peer
  floor is unchanged) and a v0.19.1 changelog entry covering the two CI fixes.
- docs/external-plugin-guide.md: baseline line -> v0.19.1 / DSH 0.1.5-rc.1+,
  verified on rc.2.
- Comment-only: `DSH 0.1.5-rc.1` -> `0.1.5-rc.1+` where the note describes a
  behaviour that arrived in rc.1 and is unchanged in rc.2 (native guide
  description rendering, in src/client/native/index.ts, src/client/service.ts
  and the three specs that assert it).
2026-09-11 12:02:44 +08:00
Menghuan1918 725b2f7cec feat(dsh): adapt to DSH 0.1.5-rc.1 and restore the guide description
Baseline moves to DSH 0.1.5-rc.1 — the 0.1.5 line's first release
candidate, and the npm `latest` dist-tag now: peer floor ^0.1.5-rc.1,
devDependency pins, the CI mount-lane pin and dsh.plugin.json engines
all follow. 0.1.5-alpha.2 users stay on v0.19.0-alpha.1.

The upstream delta from alpha.2 is small: 373 changed files, mostly
version bumps, sidebar preview polish and test snapshots. Exactly two
changes touch this plugin, and only one needs work:

- `SidebarRightGuideEntry.description` is back (optional). The native
  guide renders it only while it lists at most 4 entries; a longer list
  drops every description. The plugin restores `TabDescriptor.description`
  and the six built-in `guideDesc*` lines (20 dictionaries) verbatim from
  0b6ac5d^, but deliberately does NOT restore the old generic
  `nativeGuideDesc` fallback: the host has no fallback of its own, so a
  descriptor that declares none now ships no `description` field at all
  and renders as a clean title-only capsule.

  Consequence worth knowing: the plugin contributes six guide entries, so
  the default composition is over the 4-entry limit and shows titles only.
  The mount lane proves the restored field end to end by shrinking the
  enabled set to three types through the plugin's own settings route
  (scratch profile only) and requiring the Files capsule to grow its line.

- The built-in `files` type declares a guide description again and uses a
  coloured folder glyph; the plugin owns that kind, so nothing to do.

Verified unchanged from alpha.2 (so nobody re-checks them): the global
main-panel model, the file address grammar (util/workspace-path changed
only its package.json), the native tab-body host contract (.paneBody is
still a block scroller with a definite height), the core/agent/session/
subagent host APIs and the ui-primitives export surface.

Restore caveat fixed in the lane: the settings route merges patches
key-wise, so undoing a temporary `tabsEnabled` change by posting the
original (empty) map leaves the disabled keys behind — the e2e restores
every key it touched explicitly.
2026-09-10 14:41:16 +08:00
Menghuan1918 0b6ac5d267 feat(dsh): adapt to DSH 0.1.5-alpha.2
Baseline moves to DSH 0.1.5-alpha.2 only (peer floor ^0.1.5-alpha.2,
CI pin, manifest engines); alpha.1 users stay on v0.19.0-alpha.0.

Host-contract changes handled:
- the native guide entry lost its `description` field (entries are
  icon+title capsules now): `TabDescriptor.description` and the six
  `guideDesc*` keys plus the `nativeGuideDesc` fallback are removed.
- the file address grammar changed: `fileAddressFor` always returns a
  session-scoped address (absolute paths keep their leading `/`),
  `parseFileAddress` is prefix-based and strips `?`/`#`. The plugin's
  purity-gated mirror follows.
- global main panels replaced the `conversation` root slot with the
  keyed `main` slot (`main.conversation`): the bottom workbench's
  center-column locator now accepts both keys and skips
  `display: contents` slot hosts.

Fixes a pre-existing fill bug the alpha.2 probe made obvious: the native
tab body host is a block scroller with a definite height, so tab roots
that only declared `flex: 1` collapsed to content height and the side
chat composer drifted off the pane bottom. The native adapter now wraps
every tab body in a `height: 100%` column flex host.

Also promotes the dependencies `dsh-client-ui-primitives@0.1.5-alpha.2`
dropped from its manifest (anser / shiki / mdast-util-* / micromark-* /
katex / @shikijs/langs) and the newly unmet `dsh-session-persistence`
peer into devDependencies.
2026-09-09 23:09:48 +08:00
Menghuan1918 d4765819c0 feat(guide): let a tab type declare its own line in the new-tab list
The native new-tab list rendered one generic line ("opens in the DSH
sidebar") under every plugin entry, so six plugin rows read identically.
`TabDescriptor.description` now carries the real purpose (string or
locale-following thunk; absent falls back to the generic line), and the
six visible builtins declare theirs across all 20 dictionaries.

- service.ts: `TabDescriptor.description` + docs (guide §4.1, §0 row).
- native/: the guide entry's description follows the descriptor; the
  `files` takeover reuses the editor's line.
- builtins: files / changes / tasks / side chat / terminal / browser.
- tests: builtins assert every visible type declares a distinct line;
  the lifecycle test asserts descriptor lines (and the takeover reuse).
2026-09-09 22:25:59 +08:00
Menghuan1918 91de0e2932 fix(native): give the "Files" guide row its glyph
The guide renders `entry.icon`, and the `files` kind takeover registered
without one — so after the editor type stopped contributing its own
duplicate row (b56ceec), the single "Files" row was the only entry in the
new-tab list with a blank icon slot. The takeover now carries the editor
descriptor's icon (the takeover IS that descriptor's page).

Extracted `guideIconOf` so both registration sites build the icon field
the same way; the lifecycle test asserts the takeover's guide entry has
an icon.
2026-09-09 15:18:04 +08:00
Menghuan1918 b56ceec41d fix(native): offer one "Files" row in the new-tab list
The editor type's page identity IS the `files` kind takeover (same
explorer, same title), so the guide/new-tab list showed two identical
"Files" entries — observed on a real profile after the takeover landed.
The editor type now contributes no guide entry of its own; it stays
registered as the file RESOURCE viewer. Covered by the registration
lifecycle test (editor: no guide, files takeover: guide).
2026-09-09 15:06:31 +08:00
Menghuan1918 4da2b43610 fix(native): title a file tab by its own name, not the descriptor's
The editor type serves both the files PAGE and every file RESOURCE; its
native `title` callback ignored the address, so every opened file showed
up in the strip as "Files" — indistinguishable tabs. Verified on a real
profile: after opening `AGENTS.md` from the tree and a chat file link,
the strip read ["文件", "文件", "文件"].

`title(address)` now returns the file name for a file address and keeps
the descriptor title for a page address (`sidebar://editor`). Covered by
the registration-lifecycle test in tests/native-surface.spec.ts.
2026-09-09 14:34:08 +08:00
Menghuan1918 aa1b9945d9 fix(native): register the plugin's tab types when the registry service arrives
The native seat declares `sidebar.right.pane.tab` BEFORE it provides
`sidebarRightTabs`, so driving the registration off the slot declaration
read the service as missing and registered nothing — permanently, since a
declaration never collapses. Observed on a real DSH profile (0.1.5-alpha.1,
`dsh web` on the web profile): the plugin host and its other slot
registrations mounted, the native guide page stayed empty, and a probe
printed `sidebarRightTabs= undefined` at declaration time with the registry
present three seconds later. The scratch mount lane never saw it because
there the plugin activates after the native package finished providing.

`registerNativeSurface` now waits on the SERVICE (`ctx.inject`), which
re-runs whenever the registry appears/reappears, and keeps the per-body
slot registrations on `slots.inject` (they only need the declaration).

Regression test: `tests/native-surface.spec.ts` models the real order
(slot callback fires first, registry arrives later) and fails on the old
implementation. Verified on the real web profile: all guide entries
(files / editor / git / subagent / sidechat / terminal / browser) appear
and the terminal tab renders.
2026-09-09 13:07:53 +08:00
Menghuan1918 d7e3e2b986 fix(test): give the native-surface terminal descriptor a component
TabDescriptor requires `component`; the fixture omitted it, so CI's
typecheck step failed on the phase-2 branch (vitest never compiled the
file's props strictly, so the local run stayed green).
2026-09-09 12:33:49 +08:00
Menghuan1918 51546f7433 feat(native): render the plugin's tabs in DSH's native right Sidebar
Phase 2 of the 0.1.5 adaptation: the plugin stops drawing its own right
panel and contributes tab TYPES to DSH's native right Sidebar, which owns
the right column. The bottom workbench (terminal dock) stays plugin-owned.

Registrations (src/client/native/):
- every TabDescriptor becomes a native tab type (kind = descriptor.id, the
  default `extension` band) plus a keyed body in `sidebar.right.pane.tab`
  and a live chip title in `sidebar.right.pane.tab.title`
- the `editor` type also claims `dsh-resource://file/**`, so it outranks
  the built-in `text` preview (fallback) and every file the product opens
  lands in the plugin's editor
- the built-in `files` page kind is TAKEN OVER by an extension
  registration of the same kind: `openTab('files')` draws the plugin's
  explorer, and the built-in resumes when the plugin unregisters
- registrations follow the plugin registry + the side-card settings: a
  type registered later (external plugin) gets its native type too, a
  disabled type is unregistered (absent from the guide, refuses opens)

Adapter (src/client/native/tab-adapter.tsx):
- one synthetic plugin `SidebarTab` per native tab id, minted from the
  native record + navigation params (or the descriptor's own createTab,
  which a native guide open bypasses), kept live across navigations and
  updateTab writes
- the explorer's per-tab expansion/reveal sets and the per-kind instance
  counter, which the plugin's own layout used to hold

Service routing (src/client/service.ts):
- `setSurface` installs the native write face; openTab/openFile land
  natively (a path becomes a resource address, a path-less editor open
  becomes the `files` page, the rest carry the seed as navigation params),
  closeTab/updateTab/activateTab recognise native tab ids
- new optional `OpenTabSeed.target` ('right' default, 'bottom' keeps the
  bottom workbench); the bottom panel's own + menu and auto-terminal pass
  'bottom'
- src/client/native/surface.ts probes the controller's per-session writes
  (`openTabIn`/`openResourceIn`/`closeIn`, not in `ISidebarRight`) and
  queues opens for a session whose surface is not mounted yet

Right panel retired behaviourally (Phase 3 deletes the code): Sidebar
renders its bottom workbench only, keeps the panel collapsed, and hides
the right-panel toggle. The panel-specific e2e specs are removed; the
mount lane now drives the native guide (tab sweep), the plugin explorer
inside the native pane (editor/mermaid/README chunks) and the sidechat
host routes.

Verified: pnpm typecheck / lint / build / test (126 files, 1349 tests) /
check:consumer-types, plus pnpm test:mount against a real
@deepseek-ai/dsh@0.1.5-alpha.1 host (7/7).
2026-09-09 11:47:31 +08:00