diff --git a/CHANGELOG.md b/CHANGELOG.md index f03bc01..74484ed 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ ## 2026-04-04 +### 主 Agent 结果卡支持直达配置版本 + +- 主 Agent 当前运行卡、执行结果卡、平台 Agent 最近执行卡,现在不只显示 `配置 vN / 平台 Agent vN`,而且可以直接点进去打开对应的历史弹层。 +- 历史弹层新增“预选版本”能力:从执行结果进入时,会自动定位到本轮真实使用的那一版,不用再手动在版本列表里找。 +- 这条直达链已经补进前端回归,防止后续又退回成“只能看版本号,不能回到版本历史”。 + ### 主 Agent 配置漂移提示与平台执行追溯 - 主 Agent 当前运行卡、执行结果卡现在不只展示 `配置 vN`,还会在发现本轮执行使用的是旧版主配置或旧版平台 Agent 配置时,直接标出 `主配置已更新 / 平台 Agent 已更新`。 diff --git a/web/storyforge-web-v4/assets/app.js b/web/storyforge-web-v4/assets/app.js index 9a38f89..09d62eb 100644 --- a/web/storyforge-web-v4/assets/app.js +++ b/web/storyforge-web-v4/assets/app.js @@ -1242,7 +1242,7 @@ function renderOneLinerRunsHtml() {
配置 v${escapeHtml(formatNumber(currentRunConfigVersion.version_no || 0))} ${currentRunOnelinerConfigStale ? `主配置已更新` : ""} - 查看配置历史 + 查看配置历史
` : ""} @@ -1374,8 +1374,8 @@ function renderOneLinerMessagesHtml() { ${executionCard.platform_agent_name ? `${escapeHtml(executionCard.platform_agent_name)}` : ""} ${executionCard.assistant_name ? `${escapeHtml(executionCard.assistant_name)}` : ""} ${profileVersion.version_no ? `配置 v${escapeHtml(formatNumber(profileVersion.version_no || 0))}` : ""} - ${profileVersion.version_no ? `看主配置历史` : ""} - ${executionCard.platform && executionCard.platform_agent_profile?.version_no ? `看平台配置历史` : ""} + ${profileVersion.version_no ? `看主配置历史` : ""} + ${executionCard.platform && executionCard.platform_agent_profile?.version_no ? `看平台配置历史` : ""} ${executionCard.readiness_label ? `= 50 ? "blue" : "orange"}">${escapeHtml(executionCard.readiness_label)} ${escapeHtml(formatNumber(executionCard.readiness_score || 0))}` : ""} ${executionCard.primary_action?.key ? `${escapeHtml(executionCard.primary_action.label || "执行下一步")}` : ""} @@ -2033,7 +2033,7 @@ function renderOneLinerExecutionPayloadHtml(payload) {
配置 v${escapeHtml(formatNumber(configVersion.version_no || 0))} ${currentRunOnelinerConfigStale ? `主配置已更新` : ""} - 查看配置历史 + 查看配置历史
` : ""} @@ -2047,7 +2047,7 @@ function renderOneLinerExecutionPayloadHtml(payload) { ${platformAgentProfile.assistant_name ? `${escapeHtml(platformAgentProfile.assistant_name)}` : ""} ${platformAgentProfile.version_no ? `${escapeHtml(platformLabel(platformAgentProfile.platform || payload.platform || ""))} Agent v${escapeHtml(formatNumber(platformAgentProfile.version_no || 0))}` : ""} ${currentRunPlatformAgentConfigStale ? `平台 Agent 已更新` : ""} - ${platformAgentProfile.platform && platformAgentProfile.version_no ? `看平台配置历史` : ""} + ${platformAgentProfile.platform && platformAgentProfile.version_no ? `看平台配置历史` : ""} ${platformAgentProfile.readiness_label ? `= 50 ? "blue" : "orange"}">${escapeHtml(platformAgentProfile.readiness_label)} ${escapeHtml(formatNumber(platformAgentProfile.readiness_score || 0))}` : ""} @@ -4513,6 +4513,8 @@ function renderPlatformAgentPanel() {
${item.recent_execution.recommended_action?.action ? `${escapeHtml(item.recent_execution.recommended_action.label || "回到业务页")}` : ""} + ${item.recent_execution.oneliner_profile_version_no ? `主配置历史` : ""} + ${item.recent_execution.platform_agent_profile_version_no ? `平台配置历史` : ""} 查看执行结果 回到主 Agent 查看
@@ -8794,12 +8796,21 @@ function openOneLinerProfileAction() { }); } -async function openOneLinerProfileHistoryAction() { +function resolvePreferredVersionId(history, preferredVersionId = "") { + const items = safeArray(history?.items || history); + const normalizedPreferred = String(preferredVersionId || "").trim(); + if (normalizedPreferred && items.some((item) => String(item?.id || "") === normalizedPreferred)) { + return normalizedPreferred; + } + return String(items[0]?.id || ""); +} + +async function openOneLinerProfileHistoryAction(preferredVersionId = "") { const project = requireSelectedProject(); const history = await loadPolicyVersions(`/v2/oneliner/profile/versions?project_id=${encodeURIComponent(project.id)}`); const auditsPayload = await storyforgeFetch(`/v2/oneliner/profile/audits?project_id=${encodeURIComponent(project.id)}`).catch(() => ({ items: [] })); const audits = safeArray(auditsPayload?.items || auditsPayload); - const selectedVersionId = history.items[0]?.id || ""; + const selectedVersionId = resolvePreferredVersionId(history, preferredVersionId); openActionModal({ title: "OneLiner 主配置历史", description: "回看主 Agent 核心配置的历史版本、变更原因和回滚记录。", @@ -8932,7 +8943,7 @@ function getAdminGovernanceDirectoryProjectOptions(targetUserId) { })); } -function renderPolicyVersionsHtml(items, emptyText = "暂无历史版本。") { +function renderPolicyVersionsHtml(items, emptyText = "暂无历史版本。", selectedVersionId = "") { const versions = safeArray(items); if (!versions.length) { return `

还没有历史版本

${escapeHtml(emptyText)}

`; @@ -8943,6 +8954,7 @@ function renderPolicyVersionsHtml(items, emptyText = "暂无历史版本。") {

${escapeHtml(version.summary || "没有补充摘要。")}

版本 ${escapeHtml(formatNumber(version.version_no || 0))} + ${String(version.id || "") === String(selectedVersionId || "") ? `当前预选` : ""} ${version.created_at ? `${escapeHtml(formatDateTime(version.created_at))}` : ""} ${version.rollback_from_version_id ? `回滚生成` : ""}
@@ -9075,10 +9087,10 @@ function openUserPlatformPolicyAction(platform) { }); } -async function openUserGlobalPolicyHistoryAction() { +async function openUserGlobalPolicyHistoryAction(preferredVersionId = "") { const project = requireSelectedProject(); const history = await loadPolicyVersions(`/v2/oneliner/governance/user/global/versions?project_id=${encodeURIComponent(project.id)}`); - const selectedVersionId = history.items[0]?.id || ""; + const selectedVersionId = resolvePreferredVersionId(history, preferredVersionId); const versionOptions = buildPolicyVersionOptions(history); openActionModal({ title: "我的全局策略历史", @@ -9087,7 +9099,7 @@ async function openUserGlobalPolicyHistoryAction() { hideSubmit: !selectedVersionId, fields: [ { type: "html", label: "当前版本", html: renderPolicyVersionSummary(appState.userGlobalPolicy || {}, "你还没有发布自己的全局策略。") }, - { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, "你的全局策略还没有历史版本。") }, + { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, "你的全局策略还没有历史版本。", selectedVersionId) }, ...(selectedVersionId ? [ { name: "versionId", label: "回滚版本", type: "select", value: selectedVersionId, options: versionOptions }, { name: "reason", label: "回滚原因", type: "textarea", rows: 3, value: "", placeholder: "例如:恢复到更稳妥的首页动作和语气策略" } @@ -9110,11 +9122,11 @@ async function openUserGlobalPolicyHistoryAction() { }); } -async function openUserPlatformPolicyHistoryAction(platform) { +async function openUserPlatformPolicyHistoryAction(platform, preferredVersionId = "") { const normalizedPlatform = normalizePlatformValue(platform || getPreferredPlatform(), "douyin"); const project = requireSelectedProject(); const history = await loadPolicyVersions(`/v2/oneliner/governance/user/platforms/${encodeURIComponent(normalizedPlatform)}/versions?project_id=${encodeURIComponent(project.id)}`); - const selectedVersionId = history.items[0]?.id || ""; + const selectedVersionId = resolvePreferredVersionId(history, preferredVersionId); const versionOptions = buildPolicyVersionOptions(history); openActionModal({ title: `${platformLabel(normalizedPlatform)} 平台策略历史`, @@ -9123,7 +9135,7 @@ async function openUserPlatformPolicyHistoryAction(platform) { hideSubmit: !selectedVersionId, fields: [ { type: "html", label: "当前版本", html: renderPolicyVersionSummary(appState.userCurrentPlatformPolicy || {}, `你还没有发布 ${platformLabel(normalizedPlatform)} 平台策略。`) }, - { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, `${platformLabel(normalizedPlatform)} 还没有历史版本。`) }, + { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, `${platformLabel(normalizedPlatform)} 还没有历史版本。`, selectedVersionId) }, ...(selectedVersionId ? [ { name: "versionId", label: "回滚版本", type: "select", value: selectedVersionId, options: versionOptions }, { name: "reason", label: "回滚原因", type: "textarea", rows: 3, value: "", placeholder: "例如:恢复到更适合这个平台的拆解方式" } @@ -9308,11 +9320,11 @@ function openAdminOverridePolicyAction() { }); } -async function openAdminOverrideHistoryAction() { +async function openAdminOverrideHistoryAction(preferredVersionId = "") { const target = getAdminOverrideTargetState(); if (!ensureAdminOverrideTargetReady(target)) return; const history = await loadPolicyVersions(`/v2/admin/oneliner/governance/overrides/versions?target_user_id=${encodeURIComponent(target.targetUserId)}&target_project_id=${encodeURIComponent(target.targetProjectId)}&platform=${encodeURIComponent(target.platform)}`); - const selectedVersionId = history.items[0]?.id || ""; + const selectedVersionId = resolvePreferredVersionId(history, preferredVersionId); openActionModal({ title: "管理员覆盖历史", description: "查看当前目标的管理员覆盖版本,并从历史里选择一个版本回滚。", @@ -9320,7 +9332,7 @@ async function openAdminOverrideHistoryAction() { hideSubmit: !selectedVersionId, fields: [ { type: "html", label: "当前目标", html: renderPolicyVersionSummary(appState.adminOverridePolicy || {}, `当前查看的是 ${formatAdminGovernanceTargetLabel(target)} 的覆盖历史。`) }, - { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, "当前目标还没有历史版本。") }, + { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, "当前目标还没有历史版本。", selectedVersionId) }, ...(selectedVersionId ? [ { name: "versionId", label: "回滚版本", type: "select", value: selectedVersionId, options: safeArray(history.items).map((item) => ({ value: item.id, label: `v${formatNumber(item.version_no || 0)} · ${item.title || brief(item.summary || item.id, 24)}` })) }, { name: "reason", label: "回滚原因", type: "textarea", rows: 3, value: "", placeholder: "例如:这版覆盖太激进,需要恢复到上一版" } @@ -9345,10 +9357,10 @@ async function openAdminOverrideHistoryAction() { }); } -async function openSystemMainPolicyHistoryAction() { +async function openSystemMainPolicyHistoryAction(preferredVersionId = "") { if (!ensureAdminGovernanceAccess()) return; const history = await loadPolicyVersions("/v2/admin/oneliner/governance/system/main-agent/versions"); - const selectedVersionId = history.items[0]?.id || ""; + const selectedVersionId = resolvePreferredVersionId(history, preferredVersionId); openActionModal({ title: "系统主 Agent 历史", description: "查看系统主 Agent 的历史版本,并选择某个版本回滚。", @@ -9356,7 +9368,7 @@ async function openSystemMainPolicyHistoryAction() { hideSubmit: !selectedVersionId, fields: [ { type: "html", label: "当前版本", html: renderPolicyVersionSummary(appState.adminSystemMainPolicy || {}, "系统主 Agent 还没有历史版本。") }, - { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, "系统主 Agent 还没有历史版本。") }, + { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, "系统主 Agent 还没有历史版本。", selectedVersionId) }, ...(selectedVersionId ? [ { name: "versionId", label: "回滚版本", type: "select", value: selectedVersionId, options: safeArray(history.items).map((item) => ({ value: item.id, label: `v${formatNumber(item.version_no || 0)} · ${item.title || brief(item.summary || item.id, 24)}` })) }, { name: "reason", label: "回滚原因", type: "textarea", rows: 3, value: "", placeholder: "例如:恢复到上一版系统主 Agent 策略" } @@ -9378,11 +9390,11 @@ async function openSystemMainPolicyHistoryAction() { }); } -async function openSystemPlatformPolicyHistoryAction(platform) { +async function openSystemPlatformPolicyHistoryAction(platform, preferredVersionId = "") { if (!ensureAdminGovernanceAccess()) return; const normalizedPlatform = normalizePlatformValue(platform || getPreferredPlatform(), "douyin"); const history = await loadPolicyVersions(`/v2/admin/oneliner/governance/system/platforms/${encodeURIComponent(normalizedPlatform)}/versions`); - const selectedVersionId = history.items[0]?.id || ""; + const selectedVersionId = resolvePreferredVersionId(history, preferredVersionId); const bundle = safeArray(appState.adminSystemPlatformPolicies).find((item) => item?.scope?.platform === normalizedPlatform) || {}; openActionModal({ title: `${platformLabel(normalizedPlatform)} 系统平台历史`, @@ -9391,7 +9403,7 @@ async function openSystemPlatformPolicyHistoryAction(platform) { hideSubmit: !selectedVersionId, fields: [ { type: "html", label: "当前版本", html: renderPolicyVersionSummary(bundle, `当前 ${platformLabel(normalizedPlatform)} 还没有系统平台历史版本。`) }, - { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, `${platformLabel(normalizedPlatform)} 还没有历史版本。`) }, + { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, `${platformLabel(normalizedPlatform)} 还没有历史版本。`, selectedVersionId) }, ...(selectedVersionId ? [ { name: "versionId", label: "回滚版本", type: "select", value: selectedVersionId, options: safeArray(history.items).map((item) => ({ value: item.id, label: `v${formatNumber(item.version_no || 0)} · ${item.title || brief(item.summary || item.id, 24)}` })) }, { name: "reason", label: "回滚原因", type: "textarea", rows: 3, value: "", placeholder: "例如:恢复到上一版平台默认方法论" } @@ -9459,13 +9471,13 @@ function openPlatformAgentProfileAction(platform) { }); } -async function openPlatformAgentProfileHistoryAction(platform) { +async function openPlatformAgentProfileHistoryAction(platform, preferredVersionId = "") { const project = requireSelectedProject(); const normalizedPlatform = normalizePlatformValue(platform || getPreferredPlatform(), "douyin"); const history = await loadPolicyVersions(`/v2/platform-agents/${encodeURIComponent(normalizedPlatform)}/profile/versions?project_id=${encodeURIComponent(project.id)}`); const audits = await storyforgeFetch(`/v2/platform-agents/${encodeURIComponent(normalizedPlatform)}/profile/audits?project_id=${encodeURIComponent(project.id)}`).catch(() => ({ items: [] })); const current = safeArray(appState.platformAgents).find((item) => item.platform === normalizedPlatform) || {}; - const selectedVersionId = history.items[0]?.id || ""; + const selectedVersionId = resolvePreferredVersionId(history, preferredVersionId); openActionModal({ title: `${platformLabel(normalizedPlatform)} Agent 配置历史`, description: "查看平台 Agent 配置版本,并从历史里选择一个版本回滚。", @@ -9473,7 +9485,7 @@ async function openPlatformAgentProfileHistoryAction(platform) { hideSubmit: !selectedVersionId, fields: [ { type: "html", label: "当前版本", html: renderPolicyVersionSummary(current, `当前 ${platformLabel(normalizedPlatform)} Agent 还没有历史版本。`) }, - { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, `当前 ${platformLabel(normalizedPlatform)} Agent 还没有历史版本。`) }, + { type: "html", label: "历史版本", html: renderPolicyVersionsHtml(history.items, `当前 ${platformLabel(normalizedPlatform)} Agent 还没有历史版本。`, selectedVersionId) }, { type: "html", label: "审计记录", html: renderPolicyAuditsHtml(safeArray(audits.items || audits), "当前还没有审计记录。") }, ...(selectedVersionId ? [ { name: "versionId", label: "回滚版本", type: "select", value: selectedVersionId, options: safeArray(history.items).map((item) => ({ value: item.id, label: `v${formatNumber(item.version_no || 0)} · ${item.title || brief(item.summary || item.id, 24)}` })) }, @@ -9642,6 +9654,8 @@ async function openPlatformAgentDetailAction(platform) {
${profile.recent_execution.recommended_action?.action ? `${escapeHtml(profile.recent_execution.recommended_action.label || "回到业务页")}` : ""} + ${profile.recent_execution.oneliner_profile_version_no ? `主配置历史` : ""} + ${profile.recent_execution.platform_agent_profile_version_no ? `平台配置历史` : ""} 查看执行结果 回到主 Agent 查看
@@ -11295,7 +11309,7 @@ document.addEventListener("click", async (event) => { return; } if (name === "open-oneliner-profile-history") { - await openOneLinerProfileHistoryAction(); + await openOneLinerProfileHistoryAction(action.dataset.versionId || ""); return; } if (name === "open-user-global-policy") { @@ -11303,7 +11317,7 @@ document.addEventListener("click", async (event) => { return; } if (name === "open-user-global-policy-history") { - await openUserGlobalPolicyHistoryAction(); + await openUserGlobalPolicyHistoryAction(action.dataset.versionId || ""); return; } if (name === "open-user-platform-policy") { @@ -11311,7 +11325,7 @@ document.addEventListener("click", async (event) => { return; } if (name === "open-user-platform-policy-history") { - await openUserPlatformPolicyHistoryAction(action.dataset.platform || ""); + await openUserPlatformPolicyHistoryAction(action.dataset.platform || "", action.dataset.versionId || ""); return; } if (name === "open-system-main-policy") { @@ -11319,7 +11333,7 @@ document.addEventListener("click", async (event) => { return; } if (name === "open-system-main-policy-history") { - await openSystemMainPolicyHistoryAction(); + await openSystemMainPolicyHistoryAction(action.dataset.versionId || ""); return; } if (name === "open-system-platform-policy") { @@ -11327,7 +11341,7 @@ document.addEventListener("click", async (event) => { return; } if (name === "open-system-platform-policy-history") { - await openSystemPlatformPolicyHistoryAction(action.dataset.platform || ""); + await openSystemPlatformPolicyHistoryAction(action.dataset.platform || "", action.dataset.versionId || ""); return; } if (name === "open-admin-override-target") { @@ -11339,7 +11353,7 @@ document.addEventListener("click", async (event) => { return; } if (name === "open-admin-override-history") { - await openAdminOverrideHistoryAction(); + await openAdminOverrideHistoryAction(action.dataset.versionId || ""); return; } if (name === "handoff-to-main-agent") { @@ -11443,7 +11457,7 @@ document.addEventListener("click", async (event) => { return; } if (name === "open-platform-agent-profile-history") { - await openPlatformAgentProfileHistoryAction(action.dataset.platform || ""); + await openPlatformAgentProfileHistoryAction(action.dataset.platform || "", action.dataset.versionId || ""); return; } if (name === "open-platform-agent-detail") { diff --git a/web/storyforge-web-v4/tests/workbench-pages.test.mjs b/web/storyforge-web-v4/tests/workbench-pages.test.mjs index 148bafe..d55b152 100644 --- a/web/storyforge-web-v4/tests/workbench-pages.test.mjs +++ b/web/storyforge-web-v4/tests/workbench-pages.test.mjs @@ -617,7 +617,7 @@ test("oneliner runtime remembers completed runs exactly once after hydration", ( }); test("system governance saves refresh control surfaces after persisting", () => { - const profile = extractBetween(APP, "function openOneLinerProfileAction()", "async function openOneLinerProfileHistoryAction()"); + const profile = extractBetween(APP, "function openOneLinerProfileAction()", "async function openOneLinerProfileHistoryAction(preferredVersionId = \"\")"); const userGlobal = extractBetween(APP, "function openUserGlobalPolicyAction()", "function openUserPlatformPolicyAction(platform)"); const userPlatform = extractBetween(APP, "function openUserPlatformPolicyAction(platform)", "function openSystemMainPolicyAction()"); const main = extractBetween(APP, "function openSystemMainPolicyAction()", "function openSystemPlatformPolicyAction(platform)"); @@ -645,16 +645,19 @@ test("system governance saves refresh control surfaces after persisting", () => }); test("oneliner profile history exposes rollback and audit entrypoints", () => { - const profileHistory = extractBetween(APP, "async function openOneLinerProfileHistoryAction()", "function parsePolicyJsonField(rawValue, label = \"策略 JSON\")"); + const profileHistory = extractBetween(APP, "async function openOneLinerProfileHistoryAction(preferredVersionId = \"\")", "function parsePolicyJsonField(rawValue, label = \"策略 JSON\")"); const playbook = extractBetween(APP, "function renderPlaybookScreen()", "function renderProductionScreen()"); const actions = extractBetween(APP, "document.addEventListener(\"click\", async (event) => {", "document.addEventListener(\"submit\", async (event) => {"); + assert.match(APP, /function resolvePreferredVersionId\(history, preferredVersionId = ""\)/); assert.match(profileHistory, /\/v2\/oneliner\/profile\/versions/); assert.match(profileHistory, /\/v2\/oneliner\/profile\/audits/); assert.match(profileHistory, /\/v2\/oneliner\/profile\/rollback/); + assert.match(profileHistory, /resolvePreferredVersionId\(history, preferredVersionId\)/); assert.match(profileHistory, /hideSubmit:\s*!selectedVersionId/); assert.match(playbook, /open-oneliner-profile-history/); assert.match(actions, /name === "open-oneliner-profile-history"/); + assert.match(actions, /openOneLinerProfileHistoryAction\(action\.dataset\.versionId \|\| ""\)/); }); test("governance UI exposes admin override target picker and history rollback entrypoints", () => { @@ -680,9 +683,9 @@ test("governance UI exposes admin override target picker and history rollback en }); test("admin governance history actions stay read-only when there are no versions yet", () => { - const overrideHistory = extractBetween(APP, "async function openAdminOverrideHistoryAction()", "async function openSystemMainPolicyHistoryAction()"); - const systemMainHistory = extractBetween(APP, "async function openSystemMainPolicyHistoryAction()", "async function openSystemPlatformPolicyHistoryAction(platform)"); - const systemPlatformHistory = extractBetween(APP, "async function openSystemPlatformPolicyHistoryAction(platform)", "function openPlatformAgentProfileAction(platform)"); + const overrideHistory = extractBetween(APP, "async function openAdminOverrideHistoryAction(preferredVersionId = \"\")", "async function openSystemMainPolicyHistoryAction(preferredVersionId = \"\")"); + const systemMainHistory = extractBetween(APP, "async function openSystemMainPolicyHistoryAction(preferredVersionId = \"\")", "async function openSystemPlatformPolicyHistoryAction(platform, preferredVersionId = \"\")"); + const systemPlatformHistory = extractBetween(APP, "async function openSystemPlatformPolicyHistoryAction(platform, preferredVersionId = \"\")", "function openPlatformAgentProfileAction(platform)"); assert.match(overrideHistory, /hideSubmit:\s*!selectedVersionId/); assert.match(systemMainHistory, /hideSubmit:\s*!selectedVersionId/); @@ -727,8 +730,8 @@ test("user governance UI exposes personal history and rollback entrypoints", () }); test("admin override actions guard against missing governance targets", () => { - const override = extractBetween(APP, "function openAdminOverridePolicyAction()", "async function openAdminOverrideHistoryAction()"); - const overrideHistory = extractBetween(APP, "async function openAdminOverrideHistoryAction()", "async function openSystemMainPolicyHistoryAction()"); + const override = extractBetween(APP, "function openAdminOverridePolicyAction()", "async function openAdminOverrideHistoryAction(preferredVersionId = \"\")"); + const overrideHistory = extractBetween(APP, "async function openAdminOverrideHistoryAction(preferredVersionId = \"\")", "async function openSystemMainPolicyHistoryAction(preferredVersionId = \"\")"); const helpers = extractBetween(APP, "function ensureAdminGovernanceAccess()", "function openUserGlobalPolicyAction()"); assert.match(helpers, /function ensureAdminOverrideTargetReady\(target\)/); @@ -753,8 +756,8 @@ test("main agent result rendering offers a direct route back into the recommende test("platform agent profiles expose history, rollback, and execution version context", () => { const actions = extractBetween(APP, "document.addEventListener(\"click\", async (event) => {", "document.addEventListener(\"submit\", async (event) => {"); - const profileEditor = extractBetween(APP, "function openPlatformAgentProfileAction(platform)", "async function openPlatformAgentProfileHistoryAction(platform)"); - const profileHistory = extractBetween(APP, "async function openPlatformAgentProfileHistoryAction(platform)", "function openPlatformAgentMemoryAction(platform)"); + const profileEditor = extractBetween(APP, "function openPlatformAgentProfileAction(platform)", "async function openPlatformAgentProfileHistoryAction(platform, preferredVersionId = \"\")"); + const profileHistory = extractBetween(APP, "async function openPlatformAgentProfileHistoryAction(platform, preferredVersionId = \"\")", "function openPlatformAgentMemoryAction(platform)"); const panel = extractBetween(APP, "function renderPlatformAgentPanel()", "function renderAdminOpsPanel()"); const detail = extractBetween(APP, "async function openPlatformAgentDetailAction(platform)", "function openPlatformSkillReviewAction(platform, skillId, accepted)"); const execution = extractBetween(APP, "function renderOneLinerExecutionPayloadHtml(payload)", "function parseOneLinerActionPayloadValue(value)"); @@ -771,6 +774,8 @@ test("platform agent profiles expose history, rollback, and execution version co assert.match(panel, /open-platform-agent-profile-history/); assert.match(detail, /open-platform-agent-profile-history/); + assert.match(panel, /data-version-id="\$\{escapeHtml\(item\.recent_execution\.platform_agent_profile_version_id \|\| ""\)\}"/); + assert.match(detail, /data-version-id="\$\{escapeHtml\(profile\.recent_execution\.platform_agent_profile_version_id \|\| ""\)\}"/); assert.match(panel, /platform_agent_profile_version_no/); assert.match(panel, /recent_execution\.recommended_action\?\.action/); assert.match(panel, /recent_execution\.workstream_label/); @@ -779,7 +784,7 @@ test("platform agent profiles expose history, rollback, and execution version co assert.match(detail, /recent_execution\.workstream_label/); assert.match(execution, /platformAgentProfile\.version_no/); assert.match(actions, /name === "open-platform-agent-profile-history"/); - assert.match(actions, /openPlatformAgentProfileHistoryAction/); + assert.match(actions, /openPlatformAgentProfileHistoryAction\(action\.dataset\.platform \|\| "", action\.dataset\.versionId \|\| ""\)/); }); test("platform agent recent execution highlights when newer configs exist", () => { @@ -954,11 +959,14 @@ test("live recorder mutations return to the recorder maintenance panel after suc test("main agent execution cards can jump to oneliner and platform profile history", () => { const messages = extractBetween(APP, "function renderOneLinerMessagesHtml()", "function renderAutoConnectingScreen(screenTitle, nextStepText)"); + const runtime = extractBetween(APP, "function renderOneLinerRunsHtml()", "function renderOneLinerMessagesHtml()"); + const execution = extractBetween(APP, "function renderOneLinerExecutionPayloadHtml(payload)", "function parseOneLinerActionPayloadValue(value)"); assert.match(messages, /data-action="open-oneliner-profile-history"/); assert.match(messages, /data-action="open-platform-agent-profile-history"/); - assert.match(APP, /function renderOneLinerExecutionPayloadHtml\(payload\)/); - assert.match(APP, /data-action="open-oneliner-profile-history"/); - assert.match(APP, /data-action="open-platform-agent-profile-history"/); + assert.match(messages, /data-version-id="\$\{escapeHtml\(profileVersion\.version_id \|\| ""\)\}"/); + assert.match(runtime, /data-version-id="\$\{escapeHtml\(currentRunConfigVersion\.version_id \|\| ""\)\}"/); + assert.match(execution, /data-version-id="\$\{escapeHtml\(configVersion\.version_id \|\| ""\)\}"/); + assert.match(execution, /data-version-id="\$\{escapeHtml\(platformAgentProfile\.version_id \|\| ""\)\}"/); }); test("oneliner runtime shows grouped run health summary above the current run card", () => {