0.5.4:入口搬进左侧栏导航列
用户要的是「插件 / 定时任务 / 任务看板 / MCP 连接器」那一列,底部那条不合位。 那一列只由 sidebar.panellist 驱动,点击又由宿主写死为 selectPanel(id) 去要 main 槽, 所以两槽必须成对注册,范围收在「纯跳转」。 - sidebar.panellist:一行导航(id sansheng-liubu、order 10、label 三省六部), 图标是插件画的 18px 细线「三」字样标,激活时线宽 1.6。 - main:只作重定向桩(key sansheng-liubu)。挂载即 dockToSidebarTab: 停靠右侧栏、清提示、selectPanel(null) 退回原会话;没有会话时页面中央写明原因。 不渲染朝堂、不承载聊天。 - 底部入口保留,两处等价,共用同一条提示存储。 - check-install 从「禁止 panellist/main」改为「允许导航行 + 重定向桩」, 仍禁止 panellist.actions 与把朝堂面板塞进 main。 - 41 项测试、node --check、git diff --check、check-install 全过。
This commit is contained in:
parent
76fc05d97b
commit
5b37f114cc
|
|
@ -2,6 +2,14 @@
|
|||
|
||||
> 版本号以 `package.json` 为准(当前 0.5.x 线);下面 0.6.x 条目沿用旧编号,保留作历史。
|
||||
|
||||
## 0.5.4 — 入口搬进左侧栏导航列
|
||||
|
||||
- 用户要的不是底部那一条,而是「插件 / 定时任务 / 任务看板 / MCP 连接器」那一列;那一列只认 `sidebar.panellist`,于是注册一行导航:`id: sansheng-liubu`、`order: 10`、`label: 三省六部`,图标是插件画的 18px 细线「三」字样标(`SanshengNavGlyph`,激活时线宽 1.6)。
|
||||
- 那一列的点击行为由宿主写死为 `selectPanel(id)`,一定要 `main` 槽,所以同时注册 `main`(`key: sansheng-liubu`)作为**重定向桩**:`SanshengDockRedirect` 挂载后立刻调 `dockToSidebarTab(host)`,停靠右侧栏、清掉旧提示、`selectPanel(null)` 退回原会话;没有会话时只在页面中央写明原因(`.sl-dock-stub`)。它不渲染朝堂、不承载聊天,这是对 0.5.0「两个槽一律不注册」的收敛式修订。
|
||||
- 底部入口(`sidebar.footer.action`)保留:两处入口等价,共用同一条提示存储。
|
||||
- 新增 2 条测试:导航行与 `main` 桩的注册(含 `label()` 与 `key`)、`dockToSidebarTab` 成功/失败两条路径(失败时不得 `selectPanel`)。另修了断言写法:`h("svg", props, [children])` 在测试替身里是单层嵌套,要先 `.flat()`。
|
||||
- 41 项测试、`node --check`、`git diff --check`、`check-install` 全部通过。
|
||||
|
||||
## 0.5.3 — 左侧栏也有三省六部入口
|
||||
|
||||
- 在左侧栏底部(`sidebar.footer.action`,`id: sansheng-liubu:rail`)加了一个常驻入口:只做「把朝堂停靠到当前会话的右侧栏」,与会话头开关共用同一条提示存储,不切整页面板、不新增聊天存储。
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
## 2. 预览依据
|
||||
|
||||
0.5.3 的预览图由 `scripts/preview.mjs` 生成:脚本用 vm 加载**真实的** `panel/lib/client.js`,用会重渲染的 hooks 替身跑真实组件树,把结果序列化成 HTML,再用 headless Chrome 截图。因此它是真实 CSS + 真实 DOM 的渲染结果,不是生成式模拟图。
|
||||
0.5.4 的预览图由 `scripts/preview.mjs` 生成:脚本用 vm 加载**真实的** `panel/lib/client.js`,用会重渲染的 hooks 替身跑真实组件树,把结果序列化成 HTML,再用 headless Chrome 截图。因此它是真实 CSS + 真实 DOM 的渲染结果,不是生成式模拟图。
|
||||
|
||||
440px 明亮主题:
|
||||
|
||||
|
|
@ -37,6 +37,10 @@
|
|||
|
||||

|
||||
|
||||
左侧栏导航行的观感(展开/折叠/激活态,以及 main 重定向桩的两种文案):
|
||||
|
||||

|
||||
|
||||
重新生成的方式写在 `docs/panel-handoff.md` 顶部。截图只覆盖组件在给定容器宽度下的表现,**不覆盖**宿主槽位宽度、滚动容器与真实主题变量注入;最终验收仍需在 DSH Host 中截图确认。统计数字 10 / 3 / 4 是测试替身给的示例数据,不得硬编码为真实数据。
|
||||
|
||||
## 3. 面板结构
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
# 三省六部面板:换环境开发交接方案
|
||||
|
||||
日期:2026-11-08
|
||||
当前版本:`0.5.3`
|
||||
状态:侧栏化改造、残留清理、容器断点与左侧栏入口均已实现并通过 39 项本地测试;尚未在真实 DSH Host 里做最终视觉验收。
|
||||
当前版本:`0.5.4`
|
||||
状态:侧栏化改造、残留清理、容器断点与左侧栏入口均已实现并通过 41 项本地测试;尚未在真实 DSH Host 里做最终视觉验收。
|
||||
|
||||

|
||||
|
||||
|
|
@ -46,12 +46,14 @@ node scripts/preview.mjs --width=440 --view=tasks --theme=light --name=panel-sid
|
|||
- 十席角色:丞相、中书省、尚书省、门下省、吏部、户部、礼部、兵部、刑部、工部。
|
||||
- 朝堂图为「丞相 → 三省 → 六部」,六部两排三列,同属尚书省调度。
|
||||
- 部门为实体卡片:字徽、边框、状态点和中文状态;选中态有蓝边、浅底和勾选标记。
|
||||
- 插件只注册会话头部入口与右侧栏页签,不再注册 `main`、`sidebar.panellist` 或 `sidebar.panellist.actions`。
|
||||
- 插件注册会话头部入口、左侧栏导航行(`sidebar.panellist`)、底部入口(`sidebar.footer.action`)与右侧栏页签;`sidebar.panellist.actions` 仍不注册。
|
||||
- 右侧栏包含「朝堂 / 任务」页签、2×2 统计卡、朝堂图、部门配置和任务列表。
|
||||
- DSH 原生输入框注册 `@` 来源,列出已有会话的部门;选中后进入该部门子会话。
|
||||
- 进入部门子会话时自动选中对应部门;返回丞相主会话时恢复选中丞相。
|
||||
- 移除 Agent 预设编辑、重复的「下旨」输入框和独立聊天摘要。
|
||||
- 复用 DSH 主题变量,支持明亮、深色与窄侧栏布局。
|
||||
- 0.5.4 把入口放进左侧栏导航列(`插件 / 定时任务 / 任务看板 / MCP 连接器` 那一列):注册 `sidebar.panellist` 一行(细线「三」字样标 + 标签),点击后走宿主的 `selectPanel(id)`。
|
||||
- 因为那一列的点击一定要 `main` 槽,所以同时注册 `main`(`key: PANEL_ID`)作为**重定向桩**:进去立刻把朝堂停靠到当前会话右侧栏并 `selectPanel(null)` 退回原会话;没有会话时只在页面中央写明原因。它不渲染面板、不承载聊天。
|
||||
- 0.5.3 在左侧栏底部(`sidebar.footer.action`)加了一个常驻入口:只做「把朝堂停靠到右侧栏」这一件事,与会话头开关等价,不切整页面板、不带第二套聊天。折叠侧栏时只剩「三省」字标,展开时带文字,失败原因显示在文字下方(`role="status"`,最多两行)。
|
||||
- 0.5.3 去掉了会话头开关失败时对 `host.togglePanel()` 的回退:0.5.0 起没有 `main` 槽,那个调用只会把主区域切到一个不存在的面板上。
|
||||
- 0.5.2 把响应式断点从浏览器视口改到面板容器:`.sl-root` 声明 `container-type:inline-size;container-name:slpanel`,11 处 `@media (max-width: …)` 全部改为 `@container slpanel (max-width: …)`。真实宿主窗口最大化时侧栏仍只有 371px,原来的视口断点一个都不会触发。
|
||||
|
|
@ -59,7 +61,7 @@ node scripts/preview.mjs --width=440 --view=tasks --theme=light --name=panel-sid
|
|||
- `scripts/preview.mjs` 新增 `--viewport`,可以渲染「大窗口 + 窄侧栏」的真实宿主形态。
|
||||
- 0.5.1 清掉侧栏化残留:46 个不再渲染的 `sl-*` 类、无调用点的 `SanshengPinRow`/`DockButton`/`SidebarIcon`,以及三个无规则的幽灵类名。
|
||||
- 会话头部开关在拿不到会话时把原因显示在开关旁,不再静默回退;CSS 与组件的一致性由测试兜住。
|
||||
- 版本更新到 `0.5.3`;`CHANGELOG.md`、`panel/README.md`、`docs/panel-design.md` 已同步。
|
||||
- 版本更新到 `0.5.4`;`CHANGELOG.md`、`panel/README.md`、`docs/panel-design.md` 已同步。
|
||||
|
||||
## 3. 当前验证结果
|
||||
|
||||
|
|
@ -76,7 +78,7 @@ $env:ELECTRON_RUN_AS_NODE = '1'
|
|||
结果:
|
||||
|
||||
- 语法检查通过。
|
||||
- **39 项测试全部通过**。
|
||||
- **41 项测试全部通过**。
|
||||
- `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 与组件确实不在渲染路径上。
|
||||
|
|
@ -93,7 +95,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` | 策略与权限测试 | 与客户端测试合计 39 项 |
|
||||
| `test/policy.test.js` | 策略与权限测试 | 与客户端测试合计 41 项 |
|
||||
| `scripts/check-install.mjs` | 安装一致性检查 | 已改为校验右侧栏注册、拒绝旧的 main/panellist |
|
||||
| `scripts/preview.mjs` | 零依赖预览生成器:vm 加载真实 bundle → 渲染真实组件树 → HTML → headless Chrome 截图 | 需放开沙箱跑 Chrome;`--html-only` 只出 HTML |
|
||||
| `docs/panel-design.md` | 设计依据与验收标准 | 已更新到侧栏结构 |
|
||||
|
|
@ -107,15 +109,18 @@ $env:ELECTRON_RUN_AS_NODE = '1'
|
|||
- `seatMentionOptions` / `createSeatMentionSource` / `registerSeatMentions`:原生 `@` 来源。
|
||||
- `childRoleOf`:由子会话 id 反查部门角色,用于自动选中。
|
||||
- `openSeatConversation` / `returnToLead`:进入部门会话与返回丞相。
|
||||
- `apply`:只注册四个原生槽位:
|
||||
- `apply`:注册六个原生槽位:
|
||||
- `conversation.session.header.actions`(会话头开关)
|
||||
- `sidebar.panellist`(左侧栏导航列的一行;图标是插件提供的细线「三」字样标)
|
||||
- `main`(只作重定向桩:停靠右侧栏后退回原会话,不渲染面板)
|
||||
- `sidebar.footer.action`(左侧栏底部常驻入口,只做跳转)
|
||||
- `sidebar.right.pane.tab`
|
||||
- `sidebar.right.pane.tab.title`
|
||||
- `dockToSidebarTab(host)`:导航行点击后的实际动作(成功清提示并 `selectPanel(null)`,失败只写提示),导出在 `__test` 里供测试直接驱动。
|
||||
|
||||
## 5. 不可破坏的决策
|
||||
|
||||
1. **不恢复整页面板**。不要把 `main`、`sidebar.panellist` 加回来;这会让用户再次看到第二套聊天和重复入口。左侧栏入口只能用 `sidebar.footer.action` 这类「纯按钮」槽位——`sidebar.panellist` 的点击会走 `selectPanel` 去要 `main` 槽。
|
||||
1. **不恢复整页面板**。`sidebar.panellist` 只用于「左侧栏导航列的一行」,`main` 只用于「点进去立刻退回会话」的重定向桩:两者都不得渲染朝堂内容、不得承载聊天、不得出现第二套输入框。用户 0.5.4 明确要求入口出现在导航列,这是对 0.5.0「两个槽一律不注册」的收敛式修订——范围限定在「纯跳转」,不是把整页面板请回来。
|
||||
2. **不造第二套聊天存储**。消息只在 DSH 原生会话里发送与保存。
|
||||
3. **不静默改投消息**。普通 `@` 文本不能自动把当前会话消息转发给别的 Agent;进入哪个会话,消息就发给谁。
|
||||
4. **@ 只列已有会话的部门**。未设官、无子会话的部门不能伪造入口。
|
||||
|
|
@ -183,7 +188,7 @@ git clone sansheng-liubu-0.5.0.bundle 三省六部
|
|||
## 7. 可直接粘贴给新环境 Agent 的交接提示
|
||||
|
||||
```text
|
||||
你在 C:\Users\qyh15\三省六部 继续一个 DSH Web 客户端插件项目(dsh-sansheng-liubu-panel,当前 0.5.3)。
|
||||
你在 C:\Users\qyh15\三省六部 继续一个 DSH Web 客户端插件项目(dsh-sansheng-liubu-panel,当前 0.5.4)。
|
||||
|
||||
用户目标:三省六部面板只存在于会话右侧栏;聊天必须复用 DSH 原生输入框;在原生输入框用 @ 选择部门后进入该部门子会话,并自动选中右侧对应部门;不要再恢复整页面板或第二套聊天。
|
||||
|
||||
|
|
@ -194,7 +199,7 @@ git clone sansheng-liubu-0.5.0.bundle 三省六部
|
|||
- panel/test/client.test.js
|
||||
- scripts/check-install.mjs
|
||||
|
||||
当前状态:侧栏化、残留清理、容器断点与左侧栏入口都已实现,39 项测试通过,check-install 通过,工作树可能尚未提交。不要创建备份目录。
|
||||
当前状态:侧栏化、残留清理、容器断点与左侧栏入口(含导航行)都已实现,41 项测试通过,check-install 通过,工作树可能尚未提交。不要创建备份目录。
|
||||
|
||||
请先:
|
||||
1. 运行现有测试和 check-install,确认基线;
|
||||
|
|
@ -205,7 +210,7 @@ git clone sansheng-liubu-0.5.0.bundle 三省六部
|
|||
6. 用 Git 提交,不要建时间戳副本。
|
||||
|
||||
硬约束:
|
||||
- 不注册 main、sidebar.panellist、sidebar.panellist.actions;
|
||||
- 不注册 sidebar.panellist.actions;main 与 sidebar.panellist 只允许作「导航行 + 重定向桩」;
|
||||
- 不新增聊天存储,不静默把消息转发给其他 Agent;
|
||||
- @ 候选只含已有会话的部门;
|
||||
- 不改变 index.js 的角色工具权限边界;
|
||||
|
|
@ -221,7 +226,7 @@ git clone sansheng-liubu-0.5.0.bundle 三省六部
|
|||
- [ ] 进入子会话自动选中对应部门,返回后恢复丞相。
|
||||
- [ ] 原生输入框发送的消息不会误投给其他 Agent。
|
||||
- [ ] 明亮/深色主题都可读,焦点与选中状态可见。
|
||||
- [ ] 39 项测试、`node --check`、`git diff --check`、`check-install` 全部通过。
|
||||
- [ ] 41 项测试、`node --check`、`git diff --check`、`check-install` 全部通过。
|
||||
- [ ] 有真实 DSH Host 截图作为最终视觉证据。
|
||||
|
||||
## 9. 已知风险
|
||||
|
|
|
|||
Binary file not shown.
|
After Width: | Height: | Size: 77 KiB |
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dsh-sansheng-liubu-mode",
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"private": true,
|
||||
"description": "上朝:丞相统筹的三省六部多 Agent 模式",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -301,6 +301,8 @@ window.__ModuleLoader__.load({
|
|||
.sl-rail-copy{display:flex;flex-direction:column;min-width:0;gap:1px}
|
||||
.sl-rail-label{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
||||
.sl-rail-notice{font-size:10px;line-height:13px;color:var(--dsw-alias-state-error-primary,#dc2626);overflow:hidden;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;line-clamp:2}
|
||||
.sl-dock-stub{position:absolute;inset:0;display:flex;align-items:center;justify-content:center;gap:10px;padding:24px;color:var(--dsw-alias-label-secondary,#5b616b);font-size:13px;line-height:20px;text-align:center}
|
||||
.sl-dock-stub-text{max-width:min(460px,80%);overflow-wrap:anywhere}
|
||||
.sl-root{display:flex;flex-direction:column;height:100%;min-height:0;background:var(--dsw-alias-bg-layer-1,#fff);color:var(--dsw-alias-label-primary,#1f2329);font-size:13px;line-height:20px}
|
||||
.sl-crash{display:flex;flex-direction:column;gap:8px;margin:24px;padding:18px 20px;border:1px solid #e5484d;border-radius:10px;background:#fff5f5;color:#8b1a1d;font-size:13px;line-height:20px;white-space:normal}
|
||||
.sl-crash strong{font-size:14px}
|
||||
|
|
@ -1626,6 +1628,62 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
}
|
||||
|
||||
|
||||
/** 左栏导航列的图标:细线「三」字样标,和宿主其它线性图标同一观感。 */
|
||||
function SanshengNavGlyph(props) {
|
||||
const size = Number(props.size) || 18;
|
||||
const active = props.active === true;
|
||||
const bar = (key, y) => h("path", { key, d: "M6 " + y + "h6", stroke: "currentColor", strokeWidth: 1.2, strokeLinecap: "round" });
|
||||
return h("svg", {
|
||||
width: size,
|
||||
height: size,
|
||||
viewBox: "0 0 18 18",
|
||||
fill: "none",
|
||||
"aria-hidden": "true",
|
||||
"data-sansheng-glyph": active ? "active" : "idle",
|
||||
}, [
|
||||
h("rect", { key: "box", x: 2.3, y: 2.3, width: 13.4, height: 13.4, rx: 4.2, stroke: "currentColor", strokeWidth: active ? 1.6 : 1.3, opacity: active ? 1 : 0.9 }),
|
||||
bar("bar-a", 6.4),
|
||||
bar("bar-b", 9),
|
||||
bar("bar-c", 11.6),
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 把朝堂停靠到当前会话的右侧栏,然后把主区域退回原会话。
|
||||
* 抽成普通函数是为了让测试能直接驱动真实的成功/失败分支(测试替身不执行 useEffect)。
|
||||
* 成功返回 null;失败返回原因文本,并写进开关旁的提示存储。
|
||||
*/
|
||||
function dockToSidebarTab(host) {
|
||||
const result = host.openSanshengTab();
|
||||
if (result && result.ok) {
|
||||
host.setToggleNotice(null);
|
||||
host.selectPanel(null);
|
||||
return null;
|
||||
}
|
||||
const reason = result && result.error ? result.error : "当前无法停靠到右侧栏。";
|
||||
host.setToggleNotice(reason);
|
||||
return reason;
|
||||
}
|
||||
|
||||
/**
|
||||
* 「插件」那一列点击后的落点。那一列的行只由 sidebar.panellist 驱动,点击写死走
|
||||
* selectPanel(id) → 向宿主索取 main 槽;这里给 main 一个重定向桩:有会话就立刻停靠到
|
||||
* 右侧栏并退回原会话,没有会话就把原因写在页面上。它不是第二套面板,也不承载聊天。
|
||||
*/
|
||||
function SanshengDockRedirect(props) {
|
||||
const host = props.host;
|
||||
const [reason, setReason] = React.useState(null);
|
||||
React.useEffect(() => {
|
||||
const failure = dockToSidebarTab(host);
|
||||
if (failure) setReason(failure);
|
||||
}, []);
|
||||
return h("div", { className: "sl-dock-stub", "data-sansheng-dock": "1" }, [
|
||||
h("span", { key: "mark", className: "sl-rail-mark", "aria-hidden": "true", children: "三省" }),
|
||||
h("span", { key: "text", className: "sl-dock-stub-text", children: reason || "正在把朝堂停靠到右侧栏…" }),
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
function SanshengTabTitle() {
|
||||
return h("div", { className: "sl-tab-title", "data-sansheng-tab-title": "1" }, [
|
||||
h("span", { key: "mark", className: "sl-tab-mark", children: "三省" }),
|
||||
|
|
@ -1716,8 +1774,22 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
order: 40,
|
||||
}, (props) => h(SanshengToggle, { ...props, host })));
|
||||
|
||||
// 左侧栏导航列(插件 / 定时任务 / 任务看板 那一列):用户要求入口在那里。
|
||||
// 那一列的行全部来自 sidebar.panellist,点击写死走 selectPanel(id) 再向宿主索取 main 槽,
|
||||
// 所以同时注册一个 main 重定向桩:点进去立刻停靠到右侧栏并退回原会话,不留空白主区域。
|
||||
ctx.slots.inject("sidebar.panellist", () => ctx.slots.register({
|
||||
name: "sidebar.panellist",
|
||||
id: PANEL_ID,
|
||||
order: 10,
|
||||
label: () => "三省六部",
|
||||
}, (props) => h(SanshengNavGlyph, props)));
|
||||
|
||||
ctx.slots.inject("main", () => ctx.slots.register({
|
||||
name: "main",
|
||||
key: PANEL_ID,
|
||||
}, (props) => h(SanshengDockRedirect, { ...props, host })));
|
||||
|
||||
// 左侧栏底部的常驻入口:与会话头开关等价,只做「停靠到右侧栏」这一件事。
|
||||
// 不用 sidebar.panellist:那个槽的点击会走 selectPanel 去要 main 槽,而 0.5.0 起不再注册 main。
|
||||
ctx.slots.inject("sidebar.footer.action", () => ctx.slots.register({
|
||||
name: "sidebar.footer.action",
|
||||
id: PANEL_ID + ":rail",
|
||||
|
|
@ -1799,6 +1871,7 @@ button.sl-stat-members:focus-visible{outline:2px solid color-mix(in srgb,var(--s
|
|||
seatMentionOptions,
|
||||
childRoleOf,
|
||||
createSeatMentionSource,
|
||||
dockToSidebarTab,
|
||||
};
|
||||
return module.exports;
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "dsh-sansheng-liubu-panel",
|
||||
"version": "0.5.3",
|
||||
"version": "0.5.4",
|
||||
"private": true,
|
||||
"description": "三省六部 Agent 面板:在 DSH Web GUI 中常驻显示并切换团队 Agent",
|
||||
"type": "module",
|
||||
|
|
|
|||
|
|
@ -156,23 +156,74 @@ test('exports the panel and the seat mention helpers', () => {
|
|||
assert.equal(JSON.stringify(exports.inject), JSON.stringify(['slots', 'sessions', 'uiWorkspace', 'uiConversation', 'modelDirectories', 'remote', 'remote.agentPresets', 'sidebarRightTabs', 'sidebarRight']))
|
||||
})
|
||||
|
||||
test('registers only the native header action, one rail entry and right sidebar tabs', () => {
|
||||
test('registers the left nav row, one rail entry, the native header action and right sidebar tabs', () => {
|
||||
const { exports } = loadPlugin()
|
||||
const { ctx, registrations, injected } = mockContext()
|
||||
exports.apply(ctx)
|
||||
assert.deepEqual(injected, ['conversation.session.header.actions', 'sidebar.footer.action', 'sidebar.right.pane.tab', 'sidebar.right.pane.tab.title'])
|
||||
assert.equal(registrations.some((entry) => entry.options.name === 'sidebar.panellist'), false, '不再注册左侧整页面板入口')
|
||||
assert.equal(registrations.some((entry) => entry.options.name === 'sidebar.panellist.actions'), false)
|
||||
assert.equal(registrations.some((entry) => entry.options.name === 'main'), false, '不再占用 main 整页槽')
|
||||
assert.deepEqual(injected, ['conversation.session.header.actions', 'sidebar.panellist', 'main', 'sidebar.footer.action', 'sidebar.right.pane.tab', 'sidebar.right.pane.tab.title'])
|
||||
assert.equal(typeof exports.createHost(ctx).sendPrompt, 'function')
|
||||
const toggle = registrations.find((entry) => entry.options.name === 'conversation.session.header.actions')
|
||||
assert.ok(toggle, '会话头保留打开朝堂侧栏的入口')
|
||||
assert.equal(toggle.options.id, 'sansheng-liubu:toggle')
|
||||
const nav = registrations.find((entry) => entry.options.name === 'sidebar.panellist')
|
||||
assert.ok(nav, '左侧栏导航列也有入口')
|
||||
assert.equal(nav.options.id, 'sansheng-liubu')
|
||||
assert.equal(nav.options.label(), '三省六部')
|
||||
assert.ok(Number.isFinite(nav.options.order), '导航列要给出排序,才能稳定落在固定位置')
|
||||
const stub = registrations.find((entry) => entry.options.name === 'main')
|
||||
assert.ok(stub, '那一列的点击会索取 main 槽,必须有落点')
|
||||
assert.equal(stub.options.key, 'sansheng-liubu', 'main 用 key 与侧栏行对齐,不是再开一套面板')
|
||||
const tab = registrations.find((entry) => entry.options.name === 'sidebar.right.pane.tab')
|
||||
assert.ok(tab, '右侧栏注册朝堂页签')
|
||||
assert.equal(tab.options.key, 'sansheng-liubu-tab')
|
||||
})
|
||||
|
||||
test('左栏导航图标的「三」字样标按激活状态换描边', () => {
|
||||
const { exports } = loadPlugin()
|
||||
const { ctx, registrations } = mockContext()
|
||||
exports.apply(ctx)
|
||||
const nav = registrations.find((entry) => entry.options.name === 'sidebar.panellist')
|
||||
// 注册项返回 h(SanshengNavGlyph, props),再调用一次才是真正的 svg 节点。
|
||||
const glyphOf = (props) => {
|
||||
const wrapper = nav.component(props)
|
||||
return wrapper.type(wrapper.props)
|
||||
}
|
||||
const idle = glyphOf({ size: 18, active: false })
|
||||
const active = glyphOf({ size: 18, active: true })
|
||||
assert.equal(idle.type, 'svg')
|
||||
assert.equal(idle.props.width, 18)
|
||||
assert.equal(idle.props['data-sansheng-glyph'], 'idle')
|
||||
assert.equal(active.props['data-sansheng-glyph'], 'active')
|
||||
// 替身的 createElement 把可变参数放进 children,数组实参会成为单层嵌套,这里拉平。
|
||||
const kids = (idle.children || []).flat()
|
||||
assert.equal(kids.length, 4, '外框 + 三横')
|
||||
const activeKids = (active.children || []).flat()
|
||||
assert.ok(activeKids[0].props.strokeWidth > kids[0].props.strokeWidth, '激活态加粗')
|
||||
})
|
||||
|
||||
test('导航列点击后把朝堂停靠到右侧栏,再退回原会话', () => {
|
||||
const { exports } = loadPlugin()
|
||||
const { dockToSidebarTab } = exports.__test
|
||||
const calls = []
|
||||
const okHost = {
|
||||
openSanshengTab: () => ({ ok: true }),
|
||||
setToggleNotice: (value) => calls.push(['notice', value]),
|
||||
selectPanel: (id) => calls.push(['selectPanel', id]),
|
||||
}
|
||||
assert.equal(dockToSidebarTab(okHost), null)
|
||||
assert.deepEqual(calls, [['notice', null], ['selectPanel', null]], '成功后清掉提示并退出 main 槽')
|
||||
|
||||
calls.length = 0
|
||||
const failHost = {
|
||||
openSanshengTab: () => ({ ok: false, error: '当前还没有打开任何会话' }),
|
||||
setToggleNotice: (value) => calls.push(['notice', value]),
|
||||
selectPanel: (id) => calls.push(['selectPanel', id]),
|
||||
}
|
||||
assert.equal(dockToSidebarTab(failHost), '当前还没有打开任何会话')
|
||||
assert.deepEqual(calls, [['notice', '当前还没有打开任何会话']], '失败时只写提示,不能把人留在一个不存在的面板上')
|
||||
})
|
||||
|
||||
|
||||
test('summarizes the court into four sidebar stats', () => {
|
||||
const { exports } = loadPlugin()
|
||||
const { arrangeRoster, courtStats } = exports.__test
|
||||
|
|
|
|||
|
|
@ -71,8 +71,14 @@ assert(typeof panel.apply === 'function', 'panel host must export apply')
|
|||
const clientSource = await readFile(join(dirname(panelManifestPath), 'lib', 'client.js'), 'utf8')
|
||||
assert(clientSource.includes('id: "dsh-sansheng-liubu-panel"'), 'client bundle id must match the panel package name')
|
||||
assert(clientSource.includes('"sidebar.right.pane.tab"'), 'client bundle must register the right sidebar tab')
|
||||
assert(!clientSource.includes('"sidebar.panellist"'), 'client bundle must not register the retired full-page panel entry')
|
||||
assert(!clientSource.includes('name: "main"'), 'client bundle must not register a main workspace panel')
|
||||
// 0.5.4 起:「左侧栏导航列的一行 + main 重定向桩」是允许的(用户要求入口出现在那一列),
|
||||
// 但范围严格限定为纯跳转:不得注册 panellist 的更多菜单动作,也不得注册整页面板。
|
||||
assert(clientSource.includes('"sidebar.panellist"'), 'client bundle must register the left nav row')
|
||||
assert(clientSource.includes('name: "sidebar.panellist"'), 'left nav row must go through the panellist slot')
|
||||
assert(clientSource.includes('name: "main"'), 'left nav row needs a main redirect stub to leave the workspace empty')
|
||||
assert(clientSource.includes('SanshengDockRedirect'), 'main slot must only be the redirect stub, not a full-page panel')
|
||||
assert(!/sidebar\.panellist\.actions/.test(clientSource), 'client bundle must not register panellist more-menu actions')
|
||||
assert(!clientSource.includes('h(SanshengPanel, { ...props, host })'), 'main slot must not render the court panel itself')
|
||||
|
||||
console.log(JSON.stringify({
|
||||
profile: profilePath,
|
||||
|
|
|
|||
Loading…
Reference in New Issue