Commit Graph
1190 Commits
Author SHA1 Message Date
Menghuan1918 01c98b1c29 merge fix/dock-toggle-anchor into dev(备用入口锚点要认宿主角落控件的两种形态:右侧栏打开时 data-sidebar-right-expand 整个消失、同一座位换成 data-sidebar-right-toggle,只认前者就会落到视口兜底坐标 innerWidth-44——那里正是宿主自己的角落按钮群,实测重叠 18px;含判别性用例) 2026-10-09 21:33:39 +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
unsc9 ebc5d0b6b7 refactor: 精简 dev 相对 main 新增代码里的重复与白干(行为不变)
dev 分支的新增代码过了一轮「代码精简」审查(复用 / 简化 / 效率 / 修在哪一层四个角度,
分宿主侧、客户端外壳、客户端功能面板三片,另加测试与脚本),这里只落地行为完全不变的那批:

- `runGitRaw` 是 `runGit` 的纯转发别名(三个角度都点到):导出 `runGit`、删掉别名,
  `active-worktree.ts` 与它的 `vi.mock` 键同步改名。
- `open-external.ts` 的 `messageOf` 与 `fs-tree.ts` 的导出逐字相同:删本地实现改 import。
- `fs-operations.ts` 的单段名校验抄了三遍(注释却自称 shared rule):提成
  `assertSingleSegmentName`,rename / mkdir / 新建文件三处共用。
- `fs-tree.ts` 两个探测函数各抄一遍有界并发池:提成 `forEachRow`。
- `index.ts` 自己复刻了一遍 `request/header` 的 provider/model 读取:改调
  `collectModelRoutes(events, 1)[0]`;`lowestReasoningEffortOf` 的三态循环收成
  best/bestRank;`formatModelRoute` 零调用点,删掉(连带自测)。
- `state.ts`:`markUnread` / `clearUnread` 的当前会话路径改走已有的 `reduce`
  (「归约器返回同引用即 no-op」本来就在 reduce 里),删掉私有的 `replaceCurrent`;
  非当前会话那条仍只写内存不落盘,行为未动。
- `editor-dirty.ts`:`DirtyEntry.sessionId` 只服务一个没有生产调用者的
  `dirtyCountForSession`,会话隔离已由 `sessionId::tabId` 这个键承载,两个一起删,
  用例改断 `isEditorDirty(tabId, sessionId)`。
- `FileTree.tsx`:同一批行原先 `renderLevel` 与 `visibleRows` 各排一次,收进按
  `(data, sort)` 记忆的 `entriesFor`(照 `chainFor` 的形状)。
- `dock-fallback.tsx`:500ms 重测出的坐标没变就不换 state 对象(省掉一次无意义重渲染)。
- 其余同形收口:`DiffPane` 的死分支、`terminal-client` 的 `bottomTerminalKey`
  (与 `bottomTerminalContentId` 同值,调用点复用同一个 id)、`SideChatView` 的
  O(线程×目录) 排序扫描降为 Map、`conversation-draft` 的末段路径复用 `paths.baseName`、
  `TreePanel` 的目录命中集按 results 记忆。

验证:`tsc --noEmit` 只剩改动前那 3 条缺 `@xterm/*` 的既有报错;eslint 干净;
全套 vitest 与改动前的失败集合逐条一致(13 条,均为环境原因:缺 xterm 的构建/转换类
3 条、Windows 符号链接权限 3 条、语言字典串味 4 条、真起 git 的冒烟 1 条、文件级 1 条)。
2026-10-09 16:04:24 +08:00
unsc9 9021d1094e fix(client): 草稿守卫按会话记账、折叠行重命名落链尾、16 位小端数据不再当文本
代码审查第一档的三条真实缺陷(都带判别性用例):

- 未保存草稿的注册表改按 `sessionId::tabId` 记账。原生/工作台 id 只在**会话内**唯一
  (每个会话各自铸造 tab1…,工作台对同一文件在各会话复用 editor:<path>),按裸 tab id
  记账时会话 B 的编辑器挂载会报 clean 并删掉会话 A 的记录 —— 记录一没,刷新守卫就放行,
  A 的草稿静默丢失。读/清/确认三个入口都带上会话;不带会话时按「任一会话命中」保守处理
  (宁可多问一次,也不放过活着的草稿)。
- 折叠行(a/b/c 一行)的重命名提交**链尾**:菜单与预填名都指向链尾,提交却用了行渲染所在
  的链头 —— 不改字直接回车会把父目录改名。
- 无 BOM UTF-16 探测加一道「解码结果必须是文本」:16 位小端数据(值域 <256 的采样表/音频
  缓冲)高字节恒 0,与 UTF-16 的 NUL 车道一模一样,被当文本打开后可编辑、保存按 UTF-16
  整份改写(奇数长度还会丢尾字节)。真实 UTF-16 脚本/配置照旧识别。

测试:editor-unsaved-guard 新增跨会话回归两条并改写旧的「同 id 跨会话重指向」语义、
file-tree-compact-fold 新增折叠行重命名落链尾、text-encoding 新增 16 位小端判二进制
(同形状的真文本仍判 UTF-16)。
2026-10-09 15:25:53 +08:00
Menghuan1918 36f944be55 merge fix/dock-toggle-duplicate into dev(修「展开底部面板」按钮叠成两个:两套入口的互斥原先只靠 1s 轮询的 session.phase,而会话头入口由宿主自行决定渲染时机、相位失读还会按非 blank 降级——而备用入口与会话头入口在版面上就是同一位置,同时在场即精确重叠;现加一条与相位无关的兜底:会话头那套入口只要真在 DOM 里,备用入口就让位,含判别性用例) 2026-10-09 10:29:10 +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 d588cff0af merge fix/editor-host-render-wait-2 into dev(慢 runner 假失败再收一刀:mount helper 只 drain 微任务,负载下 React 可能把树的那次 flush 整个推迟到微任务之后——上一版 5s 条件预算被整整耗光(5044ms 红,下一轮同样代码就绿);现在条件等待前先让出一个宏任务边界,预算抬到 10s,仍在套件 15s testTimeout 之下,真正列不出该行照样红在断言上) 2026-10-08 22:46:31 +08:00
Menghuan1918 e656d5ba11 test(editor-host): 条件等待前先给一个宏任务边界,预算抬到 10s
`05d259cc` 把 `waitForTreeRow` 换成显式条件预算后,CI 上仍然红了一次,而且这次
**整整耗光了 5s**(5044ms,`vi.waitFor.timeout tests/editor-host.spec.tsx:89`),
下一轮同样的代码又是绿的 —— 说明问题不只是「预算太小」,而是那一轮里树的那次
flush 根本没被排上。

mount helper(`mountHostWithTreeWithCwd` 等)只 drain 两个微任务,而负载下 React
把异步 `fs.trees` 应答引发的 `setState` + flush 整个推迟到微任务之后是完全可能的
(`630d10f` 的提交信息已经记下这个机制)。所以现在在条件等待之前先让出一个**宏任务
边界**,给那次被推迟的 flush 一个真正运行的机会,再把预算放在 10s(仍在套件
`testTimeout: 15s` 之下,真正列不出该行时照样红在断言上,而不是红在测试时钟上)。

纯测试改动;本机 `tests/editor-host.spec.tsx` 14/14 绿。
2026-10-08 22:46:27 +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 331508e2a4 docs(changelog): 记录 #890(编辑器显现即重新测量)与 #859(桌面壳 HTTP 走页面基址) 2026-10-08 21:58:42 +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 a735567b55 merge fix/editor-host-render-wait into dev(修 editor-host 在慢 runner 上的渲染等待:vi.waitFor 的 1000ms 默认超时与套件的 testTimeout:15s 无关,负载 runner 上树的行还没渲染出来就先超时——dev 与 #890/#859/#893 三条 lane 同时红在同一个用例上;改为显式 5s 条件预算,仍是「等条件」而不是「等固定时长」) 2026-10-08 21:58:13 +08:00
Menghuan1918 5d259cca61 test(editor-host): 慢 runner 上给「等树渲染出行」一个 5s 条件预算
CI(ubuntu lane,2 核、与 184 个文件并行)稳定红在
`tests/editor-host.spec.tsx > EditorHost native-tab context-menu actions >
keeps the bottom-workbench split for a tab that lives there`,签名是
`AssertionError: expected false to be true`、落在 **spec:74**(`waitForTreeRow`
里的 `expect(found).toBe(true)`),耗时 ~1026ms —— 正好是 `vi.waitFor` 的
**默认 1000ms**。

根因不是产品缺陷,而是预算错配:`vi.waitFor` 的默认超时与套件的
`testTimeout`(15s,当年为 Windows lane 的真实子进程抬的)**互不相干**,仍是 1s。
上次 `630d10f` 已经把这个 helper 从「drain 微任务」改成「等真实渲染条件」,但条件
等待的预算没跟着抬,于是一旦 `fs.trees` 的应答 + React flush 越过 1s(满载的
2 核 runner 上很容易),断言还是先超时。

本机复现(往 `fs.trees` mock 注入 1200ms):
- 默认 1s 预算 → 1049ms 红,签名与 CI 逐字相同;
- 5s 预算 → 1296ms 绿。

仍是**条件**等待而不是固定时长:行一渲染出来就返回;树永远列不出该行时用例照样
失败(只是从 1s 变成 5s),`630d10f` 的反判别性检查继续成立。测试改动,产品代码
零改动。同一暴露面还有 7 处 `vi.waitFor` 未给预算(`zip.spec.ts` ×4 /
`dock-fallback.spec.tsx` ×2 / 本文件外),暂未在 lane 上翻车,未一并改动。
2026-10-08 21:58:13 +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 90a88670de docs(plans): 给工作区围栏设计文档补「后续偏差」(围栏已于 v0.23.0 移除、fs.search 现在会越界)
这份 2026-08-29 的设计文档状态仍写着「已实现」,末句「`fs.search` 不动——它锚定
cwd 向下走,本来就不会越界」两处都已失真:

- 围栏本身在 v0.23.0 被用户要求整体移除(`path-security.ts` 只剩解析语义,
  `isWithin` 退化为客户端词法工具、不再是安全边界);
- #879 之后 `fs.search` 新增指名目标的直开分支,命中确实会返回工作区外路径。

按 AGENTS §6「docs/plans 逐特性设计,含实施偏差记录」补一节「后续偏差」,
并把状态行改为「已实现、随后整体移除」。纯文档改动。
2026-10-08 21:48:56 +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
Menghuan1918 c241f8336c merge fix/883-streamlines-close into dev(#883 streamLines 结算事件 exit→close:Node 的 exit 在进程死亡瞬间触发、stdout 管道可能仍有未排空数据,负载高时 Promise 带着空 lines resolve,fd 的 --type d 第二路因此偶发返回 matches 完好 + dirs 空;同时删掉 runChild fd 分支把 rejection 吞成「目录恰好为零」的 catch,让失败流进 runEngine 既有的 broken + JS 回退。含 setEngineHooks 的 spawner 缝隙与两条确定性用例) 2026-10-08 21:46:48 +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 4e51e0789c merge fix/editor-host-mount-race into dev(修 editor-host 在慢 runner 上的文件树加载竞态:等真实渲染条件而非 drain 微任务;纯测试改动,含反判别性检查与 300ms 注入下的 A/B 对照) 2026-10-06 01:19:39 +08:00
Menghuan1918 630d10fb54 test(editor-host): 等文件树真的渲染出该行再断言(修慢 runner 上的加载竞态)
两个 mount helper 只 drain 微任务,而文件树层级缓存由异步 fs.trees 应答填充:一旦那次刷新
被排成宏任务,helper 返回时树仍在 loading 行,断言就找不到 [class*="explorerName"](CI 上
names= 为空 / 本地注入延迟时 names=tmp,CI 只报了第一个挂掉的用例,同一模式实际影响 3 个)。

改为 vi.waitFor 等待真实渲染条件(不是调大固定超时):树真列不出该行时仍按 1s 超时失败——
反判别性检查(把 mock 里的 a.ts 换成永不出现的 b.ts)确认 3 个用例仍会在 1.0s 内失败。
300ms 宏任务注入下:修复前 5/5 轮全红(各 3 用例)→ 修复后 5/5 轮全绿 14/14。

纯测试改动,产品代码零改动(与 #855 无关:把 EditorHost.tsx 单独 revert 到 #855 之前,
同一探针仍 3/3 轮全红、文本逐字相同)。
2026-10-06 01:19:38 +08:00
Menghuan1918 91f9910ad6 docs(changelog): 记录 CRLF 三层 \r 误判与预览双拼写渲染的修复及未修的保存侧归一 2026-10-06 00:59:49 +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 4fdbaa158a merge feat/855-editor-auto-refresh into dev(#855 P1 编辑器预览在 LLM 改完文件后自动刷新:信号源用既有 changes.ops 增量流、每会话一条共享消费者 + 成员选举(N 个 tab 每 tick 仍 1 个请求)、只刷新命中且未命中零重读、dirty/编辑态一律跳过不覆盖用户输入、含 14 条判别性用例)
# Conflicts:
#	CHANGELOG.md
2026-10-06 00:56:50 +08:00
Menghuan1918 34ce191981 docs: 修正 #855 的用例数、脏态出口口径与轮询叠加口径
- **[硬数字]** CHANGELOG 的 `tests/editor-auto-refresh.spec.tsx` 用例数
  11 → 14(原本就少 1,加上本批新增 2 例);同批核对:既有 #167 的 4 条、
  2.5s 节奏、「N 个编辑器 tab 每 tick 1 个请求」均属实。
- **[用户可见承诺]** 删掉「dirty / 编辑态由既有的『编辑 → 预览』边沿补刷」
  这句不成立的话:该边沿**自身带 dirty 守卫**(`EditorHost.tsx` 的边沿判定
  要求 `dirty !== true`,`tests/editor-refresh.spec.tsx` 的 B 例两半都钉住了:
  干净时 fsRead 1→2,dirty 时仍是 1)。按事实改写为:未 dirty 时点页头
  「预览」会重载并拿到新内容;dirty 时该边沿被抑制,真正的两条出口是**页头
  刷新按钮**(`window.confirm` 后重载)与**「保存 → `fs-conflict` 横幅的
  reload」**(保存带 `mtimeMs` 基线,不会静默覆盖模型字节)。结论句:dirty
  期间保持旧内容直到用户显式动作,**不存在看不到新内容的死路**。指南 §5.2、
  指南行为差异表、CHANGELOG、设计文档 §4.2 四处同步。
- **[叠加口径]** 同一会话同时开着文件变动页(会话透镜)与编辑器时,该会话
  每 tick 是 **2 个** `changes.ops` 请求——「每 tick 1 个」只算编辑器这一份。
  一次性探针实测:会话透镜单独 1/tick、编辑器单独 1/tick、两者同开 2/tick
  (记进 CHANGELOG、指南行为差异表与设计文档 §4.1)。
- 设计文档 §5/§6 的用例数与门禁数字同步为本次实测(184 文件 2152 通过 /
  13 跳过 / 0 失败)。
2026-10-06 00:55:52 +08:00
Menghuan1918 dc04efaabf test(editor): #855 收尾——补 read 与 opBaseline 两条判别性守护
独立验证节点列出的两处测试盲区,逐条补判别性用例(12 → 14 例):

- **「只认 write/edit」这半个判据此前无守护**(变异:把命中判据放行
  `kind === 'read'` 后原有 12 例全绿)。新增「B: 模型 read 本文件零重读」:
  读出的是最近一次「模型读这个文件」的调用,字节没变,任何重读都是多余。
  变异复验:放行 `read` → 仅该例红(`expected 2 to be 1`),其余 13 例绿。
- **`EditorHost` 的 `opBaseline` 守卫此前未被判别**(变异:放松守卫后原有
  12 例全绿)。新增「I: 重新定向到刚被 touch 的路径不重复读」:同一 tab
  切到刚被模型写过的路径时,它自己的加载就是那次写入的新鲜读数,不得再重读
  重挂(否则滚动位置在字节相同时被丢掉)。变异复验:只留 `null` 判断、不再
  按路径比对基线 → 仅该例红(`expected 2 to be 1`),其余 13 例(含原有
  12 例)绿 → **保留守卫**,不是「只省一次多余重读」。
  附注:把守卫连同消费行一起删掉是更狠的变异,会在这条例上变成重载自旋
  (隔离运行 15s 超时),全量跑还会因该自旋污染后续用例——两个变异都只用于
  取证,源码已逐字节还原(`git diff --exit-code` 干净)。
2026-10-06 00:55:49 +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 3e2387653f docs(changelog): 为 #363 落地补上贡献者署名与其 PR 状态 2026-10-06 00:38:01 +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 97e353599e merge feat/774-terminal-tab into dev(#774 插件内置底部终端 tab:新内置类型 terminal-bottom + TabDescriptor.bottomOnly、宿主 webTerminals 结构化探测供 PTY、xterm 整份进新 chunk lib/client-terminal.js、刷新靠恒定 contentId 认回同一 shell;含验证后的收尾修正:bottomOnly 原生承载面的单元守护、关闭路径空 sessionId 防御、判别性断言修正、文档数字与口径) 2026-10-06 00:14:04 +08:00
Menghuan1918 243e09a789 docs: 合并后重测 chunk 体积(748,716 B)并同步测试地图
- CHANGELOG:chunk 体积按**合并 dev 之后的树**重测为 **748,716 字节**
  (`pnpm build` 连跑两次一致)。该 chunk 还内嵌 zh/en 词典,dev 删掉 12 个
  titleBar key、又加进 #132 / #817 的新 key,所以这个数字随词典增删浮动——
  #774 分支单独构建时是 749,897 字节;两个数字都写进条目,避免下一个读者
  以为又写错了。
- AGENTS §6 测试地图:`native-registration.spec.ts` 的守护清单补上
  「`bottomOnly` 描述符不产生任何原生注册」。
2026-10-06 00:11:12 +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 66eb494bb3 docs: 修正 #774 的三处不实数字与 e2e 入口口径
- CHANGELOG:chunk 体积 750,030 → **749,897** 字节(实测 wc -c
  lib/client-terminal.js);chunk 名镜像点 9 处 → **8 处**(按 AGENTS §5 口径,
  tests/manifest-consistency.spec.ts 从 CHUNK_NAMES 派生,无需字面量改动)。
- e2e 入口写法改正:lane 点的是**空面板的类型卡片**(PaneEmptyCards,与 `+` 菜单
  同一份 buildNewTabOptions),不是 `+` 菜单;并注明 `+` 菜单那条点击路径 lane 里
  没有覆盖。计划文档同步。
- 计划文档第 6 节:「未验证:真实挂载 lane」改为已实测(实现节点与独立验证节点都
  跑过),并如实写明**完整 lane 曾因无关 spec zz-expand-refresh 抖动失败过一次、
  单独重跑即过**,所以「完整 lane 一次通过」不能当证据用。
- 计划文档与 CHANGELOG 同步本次新增的单元守护与用例数(14 → 15 条)。
2026-10-06 00:06:40 +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 1f6e2ea5d0 docs(changelog): 记录 titleBar 让位机制的整套移除与其旧数据安全忽略 2026-10-05 23:55:21 +08:00
Menghuan1918 868e221689 merge chore/430-drop-titlebar-strip into dev(删除整套 titleBar 让位机制与配置:titlebar-strip / wco / shell-presets 三个模块、4 个偏好键与设置控件、12 个词典 key × 21 份词典、5 个 spec;保留 hostTransportBase 与自定义 CSS 逃生口;含三层旧数据安全忽略的迁移测试) 2026-10-05 23:55:12 +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 2ac881d10b test(markdown): cover the changes reading pane, line destinations, hidden anchors (#363) 2026-10-05 23:47:28 +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