@@ -10034,7 +10053,7 @@ function openTenantQuotaAction() {
});
rememberAction("租户额度已更新", "当前项目的预算与配额已经保存。", "green", saved);
await loadAgentControlSurfaces(project.id);
- renderAll();
+ focusCreditsWorkspace("credits-quota-anchor");
}
});
}
@@ -10284,6 +10303,7 @@ function openBenchmarkLinkAction(defaults = {}) {
async function scanAdminOpsAction() {
if (!isSuperAdmin()) throw new Error("只有平台管理者才能调用运维 Agent。");
setBusy(true, "运维 Agent 正在扫描故障事件...");
+ let shouldRefocus = false;
try {
const payload = await storyforgeFetch("/v2/admin/ops/incidents/scan", {
method: "POST",
@@ -10291,9 +10311,14 @@ async function scanAdminOpsAction() {
});
rememberAction("运维扫描已完成", `本轮共归集 ${formatNumber(payload.count)} 条故障事件。`, payload.count ? "orange" : "green", payload);
await loadAgentControlSurfaces(getOneLinerProjectId());
+ shouldRefocus = true;
} finally {
setBusy(false, "");
- renderAll();
+ if (shouldRefocus) {
+ focusAdminOpsWorkspace("admin-ops-anchor");
+ } else {
+ renderAll();
+ }
}
}
@@ -10352,7 +10377,7 @@ function openAdminIncidentReviewAction(incidentId) {
});
rememberAction("审计结果已保存", `事件「${saved.title}」已更新为 ${saved.status}。`, "green", saved);
await loadAgentControlSurfaces(getOneLinerProjectId());
- renderAll();
+ focusAdminOpsWorkspace("admin-ops-anchor");
}
});
}
@@ -10388,7 +10413,7 @@ function openAdminRepairPlanAction(incidentId) {
});
rememberAction("修复计划已生成", `已为事件「${incident.title}」生成 repair plan。`, "green", saved);
await loadAgentControlSurfaces(getOneLinerProjectId());
- renderAll();
+ focusAdminOpsWorkspace("admin-ops-anchor");
}
});
}
@@ -10490,7 +10515,7 @@ function openAdminFixRunAuditAction(runId) {
});
rememberAction("修复计划已审计", `修复计划 ${runId} 已更新为 ${saved.audit_status || values.reviewStatus}。`, "green", saved);
await loadAgentControlSurfaces(getOneLinerProjectId());
- renderAll();
+ focusAdminOpsWorkspace("admin-ops-anchor");
}
});
}
diff --git a/web/storyforge-web-v4/tests/workbench-pages.test.mjs b/web/storyforge-web-v4/tests/workbench-pages.test.mjs
index cd77901..5ad5d60 100644
--- a/web/storyforge-web-v4/tests/workbench-pages.test.mjs
+++ b/web/storyforge-web-v4/tests/workbench-pages.test.mjs
@@ -1017,6 +1017,24 @@ test("review actions return to the review workspace with the saved review in foc
assert.match(APP, /data-review-id="\$\{escapeHtml\(review\.id\)\}"/);
});
+test("quota and admin ops mutations refocus the user into the most relevant workbench area", () => {
+ const quota = extractBetween(APP, "function openTenantQuotaAction()", "function openCreateAssistantAction()");
+ const scanOps = extractBetween(APP, "async function scanAdminOpsAction()", "function openAdminIncidentReviewAction(incidentId)");
+ const reviewIncident = extractBetween(APP, "function openAdminIncidentReviewAction(incidentId)", "function openAdminRepairPlanAction(incidentId)");
+ const repairPlan = extractBetween(APP, "function openAdminRepairPlanAction(incidentId)", "function openAdminFixRunDetailAction(runId)");
+ const auditFixRun = extractBetween(APP, "function openAdminFixRunAuditAction(runId)", "function openJobDetailAction(jobId)");
+
+ assert.match(APP, /function focusCreditsWorkspace\(anchorId = "credits-quota-anchor"\)/);
+ assert.match(APP, /function focusAdminOpsWorkspace\(anchorId = "admin-ops-anchor"\)/);
+ assert.match(APP, /id="credits-quota-anchor"/);
+ assert.match(APP, /id="admin-ops-anchor"/);
+ assert.match(quota, /focusCreditsWorkspace\("credits-quota-anchor"\)/);
+ assert.match(scanOps, /focusAdminOpsWorkspace\("admin-ops-anchor"\)/);
+ assert.match(reviewIncident, /focusAdminOpsWorkspace\("admin-ops-anchor"\)/);
+ assert.match(repairPlan, /focusAdminOpsWorkspace\("admin-ops-anchor"\)/);
+ assert.match(auditFixRun, /focusAdminOpsWorkspace\("admin-ops-anchor"\)/);
+});
+
test("assistant actions return to the playbook workspace with the saved assistant in focus", () => {
const createAssistant = extractBetween(APP, "function openCreateAssistantAction()", "function openEditAssistantAction(assistantId = \"\")");
const editAssistant = extractBetween(APP, "function openEditAssistantAction(assistantId = \"\")", "function openAnalyzeSelectedAccountAction()");