DSH 整体界面缩放(75%–200%,5% 一档):设置行、会话头部步进器、Ctrl/⌘+滚轮三种入口;内置 shim 换算 rect、视口单位、媒体查询与指针坐标,使 position: fixed 浮层始终贴住触发元素。
安装
# GitHub 源码(首次需按提示配置 allowBuilds 构建授权后重试)
dsh plugin --profile web add github:Cieux/dsh-zoom-scale
装任何插件都等于在你的机器上跑第三方代码,权限和你本人一样大——能读你的文件、用你的凭据、访问网络,工具审批管不到它。GitHub 来源的插件还会在安装时执行构建脚本——pnpm 默认拦截,所以安装可能停在 ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED 或 ERR_PNPM_IGNORED_BUILDS;dsh 会打印出需要添加的确切键名,把它加进该 profile 的 pnpm-workspace.yaml 的 allowBuilds 下,重跑一次即可装上。放行构建本身就是一次信任判断:请只安装可信来源,并尽量锁定 commit(github:owner/repo#sha)。
README
Interface zoom for DeepSeek Harness (DSH). Scales the whole Web / Desktop UI and keeps every overlay (menus, tooltips, hover cards, dialogs) anchored to its trigger at any zoom level.
Features
- Range: 75% – 200%, 5% steps
- Entry points
- Settings → General → Interface zoom (stepper + reset)
- Session header
− 125% +control (click the percentage to reset to 100%) Ctrl(⌘on macOS) + wheelCtrl/⌘+=,-,0
- Persistence: same-origin cookie (the desktop shell changes ports between launches) mirrored to localStorage
Two halves
| File | Runs in | Owns |
|---|---|---|
index.js |
host (Node) | the head script: the shim source, the seed scale, a reserved desktop-window-restore hook (not implemented, see Desktop window memory) |
lib/shim.cjs |
page, before any client module | every geometry conversion; publishes window.__dshzs |
client.js |
page, as a Loader module | the controls, the preference, the locale dictionaries, a fallback shim |
index.js injects one head script, so the shim is installed before any client module runs and applies the remembered scale before the shell's first mount. client.js drives window.__dshzs when it exists and installs a fallback only when it does not, so no rect is divided twice.
What the shim converts
Chromium reports rects, window size and pointer coordinates in visual pixels after html { zoom }, while CSS lengths stay in layout pixels — every position: fixed overlay would drift. The shim divides that back out, roughly for: element and Range rects, window and VisualViewport metrics, scrolling APIs, pointer and wheel coordinates, hit testing, SVG screen matrices, viewport units (vw/vh/vmin/vmax → calc(… / var(--dshzs-scale))), media-query bounds and devicePixelRatio. Every step is guarded on its own, so a missing API degrades one behaviour instead of the whole zoom.
Stylesheet coverage
Converted declarations follow --dshzs-scale, so a scale change only re-derives media-query bounds and no stylesheet is rescanned. New CSS is caught by a MutationObserver, the adoptedStyleSheets setter, CSSStyleSheet.insertRule / replaceSync, and a capture-phase load listener.
Desktop window memory
Reserved, not implemented. The head script reads localStorage['dshzs:window'] and, under the dsh-app: protocol the desktop shell uses, restores the main window with resizeTo / moveTo. This plugin never writes that key, so the branch does nothing today; it is kept only as the contract a later implementation would fill.
Payload — CSS pixels (DIP), screen coordinates:
{ "x": 234, "y": 90, "w": 1440, "h": 900 }
Only a position inside the current display's work area is restored: saved.x / saved.y are checked against screen.availLeft / availTop, so a position on another monitor is dropped while the size still applies. The shell may also impose a minimum size of its own.
If you need the feature now, install one of these instead:
| Plugin | Platform | Notes |
|---|---|---|
dsh-window-bounds |
all | page-side resizeTo / moveTo, logical pixels; does not restore the maximized state |
dsh-window-state |
Windows | native user32.dll, also remembers the maximized state; the window may flash at the default size first |
Install only one. They write different keys but drive the same window, so the last writer wins. Neither needs a change here: a window resize needs no hook, because vw / vh are already rewritten to calc(… / var(--dshzs-scale)).
Install
# from a local directory
dsh plugin add /path/to/dsh-zoom-scale
# or from the packaged artifact
dsh plugin add ./dsh-zoom-scale-0.2.9.tgz
After installation reload DSH (a restart is recommended for the desktop app). The "Interface zoom" row appears under Settings → General.
Compatibility
- DSH 0.1.7 or newer. The head script is delivered through
webserver/index-inject, and 0.1.7-rc.1 is the first release whose published packages provide it. 0.1.0–0.1.6 were not tested.schemasteryis loaded optionally, so a profile that carries only this plugin still boots (the configurable scale is then absent and the seed stays at 100 %). - Upgrading from 0.2.4 or earlier: rename the patch id. The bundle patch id is
dsh-zoom-scalesince 0.2.5, but a profile's owncordis.patch.ymlis not migrated for you. If it still carries- id: zoom, that entry covers something that no longer exists and the plugin silently does not load (no head script, nowindow.__dshzs). Rename the id in the profile file and restart. - Do not set
zoomon the root. The shim ownshtml { zoom }; a secondhtmldeclaration overwrites it (or is overwritten, depending on cascade order) and desynchronises every conversion.zoomon a descendant multiplies with the root zoom, so leavezoomalone outside the shim. - Do not use
transform: scale()to zoom. It multiplies with the root zoom, creates a containing block that re-anchorsposition: fixedoverlays (the shim cannot correct that), makesgetBoundingClientRectdisagree with the conversions, and stretches glyphs instead of re-rasterising them. - Do not write
--dshzs-scale. The shim rewrites it on every change; an inline value on<html>wins over the shim's stylesheet and breaks every converted length. Read the variable, never write it. - Viewport units are rewritten in stylesheets and in rules added through
insertRule,replaceSyncandadoptedStyleSheets. Inlinestyleattributes are converted too, but only after they are observed, so put first-paint-critical measurements in stylesheet rules. - Colours: use the
--dsw-*tokens. Hard-coded colours do not follow the dark theme. - To read the current scale, use
window.__dshzs?.get()orhtml[data-dshzs](published by the head shim itself, absent at 100 %). Do not readdocumentElement.style.zoom: in shim mode the zoom lives in a<style>element and only the fallback path writes it inline. At 100 % that style is empty anddata-dshzsis absent — that does not mean the plugin is missing. - Do not install a second shim.
window.__dshzshas one owner; wrapping the same properties again divides every rect twice. Drive the existing object withset().
Changelog
- Fix: a Ctrl+wheel step takes its direction from the current event again, so the wheel feels immediate; the accumulator only decides whether a step has been earned. 0.2.8 derived the direction from the accumulator, which made a reversed gesture lag.
- Fix:
normalizeScale(null)returns the default (100 %).Number(null)is 0, which used to clamp toMIN_SCALE(75 %). - Refactor: the preference math (
normalizeScale,parseStoredScale,parseCookieScale) lives inlib/prefs.cjswith edge-case tests.client.jskeeps inlined copies andtest/prefs.test.mjsextracts them from the source to prove the two agree. - Tests:
browser/fallback.mjscompares the client's fallback shim withlib/shim.cjson rects, window metrics and pointer coordinates at 125/150/200 %. - Build:
client.jsis generated. The fallback geometry shim is compiled in fromlib/shim.cjsbyscripts/build-client.mjs, so both halves run one implementation instead of a hand-written subset; CI fails when the committed artifact is stale.
License
MIT
dsh-zoom-scale(中文)
DeepSeek Harness(DSH)Web / Desktop 界面的整体缩放插件。把整个 UI 按比例缩放,同时保证所有浮层(菜单、tooltip、hover card、弹窗)在任意缩放下仍然贴住各自的触发元素。
功能
- 区间:75% – 200%,5% 步进
- 入口
- 设置 → 通用设置 → 界面缩放(带 +/- 步进与重置)
- 会话头部右侧的
− 125% +控件(点击百分比重置为 100%) Ctrl(macOS 为⌘)+ 滚轮直接缩放Ctrl/⌘+=、-、0
- 记忆:缩放值写入同源 cookie(桌面壳每次启动端口会变,cookie 按 host 保留)并镜像到 localStorage
两半
| 文件 | 运行位置 | 负责 |
|---|---|---|
index.js |
宿主(Node) | head 脚本:shim 源码、初始缩放值、预留的桌面窗口还原接口(未实装,见桌面窗口记忆) |
lib/shim.cjs |
页面,早于任何客户端模块 | 全部几何换算;发布 window.__dshzs |
client.js |
页面,作为 Loader 模块 | 控件、偏好读写、语言词条、兜底 shim |
index.js 注入一段 head 脚本,shim 因此在任何客户端模块之前安装,并在宿主首次挂载前应用记住的缩放值。client.js 在 window.__dshzs 存在时驱动它,不存在时才安装兜底 shim,同一个 rect 不会被除两次。
shim 换算什么
html { zoom } 之后,Chromium 在窗口像素里报告 rect、窗口尺寸和指针坐标,而 CSS 长度仍在布局像素里 —— 每个 position: fixed 浮层都会漂移。shim 把这些量除回去,大致覆盖:元素与 Range 的 rect、窗口与 VisualViewport 尺寸、滚动 API、指针与滚轮坐标、命中测试、SVG 屏幕矩阵、视口单位(vw/vh/vmin/vmax → calc(… / var(--dshzs-scale)))、媒体查询边界与 devicePixelRatio。每一步单独兜底:某个 API 缺失只退化一项行为,不会连带停掉整个缩放。
样式表覆盖
换算后的声明通过 --dshzs-scale 跟随缩放,所以换档时只需重新推导媒体查询边界,不会重扫样式表。新来的 CSS 由 MutationObserver、adoptedStyleSheets 的 setter、CSSStyleSheet.insertRule / replaceSync 以及捕获阶段的 load 监听收拢。
桌面窗口记忆
预留接口,未实装。 head 脚本会读 localStorage['dshzs:window'],在桌面壳使用的 dsh-app: 协议下用 resizeTo / moveTo 还原主窗口。本插件从不写这个键,所以这条分支目前不会生效 —— 它只是留给将来实装时用的契约。
负载格式为 CSS 像素(DIP)、屏幕坐标:
{ "x": 234, "y": 90, "w": 1440, "h": 900 }
只还原当前显示器工作区内的位置:saved.x / saved.y 相对 screen.availLeft / availTop 校验,位于其它显示器的位置会被丢弃,尺寸仍然生效。壳也可能有自己的最小尺寸约束。
现在就想要这个功能,请改装下面的插件:
| 插件 | 平台 | 说明 |
|---|---|---|
dsh-window-bounds |
全平台 | 页面侧 resizeTo / moveTo,逻辑像素;不还原最大化 |
dsh-window-state |
仅 Windows | 原生 user32.dll,能记住最大化;窗口会先以默认尺寸闪现一次 |
两者只装一个:键不同,但操作的是同一个窗口,谁后跑谁赢。装哪个都不需要改本插件 —— 窗口尺寸变化不需要钩子,vw / vh 已被改写成 calc(… / var(--dshzs-scale))。
安装
# 本地目录
dsh plugin add /path/to/dsh-zoom-scale
# 或安装打包产物
dsh plugin add ./dsh-zoom-scale-0.2.9.tgz
安装后重载 DSH(桌面应用建议重启),在 设置 → 通用设置 中即可看到「界面缩放」一行。
与其它 CSS / 插件共处
- 需要 DSH 0.1.7 及以上:head 脚本经
webserver/index-inject注入,0.1.7-rc.1 是查证过第一个提供该事件的发布;0.1.0–0.1.6 未验证。schemastery改为可选加载,所以只装本插件的干净 profile 也能启动(此时没有可配置的缩放项,种子保持 100 %)。 - 从 0.2.4 及更早升级:记得改 patch id:bundle patch 的 id 从 0.2.5 起是
dsh-zoom-scale,但 profile 自己的cordis.patch.yml不会自动迁移。如果里面还写着- id: zoom,那条覆盖的是一个已不存在的条目,插件会静默不加载(没有 head 脚本、也没有window.__dshzs)。把 id 改掉再重启。 - 不要给根元素写
zoom:html { zoom }归 shim 所有,再写一条会覆盖它(或被它覆盖,取决于层叠顺序),换算随之错位;而后代元素上的zoom会与根缩放相乘,所以 shim 之外不要碰zoom。 - 不要用
transform: scale()做缩放:它会与根缩放相乘,创建新的包含块使position: fixed浮层改相对它定位(shim 修正不了),让getBoundingClientRect与换算结果不一致,而且文字是被拉伸而非重新栅格化。 - 不要写
--dshzs-scale:shim 每次换档都会重写它;写在<html>内联样式上反而会赢过 shim 的样式表,让所有换算长度失效。请读它,不要写它。 - 视口单位会被改写:样式表里的
100vh变成calc(100vh / var(--dshzs-scale, 1)),运行时经insertRule、replaceSync、adoptedStyleSheets插入的规则同样接管。内联style也会转换,但要等它被观察到,所以首帧就要准确的尺寸优先写成样式表规则。 - 颜色用
--dsw-*令牌:硬编码颜色不会跟随暗色主题。 - 判断当前缩放用
window.__dshzs?.get()(百分比)或html[data-dshzs](由 head shim 自己发布,100 % 时不存在)。不要读documentElement.style.zoom:shim 模式下 zoom 写在<style>里,只有降级路径才写内联;100 % 时那条样式表是空的、也没有data-dshzs,但这不代表插件没装。 - 不要再装一套 shim:
window.__dshzs只有一个持有者,重复包装同一批属性会让每个 rect 被除两次。要接管请调用它的set()。
变更记录
- 修复:Ctrl+滚轮的一步方向回到「本次事件」,滚动立即跟手;累加器只决定「够不够一步」。0.2.8 用累计值定方向,反向手势会有滞后感。
- 修复:
normalizeScale(null)返回默认值 100 %。Number(null)是 0,此前会被夹到MIN_SCALE(75 %)。 - 重构:偏好数学(
normalizeScale、parseStoredScale、parseCookieScale)收进lib/prefs.cjs并补边界测试;client.js保留内联副本,test/prefs.test.mjs从源码里提取这些函数,证明两份一致。 - 测试:
browser/fallback.mjs在 125/150/200 % 下对比 client 降级 shim 与lib/shim.cjs的 rect、窗口尺寸与指针坐标。 - 构建:
client.js改为构建产物:降级几何 shim 由scripts/build-client.mjs从lib/shim.cjs内联进来,两半共用一份实现,不再是手写的子集;提交的产物过期时 CI 会失败。
许可
MIT
链接
同类插件
zhu1090093659/dsh-web#packages/dsh-task-board★ 10406
侧边栏多列任务看板:卡片交给真实 DSH 智能体会话执行,支持 cron 定时(Host 侧到点执行,关浏览器也生效)。
zhu1090093659/dsh-web#packages/dsh-web-all★ 10406
DSH Web UI 插件与皮肤合集:任务看板、git 图、右侧面板、远程移动端 UI、桌宠、实时 token 统计与皮肤中心。
ccch1mneyyy/dsh-TUI★ 7675
Claude Code 风格全屏终端 UI:像素鲸鱼顶栏、实时工作状态行、思考流式展开。
MeteorNOX/DeepSeek-Balance-Whale-Widget★ 7201
右下角常驻的小鲸鱼挂件:余额、今日已用与每轮对话消耗(含峰谷价),余额预警与今日预算的泡泡内容都可编辑;泡泡点击序列模块化自定义,支持并列加权 A/B、随机台词与随机图片;内置 30+ 厂商模板(OpenAI / OpenRouter / Kimi / 硅基流动 / 方舟 / 智谱 / MiniMax 等),按模型查余额与订阅额度;另有任务结束音效、导入音频、自定义角色与资源管理。数据全在本机,无遥测。
omdsh-dev/DSH-better-sidebar★ 5142
侧边栏完整工作台:内置文件渲染编辑、终端、Git 与子代理,支持三方插件注册新 Tab。
Devin-AXIS/deepseek-design#deepseek-idesign★ 1816
可视化设计工作室,支持网站、App 原型、海报、信息卡、报告和杂志的模板创建、元素编辑、选区级 AI 草稿衔接与导出。
社区评论
评论公开保存在 GitHub Discussions。加载评论会连接 GitHub 和 Giscus;发表内容需要 GitHub 账号。