feat(sidebar): 菜单层级/性能 + 选中条吸底 + 打包进度 + 修复「在侧边打开」

用户实测反馈 5 条:

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

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

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

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

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

验证:typecheck / lint / test(135 文件 1461 通过)/ build 全绿;
DSH_CMD='npx -y --package @deepseek-ai/dsh@0.1.7-rc.1 dsh' pnpm test:mount 7/7 通过;
新增/更新测试:menu-perf(3)、archive(10)、open-in-app(18)、open-with(10)、multiselect(9)、
zip(37)、service(64)、editor-host(11)、builtins(23)、locales(20)
This commit is contained in:
Menghuan1918 committed 2026-09-28 20:11:46 +08:00
1 parent 13d4bae321
commit ee1fe05067
41 files changed
+2228 -597

No files matched your search

+19 -5
View File
@@ -416,8 +416,14 @@ export interface OpenTabSeed {
* the plugin's content is registered there as native tab types; `'bottom'`
* is the plugin's own bottom workbench. Only the plugin's own flows pass
* `'bottom'` (the bottom panel's + menu, the auto-terminal).
*
* `'side'` also means the right Sidebar, but it lands in a SECOND pane
* there (`preferNewPane`, the host's own split): that is the "open to the
* side" action, which must not fall back to the bottom workbench a native
* tab never lives in. A path-less editor seed is the file explorer page, so
* `'side'` only changes where a path seed lands.
*/
target?: 'right' | 'bottom'
target?: 'right' | 'bottom' | 'side'
}
/**
@@ -449,9 +455,9 @@ export interface NativeTabParams {
*/
export interface SidebarSurface {
/** Open a page type in one session's native surface. */
openTab(input: { sessionId: string; kind: string; params: NativeTabParams; revealIfOpened: boolean }): void
openTab(input: { sessionId: string; kind: string; params: NativeTabParams; revealIfOpened: boolean; preferNewPane?: boolean }): void
/** Open a resource address in one session's native surface. */
openResource(input: { sessionId: string; address: string; line?: number; revealIfOpened: boolean }): void
openResource(input: { sessionId: string; address: string; line?: number; revealIfOpened: boolean; preferNewPane?: boolean }): void
/** The file address of one path (the native surface owns the grammar). */
fileAddress(sessionId: string, cwd: string | undefined, path: string): string
/** Close one native tab; the closed record's type/title, or undefined when the id is not native. */
@@ -900,6 +906,12 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
// included) as navigation params, which the tab adapter merges onto the
// synthetic record's `tab.path` for the registered component.
if (surface !== undefined && seed.target !== 'bottom') {
// "Open to the side" asks the host for a NEW pane instead of reusing
// the pane the acting tab lives in. `revealIfOpened: false` permits a
// duplicate of an already-open resource, so the split really happens
// (the host's `preferNewPane` falls back to the target pane when no
// split is available — that fallback is the host's rule, not ours).
const side = seed.target === 'side'
const state = store.getSnapshot().state
// The descriptor's own factory mints what a view needs beyond the seed:
// the side chat's thread bootstrap / reattach meta, the terminal's
@@ -926,7 +938,8 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
surface.openResource({
sessionId: targetSessionId,
address: surface.fileAddress(targetSessionId, scope?.cwd, seed.path),
revealIfOpened: true,
revealIfOpened: side ? false : true,
...(side ? { preferNewPane: true } : {}),
})
} else {
// The path-less editor window IS the file explorer.
@@ -946,7 +959,8 @@ export function createBetterSidebarService(store: SidebarStore): BetterSidebarSe
...(seed.diff === undefined ? {} : { diff: seed.diff }),
...(synthetic.meta === undefined ? {} : { meta: synthetic.meta }),
},
revealIfOpened,
revealIfOpened: side ? false : revealIfOpened,
...(side ? { preferNewPane: true } : {}),
})
}
// The native surface reports one open event, not create-vs-focus, so a