fix(ui): open skill previews in the shared drawer

This commit is contained in:
Sycun committed 2026-11-15 11:18:49 +08:00
1 parent 91d3e3ac3f
commit 42d8755a45
4 files changed
+84 -5

No files matched your search

+2
View File
@@ -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 清理以及“查看 → 编辑”切换,防止只验证编辑表单而遗漏只读详情入口。
+79 -2
View File
@@ -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(
+2 -2
View File
@@ -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();
+1 -1
View File
@@ -7066,7 +7066,7 @@
<script src="/static/js/theme.js"></script>
<script src="/static/js/builtin-tools.js"></script>
<script src="/static/js/auth.js?v=20261008-password-eye-1"></script>
<script src="/static/js/modal.js?v=20261115-2"></script>
<script src="/static/js/modal.js?v=20261115-skill-view-drawer"></script>
<dialog id="vulnerability-download-dialog" aria-labelledby="vulnerability-download-heading" aria-describedby="vulnerability-download-hint">
<div class="vulnerability-download-content">
<h3 id="vulnerability-download-heading" data-i18n="vulnerabilityDownload.title">下载漏洞报告</h3>