From 5b2f87d20574b412fac865475e3812c9a9bdd69a Mon Sep 17 00:00:00 2001
From: Sycun <165354365+Sycun@users.noreply.github.com>
Date: Sun, 15 Nov 2026 10:13:50 +0800
Subject: [PATCH 1/5] feat(vulnerabilities): show timestamps and support
oldest-first ordering
---
internal/database/vulnerability.go | 7 ++++--
internal/handler/vulnerability.go | 4 +--
internal/handler/vulnerability_group_test.go | 4 +++
web/static/css/vulnerability-list.css | 24 +++++++++++++++---
web/static/i18n/ar-SA.json | 3 ++-
web/static/i18n/en-US.json | 3 ++-
web/static/i18n/ru-RU.json | 3 ++-
web/static/i18n/zh-CN.json | 3 ++-
web/static/js/vulnerability-workspace.js | 3 ++-
web/static/js/vulnerability.js | 26 ++++++++++++++++++--
web/templates/index.html | 9 ++++---
11 files changed, 71 insertions(+), 18 deletions(-)
diff --git a/internal/database/vulnerability.go b/internal/database/vulnerability.go
index 45cdee27..8fe9931d 100644
--- a/internal/database/vulnerability.go
+++ b/internal/database/vulnerability.go
@@ -374,6 +374,9 @@ func (db *DB) ListVulnerabilitiesByGroupForAccess(limit, offset int, filter Vuln
case "severity":
itemOrder = vulnerabilitySeverityRankExpr + ", created_at DESC, id"
groupOrder = "group_severity, group_latest DESC, " + groupOrder
+ case "oldest":
+ itemOrder = "created_at ASC, id"
+ groupOrder = "group_oldest ASC, " + groupOrder
case "latest":
groupOrder = "group_latest DESC, " + groupOrder
}
@@ -382,12 +385,12 @@ func (db *DB) ListVulnerabilitiesByGroupForAccess(limit, offset int, filter Vuln
if groupQuery != "" {
prefix = `WITH scoped AS (` + groupQuery + `),
page_groups AS (
- SELECT group_key, MIN(group_is_ip) AS group_is_ip, MIN(severity_rank) AS group_severity, MAX(created_at) AS group_latest
+ SELECT group_key, MIN(group_is_ip) AS group_is_ip, MIN(severity_rank) AS group_severity, MAX(created_at) AS group_latest, MIN(created_at) AS group_oldest
FROM scoped GROUP BY group_key
ORDER BY ` + groupOrder + ` LIMIT ? OFFSET ?
),
page_items AS (
- SELECT scoped.id, scoped.group_key, page_groups.group_is_ip, page_groups.group_severity, page_groups.group_latest
+ SELECT scoped.id, scoped.group_key, page_groups.group_is_ip, page_groups.group_severity, page_groups.group_latest, page_groups.group_oldest
FROM scoped JOIN page_groups USING (group_key)
)`
args = append(args, limit, offset)
diff --git a/internal/handler/vulnerability.go b/internal/handler/vulnerability.go
index 0833c321..19a1b0b1 100644
--- a/internal/handler/vulnerability.go
+++ b/internal/handler/vulnerability.go
@@ -190,8 +190,8 @@ func (h *VulnerabilityHandler) ListVulnerabilities(c *gin.Context) {
access := vulnerabilityAccessFromContext(c)
groupBy := c.Query("group_by")
sortBy := c.Query("sort")
- if sortBy != "" && sortBy != "severity" && sortBy != "latest" {
- c.JSON(http.StatusBadRequest, gin.H{"error": "sort must be severity or latest"})
+ if sortBy != "" && sortBy != "severity" && sortBy != "latest" && sortBy != "oldest" {
+ c.JSON(http.StatusBadRequest, gin.H{"error": "sort must be severity, latest or oldest"})
return
}
diff --git a/internal/handler/vulnerability_group_test.go b/internal/handler/vulnerability_group_test.go
index 9c9907c7..0c54a6d7 100644
--- a/internal/handler/vulnerability_group_test.go
+++ b/internal/handler/vulnerability_group_test.go
@@ -124,6 +124,10 @@ func TestListVulnerabilitiesGroupedViews(t *testing.T) {
{"group_by=task&sort=severity&page=2", []string{"domain-new", "filtered", "ipv6"}},
{"group_by=host&sort=latest", []string{"filtered", "domain-new", "domain-old", "unknown"}},
{"group_by=task&sort=latest", []string{"filtered", "ipv6", "domain-new", "unknown"}},
+ {"group_by=none&sort=oldest", []string{"domain-old", "domain-new"}},
+ {"group_by=none&sort=oldest&page=2", []string{"subdomain", "ipv6"}},
+ {"group_by=host&sort=oldest", []string{"domain-old", "domain-new", "filtered", "domain-old"}},
+ {"group_by=task&sort=oldest", []string{"domain-old", "subdomain", "domain-new", "ipv6", "filtered"}},
{"group_by=none&sort=severity", []string{"domain-old", "unknown"}},
{"group_by=host&sort=severity&severity=high", []string{"unknown", "subdomain"}},
{"group_by=host&sort=latest&q=missing", []string{}},
diff --git a/web/static/css/vulnerability-list.css b/web/static/css/vulnerability-list.css
index e1fab152..b34106ef 100644
--- a/web/static/css/vulnerability-list.css
+++ b/web/static/css/vulnerability-list.css
@@ -10,7 +10,8 @@
.vulnerability-record-row {
display: grid;
- grid-template-columns: 18px 52px minmax(0, 1fr) auto;
+ grid-template-columns: 18px 52px minmax(220px, 1fr) auto max-content;
+ overflow-x: auto;
align-items: center;
column-gap: 12px;
min-height: 72px;
@@ -124,7 +125,7 @@
@media (max-width: 600px) {
.vulnerability-record-row {
- grid-template-columns: 18px 46px minmax(0, 1fr);
+ grid-template-columns: 18px 46px minmax(200px, 1fr) auto max-content;
gap: 8px;
padding: 12px;
}
@@ -133,7 +134,24 @@
min-height: 0 !important;
}
.vulnerability-record-actions {
- grid-column: 2 / -1;
justify-content: flex-end;
}
}
+
+.vulnerability-record-time {
+ display: flex;
+ flex-direction: column;
+ gap: 3px;
+ white-space: nowrap;
+ font-size: 12px;
+ font-variant-numeric: tabular-nums;
+ color: var(--text-secondary);
+}
+
+.vulnerability-record-time-label { font-size: 11px; }
+
+/* Keep the status menu inside the scrollable row without clipping its options. */
+.vulnerability-record-row .vuln-status-picker-menu {
+ position: static;
+ margin-top: 6px;
+}
diff --git a/web/static/i18n/ar-SA.json b/web/static/i18n/ar-SA.json
index fb21ccc4..f75c7f30 100644
--- a/web/static/i18n/ar-SA.json
+++ b/web/static/i18n/ar-SA.json
@@ -2820,7 +2820,8 @@
"sortLabel": "الترتيب",
"sortDefault": "الترتيب الافتراضي",
"sortSeverity": "الأعلى خطورة أولاً",
- "sortLatest": "الأحدث أولاً",
+ "sortLatest": "الإنشاء: الأحدث أولاً",
+ "sortOldest": "الإنشاء: الأقدم أولاً",
"expandPage": "توسيع الصفحة",
"collapsePage": "طي الصفحة",
"hostPagination": "عرض {{start}}–{{end}} من أصل {{total}} مجموعة حسب المضيف",
diff --git a/web/static/i18n/en-US.json b/web/static/i18n/en-US.json
index 71a13efc..ba50a0f7 100644
--- a/web/static/i18n/en-US.json
+++ b/web/static/i18n/en-US.json
@@ -2962,7 +2962,8 @@
"sortLabel": "Sort",
"sortDefault": "Default order",
"sortSeverity": "Severity first",
- "sortLatest": "Newest findings",
+ "sortLatest": "Created: newest first",
+ "sortOldest": "Created: oldest first",
"expandPage": "Expand page",
"collapsePage": "Collapse page",
"hostPagination": "Showing {{start}}–{{end}} of {{total}} host groups",
diff --git a/web/static/i18n/ru-RU.json b/web/static/i18n/ru-RU.json
index 5a11dc74..14caeba3 100644
--- a/web/static/i18n/ru-RU.json
+++ b/web/static/i18n/ru-RU.json
@@ -2975,7 +2975,8 @@
"sortLabel": "Сортировка",
"sortDefault": "По умолчанию",
"sortSeverity": "По критичности",
- "sortLatest": "Сначала новые",
+ "sortLatest": "Создание: сначала новые",
+ "sortOldest": "Создание: сначала старые",
"expandPage": "Развернуть страницу",
"collapsePage": "Свернуть страницу",
"hostPagination": "Показано {{start}}–{{end}} из {{total}} групп по хостам",
diff --git a/web/static/i18n/zh-CN.json b/web/static/i18n/zh-CN.json
index e2cd13b3..2cf56c02 100644
--- a/web/static/i18n/zh-CN.json
+++ b/web/static/i18n/zh-CN.json
@@ -2950,7 +2950,8 @@
"sortLabel": "排序",
"sortDefault": "默认顺序",
"sortSeverity": "高危优先",
- "sortLatest": "最新发现",
+ "sortLatest": "创建时间:最新优先",
+ "sortOldest": "创建时间:最早优先",
"expandPage": "展开本页",
"collapsePage": "收起本页",
"hostPagination": "显示 {{start}}–{{end}} / 共 {{total}} 个域名组",
diff --git a/web/static/js/vulnerability-workspace.js b/web/static/js/vulnerability-workspace.js
index a198d4d6..1649de8a 100644
--- a/web/static/js/vulnerability-workspace.js
+++ b/web/static/js/vulnerability-workspace.js
@@ -146,7 +146,8 @@ async function openVulnerabilityInspector(id) {
${escapeHtml(vulnSeverityLabel(v.severity))}
${buildVulnerabilityStatusPicker(v)}
${escapeHtml(v.type || '')}
- ${escapeHtml(new Date(v.created_at).toLocaleString(vulnDateLocale()))}
+ ${escapeHtml(vulnT('vulnerabilityMd.labelCreated'))}: ${renderVulnerabilityTimestamp(v.created_at)}
+ ${escapeHtml(vulnT('vulnerabilityMd.labelUpdated'))}: ${renderVulnerabilityTimestamp(v.updated_at)}
diff --git a/web/static/js/vulnerability.js b/web/static/js/vulnerability.js
index f971ce22..efc141d7 100644
--- a/web/static/js/vulnerability.js
+++ b/web/static/js/vulnerability.js
@@ -239,7 +239,7 @@ let vulnerabilityView = savedVulnerabilityView === 'case' ? 'none'
let vulnerabilityListRequest = 0;
let vulnerabilityStatsRequest = 0;
const savedVulnerabilitySort = localStorage.getItem('vulnerabilityListSort');
-let vulnerabilitySort = ['severity', 'latest'].includes(savedVulnerabilitySort) ? savedVulnerabilitySort : '';
+let vulnerabilitySort = ['severity', 'latest', 'oldest'].includes(savedVulnerabilitySort) ? savedVulnerabilitySort : '';
let vulnerabilityHostQuery = '';
let vulnerabilityTaskQuery = '';
let vulnerabilityBrowserSelection = '';
@@ -1402,7 +1402,7 @@ function renderVulnerabilities(vulnerabilities, renderOptions) {
}
function changeVulnerabilitySort(value) {
- if (!['', 'severity', 'latest'].includes(value)) return;
+ if (!['', 'severity', 'latest', 'oldest'].includes(value)) return;
vulnerabilitySort = value;
localStorage.setItem('vulnerabilityListSort', value);
loadVulnerabilities(1);
@@ -1597,6 +1597,24 @@ function renderVulnerabilityList(items) {
return `
${items.map(renderVulnerabilityListItem).join('')}
`;
}
+// Use the browser's local timezone and preserve seconds for chronological comparison.
+function formatVulnerabilityTimestamp(value) {
+ if (!value) return '—';
+ const date = new Date(value);
+ if (!Number.isFinite(date.getTime())) return '—';
+ return date.toLocaleString(vulnDateLocale(), {
+ year: 'numeric', month: '2-digit', day: '2-digit',
+ hour: '2-digit', minute: '2-digit', second: '2-digit', hour12: false
+ });
+}
+
+function renderVulnerabilityTimestamp(value) {
+ const label = formatVulnerabilityTimestamp(value);
+ if (label === '—') return label;
+ const iso = new Date(value).toISOString();
+ return `
`;
+}
+
function renderVulnerabilityListItem(vuln) {
const id = escapeAttr(vuln.id);
const jsID = escapeJsStringAttr(vuln.id);
@@ -1615,6 +1633,10 @@ function renderVulnerabilityListItem(vuln) {
${buildVulnerabilityStatusPicker(vuln)}
+
+ ${escapeHtml(vulnT('vulnerabilityMd.labelCreated'))}
+ ${renderVulnerabilityTimestamp(vuln.created_at)}
+
`;
}
diff --git a/web/templates/index.html b/web/templates/index.html
index 7ee100eb..94232705 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -48,7 +48,7 @@
-
+
@@ -2864,7 +2864,8 @@
@@ -7106,8 +7107,8 @@
-
-
+
+
From 6518bfe7d582c8a8c9a8fa5689885ce088c0b6c9 Mon Sep 17 00:00:00 2001
From: Sycun <165354365+Sycun@users.noreply.github.com>
Date: Sun, 15 Nov 2026 10:45:51 +0800
Subject: [PATCH 2/5] feat(ui): unify responsive surfaces and detail drawers
---
docs/ui-design-system.md | 63 +++++
scripts/check-ui-design-system.cjs | 358 +++++++++++++++++++++++++
scripts/ui-realistic-scenarios.cjs | 411 +++++++++++++++++++++++++++++
web/static/css/design-system.css | 299 +++++++++++++++++++++
web/static/i18n/ar-SA.json | 1 +
web/static/i18n/en-US.json | 1 +
web/static/i18n/ru-RU.json | 1 +
web/static/i18n/zh-CN.json | 1 +
web/static/js/modal.js | 121 ++++++++-
web/static/js/roles.js | 2 +
web/static/js/skills.js | 2 +
web/static/js/tasks.js | 23 +-
web/templates/index.html | 25 +-
13 files changed, 1282 insertions(+), 26 deletions(-)
create mode 100644 docs/ui-design-system.md
create mode 100644 scripts/check-ui-design-system.cjs
create mode 100644 scripts/ui-realistic-scenarios.cjs
create mode 100644 web/static/css/design-system.css
diff --git a/docs/ui-design-system.md b/docs/ui-design-system.md
new file mode 100644
index 00000000..3c7e9bfd
--- /dev/null
+++ b/docs/ui-design-system.md
@@ -0,0 +1,63 @@
+# 界面样式约定
+
+主应用的公共样式位于 `web/static/css/design-system.css`,在模块与移动端 CSS 后加载。
+颜色沿用现有主题变量;卡片圆角 16px,控件圆角 10px,桌面正文内边距 24px,移动端 16px。
+状态色、选中态、图表、终端和工作流画布保留各自的业务语义。
+
+## 容器选择
+
+- 详情、日志、长表单:右侧抽屉,默认 720px;代码、长文本等宽编辑面板 960px;标题栏可展开至 1440px。
+- 手机(小于 768px):抽屉全屏,适配安全区,正文单独滚动,底部操作保持可见。
+- 确认、重命名、简短绑定:居中短弹窗,手机上同样保持紧凑。
+- 数据比较和批量操作继续使用表格;终端、工作流、会话工作区不强制改成卡片列表。
+
+`web/static/js/modal.js` 的 `DRAWER_IDS` 和 `WIDE_IDS` 管理既有模块迁移清单。
+新模块应通过 `openAppModal` / `closeAppModal` 开关容器,关闭时保留原有清理和未保存提示逻辑。
+共用生命周期负责嵌套层级、背景滚动锁定、焦点返回、Tab 焦点约束和 Escape 触发原关闭按钮。
+异步更新的标题栏会自动补齐展开按钮。短 C2 休眠设置仍为弹窗。
+
+不要再为单个抽屉添加独立的定位、遮罩、圆角或主题色覆盖。
+现阶段公共布局中少量 `!important` 用于覆盖历史内联宽高和移动端旧规则;后续修改这些模块时可逐步去除对应历史声明。
+
+## 验证
+
+前端回归:
+
+```sh
+node --test web/static/js/*.test.cjs
+```
+
+浏览器验证需要外部安装的 Playwright 和 Chromium,例如:
+
+```sh
+npm install --prefix /tmp/csai-ui-tools playwright
+/tmp/csai-ui-tools/node_modules/.bin/playwright install chromium
+NODE_PATH=/tmp/csai-ui-tools/node_modules node scripts/check-ui-design-system.cjs
+```
+
+脚本使用真实模板、样式和选定模块的真实渲染函数,配以合成数据;不启动后端或访问测试目标。
+检查 1440、1024、390、360px 四档屏宽和深浅主题,验证抽屉边界、内部横向溢出、底栏、嵌套层级、展开、键盘关闭、焦点返回,以及主页面横向溢出。
+截图与结果默认写入系统临时目录,也可通过 `CSAI_UI_ARTIFACTS` 指定目录。
+这覆盖界面布局和公共交互,不等同于真实后端数据、保存操作、所有下拉菜单状态或物理手机软键盘的完整验收。
+
+### 真实数据形态回归
+
+`check-ui-design-system.cjs` 现在调用 `ui-realistic-scenarios.cjs`,并加载真实 i18next/翻译实现。
+回归数据依据实际页面的数量、文本长度和按钮状态匿名构造,不复制目标地址、凭据或业务证据。
+
+- 365 条队列任务,分别渲染暂停、运行、完成状态;验证真实操作按钮不会挤压标题或越界。
+- 626 个工具、614 个已启用工具及长描述;使用真实角色编辑入口检查统计换行和正文滚动。
+- 角色与多文件 Skill 的新增/编辑切换,以及打开编辑后跨越桌面/手机断点;验证翻译刷新不改变编辑标题。
+- 50 条长漏洞记录和三页分页:验证手机整页滚动,标题与分页不会固定占用记录区。
+
+所有场景都在四档屏宽与两种主题下运行;夹具请求拒绝非 GET 操作。
+需要定位单个断点时可设置 `CSAI_UI_WIDTHS=390`;提交前省略该变量运行完整矩阵。
+
+### 队列动态文案与按钮对比度
+
+队列标题将可翻译的前缀与原样保留的队列名称分开渲染;执行按钮的 `data-i18n` 随暂停、待执行及 Cron 状态更新。
+主要操作的小号按钮明确使用强调色背景和配套文字色,避免旧尺寸样式把背景改灰后仍保留深色文字。
+
+回归增加了:暂停/待执行/运行/完成/取消、Cron 开关、中英文切换、桌面与手机断点切换、空标题和含特殊字符的标题。
+针对可见的开始/继续/重跑按钮,检查正常、悬停和键盘焦点状态下的计算颜色,要求文字与不透明背景的对比度不低于 4.5:1;每档尺寸和主题的计算结果保存为 `queue-contrast-*.json`。
+浏览器回归使用真实 i18next 翻译函数,不再用固定中文替代函数覆盖它。
diff --git a/scripts/check-ui-design-system.cjs b/scripts/check-ui-design-system.cjs
new file mode 100644
index 00000000..e2f81f8f
--- /dev/null
+++ b/scripts/check-ui-design-system.cjs
@@ -0,0 +1,358 @@
+/** Offline Chromium layout/keyboard regression checks using production HTML/CSS/renderers.
+ * Install Playwright outside the source tree; run with NODE_PATH pointing to that node_modules.
+ * Uses synthetic records; never starts the backend or sends requests to assessment targets.
+ */
+const { chromium } = require("playwright");
+const fs = require("fs"),
+ http = require("http"),
+ path = require("path");
+const root = path.resolve(__dirname, "..");
+const out =
+ process.env.CSAI_UI_ARTIFACTS ||
+ fs.mkdtempSync(path.join(require("os").tmpdir(), "csai-ui-"));
+fs.mkdirSync(out, { recursive: true });
+const html = fs
+ .readFileSync(root + "/web/templates/index.html", "utf8")
+ .replace(/',
+ );
+const server = http.createServer((req, res) => {
+ const p = req.url.split("?")[0];
+ if (p.startsWith("/api/")) {
+ res.setHeader("Content-Type", "application/json");
+ return res.end("{}");
+ }
+ if (p === "/") {
+ res.setHeader("Content-Type", "text/html");
+ return res.end(html);
+ }
+ const f = path.join(root, "web", p);
+ if (!f.startsWith(root + "/web/") || !fs.existsSync(f)) {
+ res.statusCode = 404;
+ return res.end();
+ }
+ res.setHeader(
+ "Content-Type",
+ p.endsWith(".css")
+ ? "text/css"
+ : p.endsWith(".js")
+ ? "application/javascript"
+ : "application/octet-stream",
+ );
+ res.end(fs.readFileSync(f));
+});
+(async () => {
+ await new Promise((r) => server.listen(0, "127.0.0.1", r));
+ const browser = await chromium.launch({ headless: true });
+ const findings = [];
+ let count = 0;
+ for (const width of process.env.CSAI_UI_WIDTHS
+ ? process.env.CSAI_UI_WIDTHS.split(",").map(Number)
+ : [1440, 1024, 390, 360])
+ for (const theme of ["light", "dark"]) {
+ const height =
+ width === 360 ? 640 : width === 390 ? 844 : width === 1024 ? 768 : 900;
+ const page = await browser.newPage({
+ viewport: { width, height },
+ colorScheme: theme,
+ locale: "zh-CN",
+ });
+ page.on("pageerror", (e) =>
+ findings.push({ width, theme, issue: e.message }),
+ );
+ await page.goto("http://127.0.0.1:" + server.address().port);
+ await page.evaluate(() => window.i18nReady);
+ await page.evaluate((t) => {
+ document.documentElement.dataset.theme = t;
+ document
+ .querySelectorAll(".page")
+ .forEach((e) => e.classList.remove("active"));
+ document
+ .getElementById("page-roles-management")
+ .classList.add("active");
+ }, theme);
+ const ids = await page
+ .locator('[data-ui-surface="drawer"]')
+ .evaluateAll((els) => els.map((e) => e.id));
+ for (const id of ids) {
+ // A drawer nested in a page is visible only while that page is active.
+ await page.evaluate((id) => {
+ const e = document.getElementById(id);
+ e.closest(".settings-section-content")?.classList.add("active");
+ const parent = e.closest(".page");
+ if (parent) {
+ document
+ .querySelectorAll(".page")
+ .forEach((p) => p.classList.remove("active"));
+ parent.classList.add("active");
+ }
+ openAppModal(id);
+ }, id);
+ await page.waitForTimeout(220);
+ const info = await page.evaluate((id) => {
+ const e = document.getElementById(id),
+ p = e.firstElementChild,
+ r = p.getBoundingClientRect(),
+ s = getComputedStyle(p),
+ b = p.querySelector(
+ ".modal-body,.projects-modal-body,.c2-modal-body,#vulnerability-inspector-body",
+ );
+ return {
+ id,
+ x: r.x,
+ y: r.y,
+ w: r.width,
+ h: r.height,
+ bg: s.backgroundColor,
+ overflow: b ? b.scrollWidth > b.clientWidth + 2 : false,
+ footer: p
+ .querySelector(
+ ".modal-footer,.projects-modal-footer,.c2-modal-footer",
+ )
+ ?.getBoundingClientRect().bottom,
+ };
+ }, id);
+ count++;
+ const channel = Number(info.bg.match(/\d+/)?.[0]);
+ if (
+ (theme === "dark" && channel > 100) ||
+ (theme === "light" && channel < 200)
+ )
+ findings.push({
+ width,
+ theme,
+ id,
+ issue: "surface theme mismatch",
+ bg: info.bg,
+ });
+ if (
+ info.x < -0.5 ||
+ info.y < -0.5 ||
+ Math.abs(info.x + info.w - width) > 2 ||
+ Math.abs(info.h - height) > 2 ||
+ info.footer > height + 1 ||
+ info.overflow
+ )
+ findings.push({ width, theme, ...info });
+ if (
+ [
+ "role-modal",
+ "asset-editor-modal",
+ "vulnerability-modal",
+ "skill-modal",
+ ].includes(id)
+ )
+ await page.screenshot({
+ animations: "disabled",
+ path: out + "/" + id + "-" + width + "-" + theme + ".png",
+ });
+ await page.evaluate((id) => closeAppModal(id), id);
+ }
+ // Compact actions should remain short on mobile; test nested layer and restoration.
+ await page.evaluate(() => {
+ openAppModal("fact-detail-modal");
+ openAppModal("fact-modal");
+ });
+ const nested = await page.evaluate(
+ () =>
+ Number(
+ getComputedStyle(document.getElementById("fact-modal")).zIndex,
+ ) >
+ Number(
+ getComputedStyle(document.getElementById("fact-detail-modal"))
+ .zIndex,
+ ),
+ );
+ if (!nested) throw new Error("nested stacking");
+ await page.evaluate(() => {
+ closeAppModal("fact-modal");
+ closeAppModal("fact-detail-modal");
+ openAppModal("project-modal");
+ });
+ const small = await page.locator("#project-modal > div").boundingBox();
+ if (small.height >= height - 10)
+ throw new Error("short dialog is full screen");
+ await page.evaluate(() => closeAppModal("project-modal"));
+ if (width === 1440) {
+ await page.evaluate(() => openAppModal("role-modal"));
+ await page.locator("#role-modal .app-drawer-expand").click();
+ const expanded = await page.locator("#role-modal > div").boundingBox();
+ if (expanded.width < 1200) throw new Error("expand failed");
+ await page.evaluate(() => closeAppModal("role-modal"));
+ }
+ // Load production renderers with synthetic data; no backend or target execution.
+ await page.evaluate(() => {
+ window.apiFetch = async () => ({
+ ok: true,
+ json: async () => ({
+ log: {
+ createdAt: "2026-11-15T08:00:00Z",
+ category: "config",
+ action: "apply",
+ result: "success",
+ message: "配置已保存",
+ detail: { source: "UI fixture" },
+ },
+ }),
+ });
+ window.showToast = (m) => console.log("TOAST", m);
+ });
+ for (const script of ["knowledge", "audit", "roles", "c2"])
+ await page.addScriptTag({ url: "/static/js/" + script + ".js" });
+ await page.evaluate(() => showAuditLogDetail("fixture"));
+ await page.waitForTimeout(100);
+ if (
+ (await page
+ .locator("#audit-detail-modal .app-drawer-expand")
+ .count()) !== 1
+ ) {
+ console.log(
+ await page
+ .locator("#audit-detail-modal")
+ .evaluateAll((es) => es.map((e) => e.outerHTML)),
+ );
+ throw new Error("deferred audit header missing");
+ }
+ await page.screenshot({
+ animations: "disabled",
+ path: out + "/audit-" + width + "-" + theme + ".png",
+ });
+ await page.keyboard.press("Escape");
+ if (await page.locator("#audit-detail-modal").count())
+ throw new Error("Escape did not run audit cleanup");
+ await page.evaluate(() =>
+ showRetrievalLogDetailsModal(
+ {
+ createdAt: "2026-11-15T08:00:00Z",
+ query: "查找接口鉴权检查方法",
+ riskType: "鉴权",
+ },
+ [
+ {
+ title: "接口鉴权检查",
+ category: "Web",
+ content: "验证不同角色之间的数据访问边界。",
+ },
+ ],
+ ),
+ );
+ await page.waitForTimeout(100);
+ await page.screenshot({
+ animations: "disabled",
+ path: out + "/retrieval-" + width + "-" + theme + ".png",
+ });
+ await page.evaluate(() => closeRetrievalLogDetailsModal());
+ await page.route("**/api/**", (route) =>
+ route.fulfill({ json: { profiles: [], projects: [], listeners: [] } }),
+ );
+ await page.evaluate(() => C2.showCreateListenerModal());
+ await page.waitForTimeout(200);
+ if ((await page.locator("#c2-modal .app-drawer-expand").count()) !== 1)
+ throw new Error("C2 header missing");
+ await page.screenshot({
+ animations: "disabled",
+ path: out + "/c2-" + width + "-" + theme + ".png",
+ });
+ await page.evaluate(() => C2.closeModal());
+ // Test focus wrap, native close cleanup and restoration through real role handlers.
+ await page.evaluate(() => {
+ const b = document.createElement("button");
+ b.textContent = "Open editor";
+ document.body.appendChild(b);
+ b.focus();
+ window.fixtureFocus = b;
+ openAppModal("role-modal");
+ });
+ await page.waitForTimeout(30);
+ await page.locator("#role-modal .modal-footer .btn-primary").focus();
+ await page.keyboard.press("Tab");
+ if (
+ !(await page.evaluate(() =>
+ document
+ .getElementById("role-modal")
+ .contains(document.activeElement),
+ ))
+ )
+ throw new Error("focus escaped");
+ await page.keyboard.press("Escape");
+ if (
+ !(await page.evaluate(
+ () =>
+ !isAppModalOpen("role-modal") &&
+ document.activeElement === window.fixtureFocus,
+ ))
+ )
+ throw new Error("close/focus restore failed");
+ await page.evaluate(() => {
+ window.fixtureFocus.remove();
+ roles = [
+ {
+ name: "安全审计",
+ description: "检查授权范围内的代码与配置,整理可复核的证据。",
+ tools: ["read_file", "search_code"],
+ enabled: true,
+ },
+ {
+ name: "报告整理",
+ description: "汇总已验证发现,生成清晰的报告。",
+ tools: [],
+ enabled: true,
+ },
+ ];
+ renderRolesList();
+ });
+ const pageIds = await page
+ .locator(".page[id]")
+ .evaluateAll((es) => es.map((e) => e.id));
+ for (const id of pageIds) {
+ await page.evaluate((id) => {
+ document
+ .querySelectorAll(".page")
+ .forEach((e) => e.classList.toggle("active", e.id === id));
+ if (window.CSAMobile)
+ CSAMobile.wrapTables(document.getElementById(id));
+ }, id);
+ const overflow = await page.evaluate(
+ () => document.documentElement.scrollWidth > innerWidth + 2,
+ );
+ if (overflow)
+ findings.push({ width, theme, id, issue: "page overflow" });
+ if (
+ [
+ "page-dashboard",
+ "page-roles-management",
+ "page-asset-library",
+ "page-workflows",
+ "page-settings",
+ ].includes(id)
+ )
+ await page.screenshot({
+ animations: "disabled",
+ path: out + "/" + id + "-" + width + "-" + theme + ".png",
+ });
+ }
+ await require("./ui-realistic-scenarios.cjs")({
+ page,
+ width,
+ height,
+ theme,
+ out,
+ });
+ await page.close();
+ }
+ fs.writeFileSync(
+ out + "/results.json",
+ JSON.stringify({ count, findings }, null, 2),
+ );
+ console.log(JSON.stringify({ count, findings, artifacts: out }, null, 2));
+ if (findings.length) process.exitCode = 1;
+ await browser.close();
+ server.close();
+})().catch((e) => {
+ console.error(e);
+ server.close();
+ process.exit(1);
+});
diff --git a/scripts/ui-realistic-scenarios.cjs b/scripts/ui-realistic-scenarios.cjs
new file mode 100644
index 00000000..5acce0eb
--- /dev/null
+++ b/scripts/ui-realistic-scenarios.cjs
@@ -0,0 +1,411 @@
+// Anonymized reproductions of populated UI states: 365 tasks, 626 tools,
+// 614 enabled tools, multi-file skill, 50 long findings. All writes are rejected.
+const assert = require("node:assert/strict");
+module.exports = async function ({ page, width, height, theme, out }) {
+ for (const script of [
+ "tasks",
+ "skills",
+ "vulnerability",
+ "vulnerability-workspace",
+ ])
+ await page.addScriptTag({ url: "/static/js/" + script + ".js" });
+ await page.evaluate(() => {
+ const tools = Array.from({ length: 626 }, (_, i) => ({
+ name: "review_tool_" + i,
+ description: "检查授权范围内的接口、权限和配置,保留可复核证据。".repeat(
+ 4,
+ ),
+ enabled: i < 614,
+ }));
+ const role = {
+ name: "界面回归角色",
+ description: "真实规模的长描述与工具清单",
+ enabled: true,
+ tools: [],
+ user_prompt: "根据已有证据整理报告。".repeat(12),
+ };
+ const queue = {
+ id: "ui-fixture",
+ title: "多目标授权评估回归队列",
+ status: "paused",
+ role: role.name,
+ agentMode: "single",
+ scheduleMode: "manual",
+ concurrency: 2,
+ totalTasks: 365,
+ completedTasks: 34,
+ createdAt: "2026-11-10T13:01:13Z",
+ tasks: Array.from({ length: 365 }, (_, i) => ({
+ id: "task-" + i,
+ status: i < 34 ? "completed" : "pending",
+ message:
+ "https://long-service-name-" + i + ".example.test/verification",
+ })),
+ };
+ window.fixtureQueue = queue;
+ window.apiFetch = async (input, opts = {}) => {
+ if (opts.method && opts.method !== "GET")
+ throw new Error("UI regression must not write: " + input);
+ const url = new URL(input, location.origin);
+ let data = {};
+ if (url.pathname === "/api/roles") data = { roles: [role] };
+ else if (url.pathname === "/api/config/tools") {
+ const size = Number(url.searchParams.get("page_size") || 20),
+ index = Number(url.searchParams.get("page") || 1);
+ data = {
+ tools: tools.slice((index - 1) * size, index * size),
+ total: 626,
+ total_enabled: 614,
+ total_pages: Math.ceil(626 / size),
+ page: index,
+ page_size: size,
+ };
+ } else if (url.pathname === "/api/batch-tasks/ui-fixture")
+ data = { queue };
+ else if (url.pathname.endsWith("/files"))
+ data = {
+ files: [
+ { path: "SKILL.md" },
+ { path: "references/long-reference-name.md" },
+ { path: "assets/README.txt" },
+ ],
+ };
+ else if (url.pathname.startsWith("/api/skills/"))
+ data = {
+ skill: {
+ id: "review-skill",
+ description: "多文件技能包编辑测试",
+ content: "# 审核步骤\n" + "核对已有证据。\n".repeat(40),
+ },
+ };
+ return { ok: true, json: async () => data };
+ };
+ window.showNotification = (message, type) => {
+ if (type === "error") throw new Error(message);
+ };
+ roles = [role];
+ });
+ const activate = async (id) =>
+ page.evaluate(
+ (id) =>
+ document
+ .querySelectorAll(".page")
+ .forEach((e) => e.classList.toggle("active", e.id === id)),
+ id,
+ );
+ const shot = async (name) =>
+ page.screenshot({
+ animations: "disabled",
+ path: `${out}/real-${name}-${width}-${theme}.png`,
+ });
+ const contrastResults = [];
+ await activate("page-tasks");
+ const states = [
+ { status: "paused", scheduleMode: "manual", label: "继续执行" },
+ { status: "pending", scheduleMode: "manual", label: "开始执行" },
+ {
+ status: "pending",
+ scheduleMode: "cron",
+ scheduleEnabled: true,
+ label: "立即执行一轮",
+ },
+ {
+ status: "pending",
+ scheduleMode: "cron",
+ scheduleEnabled: false,
+ label: "开始执行",
+ },
+ { status: "running", scheduleMode: "manual" },
+ { status: "completed", scheduleMode: "manual" },
+ { status: "cancelled", scheduleMode: "manual" },
+ ];
+ for (const state of states) {
+ await page.evaluate(async (state) => {
+ Object.assign(fixtureQueue, state);
+ await showBatchQueueDetail("ui-fixture");
+ }, state);
+ await page
+ .locator("#batch-queue-detail-content .batch-task-item")
+ .first()
+ .waitFor();
+ const layout = await page
+ .locator("#batch-queue-detail-modal .modal-header")
+ .evaluate((e) => {
+ const title = e.querySelector("h2").getBoundingClientRect(),
+ header = e.getBoundingClientRect();
+ const controls = Array.from(e.querySelectorAll("button"))
+ .filter((b) => b.getClientRects().length)
+ .map((b) => b.getBoundingClientRect());
+ return {
+ titleWidth: title.width,
+ headerHeight: header.height,
+ allInside: controls.every(
+ (r) => r.left >= header.left && r.right <= header.right + 1,
+ ),
+ titleOverlaps: controls.some(
+ (r) =>
+ r.left < title.right &&
+ r.right > title.left &&
+ r.top < title.bottom &&
+ r.bottom > title.top,
+ ),
+ };
+ });
+ assert(layout.titleWidth > 200, JSON.stringify(layout));
+ assert(layout.headerHeight < 190, JSON.stringify(layout));
+ assert(layout.allInside && !layout.titleOverlaps, JSON.stringify(layout));
+ await page.evaluate(() => applyTranslations(document.body));
+ const assertLabels = async () => {
+ const text = await page.locator("#batch-queue-detail-title").innerText();
+ assert.equal(text, "批量任务队列 - 多目标授权评估回归队列");
+ if (state.label)
+ assert.equal(
+ await page.locator("#batch-queue-start-btn").innerText(),
+ state.label,
+ );
+ else
+ assert.equal(
+ await page.locator("#batch-queue-start-btn").isVisible(),
+ false,
+ );
+ };
+ await assertLabels();
+ // Real breakpoint transitions call mobile boot, which reapplies all translations.
+ if (width === 1440 && state.label) {
+ await page.setViewportSize({ width: 390, height: 844 });
+ await page.waitForTimeout(150);
+ await assertLabels();
+ await page.setViewportSize({ width, height });
+ await page.waitForTimeout(150);
+ await assertLabels();
+ }
+ for (const button of await page
+ .locator(
+ "#batch-queue-detail-modal .modal-header-actions .btn-primary:visible",
+ )
+ .all()) {
+ for (const appearance of ["normal", "hover", "focus"]) {
+ if (appearance === "normal")
+ await page.mouse.move(width - 4, height - 4);
+ if (appearance === "hover") await button.hover();
+ if (appearance === "focus") {
+ await page.mouse.move(width - 4, height - 4);
+ await button.focus();
+ await page.keyboard.press("Tab");
+ await page.keyboard.press("Shift+Tab");
+ assert(
+ await button.evaluate((e) => e.matches(":focus-visible")),
+ "Keyboard focus indicator missing",
+ );
+ }
+ await page.waitForTimeout(220);
+ const colors = await button.evaluate((e) => ({
+ foreground: getComputedStyle(e).color,
+ background: getComputedStyle(e).backgroundColor,
+ disabled: e.disabled,
+ text: e.textContent,
+ }));
+ assert(!colors.disabled);
+ const rgb = (value) => {
+ assert(/^rgb/.test(value), JSON.stringify(colors));
+ const values = value.match(/[\d.]+/g).map(Number);
+ assert(
+ values.length === 3 || values[3] === 1,
+ "Primary background must be opaque",
+ );
+ return values.slice(0, 3).map((v) => {
+ const c = v / 255;
+ return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
+ });
+ };
+ const lum = (value) => {
+ const [r, g, b] = rgb(value);
+ return 0.2126 * r + 0.7152 * g + 0.0722 * b;
+ };
+ const a = lum(colors.foreground),
+ b = lum(colors.background);
+ const ratio = (Math.max(a, b) + 0.05) / (Math.min(a, b) + 0.05);
+ contrastResults.push({
+ state: state.status,
+ label: state.label,
+ appearance,
+ ratio,
+ ...colors,
+ });
+ assert(
+ ratio >= 4.5,
+ JSON.stringify({ width, theme, appearance, ratio, ...colors }),
+ );
+ }
+ }
+ if (state.status === "paused") await shot("queue");
+ await page.evaluate(() => closeBatchQueueDetailModal());
+ }
+ // Queue names are literal content, including characters that look like markup.
+ await page.evaluate(async () => {
+ fixtureQueue.title = "复核 & <说明>";
+ fixtureQueue.status = "paused";
+ await showBatchQueueDetail("ui-fixture");
+ applyTranslations(document.body);
+ });
+ assert.equal(
+ await page.locator("#batch-queue-detail-title").innerText(),
+ "批量任务队列 - 复核 & <说明>",
+ );
+ assert.equal(await page.locator("#batch-queue-detail-title > *").count(), 1);
+ await page.evaluate(async () => {
+ fixtureQueue.title = "";
+ await showBatchQueueDetail("ui-fixture");
+ applyTranslations(document.body);
+ });
+ assert.equal(
+ await page.locator("#batch-queue-detail-title").innerText(),
+ "批量任务队列",
+ );
+ await page.evaluate(() => {
+ fixtureQueue.title = "多目标授权评估回归队列";
+ });
+ require("node:fs").writeFileSync(
+ `${out}/queue-contrast-${width}-${theme}.json`,
+ JSON.stringify(contrastResults, null, 2),
+ );
+ // A real language change translates the prefix and action, but never the queue name.
+ await page.evaluate(async () => {
+ fixtureQueue.status = "paused";
+ await showBatchQueueDetail("ui-fixture");
+ onLanguageSelect("en-US");
+ });
+ await page.waitForFunction(
+ () =>
+ document.documentElement.lang === "en-US" &&
+ document.getElementById("batch-queue-start-btn").textContent === "Resume",
+ );
+ assert(
+ (await page.locator("#batch-queue-detail-title").innerText()).endsWith(
+ " - 多目标授权评估回归队列",
+ ),
+ );
+ await page.evaluate(() => onLanguageSelect("zh-CN"));
+ await page.waitForFunction(
+ () =>
+ document.documentElement.lang === "zh-CN" &&
+ document.getElementById("batch-queue-start-btn").textContent ===
+ "继续执行",
+ );
+ assert.equal(
+ await page.locator("#batch-queue-detail-title").innerText(),
+ "批量任务队列 - 多目标授权评估回归队列",
+ );
+ await page.evaluate(() => closeBatchQueueDetailModal());
+ await activate("page-roles-management");
+ await page.evaluate(() => editRole("界面回归角色"));
+ await page.locator("#role-tools-list input").first().waitFor();
+ await page.evaluate(() => applyTranslations(document));
+ assert.equal(await page.locator("#role-modal-title").innerText(), "编辑角色");
+ const stats = await page.locator("#role-tools-stats").evaluate((e) => ({
+ width: e.clientWidth,
+ scroll: e.scrollWidth,
+ text: e.textContent,
+ }));
+ assert(stats.text.includes("614") && stats.text.includes("626"), stats.text);
+ assert(stats.scroll <= stats.width + 2, JSON.stringify(stats));
+ await page.locator("#role-tools-stats").scrollIntoViewIfNeeded();
+ await shot("role-tools");
+ await page.evaluate(() => closeRoleModal());
+ await page.evaluate(() => showAddRoleModal());
+ await page.evaluate(() => applyTranslations(document));
+ assert.equal(await page.locator("#role-modal-title").innerText(), "添加角色");
+ await page.evaluate(() => closeRoleModal());
+ await activate("page-skills-management");
+ await page.evaluate(() => editSkill("review-skill"));
+ await page.locator("#skill-content").waitFor();
+ await page.evaluate(() => applyTranslations(document));
+ assert.equal(
+ await page.locator("#skill-modal-title").innerText(),
+ "编辑Skill",
+ );
+ await shot("skill");
+ await page.evaluate(() => closeSkillModal());
+ await page.evaluate(() => showAddSkillModal());
+ await page.evaluate(() => applyTranslations(document));
+ assert.equal(
+ await page.locator("#skill-modal-title").innerText(),
+ "添加Skill",
+ );
+ await page.evaluate(() => closeSkillModal());
+ // Real breakpoint transition: mobile boot reapplies the translations.
+ if (width === 1440) {
+ await activate("page-roles-management");
+ await page.evaluate(() => editRole("界面回归角色"));
+ await page.setViewportSize({ width: 390, height: 844 });
+ await page.waitForTimeout(100);
+ assert.equal(
+ await page.locator("#role-modal-title").innerText(),
+ "编辑角色",
+ );
+ await page.evaluate(() => closeRoleModal());
+ await page.setViewportSize({ width, height });
+ await activate("page-skills-management");
+ await page.evaluate(() => editSkill("review-skill"));
+ await page.setViewportSize({ width: 390, height: 844 });
+ await page.waitForTimeout(100);
+ assert.equal(
+ await page.locator("#skill-modal-title").innerText(),
+ "编辑Skill",
+ );
+ await page.evaluate(() => closeSkillModal());
+ await page.setViewportSize({ width, height });
+ }
+ await activate("page-vulnerabilities");
+ await page.evaluate(() => {
+ const rows = Array.from({ length: 50 }, (_, i) => ({
+ id: "finding-" + i,
+ title: "接口响应与权限检查发现:包含较长的组件版本和复现说明 " + i,
+ description: "已验证的证据摘要。".repeat(10),
+ severity: i % 3 ? "low" : "high",
+ status: "open",
+ target: "https://service-" + i + ".example.test",
+ target_host: "service-" + i + ".example.test",
+ target_domain: "example.test",
+ createdAt: "2026-11-10T12:00:00Z",
+ }));
+ vulnerabilityPagination = {
+ currentPage: 1,
+ totalPages: 3,
+ total: 110,
+ pageSize: 50,
+ };
+ renderVulnerabilities(rows, { view: "host" });
+ renderVulnerabilityPagination();
+ });
+ await page.locator(".vulnerability-record-row").first().waitFor();
+ if (width < 768) {
+ await page
+ .locator(".vulnerability-record-row")
+ .first()
+ .scrollIntoViewIfNeeded();
+ await page.locator("#page-vulnerabilities").evaluate((e) => {
+ e.scrollTop +=
+ e.querySelector(".vulnerability-record-row").getBoundingClientRect()
+ .top - e.getBoundingClientRect().top;
+ });
+ const scroll = await page
+ .locator("#page-vulnerabilities")
+ .evaluate((e) => ({
+ height: e.clientHeight,
+ scrollTop: e.scrollTop,
+ contentOverflow: getComputedStyle(e.querySelector(".page-content"))
+ .overflowY,
+ headerBottom: e.querySelector(".page-header").getBoundingClientRect()
+ .bottom,
+ top: e.getBoundingClientRect().top,
+ }));
+ assert(
+ scroll.scrollTop > 0 && scroll.headerBottom <= scroll.top + 1,
+ JSON.stringify(scroll),
+ );
+ assert(scroll.contentOverflow === "visible", JSON.stringify(scroll));
+ assert(scroll.height >= height - 150, JSON.stringify(scroll));
+ }
+ await shot("findings");
+};
diff --git a/web/static/css/design-system.css b/web/static/css/design-system.css
new file mode 100644
index 00000000..8138ef47
--- /dev/null
+++ b/web/static/css/design-system.css
@@ -0,0 +1,299 @@
+/* Shared application surfaces. Loaded last to bridge legacy module styles.
+ * Use data-ui-surface="drawer" for details/long forms; short actions use dialog.
+ * Keep table density, semantic status colors and specialist workspaces intact.
+ */
+:root {
+ --ui-radius-card: 16px;
+ --ui-radius-control: 10px;
+ --ui-surface: var(--bg-primary);
+ --ui-surface-muted: var(--bg-secondary);
+ --ui-border: var(--border-color);
+ --ui-shadow: 0 2px 8px rgba(15, 23, 42, .04);
+ --ui-overlay: rgba(15, 23, 42, .42);
+ --ui-panel-shadow: -12px 0 40px rgba(15, 23, 42, .16);
+ --ui-space: 24px;
+}
+html[data-theme="dark"] {
+ --ui-shadow: 0 2px 8px rgba(0, 0, 0, .12);
+ --ui-overlay: rgba(0, 0, 0, .58);
+ --ui-panel-shadow: -12px 0 40px rgba(0, 0, 0, .32);
+}
+/* Explicit surface inventory: no wildcard class matching, no changes to charts,
+ * terminals, graph nodes, selected-state fills or severity indicators. */
+html body .page :is(
+ .dashboard-section, .dashboard-card, .dashboard-kpi-card, .asset-total-card, .asset-recent-card, .asset-panel, .asset-list-card,
+ .knowledge-item-card, .retrieval-log-card, .skill-card, .role-card, .batch-queue-item,
+ .tool-guard-card, .mcp-management-panel, .projects-sidebar-card, .projects-panel,
+ .projects-settings-card, .rbac-panel, .rbac-catalog-card, .robot-card,
+ .workflow-panel, .c2-listener-card, .c2-profile-card, .settings-subsection,
+ .storage-overview-card, .skills-overview-card
+) {
+ border-radius: var(--ui-radius-card);
+ border-color: var(--ui-border);
+ box-shadow: var(--ui-shadow);
+}
+html body .page :is(.knowledge-item-card, .skill-card, .role-card, .workflow-panel, .settings-subsection) {
+ background: var(--ui-surface);
+ color: var(--text-primary);
+}
+html body .page-header {
+ gap: 16px;
+ align-items: center;
+ flex-wrap: wrap;
+}
+html body .page-header > h2 { font-size: 22px; line-height: 1.4; letter-spacing: -.02em; }
+html body .page-header-actions { display: flex; flex-wrap: wrap; gap: 8px; }
+html body :is(.page, [data-ui-surface]) :is(.btn-primary, .btn-secondary) {
+ border-radius: var(--ui-radius-control) !important;
+ min-height: 36px;
+ box-shadow: none;
+}
+html body :is(.page, [data-ui-surface]) :is(button, input, textarea, select, [role="button"]):focus-visible {
+ outline: 2px solid var(--accent-color);
+ outline-offset: 3px;
+}
+html body :is(.form-group, .settings-form, .modal-body, .projects-modal-body, .c2-modal-body)
+ :is(input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="hidden"]), textarea, select) {
+ border-radius: var(--ui-radius-control);
+ border-color: var(--ui-border);
+ color: var(--text-primary);
+ background-color: var(--input-bg);
+ max-width: 100%;
+}
+/* Layering is assigned by the modal lifecycle, including nested short dialogs. */
+html body [data-ui-surface] {
+ z-index: var(--app-overlay-order, 10060) !important;
+ background: var(--ui-overlay) !important;
+ backdrop-filter: none;
+}
+html body [data-ui-surface="drawer"] {
+ position: fixed;
+ inset: 0;
+ width: 100%;
+ height: 100%;
+ padding: 0 !important;
+ overflow: hidden;
+ --app-drawer-width: 720px;
+}
+html body [data-ui-surface="drawer"].app-drawer-wide { --app-drawer-width: 960px; }
+html body [data-ui-surface="drawer"].app-drawer-expanded { --app-drawer-width: 1440px; }
+/* !important only on the layout contract: old modules set inline dimensions. */
+html body [data-ui-surface="drawer"] > :is(.modal-content, .projects-modal-dialog, .c2-modal) {
+ position: absolute !important;
+ inset-block: 0 !important;
+ inset-inline: auto 0 !important;
+ width: min(var(--app-drawer-width), calc(100% - 48px)) !important;
+ min-width: 0 !important;
+ max-width: none !important;
+ height: 100% !important;
+ height: 100dvh !important;
+ min-height: 0 !important;
+ max-height: none !important;
+ margin: 0 !important;
+ padding: 0 !important;
+ border: 0;
+ border-inline-start: 1px solid var(--ui-border);
+ border-radius: var(--ui-radius-card) 0 0 var(--ui-radius-card) !important;
+ display: flex;
+ flex-direction: column;
+ overflow: hidden !important;
+ background: var(--ui-surface) !important;
+ color: var(--text-primary);
+ box-shadow: var(--ui-panel-shadow);
+ animation: app-panel-in .18s ease-out !important;
+}
+html[dir="rtl"] body [data-ui-surface="drawer"] > :is(.modal-content, .projects-modal-dialog, .c2-modal) {
+ border-radius: 0 var(--ui-radius-card) var(--ui-radius-card) 0 !important;
+}
+html body [data-ui-surface="drawer"] :is(.modal-header, .projects-modal-header, .c2-modal-header, .vulnerability-inspector-header) {
+ display: flex;
+ align-items: center;
+ flex: 0 0 auto;
+ flex-wrap: wrap;
+ gap: 12px;
+ padding: 20px var(--ui-space) !important;
+ border-radius: 0;
+ border-bottom: 1px solid var(--ui-border);
+ background: var(--ui-surface) !important;
+ color: var(--text-primary);
+ box-shadow: none;
+}
+html body [data-ui-surface="drawer"] :is(.modal-header, .projects-modal-header, .c2-modal-header)::after { display: none; }
+html body [data-ui-surface="drawer"] :is(.modal-header, .projects-modal-header, .c2-modal-header, .vulnerability-inspector-header) :is(h2, h3) {
+ font-size: 19px;
+ line-height: 1.5;
+ color: var(--text-primary);
+ margin: 0;
+ overflow-wrap: anywhere;
+}
+html body [data-ui-surface="drawer"] :is(.modal-header, .projects-modal-header, .c2-modal-header, .vulnerability-inspector-header) > :first-child { flex: 1; min-width: 0; }
+html body [data-ui-surface="drawer"] :is(.modal-close, .projects-modal-close, .c2-modal-close) {
+ position: static;
+ flex: 0 0 36px;
+ width: 36px;
+ height: 36px;
+ margin: 0;
+}
+html body [data-ui-surface="drawer"] :is(.modal-body, .projects-modal-body, .c2-modal-body, #vulnerability-inspector-body) {
+ flex: 1 1 auto;
+ min-height: 0;
+ max-height: none !important;
+ overflow-y: auto !important;
+ overscroll-behavior: contain;
+ padding: var(--ui-space) !important;
+ background: var(--ui-surface) !important;
+ color: var(--text-primary);
+ scrollbar-gutter: stable;
+}
+html body [data-ui-surface="drawer"] :is(.modal-footer, .projects-modal-footer, .c2-modal-footer) {
+ flex: 0 0 auto;
+ display: flex;
+ flex-wrap: wrap;
+ gap: 10px;
+ padding: 16px var(--ui-space) !important;
+ border-top: 1px solid var(--ui-border);
+ background: var(--ui-surface) !important;
+ box-shadow: none;
+}
+html body [data-ui-surface="drawer"] #c2-modal-content {
+ display: flex;
+ flex-direction: column;
+ flex: 1;
+ min-height: 0;
+ max-height: none;
+ overflow: hidden;
+}
+html body .app-drawer-expand {
+ display: inline-flex;
+ justify-content: center;
+ align-items: center;
+ flex: 0 0 36px;
+ width: 36px;
+ height: 36px;
+ border: 1px solid var(--ui-border);
+ border-radius: var(--ui-radius-control);
+ background: var(--ui-surface-muted);
+ color: var(--text-secondary);
+ font-size: 22px;
+ cursor: pointer;
+}
+html body .app-drawer-expand[aria-pressed="true"] { color: var(--accent-color); border-color: var(--accent-color); }
+html body [data-ui-surface="dialog"] > :is(.modal-content, .projects-modal-dialog, .c2-modal) {
+ border-radius: var(--ui-radius-card);
+ background: var(--ui-surface);
+ color: var(--text-primary);
+ border-color: var(--ui-border);
+}
+@keyframes app-panel-in { from { opacity: .6; transform: translateX(24px); } to { opacity: 1; transform: translateX(0); } }
+@media (max-width: 767.98px) {
+ :root { --ui-space: 16px; }
+ html body .page-header > h2 { font-size: 20px; }
+ html body :is(.page, [data-ui-surface]) :is(.btn-primary, .btn-secondary) { min-height: 44px; }
+ html body [data-ui-surface="drawer"] > :is(.modal-content, .projects-modal-dialog, .c2-modal) {
+ width: 100% !important;
+ border: 0;
+ border-radius: 0 !important;
+ padding-top: env(safe-area-inset-top, 0px) !important;
+ padding-bottom: env(safe-area-inset-bottom, 0px) !important;
+ }
+ html body [data-ui-surface="drawer"] :is(.modal-header, .projects-modal-header, .c2-modal-header, .vulnerability-inspector-header) { padding-block: 12px !important; }
+ html body [data-ui-surface="drawer"] :is(.modal-close, .projects-modal-close, .c2-modal-close) { width: 44px; height: 44px; flex-basis: 44px; }
+ html body .app-drawer-expand { display: none; }
+ html body [data-ui-surface="drawer"] :is(input, textarea, select) { font-size: 16px; }
+ html body [data-ui-surface="drawer"] .modal-header-actions { flex-wrap: wrap; }
+ html body [data-ui-surface="drawer"] #skill-package-editor > div { flex-direction: column; }
+ html body [data-ui-surface="drawer"] #skill-package-tree { width: 100%; max-height: 180px; }
+ /* Short actions remain compact, including on phones. */
+ html body [data-ui-surface="dialog"] > :is(.modal-content, .projects-modal-dialog, .c2-modal) {
+ width: calc(100% - 32px) !important;
+ height: auto !important;
+ min-height: 0 !important;
+ max-height: calc(100dvh - 48px) !important;
+ margin: 24px auto !important;
+ border-radius: var(--ui-radius-card) !important;
+ }
+}
+@media (prefers-reduced-motion: reduce) {
+ html body [data-ui-surface] { animation: none !important; }
+ html body [data-ui-surface] > :is(.modal-content, .projects-modal-dialog, .c2-modal) { animation: none !important; transition: none !important; }
+}
+
+/* The common header is quiet; module status badges retain their own colors. */
+html body [data-ui-surface="drawer"] :is(.modal-header, .projects-modal-header, .c2-modal-header) h2::before { display: none; }
+html body [data-ui-surface="drawer"] .form-group { margin-bottom: 18px; }
+html body [data-ui-surface="drawer"] .form-group:last-child { margin-bottom: 0; }
+
+html body .page :is(.asset-table, .info-collect-table, .data-table, .chat-files-table, .audit-log-table) th {
+ background: var(--ui-surface-muted);
+ color: var(--text-secondary);
+ border-color: var(--ui-border);
+ font-weight: 600;
+}
+html body [data-ui-surface="dialog"] :is(.modal-header, .projects-modal-header, .c2-modal-header, .modal-footer, .projects-modal-footer, .c2-modal-footer) {
+ background: var(--ui-surface);
+ border-color: var(--ui-border);
+ color: var(--text-primary);
+ box-shadow: none;
+}
+html[dir="rtl"] body [data-ui-surface="drawer"] > :is(.modal-content, .projects-modal-dialog, .c2-modal) {
+ animation-name: app-panel-in-rtl !important;
+}
+@keyframes app-panel-in-rtl { from { opacity: .6; transform: translateX(-24px); } to { opacity: 1; transform: translateX(0); } }
+@media (prefers-reduced-motion: reduce) {
+ html[dir="rtl"] body [data-ui-surface="drawer"] > :is(.modal-content, .projects-modal-dialog, .c2-modal) { animation: none !important; }
+}
+
+/* Data-heavy queue actions get their own row; never compete with the title. */
+html body #batch-queue-detail-modal .modal-header {
+ display: grid;
+ grid-template-columns: minmax(0, 1fr) 36px 36px;
+ align-items: center;
+}
+html body #batch-queue-detail-modal .modal-header > h2 { grid-column: 1; grid-row: 1; }
+html body #batch-queue-detail-modal .app-drawer-expand { grid-column: 2; grid-row: 1; }
+html body #batch-queue-detail-modal .modal-close { grid-column: 3; grid-row: 1; }
+html body #batch-queue-detail-modal .modal-header-actions {
+ grid-column: 1 / -1;
+ grid-row: 2;
+ display: flex;
+ justify-content: flex-start;
+ flex-wrap: wrap;
+ min-width: 0;
+}
+html body #role-modal .role-tools-stats,
+html body #role-modal .role-tools-stats-row { min-width: 0; max-width: 100%; }
+html body #role-modal .role-tools-stats span { white-space: normal; overflow-wrap: anywhere; min-width: 0; }
+
+@media (max-width: 767.98px) {
+ html body #batch-queue-detail-modal .modal-header { grid-template-columns: minmax(0, 1fr) 44px; gap: 8px; }
+ html body #batch-queue-detail-modal .modal-close { grid-column: 2; }
+ html body #batch-queue-detail-modal .modal-header-actions { gap: 8px; }
+ /* One page scroll: actions and pagination no longer reserve most of the screen. */
+ html body #page-vulnerabilities.active { display: block; overflow-y: auto; overscroll-behavior: contain; }
+ html body #page-vulnerabilities > .page-header { position: static; }
+ html body #page-vulnerabilities > .page-content {
+ height: auto; max-height: none; overflow: visible; flex: none;
+ }
+ html body #page-vulnerabilities > .vulnerability-page-footer { position: static; }
+ html body #vulnerability-pagination { position: static; }
+ html body #page-vulnerabilities .dashboard-stats {
+ display: grid; grid-template-columns: repeat(6, minmax(96px, 1fr));
+ overflow-x: auto; padding-bottom: 6px;
+ }
+ html body #page-vulnerabilities .stat-card { min-height: 84px; padding: 10px; }
+}
+/* Queue primary actions keep their semantic fill even with .btn-small.
+ * Mobile's dark foreground assumes an accent fill, never a translucent gray. */
+html body #batch-queue-detail-modal .modal-header-actions .btn-primary {
+ background: var(--accent-color) !important;
+ border-color: var(--accent-color);
+ color: #fff !important;
+}
+html[data-theme="dark"] body #batch-queue-detail-modal .modal-header-actions .btn-primary {
+ color: #0b1120 !important;
+}
+html body #batch-queue-detail-modal .modal-header-actions .btn-primary:is(:hover, :focus-visible, :active):not(:disabled) {
+ background: var(--accent-hover) !important;
+ border-color: var(--accent-hover);
+}
+html body #batch-queue-detail-modal #batch-queue-detail-title { display: block; }
diff --git a/web/static/i18n/ar-SA.json b/web/static/i18n/ar-SA.json
index fb21ccc4..9a6280cf 100644
--- a/web/static/i18n/ar-SA.json
+++ b/web/static/i18n/ar-SA.json
@@ -26,6 +26,7 @@
"chatModuleMissing": "لم يتمّ تحميل وحدة المحادثة بعد"
},
"common": {
+ "expandPanel": "توسيع اللوحة",
"ok": "موافق",
"cancel": "إلغاء",
"refresh": "تحديث",
diff --git a/web/static/i18n/en-US.json b/web/static/i18n/en-US.json
index 71a13efc..0265ca9a 100644
--- a/web/static/i18n/en-US.json
+++ b/web/static/i18n/en-US.json
@@ -26,6 +26,7 @@
"chatModuleMissing": "Chat module not loaded yet"
},
"common": {
+ "expandPanel": "Expand panel",
"ok": "OK",
"cancel": "Cancel",
"refresh": "Refresh",
diff --git a/web/static/i18n/ru-RU.json b/web/static/i18n/ru-RU.json
index 5a11dc74..13e9f7fa 100644
--- a/web/static/i18n/ru-RU.json
+++ b/web/static/i18n/ru-RU.json
@@ -26,6 +26,7 @@
"chatModuleMissing": "Модуль чата ещё не загружен"
},
"common": {
+ "expandPanel": "Развернуть панель",
"ok": "ОК",
"cancel": "Отмена",
"refresh": "Обновить",
diff --git a/web/static/i18n/zh-CN.json b/web/static/i18n/zh-CN.json
index e2cd13b3..b0f580bb 100644
--- a/web/static/i18n/zh-CN.json
+++ b/web/static/i18n/zh-CN.json
@@ -26,6 +26,7 @@
"chatModuleMissing": "对话模块尚未加载"
},
"common": {
+ "expandPanel": "展开面板",
"ok": "确定",
"cancel": "取消",
"refresh": "刷新",
diff --git a/web/static/js/modal.js b/web/static/js/modal.js
index ed7596d8..90c9cfc4 100644
--- a/web/static/js/modal.js
+++ b/web/static/js/modal.js
@@ -1,5 +1,5 @@
/**
- * 统一弹窗:先显示遮罩、下一帧再填大段内容,避免与 backdrop 绘制抢主线程。
+ * Shared dialog/drawer lifecycle: presentation, stacking, keyboard focus and deferred rendering.
*/
(function () {
const BODY_LOCK = 'app-modal-open';
@@ -17,6 +17,73 @@
'login-overlay',
]);
+ // Explicitly opt long forms and inspectable records into the shared surface.
+ // Short confirmations/selectors retain their existing centered-dialog behavior.
+ const DRAWER_IDS = new Set([
+ 'asset-detail-modal', 'asset-editor-modal', 'asset-import-modal', 'asset-bulk-edit-modal',
+ 'vulnerability-inspector', 'vulnerability-modal', 'vulnerability-retest-modal',
+ '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',
+ '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',
+ 'chat-files-edit-modal', 'batch-queue-detail-modal', 'mcp-detail-modal', 'attack-chain-modal',
+ ]);
+ const returnFocus = new WeakMap();
+ const surfaceObservers = new WeakMap();
+ const openOrder = [];
+
+ function prepareSurface(el) {
+ if (!el || el.id === 'login-overlay') return;
+ const drawer = DRAWER_IDS.has(el.id) && !el.querySelector('.c2-modal--sleep');
+ el.dataset.uiSurface = drawer ? 'drawer' : 'dialog';
+ el.classList.toggle('app-drawer-wide', drawer && (WIDE_IDS.has(el.id) || !!el.querySelector('.c2-modal--wide')));
+ if (!drawer) return;
+ el.setAttribute('role', 'dialog');
+ el.setAttribute('aria-modal', 'true');
+ const header = el.querySelector('.modal-header, .projects-modal-header, .c2-modal-header, .vulnerability-inspector-header');
+ if (!header) return; // Asynchronously rendered details are prepared again after rendering.
+ const title = header.querySelector('h2, h3');
+ if (title) {
+ if (!title.id) title.id = el.id + '-heading';
+ el.setAttribute('aria-labelledby', title.id);
+ }
+ const close = header.querySelector('.modal-close, .projects-modal-close, .c2-modal-close');
+ if (close && close.tagName !== 'BUTTON') {
+ close.setAttribute('role', 'button');
+ close.tabIndex = 0;
+ close.onkeydown = function (event) {
+ if (event.key === 'Enter' || event.key === ' ') { event.preventDefault(); close.click(); }
+ };
+ }
+ if (close && !close.getAttribute('aria-label')) {
+ close.setAttribute('aria-label', typeof window.t === 'function' ? window.t('common.close') : 'Close');
+ }
+ if (!header.querySelector('.app-drawer-expand')) {
+ const button = document.createElement('button');
+ button.type = 'button';
+ button.className = 'app-drawer-expand';
+ button.textContent = '⤢';
+ button.setAttribute('aria-pressed', 'false');
+ button.setAttribute('data-i18n', 'common.expandPanel');
+ button.setAttribute('data-i18n-attr', 'aria-label,title');
+ button.setAttribute('data-i18n-skip-text', 'true');
+ const label = typeof window.t === 'function' ? window.t('common.expandPanel') : 'Expand panel';
+ button.setAttribute('aria-label', label);
+ button.title = label;
+ button.onclick = function () {
+ const expanded = el.classList.toggle('app-drawer-expanded');
+ button.setAttribute('aria-pressed', String(expanded));
+ };
+ header.insertBefore(button, close && close.parentNode === header ? close : null);
+ }
+ }
+
function resolveEl(idOrEl) {
if (!idOrEl) return null;
return typeof idOrEl === 'string' ? document.getElementById(idOrEl) : idOrEl;
@@ -55,13 +122,27 @@
opts = opts || {};
const el = resolveEl(idOrEl);
if (!el) return null;
+ prepareSurface(el);
+ if (!surfaceObservers.has(el)) {
+ const observer = new MutationObserver(function () { prepareSurface(el); });
+ observer.observe(el, { childList: true, subtree: true });
+ surfaceObservers.set(el, observer);
+ }
+ if (!isElVisible(el)) returnFocus.set(el, document.activeElement);
+ const previous = openOrder.indexOf(el);
+ if (previous !== -1) openOrder.splice(previous, 1);
+ openOrder.push(el);
+ // Nested editors must stack above the detail panel they were opened from.
+ el.style.setProperty('--app-overlay-order', String(10060 + openOrder.length * 2));
el.style.display = opts.display || defaultDisplay(el);
syncBodyLock();
+ requestAnimationFrame(function () { if (isElVisible(el)) prepareSurface(el); });
if (opts.focus === false) return el;
const sel =
opts.focusSelector ||
'input.form-input, textarea.form-input, select.form-input, input:not([type="hidden"]):not([disabled]), textarea:not([disabled]), select:not([disabled])';
- const focusTarget = opts.focusEl || el.querySelector(sel);
+ const focusTarget = opts.focusEl || Array.from(el.querySelectorAll(sel)).find(item => item.getClientRects().length)
+ || el.querySelector('.modal-close, .projects-modal-close, .c2-modal-close');
if (focusTarget) {
requestAnimationFrame(function () {
focusTarget.focus();
@@ -72,7 +153,19 @@
function closeAppModal(idOrEl) {
const el = resolveEl(idOrEl);
- if (el) el.style.display = 'none';
+ if (el) {
+ el.style.display = 'none';
+ surfaceObservers.get(el)?.disconnect();
+ surfaceObservers.delete(el);
+ el.classList.remove('app-drawer-expanded');
+ const button = el.querySelector('.app-drawer-expand');
+ if (button) button.setAttribute('aria-pressed', 'false');
+ const index = openOrder.indexOf(el);
+ if (index !== -1) openOrder.splice(index, 1);
+ const target = returnFocus.get(el);
+ if (target && target.isConnected) target.focus({ preventScroll: true });
+ returnFocus.delete(el);
+ }
syncBodyLock();
return el;
}
@@ -88,6 +181,28 @@
});
}
+ // Keep keyboard focus within the topmost drawer. Existing close handlers own
+ // cleanup and dirty-form semantics, so Escape activates their close control.
+ document.addEventListener('keydown', function (event) {
+ const el = openOrder.filter(isElVisible).at(-1);
+ if (!el || el.dataset.uiSurface !== 'drawer' || event.defaultPrevented) return;
+ if (event.key === 'Escape') {
+ const close = el.querySelector('.modal-close, .projects-modal-close, .c2-modal-close');
+ if (close) { event.preventDefault(); event.stopImmediatePropagation(); close.click(); }
+ } else if (event.key === 'Tab') {
+ const items = Array.from(el.querySelectorAll('button, [href], input, select, textarea, [tabindex]'))
+ .filter(item => !item.disabled && item.tabIndex >= 0 && item.getClientRects().length);
+ if (!items.length) return;
+ const first = items[0], last = items[items.length - 1];
+ if (event.shiftKey && (document.activeElement === first || !el.contains(document.activeElement))) {
+ event.preventDefault(); last.focus();
+ } else if (!event.shiftKey && (document.activeElement === last || !el.contains(document.activeElement))) {
+ event.preventDefault(); first.focus();
+ }
+ }
+ });
+ document.querySelectorAll(OVERLAY_SELECTOR).forEach(prepareSurface);
+
window.openAppModal = openAppModal;
window.closeAppModal = closeAppModal;
window.isAppModalOpen = isAppModalOpen;
diff --git a/web/static/js/roles.js b/web/static/js/roles.js
index ee94f192..3ec24e00 100644
--- a/web/static/js/roles.js
+++ b/web/static/js/roles.js
@@ -1296,6 +1296,7 @@ async function showAddRoleModal() {
const modal = document.getElementById('role-modal');
if (!modal) return;
+ document.getElementById('role-modal-title').setAttribute('data-i18n', 'roleModal.addRole');
document.getElementById('role-modal-title').textContent = _t('roleModal.addRole');
document.getElementById('role-name').value = '';
document.getElementById('role-name').disabled = false;
@@ -1379,6 +1380,7 @@ async function editRole(roleName) {
const modal = document.getElementById('role-modal');
if (!modal) return;
+ document.getElementById('role-modal-title').setAttribute('data-i18n', 'roleModal.editRole');
document.getElementById('role-modal-title').textContent = _t('roleModal.editRole');
document.getElementById('role-name').value = role.name;
document.getElementById('role-name').disabled = true; // 编辑时不允许修改名称
diff --git a/web/static/js/skills.js b/web/static/js/skills.js
index 3e9507c5..c2f6bba0 100644
--- a/web/static/js/skills.js
+++ b/web/static/js/skills.js
@@ -498,6 +498,7 @@ function showAddSkillModal() {
if (pkg) pkg.style.display = 'none';
if (addEd) addEd.style.display = 'block';
+ document.getElementById('skill-modal-title').setAttribute('data-i18n', 'skills.addSkill');
document.getElementById('skill-modal-title').textContent = _t('skills.addSkill');
document.getElementById('skill-name').value = '';
document.getElementById('skill-name').disabled = false;
@@ -612,6 +613,7 @@ async function editSkill(skillId) {
const addEd = document.getElementById('skill-add-editor');
if (pkg) pkg.style.display = 'block';
if (addEd) addEd.style.display = 'none';
+ document.getElementById('skill-modal-title').setAttribute('data-i18n', 'skills.editSkill');
document.getElementById('skill-modal-title').textContent = _t('skills.editSkill');
document.getElementById('skill-name').value = '';
document.getElementById('skill-name').disabled = true;
diff --git a/web/static/js/tasks.js b/web/static/js/tasks.js
index 36c15fd3..66c84678 100644
--- a/web/static/js/tasks.js
+++ b/web/static/js/tasks.js
@@ -1798,8 +1798,14 @@ async function showBatchQueueDetail(queueId) {
const allowSubtaskMutation = batchQueueAllowsSubtaskMutation(queue);
if (title) {
- // textContent 本身会做转义;这里不要再 escapeHtml,否则会把 && 显示成 &...(看起来像“变形/乱码”)
- title.textContent = queue.title ? _t('tasks.batchQueueTitle') + ' - ' + String(queue.title) : _t('tasks.batchQueueTitle');
+ // Translate only the label. The queue name is literal user content and
+ // must survive mobile boot / language refresh without being replaced.
+ title.removeAttribute('data-i18n');
+ const label = document.createElement('span');
+ label.setAttribute('data-i18n', 'tasks.batchQueueTitle');
+ label.textContent = _t('tasks.batchQueueTitle');
+ title.replaceChildren(label);
+ if (queue.title) title.appendChild(document.createTextNode(' - ' + String(queue.title)));
}
// 更新按钮显示
@@ -1810,14 +1816,11 @@ async function showBatchQueueDetail(queueId) {
if (startBtn) {
// pending状态显示"开始执行",paused状态显示"继续执行"
startBtn.style.display = (queue.status === 'pending' || queue.status === 'paused') ? 'inline-block' : 'none';
- if (startBtn && queue.status === 'paused') {
- startBtn.textContent = _t('tasks.resumeExecute');
- } else if (startBtn && queue.status === 'pending') {
- const isCronPending = queue.scheduleMode === 'cron' && queue.scheduleEnabled !== false;
- startBtn.textContent = isCronPending
- ? _t('batchQueueDetailModal.startExecuteNow')
- : _t('batchQueueDetailModal.startExecute');
- }
+ const isCronPending = queue.status === 'pending' && queue.scheduleMode === 'cron' && queue.scheduleEnabled !== false;
+ const startLabelKey = queue.status === 'paused' ? 'tasks.resumeExecute'
+ : isCronPending ? 'batchQueueDetailModal.startExecuteNow' : 'batchQueueDetailModal.startExecute';
+ startBtn.setAttribute('data-i18n', startLabelKey);
+ startBtn.textContent = _t(startLabelKey);
}
const rerunBtn = document.getElementById('batch-queue-rerun-btn');
if (rerunBtn) {
diff --git a/web/templates/index.html b/web/templates/index.html
index 7ee100eb..249a7570 100644
--- a/web/templates/index.html
+++ b/web/templates/index.html
@@ -49,6 +49,7 @@
+
@@ -6401,16 +6402,14 @@