Commit Graph
725 Commits
Author SHA1 Message Date
Atlas Zeng 0c3e5e9279 merge #881 into dev(推荐目录收录音频预览插件 dsh-plugin-better-sidebar-plugin-audio)
Refs #881
2026-10-11 21:54:53 +08:00
Menghuan1918 1184d063c9 fix(release): 版本号同步到 dsh.plugin.json 与 SIDEBAR_SERVICE_VERSION
v0.25.0 的 bump 漏了两处与 package.json 必须同步的声明,CI 上
`manifest-consistency.spec.ts`(registry 清单的 version 对齐)与
`service.spec.ts`(服务上报的 version 对齐)因此变红:

- `dsh.plugin.json` 的 `version`:0.24.1 → 0.25.0(registry 通道形状,由
  `manifest-consistency.spec.ts` 守护)
- `src/client/service.ts` 的 `SIDEBAR_SERVICE_VERSION`:0.24.1 → 0.25.0
  (消费插件用它与 `features` 做能力探测,由 `service.spec.ts` 守护)

两条守护就是为这次漏项准备的:它们在**本地**全量里也该红,是我上一批只跑了
typecheck/lint + 全量却把这两条读成了「通过」——实际是那次全量跑在 bump 之前。
现补:受影响四条 spec 82/82 绿。
2026-10-10 01:25:22 +08:00
Menghuan1918 20307d5f6a feat(dock): 右侧面板展开时不显示底部入口(按用户口径重做)
上一版把「没展开」理解成了**底栏**(在 `BottomDockToggle` 里判 `bottomOpen`),
方向反了;先 `8e3447b` 整个 revert,再按真实口径重做:**宿主右侧面板展开时不显示
这个按钮**。

- 新增 `src/client/sidebar/right-panel-open.ts` 的 `useRightPanelOpen()`:
  首帧同步读取 + 每 500ms 复核。
- `BottomDockToggle`(会话头入口)与 `DockFallback`(空白会话备用入口)都在展开态
  返回 null —— 备用入口连 portal 空壳一起省掉。

**判据必须是「可见」,不能是「在不在 DOM 里」**:实测宿主把两个角落控件都留在文档里
(落屏时 `[data-sidebar-right-expand]` 与 `[data-sidebar-right-toggle]` 各 1 个,而面板
明明已经展开),只有可见性区分得开 —— 展开时可见的是 Collapse、收起时可见的是 Open。
早先按属性存在与否判定会一直读成「没展开」,按钮照旧出现在宿主编簇旁边(真机实测到)。

判据的方向也刻意取安全侧:宿主哪天换命名 → 读成 false(不隐藏),按钮照旧可用、
位置由让位逻辑兜住,而不是把按钮永久藏掉。

测试:`tests/dock-fallback.spec.tsx` 新增「右侧栏展开时一个入口都没有」(造一个**可见**的
Collapse 控件;**还原门即红** `右侧栏展开时不该有备用入口: expected <span…> to be null`),
并把两条定位用例改回「收起形态」的锚点 —— 展开态已经不渲染,那两条原先为之写的
「打开形态锚点」用例随之删除(规则把那个状态整个去掉了)。既有 8 条全绿。
`tests/e2e/blank-session-dock-entry.e2e.ts` 在真机跑过:1 passed。
2026-10-10 00:40:02 +08:00
Menghuan1918 8e3447b27a revert: 回退「只在未展开时显示底部入口」——把「没展开」理解成了底栏,实际是指右侧面板 2026-10-10 00:35:46 +08:00
Menghuan1918 31b11ef3b8 feat(dock): 底部入口只在未展开时出现(展开态交给面板自己的 ×)
产品决定(用户提的):底栏展开后不再显示头部入口 —— 收起由面板页签条右端那个 ×
负责,头部再来一个「收起」既冗余,又多一个「展开态该把入口摆哪儿」的状态。

- `BottomDockToggle`:`bottomOpen === true` 时返回 null(不再切 aria-label /
  aria-pressed,那个「收起」形态整个去掉)。
- `DockFallback`:同样在展开态不渲染(连空壳也省掉)。

顺带的效果:备用入口与宿主 chrome 争位置这件事,只在**未展开**这一个状态下需要处理。

测试:
- `tests/dock-fallback.spec.tsx` 新增「展开态一个入口都没有」用例(9 条全绿)。
- `tests/e2e/blank-session-dock-entry.e2e.ts` 按新语义改写 —— 原先断言展开后
  `data-active='true'`,现在断言**入口退场、屏上 0 个**,并补上「用面板自己的 ×
  收起后,会话头入口回来且仍只有一套」。**真机跑过:1 passed**。

全量 189 文件 / 2215 通过,typecheck / lint 干净。
2026-10-10 00:33:32 +08:00
Menghuan1918 570bebc85e fix(dock): 占位判定改用命中测试 + 多点采样(修「tab 多的时候位置也错误」)
两个真问题:

1. **页签芯片筛不出来**。原先把「占位」定义成 `button, [role="button"]` 的 rect
   相交,而右侧栏的页签芯片不是这两者 —— 页签一多,让位会**停在芯片上**。
   改用 `document.elementsFromPoint`:直接问页面「这一格下面有什么」,
   与宿主用什么标签、什么类名无关。判定为占位的是**不透明的小控件**
   (≤300px 宽:页签芯片、图标胶囊);整行的不透明背景板(会话头 titleRow、
   面板 tabStrip、面板本体)不算 —— 把它们算进去会让入口一路退到屏幕中间
   (实测退到 x=530)。

2. **只测中心点不够**。槽位宽 28px,中心空着不代表右缘不压着邻居:
   实测中心判空、box 却与 Split/Fullscreen 相交。现在沿水平方向采 **5 个点**
   (2 / 8 / 14 / 20 / 26),整格全空才算空;让位步长同时收到 4px。

真机复测(2200px 视口、右侧栏打开、开过页签):
入口落在 `2066`,宿主整簇从 `Split@2094` 起 —— **rect 相交为零**。

判别性:`tests/dock-fallback.spec.tsx` 的芯片用例把命中测试桩成「x > 430 被页签盖住」,
断言入口退到 `404px`;**关掉命中测试即红**
(`expected '464px' to be '404px'`,464 正是压在页签上的位置)。全 8 条绿,
全量 189 文件 / 2214 通过,typecheck / lint 干净。
2026-10-09 23:09:53 +08:00
Menghuan1918 225d814ce5 fix(dock): 备用入口让位要逐个槽位试探,不能只挪一个固定偏移
`fix/dock-toggle-anchor` 让锚点认出了宿主角落控件的**打开形态**
(`data-sidebar-right-toggle`),但当右侧栏打开时那个座位旁边还有同伴:宿主的角落控件
是肩并肩一簇。真机实测(2200px 视口):

    打开态:Split@2094  Fullscreen@2130  Collapse@2166   (各 28px,间隔 8px)

`measure()` 只往锚点左侧挪 `GAP + BUTTON_SIZE = 36px`,于是从 Collapse(2166) 让到
2130 —— **精确压住 Fullscreen**(28x28px 全重叠)。

改为:先按锚点算槽位,然后**逐个槽位左移,直到该槽位与任何宿主按钮都不相交**
(竖直方向真的相交才算占位,最多退 8 格;极窄窗口下停在最左,宁可贴边也不叠)。

真机复测(同一探针、同一视口):

    关闭态:入口 2124..2152,宿主 Open right sidebar@2160        → 零重叠
    打开态:入口 2058..2086,宿主整簇 Split@2094/Fs@2130/Col@2166 → 零重叠

判别性:`tests/dock-fallback.spec.tsx` 再加一条 —— 锚点在 500、紧邻左侧 464..492
站着 Fullscreen,断言入口落在 `428px`;**关掉步进即红**
(`expected '464px' to be '428px'`,即停在 Fullscreen 上)。既有 6 条保持绿;
全量 189 文件 / 2213 通过;typecheck / lint 干净。
2026-10-09 21:36:31 +08:00
Menghuan1918 0dcdb414b9 fix(dock): 备用入口的锚点要认宿主角落控件的两种形态(修压在「收起右侧栏」上)
现象:右侧栏打开时,右上角出现**两个图标叠在一起**——插件的「展开底部面板」压在
宿主的「收起右侧栏」上(用户截图)。

根因:备用入口按宿主角落控件的 rect 左移 `GAP + BUTTON_SIZE = 36px` 定位,但锚点只查
`[data-sidebar-right-expand]`。实测宿主那个座位有两种形态:

- 右侧栏**关闭**:`data-sidebar-right-expand`(aria-label「Open right sidebar」);
- 右侧栏**打开**:该属性**整个消失**,同一座位换成 `data-sidebar-right-toggle`
  (aria-label「Collapse right sidebar」)。

于是右侧栏一打开,`measure()` 找不到锚点、落到视口兜底坐标 `innerWidth - 44` ——
而那里正是宿主自己的角落按钮群(Split / Fullscreen / Collapse)。2200px 视口实测:
入口 = `2156..2184`,宿主 Collapse = `2166..2194` → **重叠 18x26px**,并切到 Fullscreen
2px。与用户截图逐字一致。

修法:锚点选择器同时认两种形态
(`'[data-sidebar-right-expand], [data-sidebar-right-toggle]'`)。

判别性:`tests/dock-fallback.spec.tsx` 新增一条 —— 只挂 `data-sidebar-right-toggle`
的宿主按钮 + 桩掉它的 rect,断言备用入口的 `left` 是 `464px`(= 500-8-28);
**还原锚点即红**:`expected '980px' to be '464px'`(980 = jsdom `innerWidth 1024 - 44`
的兜底值)。全量 189 文件 / 2212 通过;typecheck / lint 干净。
2026-10-09 21:33:39 +08:00
Menghuan1918 85736b5294 fix(dock): 会话头入口在场时,空白会话的底部入口让位(修「展开底栏」叠成两个)
现象:右上角出现**两个**「展开底部面板」按钮,精确重叠成一团(用户截图)。

根因:两套入口的互斥只靠 `session.phase`,而相位是**每 1s 轮询**来的、会话头入口
由宿主自行决定何时渲染 —— 两者之间必然有窗口;更糟的是相位路由失读时按「非 blank」
降级,一个从未成功读到的会话可能长期停在 blank。而两套入口在版面上**就是同一个
位置**(备用入口按宿主「Open right sidebar」的 rect 左移 8+28px),同时在场即重叠。

修法:在相位之外再加一条**与相位无关**的兜底 —— 只要 DOM 里存在一个不在
`[data-dsh-dock-fallback]` 内的 `[data-dsh-bottom-toggle]`(即会话头那套入口真的
渲染了),备用入口就让位。判定挂在既有的 500ms 位置对齐节拍上(resize 时也刷新),
因此最多 500ms 的让位延迟。

判别性:`tests/dock-fallback.spec.tsx` 新增「造出『相位说 blank + 会话头入口在场』
的不一致状态」用例 —— **还原守卫即红**(`会话头入口在场时备用入口必须让位:
expected <span…> to be null`);另 4 条既有用例(blank 渲染 / 非 blank 不渲染 /
相位未知不渲染 / 路由不支持降级)保持绿。typecheck / lint 干净。
2026-10-09 10:29:10 +08:00
Menghuan1918 45285014d9 merge fix/826-file-link-line-jump into dev(#826 第二半:行号不再被解析完就扔掉。两种写法合流到同一个字段——#L131 由宿主解析成 navigation.params.line、path:131 由插件在 path-line.ts 切出,都落到 SidebarTab.line,再经 FileViewerProps.line 交给 viewer;TextEditor 到达时定位一次并高亮,越界钳到最后一行,区间只取起始行。line 是瞬态(sanitizePersistedTab 白名单不含它,刷新不把读者拽回旧行);markdown/html 收到行号先强制切到编辑态再定位,避开预览自己的挂载滚动恢复。公开面是纯增量:FileViewerProps.line?: number)
# Conflicts:
#	docs/external-plugin-guide.md
2026-10-08 22:20:45 +08:00
Menghuan1918 698721eb34 merge fix/desktop-shell-http-base into dev(桌面壳的 HTTP 与 WebSocket 需要不同基址:壳把页面放在 dsh-app://app/、注入的 streamBaseUrl 指向另一个 origin,而壳的 protocol.handle 会把非静态 dsh-app 路径同源转发给宿主——插件的 JSON 路由不带 CORS 头,发到注入 origin 就是跨源、被浏览器直接拒(满屏 Failed to fetch);于是 HTTP 改骑页面基址 hostHttpBase()(document.baseURI,反代前缀也带在里面),WebSocket 继续用注入 origin。含 base-path 三种场景的用例) 2026-10-08 21:58:34 +08:00
Menghuan1918 d241faf8ea merge fix/editor-reveal-remeasure into dev(#837 后续:宿主用 MOVED 的方式 park/还原 tab body,移动节点不改变 border box,所以只看 box 变化的 ResizeObserver 永远不触发——一个在隐藏宿主里被打开的编辑器会把视口量成 0 并一直留着空白的虚拟视口(行号槽还在画,正文空)。改为每次「显现」都重新测量:IntersectionObserver 报显现本身、rAF 兜住与挂载同帧的那次显现,另接 visibilitychange / window resize;全部可缺省且逐个 dispose) 2026-10-08 21:58:34 +08:00
Menghuan1918 657f75c1be merge fix/session-scope-write-guard into dev(#848 会话切换不再把上一个项目的写操作带进新项目:文件树选中集/菜单/内联编辑器/确认框随会话与 cwd 一起失效,批量删除与打包构建按 generation 退役结算;含收尾修正——删除确认与拖拽上传改在**调用点**复核 armed scope,关掉「swap 已提交、passive effect 未 flush」之间那个仍会把 B 的 scope 配 A 的绝对路径发出去的丢数据窗口)
# Conflicts:
#	src/client/FileTree.tsx
2026-10-08 21:56:03 +08:00
Menghuan1918 62c1a0cc63 fix(safety): 删除确认与拖拽上传在调用点校验自己的 scope(#848 收尾)
独立正确性评审在 PR #853 上复现出一个**仍然丢数据**的窗口,本提交把它关掉:

**HIGH|单行删除**:`confirmDelete` 只装 `{path, isDir, name}`,scope 在确认时现读。
换会话的清理写在 **passive** effect 里,而点击可以落在「swap 已提交、effect 尚未
flush」之间 —— 此时 `propsRef.current` 已经是新会话。实测(`flushSync` 提交 swap
后立刻点那个仍挂在 DOM 上的 Confirm):

```
fsRemove({sessionId:'s2',cwd:'/projects/beta'}, '/projects/alpha/a.ts')
```

宿主对绝对路径原样执行(包含性检查是刻意移除的),于是**删掉的是上一个项目的文件**,
正是本 PR 要修的那件事。批量走的第一次 `fsRemove` 同样直接发在点击处理器里。

修法是把「armed 时的 scope」随确认一起存下来,并在**调用点**复核(`sameScope`):
单行删除存进 `confirmDelete.scope`,批量把 `confirmDeleteSelected` 从 boolean 换成
`FsScope | null`;不一致就整条请求不发(fail closed),请求本身用 armed scope,
scope 与 path 因此永远属于同一个项目。同时在途结算也按 `scopeGenRef` 退役,
不再把结果写进已经换过的项目。

**MEDIUM|拖拽上传**:`reportDrop` 的 `uploadItemsFromDrop(...).then` 里用的是**最新**
props 的 `onUploadRequest`,而 `dir` 是拖拽开始时的旧路径 —— 一次落点会把这批文件
传进新项目的树里。现在同样 armed/复核,不一致即丢弃。

测试:`tests/file-tree-session-scope.spec.tsx` 新增两条 —— 上面那条窗口的判别性用例
(**还原守卫即红**:`expected "vi.fn()" to not be called at all, but actually been
called 1 times`)与一条正向对照,钉住「请求里的 scope 与 path 必须同源」(只数调用
次数抓不到 scope 被换掉的回归)。typecheck / lint 干净,该 spec 6/6 绿。
2026-10-08 21:55:12 +08:00
Menghuan1918 06dff2f56e merge fix/871-preserve-eol into dev(#871 保存保持文件原有行尾:宿主侧在 fs.write 的唯一咽喉点先按盘上内容嗅探行尾(4096 字符多数表决,与宿主 dsh-fs-local 的 detectLineEndings 同判据),写回时按同一判定归一化,CRLF 文件不再被写成 LF 而产出整文件 diff;mtime 冲突基线、fs-conflict 横幅与 #855 的 dirty/编辑态跳过语义均不变)
# Conflicts:
#	CHANGELOG.md
2026-10-08 21:52:00 +08:00
Menghuan1918 ec26c6892b fix(fs-search): 合并收尾——点前缀手势的反斜杠按平台门控(#879)
`isDirectPathQuery` 的 `/^\.+[/\\]/` 没有做平台门控:POSIX 上 `.\notes` 是
**合法文件名**(点 + 反斜杠,两部分都是名字字符),却被判成「点前缀相对路径」
送进 `resolveTarget`,stat 一个不可能存在的路径 → 必然空结果,同时丢掉名字查询
与引擎资格。现改为平台门控的 `DOT_ANCHORED_RE`(win32 才收 `\`),并把分隔符
判定收敛到共享的 `SEPARATOR_RE`,`hasSeparator` 与它同源、不会再分叉。

判别性:新增用例 `a dot-prefixed POSIX name with a backslash stays a name query`,
还原实现即红(`matches` 由 `['.\\notes.md']` 变 `[]`、`probed` 由 true 变 false)。
`tests/fs-search.spec.ts` 31 条 + `tests/search-engines.spec.ts` 38 条全绿。

顺带:`src/search-engines.ts` 的 `close` 结算注释原写「timeout/error 的结算
在下面」,实际两者注册在上面(:282/:283),改正方向。
2026-10-08 21:48:13 +08:00
Menghuan1918 e655bf2e44 merge fix/879-fs-search-path-query into dev(#879 搜索框粘贴路径结构性零命中:searchFiles 按查询形态分流——指名单一目标(绝对路径 / ~ / ./ / ../)经 resolveTarget stat 直取、缺失立即空结果不再烧 10 万预算,含分隔符的相对片段按根相对路径匹配,普通名字查询原样不变;SKIP_DIR_NAMES 补 .worktrees/.worktree/target/venv/.venv/__pycache__,walk 与两条引擎 argv 共用。含客户端「工作区外目录命中行只清空查询」守卫)
# Conflicts:
#	CHANGELOG.md
2026-10-08 21:47:02 +08:00
finley08 fc61cddc16 fix(routes): HTTP routes ride the page base again — the desktop shell is cross-origin to the injected transport origin
The prefix fix routed every route through `__DSH_TRANSPORT__.streamBaseUrl`.
For WebSockets that base is required (a custom scheme cannot host `ws:`, and
the shell page's host is the literal `app`, whose DNS lookup never completes),
but for HTTP it is a DIFFERENT origin than the page: the Electron shell serves
the GUI from `dsh-app://app/` while `streamBaseUrl` is the Host's
`http://127.0.0.1:<port>` (`streamBaseUrl: new URL(hostUrl).origin` in the
shell's `main.js`, via `DESKTOP_IPC.boot`).

Measured on DSH 0.2.0-rc.2 + Electron shell:
- `OPTIONS /sidebar/api/fs.trees` (Origin: dsh-app://app, preflight for the
  plugin's JSON POSTs) → `405 method not allowed`, no `Access-Control-Allow-*`
  header; the actual POST answers `400` with no CORS header either.
- The shell's `protocol.handle('dsh-app', …)` forwards every NON-STATIC
  `dsh-app://app` path to the Host (`forwardWebRequest(request, hostUrl,
  hostCookie)`), so `dsh-app://app/sidebar/api/…` reaches the Host same-origin —
  the exact shape `fetch('/sidebar/api/…')` produced before the prefix fix.

Consequence in the desktop window: every plugin request is blocked by the
browser and surfaces as "Failed to fetch" — file tree (the whole sidebar body),
git, editor, uploads, archive, chunk loading. The web profile in a browser is
unaffected (there the page origin IS the transport origin), which is why the
mount lane cannot see it.

HTTP now resolves against `document.baseURI` — which carries a reverse-proxy
directory prefix too, so one rule covers both deployments — and falls back to
the transport base when no page base exists (specs / SSR). WebSockets keep the
transport base. `tests/base-path.spec.ts` pins the split per transport,
including the shell case and the no-page-base fallback.
2026-10-08 11:39:11 +08:00
finley08 b0d354f209 fix(editor): re-measure a revealed editor even when its host is only MOVED
The native right sidebar parks a `keepMounted` tab body through the host's
`retainTab` path, which moves the body into a hidden seat and back. Moving a
node never changes its border box, so the `ResizeObserver` added in #837
(d3df20e / db563ca) is never called for that path: a CodeMirror view created
while its host was hidden keeps the zero-sized viewport it measured, and the
editor stays visually blank — gutter line numbers drawn, document body empty —
until the tab is remounted. Observed on DSH 0.2.0-rc.2 + the Electron shell
with a `.yaml` file opened from the file tree while another tab was active: the
buffer holds the text (select-all copies it), only the paint is missing.

Three additive recoveries, next to the existing measure:

- `IntersectionObserver` on the host — reports the reveal itself, so a body
  that was merely moved is re-measured (the box need not change).
- a `requestAnimationFrame` follow-up after mount — a reveal that lands in the
  mount's own frame happens after CodeMirror's first measure read a zero box.
- `visibilitychange` / `window resize` — the document-level equivalents.

A non-intersecting report spends nothing, so pane scrolling does not queue
measures. `tests/text-editor-visibility.spec.tsx` gains a case for the
size-preserving reveal (and pins that the invisible report is ignored); the
existing ResizeObserver cases are unchanged.
2026-10-08 08:14:34 +08:00
NolanHo 6497046c9e fix(search-engines): settle streamLines on close, propagate fd dirs-run failures (#883)
streamLines settled its promise on the child's 'exit' event. Node fires
'exit' the moment the process dies, while the stdout pipe may still hold
undrained data — under host load the exit event can win that race and the
promise resolved with a still-empty lines array. fd's second --type d run
was the common victim (both children race, the match run usually drains
first), so the observable signature was matches intact with dirs: [] —
directory hits silently degraded into open-as-file errors, the exact
error surface #801 fixed, now intermittent.

Settlement moves to 'close' (process dead AND stdio drained, so every
readline line event has fired). The truncation kill, the timeout and the
spawn-error paths keep their semantics: whichever finish() ran first
sets the closed flag and the close handler is idempotent. The --version
probe keeps 'exit' — its stdio is 'ignore', the exit code is the only
signal it reads.

The fd branch also no longer swallows the directory run's failure: the
.catch(() => empty dir list) is deleted, so a rejection now reaches
runEngine's existing broken-marking and this one search falls back to
the plain walk — symmetric with the main run, where the old catch
degraded every failure into an invisible "zero directories".

Evidence: on an fd-equipped Linux host the real-engine suite reproduced
7/30 runs on clean dev (signature constant), 0/30 after the one-line
close change; upstream CI never saw it (ubuntu lane has no fd; ci-windows
runs serially). Two deterministic cases now pin the contracts through the
new spawner hook (scripted PassThrough children replay the racy event
order directly); each was verified red by temporarily reverting the
corresponding half of the fix.
2026-10-06 10:50:51 -07:00
HuanLinOTO 3d6d55d2ea feat(catalog): 预览插件目录收录音频预览插件(dsh-plugin-better-sidebar-plugin-audio)
- src/client/plugins-viewers.ts:新增 PluginEntry,设置页「添加插件」弹窗的预览插件目录可一键复制安装命令
- i18n:pluginAudioName / pluginAudioDesc 同步全部 20 份词典(zh/en + 19 份第三语言),key 集合由 tests/locales.spec.ts 守护
- tests/plugin-list.spec.ts:该条目写进目录清单断言
- README.md / README_EN.md:预览插件表格 3 → 4

验证:pnpm typecheck 通过;vitest run tests/locales.spec.ts tests/plugin-list.spec.ts 全绿(29 用例)。本机全量 pnpm test 的 7 个失败与本改动无关(tasks-model 语言回退 / git / plugin-meta 打包 / editor-host),已在未改动的 dev 上复现同一失败集合。
2026-10-07 00:31:16 +08:00
NolanHo 0d9fee85b8 fix(fs-search): direct-open for pasted paths + fragment path matching (#879)
A query carrying a path separator can never match an entry NAME — names
never contain separators — so pasting any path into the search box was
structurally guaranteed to return {matches:[],truncated:true} while the
walk burned its full 100k-visit budget (measured: 1.9s on a Rust repo
whose two worktree forests alone held 97k entries; real directories were
never reached).

searchFiles now routes by query shape, all three modalities sharing one
result contract:

- A query naming one path (absolute, ~/…, ./x, ../x) resolves through
  resolveTarget — the SAME primitive fs.read uses, so ~ expands (#713),
  dot-anchored spellings join onto the session cwd, and win32
  WSL/dsh-remote namespaces reinterpret — then stats the target. The hit
  is the RESOLVED path (resolve() strips shell-completion trailing
  separators, which the client's exact-string row comparisons could never
  match); a missing target answers empty immediately. Directory targets
  ride the #801 dirs contract. The exclude pref does not apply: a pasted
  path is explicit intent, same as the fs.read the click performs.
- A separator-carrying relative fragment (records/exp1) matches by
  root-relative PATH in the walk; the engines are name matchers (fd has
  no --full-path here, rg's globs are single-segment) so argv
  construction is untouched.
- Plain name queries are unchanged, and no NAME query is stolen: on
  POSIX a backslash is a name character (the ~\ gesture counts only on
  win32; util.ts~ / ~$doc.docx / .env stay name queries).

SKIP_DIR_NAMES gains the budget-eating forests seen in the wild:
.worktrees/.worktree (git worktree layouts), target, venv/.venv and
__pycache__ — shared by the walk and both engine argvs as before.

Client: a directory hit OUTSIDE the cwd (newly reachable via the paste
branch) only clears the query — the tree is cwd-rooted, and the old
ancestorDirs call synthesized junk expanded entries for foreign paths.

Verified: vitest fs-search/smoke/search-persist suites green; full run
2171 passed with one failure proven pre-existing on the clean tree
(git.spec checkout case, host git lacks --end-of-options; #841);
typecheck/lint clean.
2026-10-06 08:25:30 -07:00
ymac 419d1c4b67 fix(editor): 保存保持文件原有行尾,不再把 CRLF 文件写成 LF(#871)
编辑器传送的永远是 LF 文档(CodeMirror 没有别的行模型),`fs.write` 原样落盘,
于是在 Windows 检出上「改一行」= 整文件 diff。

- `text-encoding.ts`:`encodingOfFile` 扩成 `fileFormatOf(path)`,同一趟 64 KiB sniff
  同时给出 `{ encoding, eol }`;新增 `detectEol` / `restoreEol`(口径与宿主
  dsh-fs-local 的 detectLineEndings / restoreLineEndings 一致:前 4096 字符多数票、
  孤立 \r 不计票也不改写、还原前先归一化以免 \r\r\n)。
- `index.ts` 的 `fs.write`:落盘改为 `encodeText(restoreEol(content, eol), encoding)`。
  客户端零改动,所有保存入口自动覆盖;新文件仍是 UTF-8 + LF(项目级行尾约定另议)。
- 测试:text-encoding 补 3 条、fs-write-route 补 3 条端到端;拿掉 restoreEol 调用即 2 条红。
- 文档:设计文档 docs/plans/2026-10-06-preserve-eol-on-save.md、CHANGELOG、AGENTS §5 保存语义。

顺带核实(写进设计文档):宿主 `edit` 工具会保住行尾(editText 走 restoreLineEndings),
宿主 `write` 工具不会(writeText 原样写模型文本),那一半插件无权干预。
2026-10-06 15:36:36 +08:00
Menghuan1918 0ee870ade2 merge fix/crlf-markdown-surface into dev(修 CRLF 输入下的三层 \r 误判与预览双拼写渲染:markdown-html 的 isBlank / mermaid-blocks 的 CLOSE_FENCE_RE / markdown-code 的 closesFence 把 \r 当内容,导致 HTML 段永不终止、mermaid 围栏吞掉余下文件、链接改写从第一个围栏起全部失效;TextEditor 的 draft 快照把 CodeMirror 归一化后的 LF 文档覆盖预览源,使挂载那一趟写入的标题 id 被丢弃。含测试脚手架 CRLF 安全化与 9 条 CRLF≡LF 判别性用例) 2026-10-06 00:57:35 +08:00
Menghuan1918 ee5be9b601 fix(markdown): read a CRLF document exactly like its LF twin (#363)
The markdown pipeline's line-based scanners split on `\n` and then reason
about each line, so a Windows checkout (`core.autocrlf=true` — the
`ci-windows` lane) broke three of them at once:

- `splitHtmlBlocks`'s blank-line test (`/^[ \t]*$/`) read a CRLF blank line
  (`'\r'`) as content, so an HTML run never ended: on this repo's own README
  the splitter produced 4 segments instead of 36, and the markdown after a
  `<div>` run was rendered as raw text.
- `CLOSE_FENCE_RE` (`[ \t]*$`) never matched a CRLF closing fence, so
  `splitMermaidBlocks` swallowed the rest of the file and the splitter's own
  open-fence state never closed.
- `closesFence` (`/^[ \t]*$/`) left every CRLF fence open, so
  `maskCodeRegions` masked from the first fence to the end of the file and
  the link rewriter stopped claiming every `.md` link after it (first
  divergence on README.md: `./CHANGELOG.md%23v0230`, claimed under LF, left
  as an inert `#v0230` destination under CRLF).

The editor preview rendered the document twice as well: its draft snapshot
publishes CodeMirror's live document — always LF, whatever the file used —
one commit after mount, and that CRLF→LF re-render makes the host rebuild the
markdown elements whose text changed, discarding the heading ids the surface
pass had just written (the MutationObserver only heals them a microtask
later). Line endings are not an edit: the snapshot now keeps `draft` null
while the live document is the loaded content under any line-ending spelling.

Tests: `scanDocumentAnchors` and the README TOC slice split on `/\r?\n/`;
tests/markdown-crlf.spec.ts pins the CRLF≡LF invariant across the splitter,
the mask, both rewriters and the mermaid splitter, and two surface cases
mount a CRLF document through the real renderer — one of them a CRLF copy of
the README, so every lane exercises the spelling only `ci-windows` checks
out. Reverting the `\r` fixes turns nine of them red.
2026-10-06 00:54:24 +08:00
Menghuan1918 1748c7b0d4 feat(editor): LLM 改完文件后自动刷新正在看的预览(#855)
模型在会话里 write/edit 一个正开着的文件后,侧栏里仍是旧内容,只能手点刷新或
关掉重开——加载 effect 的依赖里没有任何一项会因写盘而变化,keepMounted 又让
切走再切回不重挂。

信号源用插件自有的 `changes.ops` 增量流(宿主按 seq > afterSeq 下发 tool/call +
tool/result,客户端折成文件操作),不新增第二个轮询机制:没有 fs.watch,也没有
任何周期性的 fsRead 指纹轮询。

- 新增 src/client/ops-stream.ts:每会话一条流 + 成员选举一个 leader,只有 leader
  跑 usePolling(self-scheduling,2.5s,与文件变动页会话透镜同一路由同一节奏)。
  一个会话开 N 个编辑器 tab 每 tick 仍只有 1 个 changes.ops 请求;成员全部离开即
  停轮询但保留游标与已发布状态,页签回来时补折离开期间错过的增量。
- 只发布结算成功的 write/edit(running === false && !isError);第一帧是基线,
  打开前已结算的写入一律不触发。
- 命中判定 fileOpKey(cwd, path):resolveSidebarPath 归一相对路径 + `.`/`..` 词法
  折叠 + 分隔符统一 + Windows 盘符/UNC 大小写折叠。
- EditorHost:命中且非 dirty、非编辑态时 setReloadSeq(+1)——复用页头刷新按钮那条
  完全相同的加载路径,手动入口原样保留。脏态优先:dirty 时绝不覆盖用户输入。

测试 tests/editor-auto-refresh.spec.tsx(12 例,jsdom + 假计时器),逐条做了
「还原源码即红」的变异验证;#167 的既有 4 条未改动。
docs:接入指南 §5.2 与行为差异表、CHANGELOG、设计文档。
2026-10-06 00:34:42 +08:00
Menghuan1918 76cf851a45 merge feat/363-md-cross-file-anchors into dev(#363 Markdown 跨文件 / 锚点导航:官方 MarkdownDelegateProvider + %23 片段载体认领本地 .md 链接、标题获得与 GitHub 一致的 slug id、空锚点隐藏、跨文件待处理锚点表;含验证 reject 后的修复:slug 不 trim/不折叠空白/删 VS16 使两份 README 的 TOC 锚点 0/15→15/15、共享围栏 mask 修 ~~~ 与图片 pass 的既有盲区、滚动宿主祖先分支的 shipped 用例)
# Conflicts:
#	CHANGELOG.md
2026-10-06 00:19:47 +08:00
Menghuan1918 fab329d469 fix(markdown): match GitHub's heading slug and mask ~~~ fences (#363)
Two defects the independent verification rejected, plus the test gaps they
left behind.

1. `githubHeadingSlug` was not GitHub's slugger. It trimmed and collapsed
   whitespace runs (GitHub does neither: every space becomes its own dash) and
   kept `\p{M}`, which left the variation selector of `🖼️` inside the id. The
   consequence was the issue's main scenario: the repo's OWN READMEs resolved
   **0 of 15** table-of-contents anchors, and the click was claimed yet did
   nothing (`scrollTop` stayed 0). The slug is now `toLowerCase()`, drop
   pictographs / `\uFE00-\uFE0F` / regional indicators / `\p{C}`, drop
   everything that is not a letter, digit, combining mark, space, `-` or `_`,
   then each space → `-`. Emoji are removed here because GitHub removes them
   while RENDERING the heading (to `<img>`) before its slugger runs; that is
   the one deliberate difference from `github-slugger`, and it is what turns
   `🚀 安装` into GitHub's real `-安装`.

2. Both source rewriters inlined a fence mask that only recognised ```, so a
   link or image demonstrated inside a `~~~` fence was rewritten
   (`[y](./b.md#u)` → `[y](./b.md%23u)`; the image half predates this feature:
   `rewriteLocalImageUrls('~~~\n![i](./p.png)\n~~~')` already produced a
   `/sidebar/file` URL on 58d7f71). One shared mask now lives in
   `src/client/markdown-code.ts` (CommonMark: 3+ backticks OR 3+ tildes, a
   closing fence no shorter than its opener, an unclosed fence running to the
   end of the text) and both passes use it.

Evidence (all on the merged tree, HEAD after `git merge origin/dev`):
- Real `TextEditor` + real host `MarkdownText`, every TOC anchor clicked:
  README.md `0/15 → 15/15`, README_EN.md `0/15 → 15/15` (shipped as a case in
  tests/markdown-surface.spec.tsx; the id-level counts are 0/16 → 16/16).
- Parity against the actual `github-slugger@2.0.0` regex (vendored in
  tests/helpers/github-slug-reference.ts), plus explicit emoji/VS16 cases.
- Mutation: restoring the old trim+collapse+`\p{M}` slug reddens 9 cases
  (both README cases included); dropping the tilde fence reddens the new
  fence case in BOTH the link and the image spec; forcing `scrollHostFor` to
  return the container reddens the two new ancestor-scroller cases.
- `scrollHostFor`'s ancestor branch was unreachable from the shipped suite
  (the mutation above used to leave 33/33 green): tests/markdown-surface.spec.tsx
  now injects the computed style (`overflowY: auto` + `scrollHeight`/
  `clientHeight`) and asserts the write lands on the ancestor, that neither
  `window.scrollTo` nor `scrollIntoView` is called, and that the container's
  own `scrollTop` is never written.

Also: the untrue "exactly like GitHub does" comment, four-form fence cases per
pass (``` / ```` / ~~~ / an inline span inside ~~~), a CHANGELOG entry, and the
recorded narrow edges (a destination with an escaped parenthesis or a
single-quoted title is not claimed — plain text, unchanged; `#L24` does not
jump to a line).

Gates: typecheck / lint clean, `vitest run --maxWorkers=3` 182 files, 2120
passed | 13 skipped; `pnpm build` complete; mount lane
(`DSH_CMD='npx -y --package @deepseek-ai/dsh@0.2.0-rc.1 dsh' pnpm test:mount`)
9 passed (2.0m), exit 0. The bare `pnpm test:mount` now dies in preflight
because the installed CLI is 0.2.0-rc.2 while the baseline pins 0.2.0-rc.1;
the lane count is 9 rather than the verifier's 11 because merging origin/dev
removed the two WCO/preset cases with the titleBar mechanism.
2026-10-06 00:19:11 +08:00
Menghuan1918 e4a4c3fa4c merge origin/dev into feat/774-terminal-tab(#774 收尾前置)
dev 前进 12 个提交(titleBar 让位机制整体移除、#132 新建文件与排序三档、
#817 后台激活改标记未读、#412 Windows「在应用中打开」候选链等)。两处冲突,
都是「双方各自新增的内容」,无实质取舍:

- CHANGELOG.md:Unreleased 保留双方条目。#774 一组在最上(本分支的新条目),
  其后是 dev 的「移除 titleBar 让位机制」「#132 新建文件 / 排序」一组,再往下
  是既有的 #109 / #203 一组(与文件里原有的空行分组一致)。
- tests/e2e/mount.e2e.ts:只在下一条用例的标题行冲突——保留本分支新增的底部
  终端用例(#774),标题取 dev 侧的新名(`a shell-stamped render URL mounts
  normally; …`;dev 已把 WCO / preset 两条场景删掉)。
- 21 份词典、AGENTS.md、docs/external-plugin-guide.md、README 自动合并:dev 删的
  12 个 titleBar 词典 key 保持删除,本分支新增的 3 个 terminal 词条保持新增。
2026-10-06 00:07:23 +08:00
Menghuan1918 6c60693e7d test(terminal): #774 收尾——补 bottomOnly 原生承载面的单元判别性守护
独立验证节点实测:把 src/client/native/index.ts 的 sync() 里
`if (descriptor.bottomOnly === true) continue` 删掉后,14 个相关 spec、158 条
断言全绿,只有挂载 lane 能抓住「原生 guide 条目从 0 变 1」——这半边当时只有
部署级守护。

- tests/native-registration.spec.ts 新增「a bottomOnly descriptor never
  reaches the native surface」:断言注册表的**事件日志**里没有该 id、没有它的
  slot,guide 条目只有 files 与 git;正控(其余描述符确实注册了)在前,所以
  这条不会因为「什么都没注册」而空过。实测删掉那行 skip 后:本次相关的 8 个
  spec / 171 条用例中只有这条红(170 绿)。
- tests/terminal-tab.spec.tsx:「已退出只说一次」那条断言原先**不判别**——
  只翻 info.state 时 statusOf 本来就返回 undefined,门在不在都一样。现在把
  phase 也置为 disconnected(statusOf 有自己的一行),断言状态行恰好 1 个、
  唯一按钮是「新建终端」、且不含 disconnected 文案。实测去掉
  TerminalView.tsx 的 `missing || ended` 门即红。
- tests/terminal-tab.spec.tsx 新增「新建终端」的**真实路由**用例:此前被假
  betterSidebar.updateTab 掩盖,现在接真 service,覆盖 surface.update 认领
  与 store.reduce(patchTab) 两半(bottomOnly 类型永远没有原生记录,落 store
  是它唯一的真实路径)。
- src/client/builtins/tabs.tsx:onClose 不再以 `scope?.sessionId ?? ''` 调宿主
  close(),缺 scope 直接 return——空 sessionId 会让宿主 no-op 并让 shell 一直
  挂着一个 per-session 槽位。
2026-10-06 00:06:37 +08:00
Menghuan1918 5b768c86f3 Merge remote-tracking branch 'origin/dev' into feat/363-md-cross-file-anchors 2026-10-06 00:05:02 +08:00
Menghuan1918 ab0d40dee8 test(markdown): give each case its own session; encode a query inside a carried fragment (#363) 2026-10-05 23:51:31 +08:00
Menghuan1918 cfe84c99b3 feat(markdown): claim local .md links and navigate headings across files (#363)
Markdown surfaces the plugin draws (editor preview, side-chat transcript,
changes reading pane, task note) now open local markdown links in the sidebar
and follow same-page / cross-file heading anchors.

The host renderer decides what a local destination even is: without a
`MarkdownDelegateProvider.openFile` a local link renders as plain text (there is
no `a[href]` to intercept), and `parseFileLink` accepts a fragment only in the
line grammar (`#L24`), so a heading fragment makes the whole destination
unparseable. So the claim is scoped by the provider (one per surface) and a
SOURCE pass carries a heading fragment past the parser as `%23` — the same shape
markdown-images.ts already uses for relative image destinations. Destinations
the plugin does not claim (non-markdown, remote, queried) keep rendering exactly
as they do today.

- `markdown-navigation.ts`: pure link judge + GitHub heading slugs (Chinese kept,
  duplicates `-1`, authored ids reserved first), collapsed-anchor hiding, the
  source rewrite, the jump that scrolls the surface's OWN scroller (never
  `window`/`scrollIntoView`), and the session+path keyed pending fragment table.
- `use-markdown-surface.ts`: one hook per surface — the container callback ref
  (DOM pass + mutation re-runs + pending fragment) and the delegate's `openFile`.
2026-10-05 23:43:14 +08:00
Menghuan1918 1ff8fa3514 feat(terminal): 底部工作台终端 tab terminal-bottom(#774)
底部 + 菜单里开得出 shell,刷新后认回同一个 shell,且**不**变成宿主
右列终端的第二个入口。

实现分三层:

1. 宿主能力层(src/client/terminal-client.ts,核心 bundle 安全):结构化
   探测 `ctx.webTerminals`(view/close/recover 三个函数都在才算数)+
   身份助手。**不写进 dsh.client.inject**:注入一个不存在的服务会把整行
   拖成 pending,插件在无终端控制器的部署上会整体不加载;也**不**
   value-import 任何 @deepseek-ai/*(纯度门),类型面手工声明。
2. chunk 层(src/client/TerminalView.tsx + terminal.module.css +
   chunks/terminal.tsx + terminal-lazy.tsx):xterm 与它的样式表整份打进
   lib/client-terminal.js(750 KB),核心包一处都没有;chunk 名在 9 处
   镜像(tsdown / bundle-route / chunk-loader / package.json.files /
   package-registry / bundle-route.spec),另两处 spec 从 CHUNK_NAMES 派生。
3. 描述符层(builtins/tabs.tsx):第 6 个内置类型,`bottomOnly: true`
   (见上一个 commit)、`single`、`available` 读同一份探测、`onClose`
   结束进程。

三条恢复语义的由来:

- **contentId 恒定,terminalId 不写进 tab.meta**:宿主 view() 显式传
  terminalId 会关掉「缺了就建」分支,一个过期 id 会把页签永久卡在
  missingTerminal;宿主自己的 (sessionId, contentId) → 终端 id 持久绑定
  本来就能在刷新后认回同一个 shell。
- **「新建终端」换代号**:DSH 重启后 PTY 没了而 localStorage 绑定还在,
  恒定 contentId 会永远认领死绑定。tab.meta.terminalRun(默认 0)+1 换
  一代 contentId 让宿主另铸进程;key 与 contentId 一起换(views 按
  (sessionId, key) 记忆化)。
- **关页签才结束进程**:宿主的契约是「视图跨 DOM 卸载存活」,这正是刷新
  能认回同一个 shell 的原因,所以卸载不 close;但不 close 会让每个关掉
  的终端永久占一个 per-session 终端槽位(terminalLimit),因此 descriptor
  的 onClose → webTerminals.close() 是唯一且必须存在的回收路径。

测试(判别性证据见交付报告):
- tests/terminal-tab.spec.tsx 14 条:view() 调用形状与 contentId 恒定性、
  mount/detach、write/resize 转发与上限夹紧、snapshot 重放 + acknowledge、
  无服务降级、missingTerminal → 换代号、onClose → close()。
- tests/builtins.spec.ts 内置清单 5 → 6,并新增「terminal-bottom 是
  bottomOnly、其余内置都不是」。
- tests/chunk-artifact.spec.ts 新增产物包含性断言:chunk 里必须有
  xterm(xterm-char-measure-element / @xterm/xterm/lib/xterm.js),
  lib/client.js 与 lib/client-registry.js 里一处都不许有。
- tests/e2e/mount.e2e.ts 第三条真实浏览器用例:先开原生右列(guide 基线
  = 宿主 terminal 恰好 1 条)→ 展开底部工作台(data-active + 布局推挤
  > 0)→ 点空面板的 Terminal 卡片 → 断言 tab 挂载、.xterm 在、chunk 有
  响应、状态不停在 unavailable/loading、宿主 terminal 条目仍为 1 且
  terminal-bottom 条目为 0、无 pageerror / 插件 console 错误。

依赖:@xterm/xterm@^6.0.0 + @xterm/addon-fit@^0.11.0(与宿主自用版本一致,
安装期零脚本,不触市场拒绝名单)。lockfile 只手工拼接这 2 个包的 4 个块:
pnpm add 会顺手重解析无关 caret 范围,产出 99+/69- 的噪声 diff。
2026-10-05 23:42:45 +08:00
Menghuan1918 95db9e4d42 feat(tabs): TabDescriptor.bottomOnly —— 只投底部、永不占原生承载面
#774 的第一条硬约束是「插件的底部终端绝不能变成宿主右列里的第二个
终端入口」(挂载 lane 钉住宿主 terminal guide 条目恰好 1 条)。已有的
两个字段都做不到:`hidden` 会连底部 + 菜单一起摘掉
(buildNewTabOptions 过滤 !hidden),而注册成普通描述符就会自动拿到
原生 tab 类型 + guide 条目。

新增一个显式的 `bottomOnly?: boolean`,效果两处,缺一不可:

- `openTab` 的原生分支条件加 `descriptor.bottomOnly !== true`:落点强制
  bottom(连 `target: 'side'` 也改道)。原生栏里的 tab 不在底部工作台的
  分栏树里,把只投底部的页面送进原生栏是归属矛盾。
- 原生承载面(src/client/native/index.ts 的 sync())跳过它:既不注册
  tab 类型,也不占 guide 条目。

字段带完整文档注释(含与 hidden 的区别、内置用例 terminal-bottom)。
接入文档同步在下一个 docs commit。
2026-10-05 23:42:40 +08:00
Menghuan1918 6776f28f73 feat(i18n): 底部终端词条 terminalNew / terminalUnavailable / terminalGone
#774 的底部工作台终端需要三句话:宿主没挂终端控制器时的说明、绑定
指向的进程已消失时的说明、以及「新建终端」这个动作本身。三者进
locales.ts 的 zh/en 与全部 19 份第三语言词典——键集必须 20 份相等
(tests/locales.spec.ts 守护),只加一份会让整套词典红。

插在 terminalShellNotFound 之后(终端词的既有聚簇),三份中文变体
(zh-HK / zh-MO / zh-TW)沿用「終端」措辞,与各自词典里的 terminal
一致。
2026-10-05 23:42:37 +08:00
Menghuan1918 85c7d12785 chore(shell): 删除 titleBar 让位机制及全部相关配置(#430)
插件自 v0.19.0 起不再自绘顶部 chrome:`223b254` 把那三条读 strip 的规则
(`top: calc(var(--dsh-title-bar-strip, 40px) + 3px)` / 右面板
`padding-top: var(--dsh-title-bar-strip, 40px)` / 折叠态 `+14px`)连同自绘
chrome 一起删掉了。此后「位置兼容模式」四方案仍在写
`--dsh-title-bar-strip` + `body[data-dsh-title-bar-compat]`,但**没有任何
消费者**:`src/**/*.css` 零命中,宿主也不读这条契约(DSH 核心整树 grep
`windowControlsOverlay|dsh-desktop-titlebar-inset|titlebarInset|
title-bar-strip|title-bar-compat` 与 `desktopWindow` 全部零命中)。结果是
用户改设置只写变量、什么都不动,而设置项描述(「标题栏条带高度:侧边栏
按钮与内容下移的像素数」)与现实不符。整套删除,不留兼容层。

删除范围(先做了完整消费者普查,见新增的设计文档):
- 计算与写入:`src/client/titlebar-strip.ts`、`src/client/wco.ts`、
  `src/client/shell-presets.ts` 三个文件整体删除;`Sidebar.tsx` 里的 strip
  计算 + 写 `--dsh-title-bar-strip` / `body[data-dsh-title-bar-compat]` 的
  effect 与 `titleBarCompat` 局部量一并清理。
- 壳信号:`desktop-env.ts` 的 `parseDesktopEnv` / `DesktopEnv` /
  `probeDesktopWindow` 与 `context-types.ts` 的 `SidebarDesktopWindowService`
  (含 Insets / DragRegion)删除。#864 新增的 `desktopWindow` 优先读取随之
  消失。**`desktop-env.ts` 文件保留**:同文件的 `hostTransportBase()` 另有
  3 个消费者(`host-route-url.ts` / `TextEditor.tsx` / `changes/DiffPane.tsx`),
  是反向代理前缀与 `dsh-app://` 自定义 scheme 的解析基准,与本机制无关。
- 配置:`titleBarScheme` / `titleBarPresetId` / `titleBarCompat` /
  `titleBarStripPx` 及 `TITLE_BAR_STRIP_{MIN,MAX,DEFAULT}` / `TITLE_BAR_SCHEMES`
  / `TitleBarScheme` / `clampTitleBarStrip`(`prefs-shared.ts` 的字段与默认值、
  `config.ts` 的 schema 字段、`client/prefs.ts` 的读迁移逻辑)。
- 设置界面:常规行的方案下拉 + 「自定义方案」齿轮弹窗 + `titleBarSchemeValue`
  / `onSchemeSelect` / `detectedEnv` / `stripSettingsOpen` 全部删除;
  **自定义 CSS 逃生口保留**,搬到独立的「自定义 CSS」分组,并去掉 scheme
  门控(非空即生效)。`SideCardSection.module.css` 的死样式 `.rowGear` 同步删。
- 词典:21 份(`locales.ts` 的 zh + en 与 19 个 `locales-*.ts`)同步删除 12 个
  只服务这些设置的 key(`settingsTitleBar*` / `settingsScheme*` /
  `presetDshDesktopDesc`);`settingsCustomCssPlaceholder` 的示例改为
  `[data-dsh-bottom-panel]` + `--dsw-font-mono`,不再引用已删变量。
- 文档:指南 §12.1 重写(删四方案 / strip 取值链 / 壳信号 / 迁移,保留用户
  空间 CSS 与两条拖拽区退出)、§7 的 `toggles` 键清单、AGENTS §5 皮肤契约与
  「契约反向引用」;新增 `docs/plans/2026-10-05-remove-titlebar-compat-strip.md`
  记录普查结论与去留理由。`docs/plans/` 的历史文档未改。

迁移安全(旧偏好数据被安全忽略):四个已删键在 OPEN 的宿主 schema 里是未知键,
解析不报错、不写回(`plugin-shape.spec.ts`);客户端 `parsePrefs` 只按声明字段
构造结果,旧键不进入 UI(`prefs.spec.ts`);一次性 `settings.yaml` 回迁按
`Config.dict` 的声明字段过滤,已删键被丢弃而非转发(`smoke.spec.ts`)。
三条新断言都做过变异证伪:让 `parsePrefs` 透传原记录 / 让 schema 重新声明
`titleBarCompat` / 去掉回迁的声明字段过滤,对应用例分别红在
「不要带上已删键」「解析结果不得含该字段」「回迁不得保留该键」。

测试:删除 `tests/titlebar-strip.spec.ts` / `wco.spec.ts` /
`shell-presets.spec.ts` / `desktop-window-strip.spec.tsx` /
`desktop-env.spec.ts`(五个文件断言的行为已整体移除,不留断言已删行为的测试);
`prefs.spec.ts` / `plugin-shape.spec.ts` / `smoke.spec.ts` /
`side-card-section{,-rows}.spec.tsx` 的夹具与断言改写;`mount.e2e.ts` 删掉 WCO
与壳预设两个场景,URL 戳记场景保留挂载与拖拽区断言、只删 strip 断言,
自定义 CSS 场景改为只写 `customCss`。

门禁:`pnpm typecheck`(0 错误)/ `pnpm lint`(0 问题)/
`pnpm exec vitest run --maxWorkers=3` —— 179 文件 / 2075 passed + 13 skipped
(删除前基线 184 文件 / 2117 passed + 13 skipped;差额 = 5 个被删 spec 的
41 条 + `prefs.spec.ts` 净减 1 条)。词典 parity(`locales.spec.ts`)与皮肤
契约(`theme.spec.ts`)均绿。
2026-10-05 23:38:04 +08:00
Menghuan1918 70d0f8fa09 Merge branch 'dev' into pr/817-dev 2026-10-05 23:18:36 +08:00
Menghuan1918 235212e72a merge fix/412-win32-open-external into dev(#412 Windows 在应用中打开:cmd start → rundll32 候选链,元字符 URL 跳过 cmd;全失败返回结构化错误并落到 UI 提示条,不再静默成功) 2026-10-05 23:17:33 +08:00
Menghuan1918 f894786e1f fix(sidebar): 补齐 #817 的两条设置项文案(zh 写成了英文、en 未改)+ 同步接入指南
复核节点在 de1e76e 上实测出三处必修项,本提交逐条收口(行为零改动):

- R1(用户可见回归):`locales.ts` 的 **zh** 词典里 `settingsSubagentDesc` /
  `settingsJobsDesc` 被写成了**英文**句——紧邻的 `settingsSubagentTitle` 仍是
  中文,`active: 'zh'` 下这两行设置项直接显示英文。现改回简体中文,内容与已改
  好的 zh-TW / zh-HK / zh-MO 三份对应(页面仍创建 + 未读红点 + 不抢焦点 +
  关闭后不再自动创建)。
- R2(同根、写反的另一半):**en** 词典的这两条**根本没改**,仍是旧行为原文
  ("Activate the Tasks page when…"——而现在的行为恰恰是不接管)。现把 de1e76e
  写进 zh 的那两句英文挪到它们本该在的 en 上。
- R3(违反 AGENTS §5「接入 API 即文档」):`docs/external-plugin-guide.md` 补上
  本次新增的两个公共 API——`OpenTabSeed.reveal?: boolean`(§7 的 seed 接口块)
  与 `BetterSidebarService.clearUnread(type, sessionId)`(§7 服务方法清单),
  并在 §0 的承载面要点里加一行索引;措辞与既有条目一致,均标 **v0.25.0+**。
- N1:`tests/sidebar-auto-activation.spec.tsx` 删掉一条误导性死代码
  (`reduceFor(... unread: [])` 对断言是空操作:它只写 bySession + 落盘,既不更新
  snapshot 也不 notify;证伪见提交后报告——保留该行、去掉 `activateTab` 一行,
  用例照样红)。
- N3:unread 的持久化往返此前零测试(`sanitizeState` 的 `Array.isArray(record.unread)`
  分支无人守护)。`tests/state.spec.ts` 新增判别性用例:写入未读 → 落盘 → **新
  store** `setSession` 读回。还原该分支后用例红在 `state.unread === undefined`。

文案核对:改后 `active:'zh'` 返回简体中文、`active:'en'` 返回新英文句;20 份词典
的这两条现在与 de1e76e 之前的版本**逐份不同**、且没有任何一份还留着旧句。

门禁:`pnpm typecheck` / `pnpm lint` / `pnpm exec vitest run --maxWorkers=3`
(179 文件 / 2058 passed + 13 skipped)全绿。
2026-10-05 23:13:23 +08:00
Menghuan1918 307513561b fix(explorer): Shift 连选改用渲染序(#132)
`visibleRows` 的 walk 枚举的是层级缓存的宿主序(`level.entries`),而
`renderLevel` 画的是 `sortEntries(level.entries, sort)` —— 排序控制一旦
离开默认档,Shift 连选的坐标系就和用户看到的行序错位:视觉上连续的一段
只选中两端,中间被排序挪过位置的行漏选(实测 `[beta, Gamma.MD]` vs
`[beta, zdir, Gamma.MD]`)。

危害不止观感:批量条的 Copy paths / Zip and download / Delete selected 都
作用于这个错误集合,而批量删除确认框只显示数量、不列路径。

让 walk 跑同一个 `sortEntries(...)`,并把 `sort` 加进依赖数组——两条路
(渲染 / 选择)从此共用一份有序视图。

判别性用例 tests/file-tree-select-order.spec.tsx:夹具宿主序
`[zdir(dir), alpha.ts, beta, Gamma.MD]`,非默认档
`{key:'type', dirsFirst:false}` 下渲染序为
`[beta, zdir, Gamma.MD, alpha.ts]`;Ctrl 点第 1 行 + Shift 点第 3 行必须选中
恰好这 3 行。在还原后的源码上该用例红(`expected [ 'beta', 'Gamma.MD' ] to
deeply equal [ 'beta', 'zdir', 'Gamma.MD' ]`),修复后绿。
2026-10-05 23:11:11 +08:00
Menghuan1918 de1e76e2f5 feat(sidebar): 后台激活的页面不再顶掉读者,改为标记未读红点
维护者在 #817 上批准了「后台自动激活不接管右侧栏」的行为,并要求同批补上
「后台新开了页面」的提示:事件不能丢,但也不能把读者正在看的页面顶走。

行为:
- 被门控跳过的那次激活仍然创建任务管理页,只是不再抢焦点
  (`OpenTabSeed.reveal: false` → 宿主 `revealIfOpened: false`,即
  「放置但不聚焦」;页面类型本来就没有自己的聚焦路径,已经存在的页面
  再开一次也只是一次聚焦,正是门控要拒绝的那件事)。
- 该页在原生右栏芯片与插件底部工作台对应页签上显示一个静态小红点
  (`aria-label` = 新词条 `tabUnread`,颜色取既有 `--dsw-alias-danger`)。
- 读者切到该页即清除标记:底部工作台走 service.activateTab;原生栏的
  点击插件看不见(`ISidebarRight` 只有 `active()` 读取器,没有选中事件流),
  所以由宿主自己的芯片按 `tab.visible` 清除——非可见芯片不清除,
  否则宿主为每个展开页签都画标题,红点刚亮就会被抹掉。
- 标记存进会话状态的 `unread: TabType[]`(随布局持久化,跨挂载/跨会话/
  刷新都在),两个承载面读同一份,不会各自为政。

文案:20 份词典同批更新两条设置项描述(门控行为变了)+ 新增 `tabUnread`
词条(ja 真日文)。

测试:`tests/sidebar-auto-activation.spec.tsx` 的门控两条改为断言
「页面仍创建 + revealIfOpened:false + 标记出现」,并加红点生命周期与
「已在任务页/正常激活不标红」三条;新增 `tests/native-tab-unread.spec.tsx`
钉住原生芯片这一承载面(画点、按 visible 清除、非可见不清除、别的类型
不串味、不破坏可访问名)。判别性用 6 处镜像还原逐条证伪(见报告)。
2026-10-05 23:03:40 +08:00
Menghuan1918 f6f7629b23 fix(open-external): Windows「在应用中打开」改为 cmd start → rundll32 候选链,全失败不再静默成功(#412)
现象(#412):Windows 上右键「在应用中打开」经常没反应。核实:`urlCommand` 的 win32 分支
只有 `rundll32.exe url.dll,FileProtocolHandler <url>` 一条候选,而 rundll32.exe 在任何
Windows 上都存在、spawn 必然成功 → 路由回 `{started:true}`,UI 拿不到任何失败信息。

修法:
① `urlCommand` → `urlCommands(...): ExternalCommand[]`(有序候选链):win32 为
   `cmd.exe /d /c start "" <url>` → `rundll32.exe url.dll,FileProtocolHandler <url>`
   (空首参是 start 的窗口标题,缺了它带引号的 URL 会被当成标题、只弹空控制台);
   darwin / linux / android / WSL 仍是单元素,语义逐字不变。
② URL 含 cmd 元字符(& % ^ ! | < > ")或控制字符时**跳过 cmd 分支**直接走 rundll32:
   Node 的 argv 引用拦不住 `cmd /c` 的第二次解析(%VAR% 展开、&/| 截断、^ 吞字符、"
   打乱引用),而 rundll32 以单个 argv 收到 URL、什么都不解释。
③ `launchExternal` 顺序尝试候选:只有 Node 发出 `spawn` 才算成功,同步抛错与 `error`
   事件都推进到下一候选;**全部候选失败**时抛 `SidebarError('internal', …)`,消息里逐个
   列出命令与底层报错(走既有 `{ok:false,error:{code,message}}` 信封)。
④ 调用方一并改形状:`EditorHost.openWith` 返回「是否被接受」(失败仍 console.error 留痕),
   `FileTree` 据此把失败渲染进既有 `openInAppFailed` 错误条——复用词条,未新增词典 key。

测试:
- tests/open-external.spec.ts:候选链顺序、元字符跳过规则、空格 URL 仍是单个 argv、
  失败回退顺序、全失败错误形状(含 `&` URL 只尝试 rundll32、reveal 分支的 path 措辞)。
- tests/open-external-windows.spec.ts(Windows lane,pnpm test:windows):只注入两个
  「不可能存在」的可执行名(`WindowsOpenerOptions` 测试缝),走**真实 spawn** 断言两条
  候选都失败时错误被回报而不是静默成功;**绝不拉起任何应用**(detached:true 会开真窗口,
  所以生产命令名一个都不在测试里出现)。
- tests/file-tree-open-with.spec.tsx / tests/editor-host.spec.tsx:被拒(返回 false)与
  抛错的打开都必须落进错误条,console-only 即红。

判别性(临时还原源码改动后跑新增用例,随后逐字恢复、md5 校验一致):
- 候选链退回单 rundll32(`if (false && …)`)→ 9 red(含 Windows lane 两条)
- spawn error 仍回 `{started:true}`(旧的「从不失败」契约)→ 6 red
- 去掉元字符跳过 → 11 red
- FileTree 不再上报失败 → 3 red
- EditorHost 恢复吞错 → 1 red

限制(写入设计文档):`start` 与 rundll32 在 handler 忽略 URL 时都退出 0,
「已启动但没打开」仍不可从退出码探测。
2026-10-05 22:58:01 +08:00
Menghuan1918andfinley08 0655b88629 feat(explorer): 资源管理器补「新建文件」+ 排序三档(#132)
第一部分:新建文件(移植贡献者 PR #832 的交互语义,写路径改落服务端)
- 新增路由 fs.createFile → fs-operations.ts 的 createWorkspaceFile:单段名、
  已存在即拒(fs-error 409,同一句 "x" already exists,绝不截断同名文件,
  落盘用 wx)、拒绝 Windows 非法字符(< > : " | ? * 与控制字符)与保留设备名
  (CON / PRN / AUX / NUL / COM1-9 / LPT1-9,带不带扩展名都拒)、路径穿越
  (..、a/b、a\b)与空名一律 bad-request 400
- src/client/api.ts 镜像 fsCreateFile;FileTree 目录行右键「新建文件」与
  「新建文件夹」并列,复用同一套行内输入(Enter 提交 / Escape 取消 / 失焦提交
  / IME 保护,图标跟随输入名),两者互斥;客户端先在已加载层做大小写不敏感的
  占用检查(newFileExists),服务端仍是最终裁决
- 词条 newFile / newFilePlaceholder / newFileInvalid / newFileExists 进入
  locales.ts 的 zh/en 与 19 份第三语言词典(ja 为真日文)

第二部分:排序三档(名称 / 类型 / 文件夹优先开关)
- 新增 src/client/file-tree-sort.ts:对 level.entries 的副本排序,不改服务端、
  不原地重排共享目录缓存;默认(名称 + 文件夹优先)与宿主 fs-tree.ts 的
  compareEntries 逐元素一致
- 控件落在文件树头部既有工具区(TreePanel 搜索行的刷新按钮旁):IconButton +
  Menu(名称 / 类型打勾 + 文件夹优先独立开关),沿用既有控件样式与可访问名
- 「按修改时间」不在本批范围

测试:tests/fs-create-file.spec.ts(11)、tests/file-tree-new-file.spec.tsx(11)、
tests/file-tree-sort.spec.tsx(12),并修 tests/file-tree-hover-title.spec.tsx 的
夹具顺序(原夹具不是任何宿主会返回的目录序)

Co-authored-by: finley08 <fazhang08@163.com>
2026-10-05 22:57:58 +08:00
Menghuan1918 9c18f05441 Merge remote-tracking branch 'origin/dev' into pr/817-dev 2026-10-05 22:48:47 +08:00
Menghuan1918 504d428b79 fix(git-lens): 纯重命名不再计入分组合计,计数簇改用字体令牌(#131)
(a) numstat 为 0/0 的条目(纯重命名、仅改权限)行上什么都不打印,但
sumLineCounts 仍把它计进 files,于是「只含纯重命名的分组」在分组头渲染
出一个空的 +N −M 计数簇。合计函数改为跳过两侧都为 0 的条目:合计=「行上
真的打印出来的数字之和」,与既有「二进制 / 未跟踪不贡献任何数」同一条
口径。只改这一个源头,两个分组头共用的 files > 0 门控不用动。

(b) .lineCounts 的裸 font-size: 10px 换成 font: var(--dsw-font-xxxs-11)
(11px/14px,weight 400),并按简写要求在其后用 font-family 覆盖回
--ds-font-family-code 代码字体。前后值:10px(行高继承 18px)→ 11px/14px;
行与分组头都是 28px 固定高度、文字 18px 行高,故布局不变,只有数字本身
大 1px。

测试:
- change-tree-counts:新增 0/0 条目不参与合计(纯重命名 / 仅改权限),
  同时钉住「改了内容的 rename 仍贡献数字」。
- changes-tab:新增「只含纯重命名的两个分组都查不到 [data-lines="group"]
  空计数簇」用例(并断言两个重命名行确实渲染了,避免空过),配一条对照
  用例「组内真有数字时计数簇照常出现且数字正确」;另加一条样式守护,钉住
  .lineCounts 走 --dsw-font-* 令牌、不含裸 font-size px。
- 还原源码/CSS 改动后这三条全红(空 span 被断言到、font 令牌断言失败)。
2026-10-05 22:39:22 +08:00
Menghuan1918 ce8366fb11 fix(editor): blame memo 在变更集消失时也失效(#212)
effect 原先在「文件已无变更集」(提交 / 丢弃后 entry === undefined)的
早退分支里直接 setKinds(EMPTY_KINDS) 返回,forgetBlame 只在有变更集的
分支才跑。于是提交前 hover 过的行继续返回提交前的 blame——包括
「Not Committed Yet」这类未提交占位——直到该文件再次产生变更集,或
memo 触顶 500 被整体清空。

把 forgetBlame 提到早退之前:变更集被重算与被清空都是失效条件。不改
过期时间,也不加缓存层。

测试:
- 新增(判别性)「提交前 hover → 变更集消失 → 再取同一行」用例,断言第
  二次重新请求且不再返回提交前答案;还原源码改动后该用例红在
  `expected "vi.fn()" to be called 2 times, but got 1 times`。
- 补一条原无守护的用例:挂载 code 视图后 api.gitBlame 调用数为 0(不预
  取),同时断言变更集确实读到了(gitDiffHead 1 次 + 色条 gutter 在
  DOM 里),避免断言因「gutter 根本没装」而空过。
- 既有的「同一行 hover 两次只打一次 git」保持为 memo 生效的守护。
2026-10-05 22:36:10 +08:00
Menghuan1918 bce22cfaf1 merge feat/212-editor-git-gutter into dev(#212 编辑器变更提示:code 视图行号槽着色 + 左侧细色条 + hover blame,一个布尔开关,样式极简) 2026-10-05 22:32:26 +08:00
Menghuan1918 2c8d11a8fc feat(editor): 编辑器未提交变更提示(行号着色 + 左侧色条 + hover blame)(#212)
code 视图(可编辑 CodeMirror)显示未提交变更的行级提示,一个布尔设置
editorGitGutter(默认开)总开关:

- 行号槽着色 + 行号左侧 2px 细色条(新增/修改/删除),取色复用文件树
  既有 tone 口径(--dsw-alias-state-*);
- hover 某行时按需取该行 blame,纯文本 tooltip(作者 · 时间 + 摘要),
  按 sessionId+path+line 记忆化,不预取整文件、滚动不重复请求;
- 行映射复用既有 useGitStatus 共享 store 与既有统一 diff 引擎
  (parseUnifiedDiff/unifiedSegments),不新增第二个 git status 轮询器;
  未跟踪文件按状态 store 整篇标新增;
- 新增宿主路由 git.diff-head(git diff HEAD,部分暂存时给出已暂存+未暂存
  的整份未提交变更,未出生 HEAD 回退 --cached)与 git.blame
  (git blame --porcelain -L,四条失败路径一律返回空,不抛);
- 只给 viewerId === 'code' 挂 decoration/gutter/tooltip,markdown/html 与
  关闭设置后不安装任何扩展;开关经 Compartment 原地重配。

不做行尾常驻作者 widget、不做徽章、不做动画、不做渐变、不做四个独立开关。
2026-10-05 22:25:51 +08:00
ymac 5f90f1d466 Merge remote-tracking branch 'origin/dev' into fix/826-file-link-line-jump
# Conflicts:
#	CHANGELOG.md
#	src/client/FileTree.tsx
#	src/client/desktop-env.ts
2026-10-05 22:20:24 +08:00