Repository navigation
Releases
dsh-unidoc v0.3.6
v0.3.6 — 修复工作区切换后文件树/根目录不刷新(固定显示旧工作区 / Fix for the tree not refreshing after a workspace switch)
问题 / Problem
切换工作区后,unidoc 的根目录与文件树固定显示旧工作区(如 PunctFlow),无论当前选中哪个工作区都不刷新。终端持续打印 文档中心根目录 = ...(说明 Client 的 hintCwd 权威信号未送达 Host),且候选解析在多个已存在会话并存时按 createdAt 降序恒命中创建最晚的工作区——与「当前选中会话」无关。
After switching workspaces the root path and file tree stayed stuck on an old workspace no matter which workspace was selected. The host kept resolving via static candidates (listSessions ordered by createdAt desc), which always hits the most recently created session when multiple existing sessions coexist — unrelated to the currently selected session.
修复 / Fix
- Client 权威信号时序:
currentSessionCwd()以官方useSessions数据源(sessions.list.getSnapshot().current→byId[id].cwd)为主路径、manager.selected回退;插件激活瞬间sessions服务可能尚未就绪,启动上报改为「立即 + 延迟 1.5s 重试」,确保权威信号最终送达 Host; - Host 可观测性:
unidoc.root新增hintCwd收付诊断日志(值变化时打印,不刷屏),排障时可直接确认「Client 的当前会话工作区是否到达 Host」; - 自动化测试:新增
tests/root-resolution.test.mjs(42 项断言,node tests/root-resolution.test.mjs)——hintCwd 权威信号(有效 / 空串 / 非目录 / 空白 / 变化跟随 / 持久性)、候选顺序(发起者 → 在线 Agent 新→旧 → live 会话 → 幽灵会话 → 兜底根)、路径锚定与防目录穿越、Agent 工具以调用者会话 cwd 为准。
The client now reads the currently selected session's workspace from the official useSessions feed (sessions.list.getSnapshot().current → byId[id].cwd), retries the startup report after 1.5s to cover service-not-ready timing, and the host logs hintCwd receipt so you can confirm the authoritative signal arrives; a 42-assertion automated suite covers the authoritative signal, candidate ordering, path safety, and agent tools.
验证 / Verification
- 创建 A、B、C 三个工作区后反复切换(不新建会话):每次打开文档中心,顶部路径与文件树跟随当前选中会话;
- 终端出现
dsh-unidoc: hintCwd = <当前工作区路径>且随切换变化(显示(none)则说明权威信号未送达,需排查部署形态); node tests/root-resolution.test.mjs输出「通过: 42 / 42 断言」。
提交 / Commits
- fix: 修复工作区切换后根目录/文件树不刷新(hintCwd 时序与可观测性)
- chore: 版本号更新至 0.3.6
- docs: 更新 README 中英双语文档
dsh-unidoc v0.3.5
v0.3.5 — 修复 v0.3.4 回归:DSH 页面侧边栏插件图标消失(Client 半端崩溃 / Fix for the v0.3.4 regression where the sidebar plugin icon disappeared)
问题 / Problem
安装 v0.3.4 后,DSH 页面侧边栏底部的文档中心图标消失,文档中心工作台也无法打开。根因:v0.3.4 将静态 bundle 的 fakeCtx.get 从「白名单写死」改为「全量转发 ctx[name]」,而 DSH 客户端运行时没有 timer 服务(dsh-client-runtime 仅提供 slots / sessions 等,timer 由静态桥接以 setTimeout 提供)。Cordis 的 ctx 是 Proxy,对未提供/未注入的服务属性访问会抛错 cannot get property "timer" without inject;由于 const value = ctx[name] 位于第一行,client.js apply 顶层 const timer = ctx.get('timer') 未受保护地抛错,导致整个 Client 半端加载失败——图标与工作台全部消失。
After updating to v0.3.4 the sidebar icon disappeared and the Document Center would not open. Root cause: v0.3.4 changed the static bundle's fakeCtx.get from a hardcoded whitelist to blanket ctx[name] forwarding, but the DSH client runtime has no timer service (it is provided by the static bridge via setTimeout). Cordis's ctx is a Proxy that throws cannot get property "timer" without inject for unprovided services; since const value = ctx[name] ran first, the unguarded const timer = ctx.get('timer') at the top of client.js apply crashed the whole client half.
修复 / Fix
scripts/build-client.mjs的fakeCtx.get改为:timer写死返回桥接实现(恢复 v0.3.3 行为,绝不访问ctx.timer);slots / sessions 等服务用 try/catch 包裹的安全转发,未提供时返回undefined(调用方容错回退),绝不抛出;- 保留 v0.3.4 的 hintCwd 工作区隔离能力(
ctx.get('sessions')仍尽力读取,失败自动回退 Host 候选解析); - 重新构建
lib/client.js,并同步修复版到已安装插件的运行目录(刷新页面即恢复图标)。
The fakeCtx.get now returns the timer bridge unconditionally (v0.3.3 behavior, never touches ctx.timer) and forwards the remaining services (slots / sessions) through a try/catch-guarded safe lookup returning undefined when absent; the v0.3.4 hintCwd workspace-isolation capability is preserved; lib/client.js was rebuilt and the fixed bundle was synced into the installed plugin directory (a page refresh restores the icon).
验证 / Verification
- 更新后刷新 DSH 页面:侧边栏底部图标正常出现,运行卡片正常,文档中心可正常打开(文件树 + 预览可用);
- 浏览器控制台无
cannot get property "timer" without inject类报错; - 文件树懒加载、5s 工作区感知轮询、hintCwd 工作区隔离均正常。
提交 / Commits
- fix: 修复 v0.3.4 回归——侧边栏插件图标消失(Client 半端崩溃)
- chore: 版本号更新至 0.3.5
- docs: 更新 README 中英双语文档
dsh-unidoc v0.3.4
v0.3.4 — 修复工作区隔离:无论打开哪个工作区都显示旧工作区 A(权威信号级修复 / Authoritative-signal fix for stale workspace isolation)
问题 / Problem
切换工作区后重新打开文档中心,无论打开哪个工作区都显示工作区 A 的根目录与文件树。v0.3.3 的「最近创建会话优先」候选在切回早已创建的历史会话(resume 持久化会话)时失效:sessionQuery.listSessions() 按 createdAt 降序返回全部会话(含持久化「幽灵」记录),历史会话的 createdAt 可能最大而永远排第一,根目录恒命中旧工作区 A。
After switching workspaces, the Document Center always showed workspace A's root and file tree. v0.3.3's "newest created session first" candidates failed when you switched back to an old historical session (resuming a persisted session): sessionQuery.listSessions() returns ALL sessions (including persisted "ghost" records) ordered by createdAt desc, so a historical session with the largest createdAt always ranked first and the root was pinned to the stale workspace A.
修复 / Fix
- Client 端权威信号:从 DSH 客户端运行时
sessions服务读取「当前选中会话」的工作区cwd(sessions.manager.selected→sessions.list.getSnapshot().byId[id].cwd),随每次unidoc.root(hintCwd)上报 Host——无论切换到新建会话还是历史会话,都能精确命中当前工作区; - Host 端 hintCwd 优先:
unidoc.root接收hintCwd(校验为目录后)直接作为根目录,unidoc.list / read / save / create等全部 RPC 以它为锚;传空串则清除 hint 走候选兜底; - 候选兜底增强:无 hint 时,在线 Agent 从最新注册向旧遍历优先,
listSessions()中 live 会话 按createdAt降序排在持久化幽灵会话之前; - 静态包形态桥接:
build-client.mjs的fakeCtx.get转发真实 ctx 服务(含sessions),静态 bundle 形态同样生效。
The client reads the currently selected session's workspace cwd from the runtime sessions service and sends it with every unidoc.root(hintCwd) call; the host prefers it (after verifying it is a directory) and anchors all RPCs to it; without a hint the fallback now prioritizes live sessions over persisted ghost records; the static bundle bridges real ctx services so it works in static-package form too.
验证 / Verification
- 先创建 A、B 两个工作区,再切回先创建的 A(resume 历史会话):顶部路径与文件树显示 A,而非「最近创建」的 B;
- 反复在 A / B / 新工作区 C 之间切换,每次打开都精确命中当前选中会话的工作区;
- 切换工作区并打开文档中心时不出现
Failed to fetch/ 传输失败错误。
提交 / Commits
- fix: 修复工作区隔离——Client 上报当前会话工作区作为权威根目录信号(hintCwd)
- chore: 版本号更新至 0.3.4
- docs: 更新 README 中英双语文档
dsh-unidoc v0.3.3
v0.3.3 — 切换工作区后文件树仍显示旧工作区的根因级修复(Root-cause fix for stale file tree after a workspace switch)
修复内容 / What's Fixed
根因(Root Cause):浏览器 RPC(Client→Host)位于 Agent 驱动链(initiator 边界)之外,agents.currentInitiator() 在 unidoc.root 中返回 undefined;而 agents.list() 按注册顺序返回所有在线 Agent(旧在前、新在后)——切换工作区后旧会话 Agent 仍在线且排在前面,导致根目录解析命中旧工作区:文件树显示旧结构,手动刷新也无效。
Browser RPCs run outside the agent initiator boundary, so agents.currentInitiator() returned undefined inside unidoc.root, and agents.list() (registration order: old first, new last) kept matching a still-online agent from the workspace you just left — the tree showed the old workspace and even a manual refresh could not fix it.
修复(Fix):
- Host 根目录解析候选重排为「最近会话优先」:发起者 Agent(工具调用场景)→ 最近创建的会话(
sessionQuery.listSessions(),newest-first)→ 在线 Agent 从最新注册向旧遍历 → 兜底sandboxPolicy.workspaceRoot(每次动态读取); - 候选
cwd去重,避免重复fs.stat; - 文件树 / 路径状态在刷新与工作区切换时完全重置:清空缓存、重置展开状态与滚动位置到根目录、关闭旧文件预览,顶部路径与文件树内容始终一致。
Root-directory resolution was reordered to "recent session first": initiator agent (tool-call context) → newest created session → online agents newest-first → dynamic sandboxPolicy.workspaceRoot fallback; duplicate cwd candidates are collapsed; the tree and path state (cache, expanded nodes, scroll position, selection) fully reset on refresh and workspace switches.
验证 / Verification
- 工作区 A 展开子目录 → 关闭 → 切到工作区 B → 重新打开:顶部路径与文件树显示 B,无 A 的残留;
- A 与 B 同时在线(多会话并存)来回切换:文件树始终跟随当前工作区;
- 手动「↻ 刷新」:展开状态与滚动位置重置到根目录视图。
提交 / Commits
- fix: 实现工作区切换感知与文件树自动刷新
- fix: 修复文件路径刷新后停留在原目录的问题
- chore: 版本号更新至 0.3.3
- docs: 更新 README 中英双语文档
dsh-unidoc v0.3.2
dsh-unidoc v0.3.2 更新内容 / Release Notes
🐛 Bug 修复 / Bug Fixes
修复工作区切换后文件树不刷新问题:当用户在 DSH 中切换 Agent 或切换会话(工作区)后,文档中心现在能够自动感知工作区变化(运行期每 5s 轮询 unidoc.root(refresh)),并完全重置文件树状态(清空缓存、重置展开状态、重置选中路径、滚动位置回顶部),正确加载新工作区的文件结构,Toast 提示「工作区已切换,文件树已刷新」。
Fixed: file tree not refreshing after a workspace switch — after switching agents/sessions (workspaces) in DSH, the Document Center now senses the change automatically (polling unidoc.root(refresh) every 5s), fully resets the tree state (cache cleared, expanded state, selected path and scroll position all reset to the root), and loads the new workspace's file structure correctly, with a "workspace switched, tree refreshed" toast.
修复文件路径刷新后停留在原目录的问题:文件树刷新/重新加载时,当前选中的目录路径现在会重置到根目录,不再停留在之前的子目录位置;工作区切换时同时关闭预览显示空状态,确保界面状态与当前工作区完全一致。
Fixed: path staying in the old directory after refresh — when the tree refreshes/reloads, the selected path now resets to the root instead of lingering in a subdirectory; on workspace switches the preview is closed (empty state), keeping the UI fully in sync with the current workspace.
提交记录 / Commits
fix: 实现工作区切换感知与文件树自动刷新— workspace-switch sensing (5s poll) & full tree auto-refreshfix: 修复文件路径刷新后停留在原目录的问题— reset selected path to root on refreshchore: 版本号更新至 0.3.2— version bump to 0.3.2 (package.json / package-lock / CHANGELOG)docs: 更新 README 中英双语文档— bilingual README + verification checklist updates
v0.3.1
dsh-unidoc v0.3.1 更新内容
中文 — Bug 修复
- 修复工作区切换后文件树不刷新的问题:当用户在 DSH 中切换 Agent 或切换会话(工作区)后,重新打开文档中心时,文件树现在能够正确识别并加载新工作区的文件结构,而非残留显示上一个工作区的文件。顶部工作区路径与文件树内容保持同步一致。
- 文件树数据生命周期与工作区根目录绑定:感知到工作区变化时自动清空树数据、懒加载缓存与展开状态,以新根目录重新加载
- 打开文档中心时先刷新根目录、再无条件重载文件树,消除「路径已更新、文件树残留旧数据」的竞态
- 运行期(每 15s)检测到工作区切换时自动重置文件树并提示
English — Bug Fix
- Fixed: file tree not refreshing after a workspace switch: after switching agents or sessions (workspaces) in DSH, reopening the Document Center now correctly detects and loads the new workspace's file structure instead of showing stale files from the previous workspace. The top workspace path and the file tree stay in sync.
- The file tree's data lifecycle is now bound to the workspace root: on detected changes it clears the tree data, lazy-load cache and expansion state, then reloads from the new root
- Opening the Document Center first refreshes the root (
unidoc.root(refresh)) and then unconditionally reloads the tree, eliminating the "path updated but tree stale" race - A 15s poll detects workspace switches while the workbench is open, resets the tree and notifies
Full changelog: CHANGELOG.md
v0.3.0
dsh-unidoc v0.3.0 更新内容
中文
- 工作区识别:插件现在能够自动识别当前 DSH 会话的工作区,并在文档中心界面中清晰显示(标题栏 + 文件树顶部);切换 Agent / 会话时自动感知并刷新文件树
- 文件树全面展开:文件树支持「展开全部」功能,可递归展示工作区中的所有文件,包括
.git、.vscode、node_modules等隐藏文件夹及其内容(异步分批加载,超大仓库不卡页面);同时提供「折叠全部」按钮 - 外部编辑器交互升级:点击「外部打开」后浮现编辑器选择菜单,用户可自由选择使用哪个外部编辑器打开文件(默认 VS Code / Sublime Text / Atom / Notepad++ / Vim / Neovim / Typora),支持自定义编辑器列表并记住上次选择
- 界面精简:移除了侧边栏入口按钮旁的「文档中心」文字,界面更加简洁
- 新图标:插件入口图标更换为 Font Awesome 铅笔字迹的文件图标(
fa-file-pen),更具辨识度
English
- Workspace detection: the plugin now auto-detects the current DSH session workspace and shows it clearly in the Document Center (title bar + top of the file tree); switching agents/sessions is sensed automatically and the tree refreshes
- Expand everything: the file tree gains an "Expand All" action that recursively reveals every file in the workspace, including hidden folders such as
.git,.vscode,node_modulesand their contents (async batched loading, no UI freeze on huge repos); a "Collapse All" action is also provided - External editor picker: clicking "Open Externally" now pops up an editor picker menu — choose an editor (VS Code / Sublime Text / Atom / Notepad++ / Vim / Neovim / Typora by default), the file opens in it, and your last choice is remembered; the editor list is fully customizable
- Cleaner UI: removed the "文档中心" text next to the sidebar entry — an icon-only button remains
- New icon: the plugin entry now uses the Font Awesome file-with-pen icon (
fa-file-pen)
Full changelog: CHANGELOG.md
v0.2.0
Changelog
[0.2.0] - 2026-08-22
Added
- HTML 预览支持新标签页打开:Host 新增
unidoc.openExternalRPC(复用 raw 路由返回可访问的 HTTP URL,优先组装绝对 URL、无请求头时退化为相对 URL),HTML 预览工具栏新增「新标签页」按钮。 - 外部编辑器集成:Host 新增
unidoc.openWithEditorRPC(child_process.spawn启动,detached+stdio: ignore+unref,绝不阻塞 Host 进程);选项面板新增「外部编辑器命令」输入框(会话级内存配置,默认code,如notepad/ 可执行文件路径);所有预览/编辑视图工具栏新增「外部打开」按钮。 - 文件树标准图标:文件树图标按扩展名映射 Font Awesome 图标(
fa-solid fa-file-*),覆盖代码 / 文档 / 图片 / PDF / Office / 压缩包 / 音视频等常见类别;GUI 未内置 FA 字体,以官方 SVG path 内嵌渲染(保留 FA 类名便于后续接入字体)。 - 构建与发布管线:
package.json新增build(esbuild 打包 host + 自定义 bundler 打包 client)、prepublishOnly(发布前自动构建)、prepare(git 安装时自动构建)脚本;新增scripts/build-host.mjs;新增devDependencies: esbuild。 - 新增
CHANGELOG.md。
Fixed
- 修复从 GitHub 安装时 client bundle 缺失:
.gitignore不再忽略lib/(仅保留*.tsbuildinfo等构建缓存忽略),lib/client.js随包提交发布;files字段明确包含lib(含src/scripts),确保npm install git+https://github.com/Che-Year/dsh-unidoc得到包含完整lib/的可用包。 - 外部编辑器启动安全与生命周期:
editorCmd仅接受命令名或可执行文件路径(无空格、无 shell 元字符,防注入);目标路径一律经fs.contains校验防目录穿越;编辑器进程 detached + unref,Host 退出不残留句柄、编辑器独立运行。