Bundle
dsh-re
把「↻ 刷新」按钮放进 DeepSeek Harness 桌面端顶部标题栏、「编辑」右边:只重载界面,不重启应用、不断会话。宿主用 webserver/index-inject 注入一行内联 script,加载 lib/ui.js 挂进外壳菜单栏(shadow DOM);拿不到菜单栏时退回角落药丸。
- Source
- lux09947-cmyk
- License
- MIT
- Updated
- Updated yesterday
Readme
# dsh-re 在 **DeepSeek Harness 桌面端**的顶部标题栏、「编辑」右边加一个「**↻ 刷新**」按钮:点一下只重载界面,**不重启应用、不断会话**。 桌面端没有地址栏,也没有「刷新」菜单项——这是给它补上的那颗按钮。纯宿主插件,不需要 `dsh.client`,浏览器半边不参与。 ## 安装 ```sh # 从 npm(发布后) dsh plugin --profile desktop add dsh-re # 或直接从 GitHub dsh plugin --profile desktop add github:LUX09947-CMYK/dsh-re ``` 装完**重启一次应用**(不是点刷新,见下面「为什么必须重启」):之后日常改 `lib/ui.js` 只需点一下刷新即可生效。 ## 用法 - 顶部标题栏「应用」「编辑」右边会出现 `↻ 刷新`,样式与「应用 / 编辑」完全一致(同一个 shadow root 里的按钮)。 - 点它 = 重新加载当前页面。对话、工作区、正在跑的会话都在宿主进程里,不受影响。 - 拿不到标题栏菜单(例如在浏览器里跑 `dsh web`,或外壳菜单栏尚未出现)时,会退回右上角的浮动药丸:`↻ 刷新` + `⇕`(换角落)+ `✕`(隐藏,写 localStorage)。 ## 工作原理 1. **宿主** `lib/index.js` 在 `apply()` 的第一件事就往 `webserver/index-inject` 表里推一行**内联 script**(`kind: 'script'`),内容是「建一个 `<script src="/api/dsh-re/ui.js">` 并吞掉 onerror」。这里有三条硬约束,踩过才知道: - 桌面外壳的 `index.html` 从安装包静态 dist 读盘,`ctx.webServer.tapIndex()` 在桌面端**完全不生效**,结构化注入行是唯一通道; - 必须用**内联** `script` 行而不是 `script-src` 行:后者要 `await loadScript(src)`,失败就 reject `__DSH_BOOT_READY__`,整个应用起不来; - 因此 `apply()` 里**不能**写对象级 `inject`——那会把 `apply()` 推迟到服务就绪之后,订阅晚于那次收集,行永远进不了表。 2. **页面** `lib/ui.js`(原生 DOM,零依赖)挂载:优先塞进外壳菜单栏 `[data-windows-menu]` 的 shadow root 里的 `[role="menubar"]`,成为「编辑」后面的第三个按钮;菜单栏迟迟不出现时先等约 10 秒,再退回角落药丸。2 秒一次的看门狗会自愈重挂,且不会挂出第二颗。 3. **自检**:挂载成功后往 `POST /api/dsh-re/ui-ping` 回打一次(带 where=titlebar|corner、userAgent);`GET /api/dsh-re/status` 能免认证读到它——「按钮到底进没进桌面窗口」用这个判断,不用问人。 4. **为什么「装完必须重启应用」、而「改 ui.js 只要刷新」**:外壳启动宿主时把注入表存进一个模块级变量(`injections = ready.injections`,`resources/app.asar/lib/main.js:11332`),此后每次页面启动都由 `ipcMain.handle(DESKTOP_IPC.boot, …)` 回这份**缓存**(同文件 `:11560`)。点刷新只能拿回同一份旧表,所以**换了提供这一行的插件就必须整个应用重启一次**;而 `ui.js` 是页面按 URL 现取的(路由每次读盘 + `no-store`),改界面只要刷新。 宿主只注册三条 exact 路由:`GET /api/dsh-re/ui.js`(每次现读盘 + `no-store`,所以改完 ui.js 点刷新就生效)、`GET /api/dsh-re/status`、`POST /api/dsh-re/ui-ping`。 ## 兼容 - `dsh.engines.dsh: >=0.2.0-rc.1`。实测环境:DeepSeek Harness 桌面端 0.2.0-rc.2(Electron 44)。 - 仅 Windows 桌面外壳有那条标题栏菜单栏;其它平台/浏览器形态自动走角落药丸,功能不受影响。 ## 开发与自测 ```sh node --check lib/index.js node --check lib/ui.js node tools/ui-smoke.mjs # 48 条断言,最小假 DOM 里跑真实 lib/ui.js ``` 冒烟测试覆盖四种局面:标题栏存在(挂进 menubar、是「编辑」右边、无药丸、ping where=titlebar)、没有菜单栏(药丸全套:刷新/换角落/隐藏/自愈重挂)、声明有标题栏但它没出现(等 5 次后兜底)、菜单栏晚到(撤药丸改挂菜单栏)。 ## 卸载 ```sh dsh plugin --profile desktop remove dsh-re ``` 隐藏按钮只是写了个 localStorage 标记,清掉 `dsh-re-ui:hidden` 就回来了。 ## License MIT
Install
dsh plugin --profile web add github:lux09947-cmyk/dsh-re
Profile: web
With the hub plugin installed, ask your agent to install it by name — it resolves the same plan shown here.
dsh plugin --profile web add github:stvlynn/dsh.fish#path:packages/dsh-plugin-hub
install dsh-re from the hub
- This source has no pinned commit, so a later push upstream changes what installs. Prefer pinning a commit.