Back to home@lzxcs

chat-width-pro

对话页面宽度设置:把固定的内容宽度暴露到设置页,默认 748px(应用当前宽度)。

Stars
0
Language
JavaScript
Created
Aug 26, 2026
Updated
Aug 26, 2026

Introduction

chat-width-pro

安装(Install)

需要 DSH(DeepSeek Harness)与 web profile(dsh web):

# 1. 安装插件(pnpm git 依赖)
dsh plugin --profile web add github:lzxcs/chat-width-pro
# 2. 在 ~/.dsh/profiles/web/cordis.patch.yml 末尾追加注入块:
- insert:
    - id: chat-width-pro
      name: 'chat-width-pro'
# 3. 重启 DSH Web(托盘菜单 → DSH Web 重启),浏览器 Ctrl+F5 刷新页面

卸载:dsh plugin --profile web remove chat-width-pro,并删掉 cordis.patch.yml 中的注入块。

Web GUI 插件:把对话页面的固定内容宽度暴露到设置页,可随时调整。

功能

  • 宽度可调:应用把整条对话列(消息流、dock 卡片、提问/审批卡片、输入框卡片 = 宽度 + 32px)统一约束在 CSS 变量 --dsh-chat-content-width 上,当前内置值为 748px。本插件在设置页(设置 → 插件 → "对话宽度") 提供数值输入,保存后立即生效(以行内样式覆盖该变量,输入框卡片宽度自动跟随)。
  • 默认 = 应用当前宽度:未设置时跟随应用内置宽度。设置卡片显示的就是当前实际生效的默认值(运行时从 DOM 读取,不写死),应用未来改内置值也会自动跟随;重置默认 删除覆盖、恢复内置宽度。
  • 范围与持久化:仅接受 240–2400 之间的整数;经 settings 服务持久化到 $DSH_HOME/settings.yamlchat-width-pro: 段(null = 未自定义)。
  • 自动跟随视图切换:会话根元素由 MutationObserver 持续同步,切换会话、进入/退出设置页后宽度设置仍然生效。
  • 优雅降级:Node half 缺失(设置路由 404)时只跳过设置卡片,对话宽度保持应用默认,不阻塞任何加载。

结构

  • lib/index.js — Node half:通过 ctx.inject 注册回环路由与 settings 命名空间。
    • GET/POST /__chat-width-pro/settings → 读取/写入 { width }(整数或 null),经 settings 服务落到 $DSH_HOME/settings.yamlchat-width-pro: 段;
    • settings.register('chat-width-pro', passThrough, { base }):让设置页能分发我们的卡片 (modlens 同款 pass-through schema)。
  • lib/client.js — Browser half:window.__ModuleLoader__.load 惰性 CJS 工厂,require('react'), 注册 settings.plugin.itemchat-width-pro 设置卡片(order: 31)。宽度覆盖逻辑:
    • 定位会话根元素 = 文档序中第一个计算样式里 --dsh-chat-content-width 非空的元素(不依赖 CSS-module 哈希类名,应用升级后依然可用);
    • 已设置宽度 → 行内样式 --dsh-chat-content-width: <W>px;未设置 → 移除行内样式(回落到应用默认), 并把默认值读回供卡片显示;
    • MutationObserver(150ms 防抖)在会话视图重挂载时重新应用。

安装(本 profile)

  • package.json dependencies 加 "chat-width-pro": "file:./chat-width-pro"
  • cordis.patch.yml insert 行 { id: chat-width-pro, name: 'chat-width-pro' }
  • pnpm-workspace.yaml packages 加入 chat-width-pro
  • pnpm install 后重启 dsh web

维护提示:pnpm 的 hoisted 链接器对 file: 依赖会拷贝进 store 而不是软链, 且不会自动重建被删除的链接。本 profile 中 node_modules\chat-width-pro 是指向 源码目录的 junctionNew-Item -ItemType Junction),因此改 lib/client.js 后刷新页面即生效(服务端按请求读文件)。若某次 pnpm install 把它清掉了, 重新执行:

New-Item -ItemType Junction -Path "node_modules\chat-width-pro" -Target "~/.dsh\profiles\web\chat-width-pro"

安全说明

设置路由绑定在 dsh 自带的回环 web 服务器上(默认 127.0.0.1),无鉴权;只读写一个数字, 不触碰文件系统。