0.5.2:断点跟随侧栏容器,窄栏不再挤压状态说明
- .sl-root 改 container-type:inline-size + container-name:slpanel,11 处视口 @media (max-width) 全部换成 @container slpanel;真实宿主侧栏 371px、窗口 最大化时旧断点一个都不触发。 - 删掉 .sl-compact .sl-grid-3/.sl-grid-6 的强制两列,它优先级高于容器断点, 会把单列规则压死;单列阈值落在 330px 容器宽(≈348px 侧栏)。 - 部门配置的「最近活动」独占一行、最多两行省略,不再和状态文字挤在一行。 - preview.mjs 新增 --viewport,可渲染「大窗口 + 窄侧栏」;入库 371px、320px 两张新预览图。 - 新增 2 条回归测试(禁止视口断点、status small 独占一行),合计 36 项。
This commit is contained in:
parent
6d2eee7626
commit
dcb4d5f57e
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -2,6 +2,16 @@
|
|||
|
||||
> 版本号以 `package.json` 为准(当前 0.5.x 线);下面 0.6.x 条目沿用旧编号,保留作历史。
|
||||
|
||||
## 0.5.2 — 断点跟随侧栏容器,窄栏不再挤压状态说明
|
||||
|
||||
- 响应式断点从浏览器视口改为面板容器:`.sl-root` 声明 `container-type:inline-size;container-name:slpanel`,11 处 `@media (max-width: …)` 全部换成 `@container slpanel (max-width: …)`。真实宿主窗口最大化时侧栏仍只有 371px,旧的视口断点一个都不会触发,等于窄栏样式从来没生效过。
|
||||
- 删掉 `.sl-compact .sl-grid-3,.sl-compact .sl-grid-6` 的强制两列:它优先级高于容器断点,会把单列规则压死。现在列数完全由容器宽度决定。
|
||||
- 单列阈值落在 330px 容器宽(约 348px 侧栏):360px 及以上保持两列,320px 降为单列。
|
||||
- 部门配置里的「最近活动」独占一行、最多两行后省略,不再和状态文字挤在同一行被裁断;`panel/lib/client.js:891` 的 `shortText(…, 46)` 保持不变。
|
||||
- `scripts/preview.mjs` 新增 `--viewport=<像素>`:窗口可比侧栏宽,用来复现「大窗口 + 窄侧栏」的真实宿主形态;新增 371px、320px 两张入库预览图。
|
||||
- 新增两条回归测试:禁止视口 `@media` 断点且必须保留容器断点;`.sl-detail-status small` 必须独占一行且不得 `white-space:nowrap`。
|
||||
- 36 项测试、`node --check`、`git diff --check`、`check-install` 全部通过。
|
||||
|
||||
## 0.5.1 — 清掉侧栏化残留,会话头开关不再静默
|
||||
|
||||
- 删除侧栏化后不再渲染的旧样式:独立聊天栏、整页面板壳、`sl-left-nav`、`sl-task-jump` 等 46 个类共约 117 行规则;CSS 由 374 行收到 257 行。
|
||||
|
|
|
|||
|
|
@ -11,16 +11,24 @@
|
|||
|
||||
## 2. 预览依据
|
||||
|
||||
0.5.1 的预览图由 `scripts/preview.mjs` 生成:脚本用 vm 加载**真实的** `panel/lib/client.js`,用会重渲染的 hooks 替身跑真实组件树,把结果序列化成 HTML,再用 headless Chrome 截图。因此它是真实 CSS + 真实 DOM 的渲染结果,不是生成式模拟图。
|
||||
0.5.2 的预览图由 `scripts/preview.mjs` 生成:脚本用 vm 加载**真实的** `panel/lib/client.js`,用会重渲染的 hooks 替身跑真实组件树,把结果序列化成 HTML,再用 headless Chrome 截图。因此它是真实 CSS + 真实 DOM 的渲染结果,不是生成式模拟图。
|
||||
|
||||
440px 明亮主题:
|
||||
|
||||

|
||||
|
||||
371px(当前宿主实测的侧栏宽度;最近活动独占一行):
|
||||
|
||||

|
||||
|
||||
360px 窄栏(检查不裁切):
|
||||
|
||||

|
||||
|
||||
320px 极窄栏(三省与六部降为单列):
|
||||
|
||||

|
||||
|
||||
440px 深色主题:
|
||||
|
||||

|
||||
|
|
@ -91,12 +99,15 @@
|
|||
|
||||
按面板实际容器宽度适配,不能只依赖整个浏览器窗口宽度。
|
||||
|
||||
- 400–480px 右侧栏:统计两列两行;三省与六部自动降为两列,卡片保持 104px 以上的可读宽度。
|
||||
- 更窄时六部与三省改为单列;组织层级用分组标题和缩进表达,不再强行绘制横线。
|
||||
- 实现方式:`.sl-root` 声明 `container-type:inline-size;container-name:slpanel`,所有断点写成 `@container slpanel (max-width: …)`;`panel/lib/client.js` 里不得再出现视口 `@media (max-width: …)` 断点,`panel/test/client.test.js` 有回归测试守着这条。
|
||||
- 1180px / 980px:整页与双栏形态的切换;侧栏形态下这两档不会生效。
|
||||
- 620px 及以下:统计两列两行;三省与六部降为两列,卡片保持 104px 以上的可读宽度。
|
||||
- 330px 及以下:三省与六部降为单列;组织层级用分组标题表达,不再强行绘制横线。
|
||||
- 极窄宽度:使用单列卡片和分组标签,隐藏无法准确表达关系的树形横线,保留组织语义。
|
||||
- 统计卡建议每张高64–72px,避免占据过多首屏空间。
|
||||
- 采用自然纵向滚动,不固定过小高度导致文字截断;表单窄屏改为上下排列。
|
||||
- 不直接按1024px生成图等比缩小;在360、400、440、480px容器中检查实际可读性。
|
||||
- 部门配置里的「最近活动」独占一行,最多两行后省略;不得与状态文字排在同一行互相挤压。
|
||||
- 不直接按1024px生成图等比缩小;在320、360、371、400、440、480px容器中检查实际可读性。
|
||||
|
||||
## 8. 数据与实现边界
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,19 @@
|
|||
# 三省六部面板:换环境开发交接方案
|
||||
|
||||
日期:2026-11-08
|
||||
当前版本:`0.5.1`
|
||||
状态:侧栏化改造与残留清理均已实现并通过 34 项本地测试;尚未在真实 DSH Host 里做最终视觉验收。
|
||||
当前版本:`0.5.2`
|
||||
状态:侧栏化改造、残留清理与容器断点均已实现并通过 36 项本地测试;尚未在真实 DSH Host 里做最终视觉验收。
|
||||
|
||||

|
||||
|
||||
> 这张图由 `scripts/preview.mjs` 渲染真实组件树 + 真实 CSS,再用 headless Chrome 截图(440 CSS px × 2 DPR),不是 DSH Host 的运行截图,也不是 AI 生图。同一脚本还产出 360px 窄栏、深色主题与任务页:
|
||||
> 这张图由 `scripts/preview.mjs` 渲染真实组件树 + 真实 CSS,再用 headless Chrome 截图(440 CSS px × 2 DPR),不是 DSH Host 的运行截图,也不是 AI 生图。同一脚本还产出宿主实测宽度 371px、窄栏 360px、极窄单列 320px、深色主题与任务页:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
|
@ -18,11 +22,15 @@
|
|||
|
||||
```bash
|
||||
node scripts/preview.mjs --width=440 --view=court --theme=light --name=panel-sidebar-440-light --out=docs/preview
|
||||
node scripts/preview.mjs --width=371 --view=court --theme=light --name=panel-sidebar-371-light --out=docs/preview
|
||||
node scripts/preview.mjs --width=360 --view=court --theme=light --name=panel-sidebar-360-light --out=docs/preview
|
||||
node scripts/preview.mjs --width=320 --view=court --theme=light --name=panel-sidebar-320-light --out=docs/preview
|
||||
node scripts/preview.mjs --width=440 --view=court --theme=dark --name=panel-sidebar-440-dark --out=docs/preview
|
||||
node scripts/preview.mjs --width=440 --view=tasks --theme=light --name=panel-sidebar-tasks-440 --out=docs/preview
|
||||
```
|
||||
|
||||
复现「大窗口 + 窄侧栏」(真实宿主形态):加 `--viewport=1200 --width=371`,页面按 1200px 窗口渲染、侧栏仍为 371px。
|
||||
|
||||
只想要中间 HTML、不调 Chrome 时加 `--html-only`。最终验收仍然必须在真实会话右侧栏里完成。
|
||||
|
||||
## 1. 一句话目标
|
||||
|
|
@ -40,9 +48,12 @@ node scripts/preview.mjs --width=440 --view=tasks --theme=light --name=panel-sid
|
|||
- 进入部门子会话时自动选中对应部门;返回丞相主会话时恢复选中丞相。
|
||||
- 移除 Agent 预设编辑、重复的「下旨」输入框和独立聊天摘要。
|
||||
- 复用 DSH 主题变量,支持明亮、深色与窄侧栏布局。
|
||||
- 0.5.2 把响应式断点从浏览器视口改到面板容器:`.sl-root` 声明 `container-type:inline-size;container-name:slpanel`,11 处 `@media (max-width: …)` 全部改为 `@container slpanel (max-width: …)`。真实宿主窗口最大化时侧栏仍只有 371px,原来的视口断点一个都不会触发。
|
||||
- 部门配置里的「最近活动」独占一行(最多两行后省略),不再和状态文字挤在同一行被裁断;单列阈值落在 330px 容器宽(360px 及以上仍两列)。
|
||||
- `scripts/preview.mjs` 新增 `--viewport`,可以渲染「大窗口 + 窄侧栏」的真实宿主形态。
|
||||
- 0.5.1 清掉侧栏化残留:46 个不再渲染的 `sl-*` 类、无调用点的 `SanshengPinRow`/`DockButton`/`SidebarIcon`,以及三个无规则的幽灵类名。
|
||||
- 会话头部开关在拿不到会话时把原因显示在开关旁,不再静默回退;CSS 与组件的一致性由测试兜住。
|
||||
- 版本更新到 `0.5.1`;`CHANGELOG.md`、`panel/README.md`、`docs/panel-design.md` 已同步。
|
||||
- 版本更新到 `0.5.2`;`CHANGELOG.md`、`panel/README.md`、`docs/panel-design.md` 已同步。
|
||||
|
||||
## 3. 当前验证结果
|
||||
|
||||
|
|
@ -59,7 +70,7 @@ $env:ELECTRON_RUN_AS_NODE = '1'
|
|||
结果:
|
||||
|
||||
- 语法检查通过。
|
||||
- **34 项测试全部通过**。
|
||||
- **36 项测试全部通过**。
|
||||
- `scripts/check-install.mjs` 通过:panel 以 link 方式安装,client bundle 已注册。
|
||||
- `modeEnabled: false` 只表示「上朝」模式尚未启用,不表示面板不可用。
|
||||
- 清理前后做了像素级 A/B:用同一份 `scripts/preview.mjs`、同一组参数,分别渲染 0.5.0 快照(`.scratch/preview-baseline/client.snapshot.js`)与 0.5.1 的 `panel/lib/client.js`,五组(440/400/360 明亮、440 任务页、440 深色)截图的 sha256 **逐字节相同**,证明删掉的 CSS 与组件确实不在渲染路径上。
|
||||
|
|
@ -76,7 +87,7 @@ $env:ELECTRON_RUN_AS_NODE = '1'
|
|||
| `panel/index.js` | 策略侧 formation/decree 提示词 | 与前端职责保持一致 |
|
||||
| `index.js` | Agent Preset 策略、角色工具权限 | 不得随意放宽写入/命令权限 |
|
||||
| `panel/test/client.test.js` | 面板结构与行为测试 | 使用最小 React 替身,`useState` 不自动更新 |
|
||||
| `test/policy.test.js` | 策略与权限测试 | 与客户端测试合计 34 项 |
|
||||
| `test/policy.test.js` | 策略与权限测试 | 与客户端测试合计 36 项 |
|
||||
| `scripts/check-install.mjs` | 安装一致性检查 | 已改为校验右侧栏注册、拒绝旧的 main/panellist |
|
||||
| `scripts/preview.mjs` | 零依赖预览生成器:vm 加载真实 bundle → 渲染真实组件树 → HTML → headless Chrome 截图 | 需放开沙箱跑 Chrome;`--html-only` 只出 HTML |
|
||||
| `docs/panel-design.md` | 设计依据与验收标准 | 已更新到侧栏结构 |
|
||||
|
|
@ -165,7 +176,7 @@ git clone sansheng-liubu-0.5.0.bundle 三省六部
|
|||
## 7. 可直接粘贴给新环境 Agent 的交接提示
|
||||
|
||||
```text
|
||||
你在 C:\Users\qyh15\三省六部 继续一个 DSH Web 客户端插件项目(dsh-sansheng-liubu-panel,当前 0.5.1)。
|
||||
你在 C:\Users\qyh15\三省六部 继续一个 DSH Web 客户端插件项目(dsh-sansheng-liubu-panel,当前 0.5.2)。
|
||||
|
||||
用户目标:三省六部面板只存在于会话右侧栏;聊天必须复用 DSH 原生输入框;在原生输入框用 @ 选择部门后进入该部门子会话,并自动选中右侧对应部门;不要再恢复整页面板或第二套聊天。
|
||||
|
||||
|
|
@ -176,7 +187,7 @@ git clone sansheng-liubu-0.5.0.bundle 三省六部
|
|||
- panel/test/client.test.js
|
||||
- scripts/check-install.mjs
|
||||
|
||||
当前状态:侧栏化与残留清理已实现,34 项测试通过,check-install 通过,工作树可能尚未提交。不要创建备份目录。
|
||||
当前状态:侧栏化、残留清理与容器断点都已实现,36 项测试通过,check-install 通过,工作树可能尚未提交。不要创建备份目录。
|
||||
|
||||
请先:
|
||||
1. 运行现有测试和 check-install,确认基线;
|
||||
|
|
@ -203,12 +214,13 @@ git clone sansheng-liubu-0.5.0.bundle 三省六部
|
|||
- [ ] 进入子会话自动选中对应部门,返回后恢复丞相。
|
||||
- [ ] 原生输入框发送的消息不会误投给其他 Agent。
|
||||
- [ ] 明亮/深色主题都可读,焦点与选中状态可见。
|
||||
- [ ] 34 项测试、`node --check`、`git diff --check`、`check-install` 全部通过。
|
||||
- [ ] 36 项测试、`node --check`、`git diff --check`、`check-install` 全部通过。
|
||||
- [ ] 有真实 DSH Host 截图作为最终视觉证据。
|
||||
|
||||
## 9. 已知风险
|
||||
|
||||
- 静态预览不能证明 DSH 实际侧栏宽度、滚动容器和槽位渲染完全一致;必须实机验收。
|
||||
- 静态预览能按任意容器宽度渲染,但**不能**证明宿主实际给出的侧栏宽度、滚动容器和槽位渲染完全一致;必须实机验收。宿主实测侧栏宽度为 371px,已作为预览图之一(`panel-sidebar-371-light.png`)。
|
||||
- 断点已改为容器查询,但容器是 `.sl-root`:若宿主把面板塞进更窄的固定宽外壳,实际生效宽度以内层容器为准。修改布局时先用 `--viewport=1200 --width=371` 复现真实形态,不要只看预览页宽度。
|
||||
- `better-sidebar` 与宿主自带 `sidebarRight` 两条注册路径都要验证;只测其中一条不够。
|
||||
- 测试用的最小 React 替身不会执行真实点击,交互问题需要宿主手测或补更真实的组件测试。
|
||||
- 若新环境 DSH 版本没有 `inputTriggers`,`@` 入口应静默不可用,但其余侧栏功能不能因此崩溃。
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 174 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 165 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 162 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 165 KiB After Width: | Height: | Size: 170 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dsh-sansheng-liubu-mode",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.2",
|
||||
"private": true,
|
||||
"description": "上朝:丞相统筹的三省六部多 Agent 模式",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ window.__ModuleLoader__.load({
|
|||
.sl-btn.primary{background:var(--dsw-alias-state-business-primary,#3b82f6);border-color:transparent;color:#fff}
|
||||
.sl-body{flex:1;min-height:0;display:flex}
|
||||
.sl-right{width:392px;min-width:300px;max-width:46%;display:flex;flex-direction:column;min-height:0;overflow-y:auto}
|
||||
@media (max-width:980px){.sl-body{flex-direction:column}.sl-right{width:auto;max-width:none;border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.14))}}
|
||||
@container slpanel (max-width:980px){.sl-body{flex-direction:column}.sl-right{width:auto;max-width:none;border-top:1px solid var(--dsw-alias-border-l1,rgba(127,127,127,.14))}}
|
||||
.sl-map{padding:12px 16px 16px;flex:none}
|
||||
.sl-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:8px;padding:14px 16px 0;flex:none}
|
||||
.sl-stat{display:flex;align-items:center;gap:7px;padding:8px 9px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.2));border-radius:10px;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.05));min-width:0}
|
||||
|
|
@ -313,7 +313,7 @@ window.__ModuleLoader__.load({
|
|||
.sl-stat-body{display:flex;flex-direction:column;min-width:0;line-height:1.15}
|
||||
.sl-stat-body b{font-size:17px;font-weight:600;font-variant-numeric:tabular-nums;letter-spacing:.01em}
|
||||
.sl-stat-body small{font-size:10px;color:var(--dsw-alias-label-tertiary,#8a8f98);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
||||
@media (max-width:980px){.sl-stats{padding:12px 14px 0}}
|
||||
@container slpanel (max-width:980px){.sl-stats{padding:12px 14px 0}}
|
||||
.sl-node{position:relative;display:flex;flex-direction:column;gap:2px;padding:8px 9px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.2));border-radius:10px;background:var(--dsw-alias-bg-layer-2,rgba(127,127,127,.05));cursor:pointer;text-align:left;color:inherit;font:inherit;min-width:0;transition:border-color .12s,box-shadow .12s,transform .12s}
|
||||
.sl-node:hover{transform:translateY(-1px);border-color:var(--dsw-alias-border-l3,rgba(127,127,127,.4))}
|
||||
.sl-node[aria-selected="true"]{border-color:color-mix(in srgb,var(--dsw-alias-state-business-primary,#3b82f6) 55%,transparent);box-shadow:inset 0 0 0 1px color-mix(in srgb,var(--dsw-alias-state-business-primary,#3b82f6) 28%,transparent)}
|
||||
|
|
@ -344,7 +344,7 @@ window.__ModuleLoader__.load({
|
|||
.sl-tab-mark{width:18px;height:18px;border-radius:5px;display:inline-flex;align-items:center;justify-content:center;font-size:9px;font-weight:600;background:var(--dsw-alias-bg-layer-3,rgba(127,127,127,.14));color:var(--dsw-alias-label-secondary,#5b616b)}
|
||||
|
||||
/* 2026 court workspace: quiet DSH surfaces, clear hierarchy, one blue accent. */
|
||||
.sl-root{--sl-accent:var(--dsw-alias-state-business-primary,#4d6bfe);--sl-card:var(--dsw-alias-bg-layer-1,#fff);--sl-page:var(--dsw-alias-bg-layer-2,#f5f6f8);--sl-line:var(--dsw-alias-border-l1,rgba(127,127,127,.14));background:var(--sl-page);font-size:13px}
|
||||
.sl-root{container-type:inline-size;container-name:slpanel;--sl-accent:var(--dsw-alias-state-business-primary,#4d6bfe);--sl-card:var(--dsw-alias-bg-layer-1,#fff);--sl-page:var(--dsw-alias-bg-layer-2,#f5f6f8);--sl-line:var(--dsw-alias-border-l1,rgba(127,127,127,.14));background:var(--sl-page);font-size:13px}
|
||||
.sl-section-kicker{font-size:9px;line-height:14px;letter-spacing:.13em;color:var(--dsw-alias-label-tertiary,#8a8f98);font-weight:600}
|
||||
.sl-state-dot{width:6px;height:6px;border-radius:50%;background:#22c55e;box-shadow:0 0 0 3px color-mix(in srgb,#22c55e 12%,transparent)}
|
||||
.sl-body{display:grid;grid-template-columns:minmax(0,1fr) 440px;gap:16px;padding:16px;overflow:hidden;background:var(--sl-page)}
|
||||
|
|
@ -402,9 +402,9 @@ window.__ModuleLoader__.load({
|
|||
.sl-root ::-webkit-scrollbar{width:6px;height:6px}
|
||||
.sl-root ::-webkit-scrollbar-thumb{background:var(--dsw-alias-border-l3,rgba(127,127,127,.3));border-radius:10px}
|
||||
.sl-root ::-webkit-scrollbar-track{background:transparent}
|
||||
@media (max-width:1180px){.sl-body{grid-template-columns:minmax(0,1fr) 400px;gap:12px;padding:12px}}
|
||||
@media (max-width:980px){.sl-body{display:flex;flex-direction:column;overflow-y:auto}.sl-right{width:auto;max-width:none;overflow:visible;border:0}.sl-task-panel{min-height:150px}.sl-stats{padding:0}.sl-detail{margin-bottom:0}}
|
||||
@media (max-width:620px){.sl-body{padding:9px;gap:10px}.sl-task-panel,.sl-map,.sl-detail{border-radius:11px}.sl-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.sl-map-head>span{display:none}}
|
||||
@container slpanel (max-width:1180px){.sl-body{grid-template-columns:minmax(0,1fr) 400px;gap:12px;padding:12px}}
|
||||
@container slpanel (max-width:980px){.sl-body{display:flex;flex-direction:column;overflow-y:auto}.sl-right{width:auto;max-width:none;overflow:visible;border:0}.sl-task-panel{min-height:150px}.sl-stats{padding:0}.sl-detail{margin-bottom:0}}
|
||||
@container slpanel (max-width:620px){.sl-body{padding:9px;gap:10px}.sl-task-panel,.sl-map,.sl-detail{border-radius:11px}.sl-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.sl-map-head>span{display:none}}
|
||||
|
||||
.sl-compact{padding:0}
|
||||
.sl-compact .sl-body{display:flex;flex-direction:column;padding:0;gap:0;overflow:hidden}
|
||||
|
|
@ -459,8 +459,8 @@ window.__ModuleLoader__.load({
|
|||
.sl-detail-head strong{font-size:15px;line-height:21px}
|
||||
.sl-detail-title small{display:block;margin-top:1px;line-height:15px}
|
||||
.sl-detail-chip{flex:none;padding:2px 7px;border-radius:5px;background:var(--sl-page);border:1px solid var(--sl-line);font-size:9px;line-height:14px;color:var(--dsw-alias-label-tertiary,#8a8f98)}
|
||||
.sl-detail-status{display:flex;align-items:center;gap:6px;min-width:0;padding:0 1px;font-size:10px;line-height:16px;color:var(--dsw-alias-label-secondary,#5b616b)}
|
||||
.sl-detail-status small{margin-left:auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-tertiary,#8a8f98)}
|
||||
.sl-detail-status{display:flex;align-items:center;flex-wrap:wrap;gap:6px;min-width:0;padding:0 1px;font-size:10px;line-height:16px;color:var(--dsw-alias-label-secondary,#5b616b)}
|
||||
.sl-detail-status small{flex:1 1 100%;margin:0;min-width:0;overflow:hidden;color:var(--dsw-alias-label-tertiary,#8a8f98);display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2;white-space:normal;overflow-wrap:anywhere}
|
||||
.sl-setting-block{display:flex;flex-direction:column;gap:9px;padding:11px;border:1px solid var(--sl-line);border-radius:11px;background:var(--sl-page)}
|
||||
.sl-setting-head{display:flex;align-items:center;justify-content:space-between;gap:8px}
|
||||
.sl-setting-head h3{margin:0;font-size:12px;line-height:18px;font-weight:600}
|
||||
|
|
@ -492,12 +492,11 @@ window.__ModuleLoader__.load({
|
|||
.sl-advanced-list div{display:flex;gap:8px;min-width:0}
|
||||
.sl-advanced-list dt{flex:none;width:58px;color:var(--dsw-alias-label-tertiary,#8a8f98)}
|
||||
.sl-advanced-list dd{margin:0;min-width:0;word-break:break-all;color:var(--dsw-alias-label-secondary,#5b616b)}
|
||||
@media (max-width:1180px){.sl-grid-6{gap:8px}.sl-node{min-height:76px;padding:10px}}
|
||||
@media (max-width:980px){.sl-grid-3,.sl-grid-6{grid-template-columns:repeat(3,minmax(0,1fr))}}
|
||||
@media (max-width:620px){.sl-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.sl-grid-3,.sl-grid-6{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.sl-connector-tri,.sl-stem{display:none}.sl-grid-1 .sl-node{width:100%}.sl-map{padding:13px 11px}.sl-detail{padding:13px}.sl-model-grid{grid-template-columns:minmax(0,1fr) 94px}}
|
||||
@media (max-width:420px){.sl-grid-3,.sl-grid-6{grid-template-columns:1fr}}
|
||||
@container slpanel (max-width:1180px){.sl-grid-6{gap:8px}.sl-node{min-height:76px;padding:10px}}
|
||||
@container slpanel (max-width:980px){.sl-grid-3,.sl-grid-6{grid-template-columns:repeat(3,minmax(0,1fr))}}
|
||||
@container slpanel (max-width:620px){.sl-stats{grid-template-columns:repeat(2,minmax(0,1fr))}.sl-grid-3,.sl-grid-6{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}.sl-connector-tri,.sl-stem{display:none}.sl-grid-1 .sl-node{width:100%}.sl-map{padding:13px 11px}.sl-detail{padding:13px}.sl-model-grid{grid-template-columns:minmax(0,1fr) 94px}}
|
||||
@container slpanel (max-width:330px){.sl-grid-3,.sl-grid-6{grid-template-columns:1fr}}
|
||||
.sl-compact .sl-stats{grid-template-columns:repeat(2,minmax(0,1fr))}
|
||||
.sl-compact .sl-grid-3,.sl-compact .sl-grid-6{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px}
|
||||
.sl-compact .sl-connector-tri,.sl-compact .sl-stem{display:none}
|
||||
.sl-compact .sl-grid-1 .sl-node{width:100%}
|
||||
button.sl-stat{appearance:none;width:100%;border:1px solid var(--sl-line);color:inherit;font:inherit;text-align:left;cursor:pointer}
|
||||
|
|
@ -512,7 +511,7 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
.sl-body.is-court .sl-detail{padding:18px}
|
||||
.sl-map-meta{display:flex;align-items:center;gap:9px;flex:none}
|
||||
.sl-map-meta>span{font-size:9px;line-height:14px;color:var(--dsw-alias-label-tertiary,#8a8f98);white-space:nowrap}
|
||||
@media (max-width:980px){.sl-body.is-court .sl-right{max-width:none}.sl-body.is-court .sl-map{padding:15px 13px}}
|
||||
@container slpanel (max-width:980px){.sl-body.is-court .sl-right{max-width:none}.sl-body.is-court .sl-map{padding:15px 13px}}
|
||||
|
||||
/* 右侧栏形态:聊天留给 DSH 原生会话,面板只承载朝堂与任务。 */
|
||||
.sl-sidebar{background:transparent}
|
||||
|
|
@ -542,7 +541,7 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
.sl-sidebar .sl-conversation-action{min-height:36px}
|
||||
.sl-side-tasks{flex:none;min-height:0;padding:15px 14px;border-radius:14px}
|
||||
.sl-sidebar .sl-task-panel .sl-section-title{padding-bottom:10px}
|
||||
@media (max-width:420px){.sl-sidebar .sl-map{padding:12px 10px}.sl-sidebar .sl-detail{padding:12px}.sl-side-tabs{position:static}}
|
||||
@container slpanel (max-width:420px){.sl-sidebar .sl-map{padding:12px 10px}.sl-sidebar .sl-detail{padding:12px}.sl-side-tabs{position:static}}
|
||||
`;
|
||||
const cssId = "dsh-sansheng-liubu-panel/panel.css";
|
||||
if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(cssId) + "]") === null) {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dsh-sansheng-liubu-panel",
|
||||
"version": "0.5.1",
|
||||
"version": "0.5.2",
|
||||
"private": true,
|
||||
"description": "三省六部 Agent 面板:在 DSH Web GUI 中常驻显示并切换团队 Agent",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -698,3 +698,23 @@ test('面板用到的每个 sl-* 类名都有对应 CSS 规则', () => {
|
|||
const missing = [...used].filter((name) => !defined.has(name)).sort()
|
||||
assert.deepEqual(missing, [], '不允许出现挂着类名却没有样式的元素')
|
||||
})
|
||||
|
||||
test('响应式跟随侧栏容器宽度,而不是浏览器视口', () => {
|
||||
const { css } = loadPlugin()
|
||||
const text = css()
|
||||
assert.match(text, /\.sl-root\{[^}]*container-type:inline-size/, '根节点要建立尺寸容器,才能按侧栏宽度断点')
|
||||
assert.equal(/@media\s*\(\s*max-width/.test(text), false, '不得再用视口断点:侧栏宽度与浏览器窗口宽度无关')
|
||||
const queries = [...text.matchAll(/@container slpanel \(max-width:(\d+)px\)/g)].map((match) => Number(match[1]))
|
||||
assert.ok(queries.length >= 10, `容器断点太少:${queries.length}`)
|
||||
for (const px of [1180, 980, 620]) {
|
||||
assert.ok(queries.includes(px), `缺少 ${px}px 容器断点`)
|
||||
}
|
||||
})
|
||||
|
||||
test('部门设置里的最近活动单独占一行,不再和状态挤在同一行', () => {
|
||||
const { css } = loadPlugin()
|
||||
const rule = css().match(/\.sl-detail-status small\{([^}]*)\}/)
|
||||
assert.ok(rule, '.sl-detail-status small 要有独立规则')
|
||||
assert.match(rule[1], /flex:1 1 100%/, '最近活动要独占一整行')
|
||||
assert.equal(/white-space:nowrap/.test(rule[1]), false, '不能强制单行,否则窄侧栏会横向挤压')
|
||||
})
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ const DEFAULTS = {
|
|||
scale: 2,
|
||||
chrome: null,
|
||||
htmlOnly: false,
|
||||
viewport: 0,
|
||||
}
|
||||
|
||||
/** 页面左侧留出的「会话区」宽度,让预览看起来是右侧栏而不是整页。 */
|
||||
|
|
@ -71,6 +72,7 @@ function printHelp() {
|
|||
--html-only 只生成 HTML,不调用 Chrome(无需安装浏览器)
|
||||
--scale=<1|2|3> 设备像素比(默认 ${DEFAULTS.scale})
|
||||
--chrome=<路径> 显式指定 Chrome/Edge 可执行文件
|
||||
--viewport=<像素> 可选:浏览器窗口宽度(默认 0 = 侧栏宽度 + 边,用来复现「大窗口 + 窄侧栏」)
|
||||
`)
|
||||
}
|
||||
|
||||
|
|
@ -106,6 +108,7 @@ function parseArgs(argv) {
|
|||
|
||||
options.width = toInt(options.width, '--width', 320, 900)
|
||||
options.scale = toInt(options.scale, '--scale', 1, 3)
|
||||
options.viewport = toInt(options.viewport, '--viewport', 0, 4000)
|
||||
if (!VIEWS.includes(options.view)) fail(`--view 只能是 ${VIEWS.join(' / ')},收到:${options.view}`)
|
||||
if (!THEMES.includes(options.theme)) fail(`--theme 只能是 ${THEMES.join(' / ')},收到:${options.theme}`)
|
||||
if (!options.name || /[\\/:*?"<>|]/.test(options.name)) fail(`--name 不能为空或包含路径字符:${options.name}`)
|
||||
|
|
@ -622,6 +625,13 @@ const DEMO_LABELS = {
|
|||
}
|
||||
const DEMO_RUNNING = new Set(['shangshu', 'hubu', 'gongbu'])
|
||||
|
||||
/** 一条较长的「最近活动」文本:真实宿主里这就是助手最后一条回复的截断,用来验证窄栏不把它挤断。 */
|
||||
const DEMO_STATUS_TEXT =
|
||||
'Chrome、Edge 和内置 Node 都可用。我把「真实组件预览生成器」交给队友做,现在已经能出图了。'
|
||||
const DEMO_NODES = new Map([
|
||||
['demo-1', { kind: 'assistant', anchorSeq: 1, data: { blocks: [{ kind: 'text', text: DEMO_STATUS_TEXT }] } }],
|
||||
])
|
||||
|
||||
function createDemoContext() {
|
||||
const members = DEMO_ROLES.map((role) => ({ id: `sess-${role}`, name: role, phase: 'active' }))
|
||||
const tasks = [
|
||||
|
|
@ -758,7 +768,7 @@ function createDemoContext() {
|
|||
},
|
||||
uiConversation: {
|
||||
binding: () => ({
|
||||
target: () => ({ getSnapshot: () => ({ nodes: new Map() }) }),
|
||||
target: () => ({ getSnapshot: () => ({ nodes: DEMO_NODES }) }),
|
||||
}),
|
||||
},
|
||||
modelDirectories: {
|
||||
|
|
@ -791,8 +801,10 @@ function createDemoContext() {
|
|||
|
||||
// #region HTML 外壳
|
||||
|
||||
function buildPage({ css, panelHtml, width, theme, view }) {
|
||||
function buildPage({ css, panelHtml, width, theme, view, viewport }) {
|
||||
const pageWidth = width + CHAT_EDGE
|
||||
// 窗口可以比侧栏宽:用来复现真实宿主里「大窗口 + 窄侧栏」的容器条件。
|
||||
const windowWidth = Math.max(Number(viewport) || 0, pageWidth)
|
||||
const dark = theme === 'dark'
|
||||
|
||||
const shellCss = `
|
||||
|
|
@ -837,6 +849,7 @@ body.pv-dark .pv-chat-edge{background:linear-gradient(90deg,#14161b 0%,#181b21 6
|
|||
|
||||
return {
|
||||
pageWidth,
|
||||
windowWidth,
|
||||
html: `<!doctype html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
|
|
@ -897,7 +910,7 @@ function readPngSize(pngPath) {
|
|||
return { width: bytes.readUInt32BE(16), height: bytes.readUInt32BE(20), bytes: bytes.length }
|
||||
}
|
||||
|
||||
function measureHeight(chrome, htmlPath, pageWidth, profileDir) {
|
||||
function measureHeight(chrome, htmlPath, pageWidth, windowWidth, profileDir) {
|
||||
const args = [
|
||||
'--headless=new',
|
||||
'--disable-gpu',
|
||||
|
|
@ -910,7 +923,7 @@ function measureHeight(chrome, htmlPath, pageWidth, profileDir) {
|
|||
'--mute-audio',
|
||||
`--user-data-dir=${profileDir}`,
|
||||
'--virtual-time-budget=3000',
|
||||
`--window-size=${pageWidth},600`,
|
||||
`--window-size=${windowWidth},600`,
|
||||
'--dump-dom',
|
||||
pathToFileURL(htmlPath).href,
|
||||
]
|
||||
|
|
@ -927,7 +940,7 @@ function measureHeight(chrome, htmlPath, pageWidth, profileDir) {
|
|||
return height
|
||||
}
|
||||
|
||||
function screenshot(chrome, htmlPath, pngPath, pageWidth, height, scale, profileDir) {
|
||||
function screenshot(chrome, htmlPath, pngPath, pageWidth, height, scale, profileDir, windowWidth) {
|
||||
const args = [
|
||||
'--headless=new',
|
||||
'--disable-gpu',
|
||||
|
|
@ -941,7 +954,7 @@ function screenshot(chrome, htmlPath, pngPath, pageWidth, height, scale, profile
|
|||
'--mute-audio',
|
||||
`--user-data-dir=${profileDir}`,
|
||||
'--virtual-time-budget=3000',
|
||||
`--window-size=${pageWidth},${height}`,
|
||||
`--window-size=${windowWidth},${height}`,
|
||||
`--screenshot=${pngPath}`,
|
||||
pathToFileURL(htmlPath).href,
|
||||
]
|
||||
|
|
@ -997,7 +1010,7 @@ async function main() {
|
|||
}
|
||||
|
||||
// 先落中间 HTML:即使后面的校验/截图失败,也能直接打开排查。
|
||||
const page = buildPage({
|
||||
const page = buildPage({ viewport: options.viewport,
|
||||
css: bundle.css,
|
||||
panelHtml,
|
||||
width: options.width,
|
||||
|
|
@ -1051,14 +1064,14 @@ async function main() {
|
|||
|
||||
let size
|
||||
try {
|
||||
const measured = measureHeight(chrome, htmlPath, page.pageWidth, profileDir)
|
||||
const measured = measureHeight(chrome, htmlPath, page.pageWidth, page.windowWidth, profileDir)
|
||||
const height = Math.max(200, Math.ceil(measured) + 2)
|
||||
size = screenshot(chrome, htmlPath, pngPath, page.pageWidth, height, options.scale, profileDir)
|
||||
size = screenshot(chrome, htmlPath, pngPath, page.pageWidth, height, options.scale, profileDir, page.windowWidth)
|
||||
|
||||
const expectedWidth = page.pageWidth * options.scale
|
||||
const expectedWidth = page.windowWidth * options.scale
|
||||
if (size.width !== expectedWidth) {
|
||||
fail(
|
||||
`截图宽度 ${size.width}px 与预期 ${expectedWidth}px(${page.pageWidth}×${options.scale})不符,` +
|
||||
`截图宽度 ${size.width}px 与预期 ${expectedWidth}px(${page.windowWidth}×${options.scale})不符,` +
|
||||
'页面可能被 Chrome 缩放或窗口尺寸未生效。',
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue