Files
apes-sidebar/README.md
T
bb2456bea9 feat(explorer): upload files into the workspace from the file tree (#239)
* feat(explorer): upload files into the workspace from the file tree

- TreePanel header: upload-files / upload-folder buttons (folder picker keeps
  the tree via webkitdirectory), with a one-line progress/result hint
- FileTree: drop files/folders onto the tree body (workspace root) or onto a
  directory row (that directory); directory context menu gains 上传到此处
- api.ts: uploadFile posts base64 to /sidebar/upload (host writes it through
  fs + shell decode; route provided for now by the local demo plugin)
- upload.ts: bytes->base64 (global-btoa-independent), FileList/DataTransfer
  collection, sequential upload with per-file results; ~48MB per-file cap
- locales: zh/en strings; icons: IconUploadOutline16

* fix(explorer): reload tree after upload and auto-dismiss the status hint

The drop/context-menu upload path cleared the level cache but never
refetched (the refreshTick bump belongs to the button path), so the
visible tree emptied and only the persistent '已上传 N 个文件' hint
remained — the tree only came back after reopening the tab.

- FileTree.uploadInto now reloads root + expanded levels after clearing,
  matching the refresh-tick path
- success status auto-dismisses after 3.5s (failures persist until the
  next action) in both TreePanel and FileTree

* feat(host): add the /sidebar/upload route (raw bytes, workspace-safe)

The file tree's upload UI needs a host route; until now it pointed at a
locally-injected demo route. This is the real implementation:

- src/index.ts: register POST /sidebar/upload (exact route, same fence and
  session-cwd resolution as every /sidebar route). Query params sessionId,
  dir, relativePath; the raw request body is streamed into the workspace.
- src/fs-operations.ts: writeWorkspaceUpload streams chunks to a temp
  sibling and renames into place, so a failed or oversized upload never
  leaves a partial file. Upload dir must sit inside the session cwd, the
  relativePath is sanitized (no '.', '..', empty or absolute segments) and
  the target must stay inside both.
- src/config.ts: uploadLimit (default 128MiB; oversized -> 413 too-large,
  a new wire code in src/wire.ts).
- client: send the File straight into the POST body (no base64 inflation)
  and cap at the same 128MiB (upload.ts, api.ts).

Tests: tests/fs-operations.spec.ts covers write, nested dirs, traversal /
containment refusal, the size cap, and no-partial-file on failure.
(pnpm test: only pre-existing node-pty/git sandbox failures, identical on
clean main; typecheck and build pass.)

* fix(host): harden upload containment, temp-file atomicity and stream failure cleanup

- relativePath: absolute paths and empty segments are refused (400), not
  silently collapsed or re-anchored (the spec's 'reject' semantics)
- temp file: uniquely named per request (randomUUID) so concurrent uploads
  to the same target stay independent; crashed-process leftovers never
  block later uploads (no pid reuse)
- write stream: permanent 'error' listener + error checks after every await
  so a failing disk rejects the operation instead of crashing the host or
  hanging the drain wait; the temp file is removed after the stream fully
  closes (Windows file locks), never leaving a partial file
- docstring now states the containment is lexical (symlink trust model)

* fix(explorer): thread upload error codes and cancellation through the client

- api.uploadFile/fetchUpload accept an AbortSignal (long-op convention);
  an aborted request rejects with the DOMException as-is instead of being
  wrapped into a 'network' error
- UploadResult carries the wire error code; the client pre-check now emits
  the same 'too-large' code as the host, and summarizeResults localizes
  'too-large' instead of showing the raw English 413 message
- uploadToDir stops the queue on abort: completed files stay, in-flight
  request is cancelled, nothing after is started
- uploadTooLarge copy no longer hardcodes a byte number (the host limit is
  configurable); MAX_UPLOAD_BYTES is documented as a mirror, not authority
- relativePathOf rejects absolute paths (isAbsolutePath) instead of
  stripping leading slashes, matching the host's 400 semantics
- progress text shared via uploadHintText for the hint and the overlay;
  success-hint duration is the exported UPLOAD_HINT_MS

* feat(explorer): full-window upload progress with cancel and VSCode-style drop targets

- UploadOverlay: blurred scrim + card over the file window (Modal token
  recipe: bg-mask-1 + mask blur, bg-layer-2, border-inverted, shadow-lv3),
  file-level progress bar, cancel button and Esc; scrim clicks do not abort
- TreePanel owns the upload session: header pickers, tree drag-drop and the
  context-menu picker funnel through startUpload; one session at a time
  (buttons disabled while busy, drops guarded); on settle the tree refreshes
  and the status hint shows success (3.5s, transient), failure or cancel
  (error color, stays)
- FileTree: drops on directory rows target that directory, drops on FILE
  rows target their parent (VSCode semantics, no more accidental root
  uploads), root row and body drop into the workspace root; drag-over
  highlights the target row (explorerRowDropTarget) plus the body outline
  and a hint pill (uploadDropHint / uploadTo) — raw-color inline outline
  replaced with the repo's dashed-accent classes
- upload status hint uses editorSearchHint + editorError like the search
  status; duplicated upload flow removed from FileTree (single caller)

* test: register the upload route in the smoke inventory

The new /sidebar/upload route joined the fenced route list, so the mount
assertion must expect it (the PR's CI gate was red).

* chore: bump to 0.14.1

Rebased onto main and cut a release version for the upload feature:
package.json / dsh.plugin.json / SIDEBAR_SERVICE_VERSION stay in sync
(test-guarded), README changelogs get the v0.14.1 entry.

* feat(explorer): keep the drop hint above DSH's page overlay and suppress its intake over the tree

DSH's whole-page image-drop intake (ui-conversation InputBar) listens on
document in the bubble phase: any 'Files' drag entering the page shows its
full-screen overlay (z-1000) and a drop anywhere adds images to the chat.
Our tree handled dragover/drop but not dragenter, so the overlay flashed
over the file window and drops outside the tree rows could leak to the
chat.

- TreePanel root now swallows dragenter/dragover/drop (preventDefault +
  stopPropagation) before the events reach document: the file window is an
  upload target, not an image target. Row/body handlers still fire first
  (bubble order) for their own targets; the root is the backstop for the
  search row, gaps and the search-results view.
- The drop hint pill is portaled to document.body at z-index 1001 — above
  DSH's overlay (z-1000) — so when a drag enters from outside the tree and
  DSH's mask lingers until dragend, our 'Drop files/folders here' /
  'Upload into {dir}' hint stays readable on top (transient decoration,
  pointer-events none; the drop still lands on the tree).

* feat(explorer): zone-split the drop overlays and fix the mask flicker over the sidebar

Sidebar.tsx's panel host now swallows the whole file-drag quartet
(enter/over/leave/drop, gated on the 'Files' type): DSH's document-level
intake keeps an enter/leave depth counter, and the leaves that escaped
the tree unbalanced it — that was the native full-screen mask flickering
over the sidebar. The region is now a black hole to that listener, so the
conversation column keeps DSH's native overlay and image intake while the
sidebar presents its own upload surface (drops over it never add images
to the chat).

The tree's drop affordance is now a pointer-inert frame portaled to
document.body at z-1001, anchored to the explorer body's viewport rect:
it replaces DSH's mask over the sidebar instead of competing with it, and
the hint pill docks at the bottom edge so the rows — the actual drop
targets — stay visible and aimable instead of sitting behind a centered
pill. Inside the tree, enter/leave depth counting (InputBar's own
pattern) replaces the relatedTarget check, which is unreliable for drag
events and flickered the row highlight on icon/label transitions; the row
target is now set authoritatively by the continuously-firing dragover.
dragleave handlers on rows are gone.

Polish: capsule hint pill with the upload icon and a float shadow, the
progress overlay fades in (the repo's dsh-row-in motion), its title gains
the icon, and progress numbers render tabular. tests/file-tree-drop.spec
pins the depth-counter behavior (child transitions keep the zone) and the
parent-directory drop semantics.

* feat(explorer): dim the whole viewport behind the tree's drop zone

The bottom-docked pill sat below the fold of attention; the zone frame
alone also failed to teach the left/right split — a drag over the sidebar
gave no hint that the conversation column still accepts drops (into the
chat, natively). The zone frame now carries the full-viewport dim itself
(a 200vmax box-shadow spread in DSH's own mask-drop token): everything
outside the tree's rect fades, the tree stays clear and aimable, and a
muted invitation centered in the space left of the zone (skipped under
200px) names the chat as the image target. The pill moves to the TOP edge
of the zone, right under the search row — the first thing the eye meets.

* feat(explorer): colorful drop heroes for both zones

The overlay is this flow's one brand moment, so it gets the color the
rest of the UI never does: hand-drawn SVG illustrations in the palette of
DSH's own native drop art (#3964FE/#679EFE/#9CE5ED) so the two zones read
as one family. The upload zone docks a hero at its top edge — a tray
illustration over the hint pill, stacked so the rows below stay aimable;
the chat zone's invitation becomes a tilted photo-cards card over its
label.

* feat(explorer): traverse dropped folders instead of reading dataTransfer.files

A dropped OS folder never surfaces in dataTransfer.files (that flat list
carries files only), so folder drops were silent no-ops while the UI
advertised 'drop files/folders'. uploadItemsFromDrop now captures entry
handles via webkitGetAsEntry — synchronously, since the dataTransfer enters
protected mode once the drop dispatch ends, while the captured handles stay
readable — then drains each directory's readEntries batches recursively,
prefixing every descendant's relative path. Entry-derived paths go through
the same sanitizer as picker paths; an entry that fails to read is skipped
rather than failing the whole drop, and the flat file list remains the
fallback where the entry API is unavailable. The FileTree drop handlers
ride the resulting promise.

---------

Co-authored-by: dsh local <dsh@local>
Co-authored-by: Menghuan1918 <menghuan2003@outlook.com>
2026-08-20 18:28:57 +08:00

26 KiB
Raw Blame History

dsh-better-sidebar

一个服务化的侧边栏框架,一套开箱即用的完整工作台

License: MIT dshfind

文件管理 编辑预览 内嵌浏览器 真实终端 Git 面板 后台任务 插件接入

右侧栏 + 底部面板双工作台,并把 ctx.betterSidebar 服务开放给所有插件——
通过 registerTab / registerFileViewer 注册新的侧边栏页面与文件预览器。
🌏 中文 · English
dsh-better-sidebar 工作台截图

✨ 功能一览

  • 🗂️ 文件工作台:资源管理器(懒加载目录树;软链接按目标类型展示——目录软链接可展开、失效链接标红)+ CodeMirror 编辑器;图片 / Markdown(含 Mermaid 图表,strict 安全渲染 + 点击放大)/ HTML / PDF / Office 内联预览
  • 🌐 内嵌浏览器:多开网页 tab,后退 / 前进 / 刷新;内容运行在沙箱 iframe;外链默认按协议分流——HTTP 在侧边栏打开、HTTPS 走系统浏览器(设置页可分别调整)
  • 💻 真实终端:xterm.js + node-pty 真实 shell,断线重连回放;可选为模型注入 terminal_* 工具
  • 🌿 Git 面板:真 diff + VSCode 式 diff tab、历史、右键暂存 / 提交 / 还原
  • 🧩 后台任务页:subagent 拓扑 + 后台任务(退出码 / 实时输出 / 强制终止)
  • 🪟 双工作台:右侧栏 + 底部面板;拖 Tab 拆分 / 合并分栏(可跨面板),移动端自动合并全宽抽屉
  • 🔁 会话隔离:布局 / Tab / 面板按会话持久化,陈旧状态自动净化
  • ⚙️ 声明式设置:设置页「侧边卡片」逐项独立开关,二级设置经齿轮弹窗
  • ⚡ 按需加载:启动只拉 ~325KB 核心,终端 / 编辑器 / Mermaid 图表等重依赖用到才按需拉取(设计文档)
  • 🌏 多语言:界面文案跟随 DSH 语言(zh / en)实时切换

🔌 核心理念:服务优先——内置的 7 tab + 6 viewer 与第三方插件通过同一套 ctx.betterSidebar API 注册,能力完全对等;官方不再内置、可由生态提供的功能,交由生态插件实现。接入文档见下方「🔌 服务化」与 外部插件接入指南。

🆕 最近更新

侧边栏 服务化基座截图 添加插件截图

v0.14.1

✨ 新功能

  • 📤 文件窗口上传(#239):头部「上传文件 / 上传文件夹」按钮 + 拖放上传(拖到树区 = 工作区根,目录行 = 进该目录,文件行 = 进其所在目录,对齐 VSCode);上传时全屏模糊进度弹层(文件级进度 + 取消 / Esc);上传中按钮禁用、成功后文件树自动刷新

🐛 修复

  • 🔒 上传链路的代码规范整改(#239):relativePath 空段 / 绝对路径显式拒绝;临时文件唯一命名(并发上传互不干扰、崩溃不阻塞);写流错误监听(磁盘失败不崩溃进程);客户端错误码与服务端统一、413 本地化

⚠️ 本版适配 DSH 0.1.0-rc.8:全部 @deepseek-ai/* peer / devDependencies 升至 ^0.1.0-rc.8(含传递依赖,lockfile 零 rc.7 残留),cordis 同步 ^4.0.0-rc.8,CI 挂载冒烟钉版 @deepseek-ai/dsh@0.1.0-rc.8。rc.7 及更早的 DSH 环境将无法解析本版依赖,请先升级 DSH。自 v0.13.1 以来的全部更改:

✨ 新功能

  • 🖼️ 统一面板宿主注入重构(#232):面板/开关簇迁入 [data-dsh-panel-host] 固定含块层(fixed inset-0 z-40),免疫桌面套壳中间层 transform 对 fixed 含块的劫持;挂载自检(页面级 transform → data-dsh-panel-host-degraded 降级同步,按未修正几何判定、祖先变换消失才退出);推挤锚点改 #root [data-dsh-frame] > [data-pane="conversation"] + #root calc 宽度防桌面壳加性溢出;chunk 激活重验证(HEAD+ETag 保留未变 chunk,5s 超时兜底 fail-open);桌面信号自动探测(win32 advanced 标题栏兼容 32px 避让,手动 pref 可覆盖);visualViewport 键盘 inset + env(safe-area-inset-*) 移动端适配
  • 📂 文件打开方式默认独立(#232):editorExplorer 默认从「合并」改为「独立」——新会话树点击 / 打开文件按路径新开文件 tab,无路径窗口即纯资源管理器;合并模式保留为可选手动开启
  • 🖥️ 终端 shell / shellArgs 设置页可配(#232):终端卡齿轮二级页面新增「Shell 路径」「Shell 参数」两行配置(此前只能通过 cordis.patch.yml 配置)——设置页写入后对之后打开的 UI 终端与模型终端(terminal_create)即时生效;留空保持 yaml → $SHELL / 登录 shell / powershell.exe 的既有解析顺序
  • 🏷️ 设置页版本徽标(#232):侧边卡片设置页顶部新增 DSH-better-sidebar v0.14.0 身份徽标(版本与服务实例同步,由测试守护)
  • 🔍 添加插件目录搜索 / 分组 / 独立滚动(#232):为插件生态增长做准备——目录列表顶部加实时搜索(按名称 / id / 描述过滤),条目支持可选 category 分组渲染,列表独立滚动(弹窗不再随条目数无限增长)

🐛 修复

  • 🔧 适配 DSH 0.1.0-rc.8(#232):13 个 @deepseek-ai/* peer / devDependencies 升至 ^0.1.0-rc.8(含传递链,lockfile 零 rc.7 残留),cordis 同步 ^4.0.0-rc.8;移除随 rc.8 消失的 dsh-client-web-react / dsh-client-schema-form(壳模块表不再提供、插件零引用);CI 挂载冒烟钉版 @deepseek-ai/dsh@0.1.0-rc.8;pnpm 11.8 supply-chain 校验适配
  • 🧩 rc.8 模块系统迁移(#232):rc.8 不再暴露 window.__DSH_MODULES__ 页面全局(改由 ctx.modules 服务提供),懒加载 chunk 的外部依赖解析全面失效——client 注入 modules 服务 + 插件自有全局共享给 chunk 副本(终端 / 编辑器 / Mermaid 恢复正常按需加载)
  • 🧩 chunk 重验证屏障健壮性(#232):HEAD 重验证加 5s 超时兜底(路由挂起时 fail-open 重取,屏障不再可能无限期阻塞懒加载);resetChunks 清挂起的重验证屏障
  • 🖱️ 拖拽健壮性(#232):快速释放(浏览器合并 / 丢失 pointermove 突发)时提交最后已知拖动位置而非回退;pointercancel / 捕获丢失中断同样保留拖动结果;提交后立即重测中心列(消除底栏宽度中间帧抖动);HMR 重激活后中心列重定位兜底(<html> 样式观察 + 底栏打开重测),修复热更新后底栏空白 / 输入框位移

v0.13.1

✨ 新功能

  • 📊 Markdown 预览安全渲染 Mermaid 图表(#164):预览的 md 含 mermaid fence 时按需下发 client-mermaid.js chunk(~7MB,无 mermaid 文件零加载);纵深防御渲染——securityLevel: 'strict' + htmlLabels: false(节点文字走真实 SVG <text>)+ SVG 注入前二次清洗(删 foreignObject/script/外来 HTML 元素、剥 @*/on*/href 属性);点击图表在弹窗中放大(滚轮以鼠标为中心缩放、拖拽平移、工具栏与快捷键),深浅色跟随重渲、解析失败回退原码
  • 🖥️ 终端 shell 与 shellArgs 可配置(#125):cordis.patch.yml 的 better-sidebar.config 可指定 shell / shellArgs(shellArgs 非空时完全替换默认参数;未配置维持自动解析 $SHELL / 登录 shell / powershell.exe 原行为),UI 终端与 agent 终端(terminal_create)同时生效;终端 tab 标题改用 shell 名(bash / zsh / powershell),内部标识改 UUID,同 shell 可开多个终端

🐛 修复

  • 🔗 聚合双挂载自动退让(#200):聚合包(如 dsh-web-ui-all)以独立条目 id 挂载同包时,cordis.patch.yml 的守卫表达式自动禁用自身 better-sidebar 行,不再重复注册 /sidebar/api 导致 duplicate prefix route 整个插件树启动失败(dsh web 崩溃);独立安装行为不变
  • 🔧 peer 依赖对齐 DSH 0.1.0-rc.7(#207,修复 #206):全部 @deepseek-ai/* peer / devDependencies 从 ^0.1.0-rc.6 升至 ^0.1.0-rc.7,CI 挂载冒烟同步钉版——消除主框架升至 rc.7 后 rc.6 / rc.7 混用依赖树导致的 agent-presets: refusing to compose an unscoped context(选模型 / 发消息报错)

v0.13.0

✨ 新功能

  • 📁 文件窗口与资源管理器二合一(#151):新 editorExplorer 设置(编辑器卡齿轮)——文件 tab 增加路径输入框头部 + 可开关的右侧停靠文件树(每 tab 记忆展开/宽度,左缘拖拽调宽 160~480px,全局文件名搜索走 host fs.search 路由,预算封顶并跳过 .git / 符号链接目录);独立模式(默认)树点击 / 输入框 Enter 按路径新开文件 tab,合并模式原地切换当前 tab;新会话默认 seed 空文件窗口(Files)替代 explorer tab,无路径窗口在独立模式为纯资源管理器、合并模式为带 chrome 的空文件窗口;树右键提供「在新 Tab 中打开」「在侧边打开」(split)
  • 🎛️ 声明式设置 select 行(#151):设置项新增 type: 'select'(options 支持 value/title/desc/icon,multi 多选存数组);带图标的选项渲染大图标选项卡、收起态同样显示图标;editorExplorer 改为图标化下拉(合并 / 独立);能力清单新增 settingSelect
  • 🔀 与 dsh-web-ui 家族右侧面板互斥(#181):读取 aionui-panel 设置命名空间的提供方选择——当选择「使用 aionui-panel」时,整个 better-sidebar(右侧栏 / 底部面板 / 浮动入口 / 各类接管)不再挂载;选择 DSH-better-sidebar(或未安装 aionui)时正常。设置页保存后实时生效(settings-document 推送),无需刷新

v0.12.3

✨ 新功能

  • 🎨 皮肤兼容(令牌驱动):全面消费 DSH 设计令牌,与 dsh-web-ui 皮肤中心 10 款皮肤兼容,换肤自动跟随;终端/编辑器表面在透明/半透明玻璃值下回退不透明底色,文字不叠在皮肤背景上(#110,修复 #106 #105 #90 #60,附带 #52 #57 #92)
  • 🗂️ 统一路径处理:UNC 路径 / 软链接分类(目录软链接可展开、失效链接标红)、HTML 路由平台守卫(#134,#65 #67 #43 #79 #115)
  • 🖥️ 终端 shell 可配置:设置项自定义 shell,Windows 自动探测 pwsh(#95)
  • 📝 编辑器新增语言:C# / Kotlin / Swift 语法高亮(#120)
  • 🧭 设置页导航图标:设置页导航图标与布局优化(#114)
  • ➕ 推荐插件目录新增:dsh-git-remotes——Git 远程 Tab(分支/上游/ahead-behind、fetch 可 prune、ff-only pull、确认后才 push,不替换内置暂存/提交)(#91);dsh-video-preview——视频内联预览(.mp4/.webm/.mov/.mkv/.avi 等,自带 /video 宿主路由支持 HTTP Range 206 拖进度条,不受 20MB mediaLimit 限制)(#126)

🐛 修复

  • 🔧 xterm 依赖迁移:弃用的 xterm 迁移至 @xterm/xterm(Closes #122,#128)
  • 📝 Markdown 编辑器:选区转对话弹窗恢复可用(#24)
  • 🐛 node-pty 加载失败不再拖垮 server(#140):宿主半改为懒加载 node-pty,缺失时插件照常挂载,终端以修复提示横幅(可复制命令 + 重试按钮)呈现,agent 终端工具自动跳过
  • 🧪 测试工程:单元测试拆分(#141)+ smoke 偶发失败修复

🚀 安装

前置:已装好 DSH(dsh web 能正常运行),Node.js ≥ 20、pnpm ≥ 10。

dsh plugin --profile web add dsh-better-sidebar@latest

装完硬刷新浏览器(Cmd/Ctrl+Shift+R)即可看到侧边栏(DSH 对 client 改动热加载,无需重启;仅 host 半更新时需要重启)。

更新
dsh plugin --profile web add dsh-better-sidebar@latest

也可把 ~/.dsh/profiles/web/package.json 里的版本号改高后 pnpm install。改完硬刷新浏览器(Cmd/Ctrl+Shift+R)即可(client 改动无需重启 DSH)。

常见问题
现象 原因与解决
报 Ignored build scripts pnpm 11 拦截构建脚本。在 profile 目录(~/.dsh/profiles/web)跑 pnpm approve-builds --all。
报 minimum release age / 版本不足 24h 装的版本发布不足 24 小时。等 24h 或重跑一次(pnpm 会自动补 minimumReleaseAgeExclude)。
报「找不到 profile 目录」 先跑一次 dsh web,让它初始化 ~/.dsh/profiles/web。
页面出现两个侧边栏 双挂载。旧的手动挂载行:~/.dsh/profiles/web/cordis.patch.yml 还留着 - insert: ... better-sidebar ...,删掉那段(同 id 重复挂载 loader 会直接报 duplicate loader entry id)。聚合包(如 @linxin666/dsh-web-ui-all)以不同 id 挂载本包时,0.13.x 起插件自身 bundle patch 会自动退让(检测到已有启用中的同包名挂载就不挂自己),无需手动处理;若仍双挂载,先确认聚合包的 bundle 顺序在 dsh-better-sidebar 之前。
Windows 下终端无法使用 node-pty 依赖预编译二进制;若当前 Node 版本没有对应产物,需装编译工具链(VS Build Tools)。主流 Node 版本一般已有预编译。
终端提示「node-pty 加载失败」 node-pty 安装缺失/损坏(如 pnpm 拦截了构建脚本)。终端横幅会给出修复命令:复制到 DSH 所在环境的终端/cmd 执行(在 ~/.dsh/profiles/web 下 pnpm approve-builds --all && pnpm rebuild node-pty),完成后重启 DSH 并点重试。插件与 DSH 核心使用同一 node-pty@^1.1.0,修复后两者同步恢复。
提示 dsh: command not found 先安装 DSH;或直接用 npx -y --package @deepseek-ai/dsh dsh plugin --profile web add dsh-better-sidebar@latest。
从源码安装 / 开发(可选,替代 npm 方式)

调试本地改动或跟随开发分支时,把依赖指向本地克隆并自行构建:

1. git clone https://github.com/omdsh-dev/DSH-better-sidebar.git ~/Code/DSH-better-sidebar
   cd ~/Code/DSH-better-sidebar && pnpm install && pnpm build
2. ~/.dsh/profiles/web/package.json 的 dependencies 写 "dsh-better-sidebar": "link:<克隆目录绝对路径>"
3. ~/.dsh/profiles/web/cordis.patch.yml 追加挂载行(需要指定终端 shell 时,在行内加 `config.shell`;`config.shellArgs` 可带参启动,非空时替换默认的 `-l`。不填则自动解析 `$SHELL` / 登录 shell / powershell.exe):
   - insert:
       - id: better-sidebar
         name: 'dsh-better-sidebar'
         config:
           shell: /bin/zsh
           shellArgs:
             - --noprofile
             - --no-rc
4. 在 ~/.dsh/profiles/web 执行 pnpm install
5. 硬刷新浏览器(Cmd/Ctrl+Shift+R)即可看到效果(client 改动无需重启 DSH;host 半改动才需重启)

更新:git pull && pnpm install && pnpm build → 硬刷新浏览器即可(client 改动热加载生效,无需重启 DSH;host 半改动才需重启)。切回 npm 通道时,把依赖改回 "dsh-better-sidebar": "^0.13.0" 再 pnpm install。

通过 plugin-registry 安装(可选,与上述二选一)

前置:DSH 已集成 plugin-registry(dsh registry 可用)。同时启用两个通道会双挂载(Node 半挂两次、页面两个侧边栏)。

git clone https://github.com/omdsh-dev/DSH-better-sidebar.git && cd DSH-better-sidebar
pnpm install && pnpm build
node scripts/package-registry.mjs   # 组装 registry/ 暂存(含清单 + 产物 + README,不入库)
dsh registry install ./registry     # 安装(默认禁用)
dsh registry enable dsh-external/dsh-better-sidebar

更新:git pull && pnpm install && pnpm build → node scripts/package-registry.mjs → dsh registry uninstall/install/enable。切换通道前先移除另一通道的挂载。

⌨️ 快捷键

操作 按键
保存编辑 Ctrl/Cmd + S
Git 提交 Ctrl + Enter
关闭 Tab 鼠标中键
拆分/合并分栏 拖 Tab 到分栏边缘 / 中间
引用文件到输入框 悬浮行尾 @文件 按钮
复制文件路径 右键行 → 复制相对/绝对地址

🔌 服务化:注册 tab 与文件预览器

从 v0.4.0 起暴露 ctx.betterSidebar 服务,其他插件可注册侧边栏页面与文件预览器(内置 7 tab + 6 viewer 亦通过同一服务注册):

import type {} from 'dsh-better-sidebar'  // 触发 ctx.betterSidebar 类型合并
export const inject = ['betterSidebar']
export function apply(ctx: Context) {
  ctx.effect(() => ctx.betterSidebar.registerTab({
    id: 'my-plugin:db', title: 'Database', component: ({ scope }) => <DbView sessionId={scope.sessionId} />,
  }))
}

v0.12.1 补齐基座能力(完整类型导出、能力探测、状态订阅、tab 角标、生命周期回调、定向打开、插件自有设置等),详见下方接入文档。

完整接入文档:

  • AGENTS.md——仓库内维护的接入文档(全字段、匹配算法、HMR 陷阱、声明式设置、版本探测);
  • docs/external-plugin-guide.md——面向外部插件开发者的接入指南(含完整最小示例)。

➕ 添加插件(推荐插件目录)

设置页「侧边卡片」两个网格末尾的虚线卡片分别打开 Tab / 预览插件弹窗:声明扩展点、「在 GitHub 上浏览更多插件」按钮(GitHub topic dsh-better-sidebar)、推荐插件目录(名字 / 仓库 / 简介 / 安装脚本),每个条目「跳转」直达仓库、「复制」把安装命令写入剪贴板。

收录新插件:向 src/client/plugins-tabs.ts(Tab 注册)或 src/client/plugins-viewers.ts(文件预览注册)追加一条 PluginEntry,并把仓库打上 dsh-better-sidebar topic;数据完整性由 tests/plugin-list.spec.ts 守护。

🛠️ 开发与构建

pnpm install      # @deepseek-ai/* 已发布到 npm(^0.1.0-rc.8),直接解析、无需令牌
pnpm typecheck    # tsc --noEmit
pnpm build        # → lib/index.js + lib/invariant.js + lib/client.js + lib/client-registry.js + lib/types
pnpm test         # vitest(含 manifest 一致性守卫,需先 build)
pnpm watch        # tsdown --watch

架构:单 npm 包、host/client 双半结构——host(src/index.ts):/sidebar/api/* JSON API、/sidebar/file 媒体路由、/sidebar/html 预览路由、/sidebar/ws/terminal WebSocket(fs / git / pty / 预览,全部会话级 + 信任围栏);client(src/client/index.tsx):portal 侧边栏 + 各视图 + 拦截;状态按会话持久化 localStorage。插件按 DSH 官方规范组织(无 default 导出、双 client bundle),运行期不依赖 npm / checkout(@deepseek-ai/* 由 web profile 提供)。

🔐 安全

  • 路由受 Host 头信任围栏保护(与 /api 一致);fs.write 原子写入;媒体/预览路由仅限会话 cwd 内文件;git 只调 CLI、绝不设置身份
  • HTML 预览与浏览器 tab 的内容在不透明源沙箱 iframe 中渲染(无 allow-same-origin/allow-top-navigation、no-referrer、权限策略全禁);/sidebar/html 路由带 CSP sandbox + 大小/路径边界;地址栏拒绝 javascript:/data:/file: 与 localhost 等本机地址
  • 界面实时显示沙箱状态(关闭时红色警示),可临时解锁当前页面;设置页可按功能关闭沙箱(默认关闭该设置,带警告文案)——关闭后内容与界面同源,仅建议对完全可信内容使用

⚠️ 已知限制

  • Git 无 push/pull/fetch;无文件 watcher(手动刷新);工具行内文件打开按钮不可拦截
  • 终端 Tab 拖到另一分栏会重挂载(shell 重开)
  • Office 三件套预览(.docx/.xlsx/.pptx)已移至「推荐插件」(Office 预览插件,见设置页「添加插件」弹窗);未安装时此类文件走代码/下载查看兜底
  • 浏览器沙箱无登录态/第三方 Cookie 受限,部分站点登录需走弹窗;被 X-Frame-Options/frame-ancestors 拒绝嵌入的站点(如 arxiv.org)显示原因面板(含「在浏览器中打开」);iframe 内部跳转不进后退栈
  • HTML 预览渲染的是已保存文件(不反映未保存草稿)
  • 移动端(<768px)无底部面板:进入窄屏时其标签页一次性并入右侧栏(迁移后回桌面仍保留在右侧栏),桌面端的底部面板只在宽视口下可用;移动端底部首展自动开终端不触发

🖥️ 平台支持

Windows / Linux / macOS 三平台适配(macOS 日常验证;其余经单元测试覆盖);node-pty 优先预编译二进制,失败需编译工具链(Windows VS Build Tools / Linux make+g+++python3 / macOS Xcode CLT)。

🔗 友情链接

  • dsh-tianshu-tui:DeepSeek Harness 交互式终端 UI 插件(渲染核心由自研 harness agent Tianshu-Tui 演进而来),在官方基础上增加 TDD 与证据门等工作流
  • dsh-TUI:Claude Code 风格全屏交互终端插件——像素鲸鱼顶栏、实时工作状态行、思考流式展开、双击 Esc 回滚、上下文进度条 + TPS 仪表,npm 一键安装
  • dshfind 插件超市:三方插件市场——GitHub topic dsh-plugin 下的公开仓库清单,每日同步 star、贡献者与增长数据
  • DeepSeek Harness Desktop:为 DeepSeek Harness 生态打造的现代化桌面端——无需配置 Node.js 或执行命令即可启动和管理本地 Harness 服务;官网