From 42d8755a45a37b646208df37dfa64c2a499f9518 Mon Sep 17 00:00:00 2001
From: Sycun <165354365+Sycun@users.noreply.github.com>
Date: Sun, 15 Nov 2026 11:18:49 +0800
Subject: [PATCH] fix(ui): open skill previews in the shared drawer
---
docs/ui-design-system.md | 2 +
scripts/ui-realistic-scenarios.cjs | 81 +++++++++++++++++++++++++++++-
web/static/js/modal.js | 4 +-
web/templates/index.html | 2 +-
4 files changed, 84 insertions(+), 5 deletions(-)
diff --git a/docs/ui-design-system.md b/docs/ui-design-system.md
index 01c61c0c..7e99fdd2 100644
--- a/docs/ui-design-system.md
+++ b/docs/ui-design-system.md
@@ -61,3 +61,5 @@ NODE_PATH=/tmp/csai-ui-tools/node_modules node scripts/check-ui-design-system.cj
回归增加了:暂停/待执行/运行/完成/取消、Cron 开关、中英文切换、桌面与手机断点切换、空标题和含特殊字符的标题。
针对可见的开始/继续/重跑按钮,检查正常、悬停和键盘焦点状态下的计算颜色,要求文字与不透明背景的对比度不低于 4.5:1;每档尺寸和主题的计算结果保存为 `queue-contrast-*.json`。
浏览器回归使用真实 i18next 翻译函数,不再用固定中文替代函数覆盖它。
+
+Skill 的“查看”入口动态创建 `skill-view-modal`,与编辑入口共用宽抽屉。回归同时验证摘要展示、按需加载全文、展开、Escape 清理以及“查看 → 编辑”切换,防止只验证编辑表单而遗漏只读详情入口。
diff --git a/scripts/ui-realistic-scenarios.cjs b/scripts/ui-realistic-scenarios.cjs
index 5acce0eb..a495af01 100644
--- a/scripts/ui-realistic-scenarios.cjs
+++ b/scripts/ui-realistic-scenarios.cjs
@@ -75,7 +75,15 @@ module.exports = async function ({ page, width, height, theme, out }) {
skill: {
id: "review-skill",
description: "多文件技能包编辑测试",
- content: "# 审核步骤\n" + "核对已有证据。\n".repeat(40),
+ name: "review-skill",
+ path: "skills/review-skill",
+ scripts: [
+ { rel_path: "scripts/check.py", description: "离线证据校核" },
+ ],
+ content:
+ url.searchParams.get("depth") === "summary"
+ ? "# 技能摘要\n按需加载正文。"
+ : "# 审核步骤\n" + "核对已有证据。\n".repeat(40),
},
};
return { ok: true, json: async () => data };
@@ -317,7 +325,76 @@ module.exports = async function ({ page, width, height, theme, out }) {
assert.equal(await page.locator("#role-modal-title").innerText(), "添加角色");
await page.evaluate(() => closeRoleModal());
await activate("page-skills-management");
- await page.evaluate(() => editSkill("review-skill"));
+ // View is dynamically created and must use the same square drawer as Edit.
+ await page.evaluate(() => viewSkill("review-skill"));
+ await page.locator("#skill-view-modal").waitFor();
+ await page.waitForTimeout(220);
+ const skillView = await page.locator("#skill-view-modal").evaluate((e) => {
+ const p = e.querySelector(".modal-content"),
+ r = p.getBoundingClientRect(),
+ s = getComputedStyle(p);
+ return {
+ surface: e.dataset.uiSurface,
+ width: r.width,
+ right: r.right,
+ height: r.height,
+ radius: s.borderRadius,
+ bg: s.backgroundColor,
+ footer: e.querySelector(".modal-footer").getBoundingClientRect().bottom,
+ };
+ });
+ assert.equal(skillView.surface, "drawer");
+ assert.equal(skillView.radius, "0px");
+ assert(
+ Math.abs(skillView.right - width) < 2 &&
+ Math.abs(skillView.height - height) < 2,
+ JSON.stringify(skillView),
+ );
+ assert(
+ Math.abs(
+ skillView.width - (width < 768 ? width : Math.min(960, width - 48)),
+ ) < 2,
+ JSON.stringify(skillView),
+ );
+ assert(skillView.footer <= height + 1, JSON.stringify(skillView));
+ assert.equal(
+ skillView.bg,
+ theme === "dark" ? "rgb(17, 24, 39)" : "rgb(255, 255, 255)",
+ );
+ assert.equal(
+ await page.locator("#skill-view-body").innerText(),
+ "# 技能摘要\n按需加载正文。",
+ );
+ await shot("skill-view-summary");
+ await page.locator("#skill-view-modal [data-skill-load-full]").click();
+ await page.waitForFunction(() =>
+ document
+ .getElementById("skill-view-body")
+ .textContent.startsWith("# 审核步骤"),
+ );
+ if (width >= 768) {
+ await page.locator("#skill-view-modal .app-drawer-expand").click();
+ assert(
+ (await page.locator("#skill-view-modal .modal-content").boundingBox())
+ .width >= skillView.width,
+ );
+ }
+ await page.keyboard.press("Escape");
+ assert.equal(await page.locator("#skill-view-modal").count(), 0);
+ assert.equal(
+ await page.evaluate(() =>
+ document.body.classList.contains("app-modal-open"),
+ ),
+ false,
+ );
+ await page.evaluate(() => viewSkill("review-skill"));
+ await page.locator("#skill-view-modal [data-skill-view-edit]").click();
+ assert.equal(await page.locator("#skill-view-modal").count(), 0);
+ await page.locator("#skill-modal").waitFor();
+ assert.equal(
+ await page.locator("#skill-modal").getAttribute("data-ui-surface"),
+ "drawer",
+ );
await page.locator("#skill-content").waitFor();
await page.evaluate(() => applyTranslations(document));
assert.equal(
diff --git a/web/static/js/modal.js b/web/static/js/modal.js
index 90c9cfc4..39591dda 100644
--- a/web/static/js/modal.js
+++ b/web/static/js/modal.js
@@ -25,13 +25,13 @@
'batch-queue-detail-modal', 'batch-manage-modal', 'batch-import-modal',
'mcp-detail-modal', 'external-mcp-modal', 'attack-chain-modal',
'fact-modal', 'fact-detail-modal', 'knowledge-item-modal', 'retrieval-log-details-modal',
- 'audit-detail-modal', 'hitl-log-modal', 'skill-modal', 'agent-md-modal', 'role-modal',
+ 'audit-detail-modal', 'hitl-log-modal', 'skill-modal', 'skill-view-modal', 'agent-md-modal', 'role-modal',
'rbac-user-modal', 'rbac-role-modal', 'chat-files-edit-modal', 'webshell-modal',
'workflow-package-import-modal', 'workflow-ai-modal', 'robot-commands-modal',
'robot-account-binding-modal', 'c2-modal',
]);
const WIDE_IDS = new Set([
- 'skill-modal', 'agent-md-modal', 'role-modal', 'fact-modal', 'vulnerability-modal',
+ 'skill-modal', 'skill-view-modal', 'agent-md-modal', 'role-modal', 'fact-modal', 'vulnerability-modal',
'chat-files-edit-modal', 'batch-queue-detail-modal', 'mcp-detail-modal', 'attack-chain-modal',
]);
const returnFocus = new WeakMap();
diff --git a/web/templates/index.html b/web/templates/index.html
index ea1be695..903d9f09 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -7066,7 +7066,7 @@
-
+